library-syncer/client/build/entrypoint.sh

43 lines
1.2 KiB
Bash
Raw Normal View History

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..."
/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..."
if [ "$SYNC_DELAY" == "true" ]; then
echo "${SYNC_SCHEDULE:-0 21 * * 5} /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:-0 21 * * 5} /syncer/sync.sh > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE
2022-08-05 21:29:22 +00:00
fi
chmod 0644 $CRONTAB_FILE
if [ "$TLS_NAME" != "" ]; then
if [ "$TLS_CUSTOM_CERT" == "true" ]; then
cat << EOF > /etc/caddy/Caddyfile
$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
$TLS_NAME {
2022-08-05 21:29:22 +00:00
root * /syncer/library
file_server
}
EOF
2022-08-05 21:29:22 +00:00
fi
fi
if [ "$LIBRARY_BROWSE" == "true" ]; then
sed -i 's/file_server/file_server browse/' /etc/caddy/Caddyfile
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 "$@"