library-syncer/client/build/sync.sh

19 lines
733 B
Bash
Raw Normal View History

2022-08-05 21:29:22 +00:00
#!/bin/sh
set -e
2022-08-07 02:36:31 +00:00
# insert optional random delay
if [ x$1 == x"delay" ]; then
2022-08-07 02:51:48 +00:00
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Waiting for random delay..."
sleep $(( RANDOM % ${SYNC_DELAY_MAX_SECONDS:-21600} + 1 ))
2022-08-05 21:29:22 +00:00
fi
2022-08-07 02:51:48 +00:00
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Sync sync starts NOW!"
2022-08-05 21:29:22 +00:00
# sync
/usr/bin/rsync -e "ssh -l syncer -p ${SYNC_PORT:-2222} -i /syncer/.ssh/id_syncer -o StrictHostKeyChecking=no" -av --exclude '*.json' $SYNC_PEER:/ /syncer/library
2022-08-05 21:29:22 +00:00
# generate content library manifest
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Generating content library manifest..."
/usr/bin/python3 /syncer/update_library_manifests.py -n "${LIBRARY_NAME:-Library}" -p /syncer/library/
2022-08-05 21:29:22 +00:00
2022-08-07 02:51:48 +00:00
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Sync tasks complete!"