d2ray/image/run.sh

39 lines
844 B
Bash
Raw Normal View History

2021-04-10 08:21:07 +00:00
#!/bin/sh
2021-04-10 10:07:21 +00:00
set +xe
2021-04-10 08:21:07 +00:00
2021-04-10 09:46:39 +00:00
mkdir -p /opt/config
mkdir -p /opt/config/logs
mkdir -p /opt/config/certs
mkdir -p /opt/config/logs/nginx
mkdir -p /opt/config/logs/xray
mkdir -p /opt/config/logs/crond
2021-04-10 09:40:04 +00:00
echo ""
2021-04-10 08:21:07 +00:00
echo "===== Checking Environment Variables ====="
if [ -z "$FQDN" ]; then
echo "FQDN must be set"
exit 1
else
echo "FQDN = $FQDN"
fi
2021-04-10 09:40:04 +00:00
echo ""
2021-04-10 08:21:07 +00:00
echo "===== Checking Certificates ===="
if [ ! -d "/etc/letsencrypt/live/$FQDN" ]; then
echo "Generating new certificates..."
2021-04-10 09:42:49 +00:00
certbot certonly -n --standalone -m dummy@dummy.com --agree-tos --no-eff-email -d $FQDN
2021-04-10 08:21:07 +00:00
else
echo "Certificate exists. Checking renewal..."
certbot renew
fi
2021-04-10 09:40:04 +00:00
echo ""
2021-04-10 08:21:07 +00:00
echo "===== Starting services ====="
crond -L /opt/config/logs/crond/log.txt
2021-04-19 07:51:22 +00:00
nginx -c /opt/nginx.conf
2021-04-10 08:21:07 +00:00
2021-04-10 09:40:04 +00:00
echo ""
2021-04-10 08:21:07 +00:00
echo "===== Starting xray ====="
2021-04-19 07:51:22 +00:00
exec /opt/xray/xray -c /opt/config.json