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-05 21:29:22 +00:00
|
|
|
echo -e "\n[$(date +"%Y/%m/%d-%H:%M:%S")] Waiting for random delay..."
|
2022-08-06 20:34:15 +00:00
|
|
|
sleep $(( RANDOM % SYNC_DELAY_MAX_SECONDS + 1 ))
|
2022-08-05 21:29:22 +00:00
|
|
|
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Sync starts NOW!"
|
|
|
|
else
|
|
|
|
echo -e "\n[$(date +"%Y/%m/%d-%H:%M:%S")] Immediate sync starts NOW!"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# sync
|
|
|
|
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Rsyncing content..."
|
|
|
|
/usr/bin/rsync -e "ssh -l syncer -p $SYNC_PORT -i /syncer/.ssh/id_syncer -o StrictHostKeyChecking=no" -av --exclude '*.json' $SYNC_PEER:/ /syncer/library
|
|
|
|
|
|
|
|
# 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' -p /syncer/library/
|
|
|
|
|
|
|
|
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Sync tasks complete!\n"
|