Created
July 6, 2020 19:27
-
-
Save blackandred/a82ed32290c84bf1568d5a331af85c11 to your computer and use it in GitHub Desktop.
Watch given directory for changes, then execute a command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright 2020 RiotKit Tech Collective | |
# ====================================== | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# About RiotKit | |
# ============= | |
# We are grassroot activists for social change, we respond to the needs of grassroot organizations, | |
# check out those fantastic mutual aid initiatives: | |
# International: | |
# - International Workers Association (https://iwa-ait.org) | |
# - Anarchist Black Cross Worldwide (https://www.abcf.net/) | |
# Poland: | |
# - Anarchistyczne FAQ (http://anarchizm.info) a translation of Anarchist FAQ | |
# (https://theanarchistlibrary.org/library/the-anarchist-faq-editorial-collective-an-anarchist-faq) | |
# - Federacja Anarchistyczna (http://federacja-anarchistyczna.pl) | |
# - Związek Syndykalistów Polski (https://zsp.net.pl) (Polish section of IWA-AIT) | |
# - Komitet Obrony Praw Lokatorów (https://lokatorzy.info.pl) | |
# - Food Not Bombs (http://foodnotbombs.pl/) | |
# Slovakia: | |
# - Priama Akcia (https://priamaakcia.sk) | |
# - Food Not Bombs (https://foodnotbombs.net/new_site/map/SLOVAKIA.html) | |
# England: | |
# - Solidarity Federation (http://solfed.org.uk) | |
# - Food Not Bombs (https://foodnotbombs.net/new_site/map/ENGLAND.html) | |
# - Anarchist Federation (http://afed.org.uk/) | |
# USA: | |
# - Anarchist Federation (https://blackrosefed.org/) | |
# Russia: | |
# - KRAS (https://aitrus.info/) | |
# - Food Not Bombs (http://foodnotbombs.net/RUSSIA.html) | |
# India: | |
# - Muktivadi Ektra Morcha (https://muktivadi.blackblogs.org/) | |
# - Anarchist Federation (https://www.facebook.com/indiananarchists/, https://thecominganarchy.wordpress.com/) | |
# Spain: | |
# - CNT-AIT (http://cnt-ait.org/) | |
# - Food Not Bombs (https://www.foodnotbombs.net/SPAIN.html) | |
# - FAI (https://federacionanarquistaiberica.wordpress.com/) | |
# Denmark: | |
# - Örestad LS (https://orestadls.wordpress.com/) | |
# Australia: | |
# - ASF-IWA (http://asf-iwa.org.au/) | |
# - Food Not Bombs (https://www.foodnotbombs.net/australia.html) | |
# Bangladesh: | |
# - BASF (https://bangladeshasf.com/) | |
# Norway: | |
# - NSF (https://www.nsf-iaa.org/) | |
# - Food Not Bombs (https://foodnotbombs.net/new_site/map/NORWAY.html) | |
# Serbia: | |
# - ASI-IWA (https://inicijativa.org/) | |
# - Food Not Bombs (https://foodnotbombs.net/new_site/map/YUGOSLAVIA.html) | |
# France: | |
# - CNTF-AIT (http://www.cnt-ait.fr/) | |
# - Food Not Bombs (http://www.foodnotbombs.net/FRANCE.html) | |
PATH_TO_WATCH=$1 | |
COMMAND_TO_EXEC=$2 | |
while inotifywait -r -e modify $PATH_TO_WATCH; do | |
echo " >> File was changed, executing callback" | |
eval $COMMAND_TO_EXEC | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment