2022-08-05 21:29:22 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
chmod 600 /syncer/.ssh/id_syncer
|
|
|
|
|
2022-08-07 02:51:48 +00:00
|
|
|
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Performing initial sync..."
|
2022-08-06 20:34:15 +00:00
|
|
|
/syncer/sync.sh > /proc/self/fd/1 2>/proc/self/fd/2
|
2022-08-07 02:51:48 +00:00
|
|
|
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Creating cron job..."
|
2022-08-06 20:34:15 +00:00
|
|
|
if [ "$SYNC_DELAY" == "true" ]; then
|
|
|
|
echo "$SYNC_SCHEDULE /syncer/sync.sh delay > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE
|
2022-08-05 21:29:22 +00:00
|
|
|
else
|
|
|
|
echo "$SYNC_SCHEDULE /syncer/sync.sh > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE
|
|
|
|
fi
|
|
|
|
chmod 0644 $CRONTAB_FILE
|
|
|
|
|
|
|
|
if [ "$TLS_NAME" != "" ]; then
|
|
|
|
if [ "$TLS_CUSTOM_CERT" == "true" ]; then
|
|
|
|
cat << EOF > /etc/caddy/Caddyfile
|
2022-08-07 02:37:22 +00:00
|
|
|
$TLS_NAME {
|
2022-08-05 21:29:22 +00:00
|
|
|
root * /syncer/library
|
|
|
|
file_server
|
|
|
|
tls /etc/caddycerts/cert.pem /etc/caddycerts/key.pem
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
else
|
|
|
|
cat << EOF > /etc/caddy/Caddyfile
|
2022-08-07 02:37:22 +00:00
|
|
|
$TLS_NAME {
|
2022-08-05 21:29:22 +00:00
|
|
|
root * /syncer/library
|
|
|
|
file_server
|
|
|
|
}
|
2022-08-07 02:37:22 +00:00
|
|
|
EOF
|
2022-08-05 21:29:22 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-08-07 02:51:48 +00:00
|
|
|
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Starting caddy..."
|
2022-08-05 21:29:22 +00:00
|
|
|
/usr/sbin/caddy start -config /etc/caddy/Caddyfile
|
|
|
|
|
2022-08-07 02:51:48 +00:00
|
|
|
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Starting cron..."
|
2022-08-05 21:29:22 +00:00
|
|
|
exec "$@"
|