ftracker/res/docker-entrypoint.sh

50 lines
1.1 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
echo " >>> Checking / Creating & patching VAPID creds <<< "
VAPID_CREDS_FILE=/etc/ftracker/vapid-creds.json
if [[ ! -f $VAPID_CREDS_FILE ]]
then
echo "Generating keypair ..."
web-push generate-vapid-keys --json > $VAPID_CREDS_FILE
echo "Patching keypair into config ..."
PUB_KEY=`cat $VAPID_CREDS_FILE | jq -r .publicKey`
echo "pushServerPublicKey = ${PUB_KEY}" >> /var/www/html/ftracker/main.js
PRIV_KEY=`cat $VAPID_CREDS_FILE | jq -r .privateKey`
echo "push_private_key = ${PRIV_KEY}" >> /etc/ftracker/config.ini
fi
echo " >>> Starting nginx <<< "
mkdir /run/nginx # needed because of bug in package
/usr/sbin/nginx -t
/usr/sbin/nginx
echo " >>> Checking / Installing SSL certificate <<< "
if [[ ${DOMAIN} ]]
then
echo "Obtaining cert for '${DOMAIN}' ..."
echo "Registering with email '${LE_EMAIL}' ..."
certbot -n \
--nginx \
--keep-until-expiring \
--redirect \
--agree-tos \
--cert-name ${DOMAIN} \
-d ${DOMAIN} \
-m ${LE_EMAIL}
echo "Checked/Installed SSL certificate."
fi
echo " >>> Starting uwsgi <<< "
2020-12-07 17:46:50 +01:00
exec /usr/sbin/uwsgi --ini /root/ftracker/res/ftracker.alpine.uwsgi.ini