mirror of
https://github.com/jbowdre/library-syncer.git
synced 2024-11-23 02:12:17 +00:00
make the sync delay disabled by default, allow setting maximum delay
This commit is contained in:
parent
2bce5b0727
commit
a05941eb49
3 changed files with 6 additions and 5 deletions
|
@ -4,10 +4,10 @@ set -e
|
|||
chmod 600 /syncer/.ssh/id_syncer
|
||||
|
||||
echo -e "\n[$(date +"%Y/%m/%d-%H:%M:%S")] Performing initial sync..."
|
||||
/syncer/sync.sh now > /proc/self/fd/1 2>/proc/self/fd/2
|
||||
/syncer/sync.sh > /proc/self/fd/1 2>/proc/self/fd/2
|
||||
echo -e "\n[$(date +"%Y/%m/%d-%H:%M:%S")] Creating cron job..."
|
||||
if [ "$SYNC_DELAY" == "false" ]; then
|
||||
echo "$SYNC_SCHEDULE /syncer/sync.sh now > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE
|
||||
if [ "$SYNC_DELAY" == "true" ]; then
|
||||
echo "$SYNC_SCHEDULE /syncer/sync.sh delay > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE
|
||||
else
|
||||
echo "$SYNC_SCHEDULE /syncer/sync.sh > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE
|
||||
fi
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
set -e
|
||||
|
||||
# initial sync is immediate, cron syncs have a random delay unless $CRON_DELAY==false
|
||||
if [ $1 != "now" ]; then
|
||||
if [ $1 == "delay" ]; then
|
||||
echo -e "\n[$(date +"%Y/%m/%d-%H:%M:%S")] Waiting for random delay..."
|
||||
sleep $(( RANDOM ))
|
||||
sleep $(( RANDOM % SYNC_DELAY_MAX_SECONDS + 1 ))
|
||||
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!"
|
||||
|
|
|
@ -10,6 +10,7 @@ services:
|
|||
- SYNC_PORT=2222
|
||||
- SYNC_SCHEDULE=0 21 * * 5
|
||||
- SYNC_DELAY=true
|
||||
- SYNC_DELAY_MAX_SECONDS=21600
|
||||
- TLS_NAME=library.lab.bowdre.net
|
||||
- TLS_CUSTOM_CERT=true
|
||||
ports:
|
||||
|
|
Loading…
Reference in a new issue