2021-11-20 14:34:06 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2021-11-20 22:49:32 +00:00
|
|
|
SOURCE=/var/www/chevereto-free/
|
2021-11-20 14:34:06 +00:00
|
|
|
TARGET=/var/www/html/
|
|
|
|
EXCLUDE="\.git|\.DS_Store|\/docs"
|
2021-11-20 22:49:32 +00:00
|
|
|
cp "${SOURCE}".gitignore "${TARGET}".gitignore
|
2021-11-20 14:34:06 +00:00
|
|
|
function sync() {
|
2021-11-27 15:23:31 +00:00
|
|
|
cp "${SOURCE}"sync.sh /var/www/sync.sh
|
2021-11-20 14:34:06 +00:00
|
|
|
rsync -r -I -og \
|
|
|
|
--chown=www-data:www-data \
|
|
|
|
--info=progress2 \
|
2021-11-20 23:31:59 +00:00
|
|
|
--exclude '.git' \
|
2021-11-27 15:23:31 +00:00
|
|
|
--include 'content/images/system/default/*' \
|
|
|
|
--include 'content/pages/default/*' \
|
2021-11-20 23:31:59 +00:00
|
|
|
--exclude 'sync.sh' \
|
2021-11-27 15:23:31 +00:00
|
|
|
--exclude 'content/images/system/*' \
|
|
|
|
--exclude 'content/images/users/*' \
|
|
|
|
--exclude 'content/pages/*' \
|
|
|
|
--filter=':- .gitignore' \
|
|
|
|
--filter=':- .dockerignore' \
|
2021-11-20 14:34:06 +00:00
|
|
|
--delete \
|
2021-11-20 22:49:32 +00:00
|
|
|
$SOURCE $TARGET
|
2021-11-20 14:34:06 +00:00
|
|
|
}
|
|
|
|
sync
|
|
|
|
inotifywait \
|
|
|
|
--event create \
|
|
|
|
--event delete \
|
|
|
|
--event modify \
|
|
|
|
--event move \
|
|
|
|
--format "%e %w%f" \
|
|
|
|
--exclude $EXCLUDE \
|
|
|
|
--monitor \
|
|
|
|
--recursive \
|
|
|
|
$SOURCE |
|
|
|
|
while read CHANGED; do
|
|
|
|
sync
|
|
|
|
done
|