dockerfiles/sub/start.sh

32 lines
894 B
Bash
Executable File

#/bin/sh
if [ ! -f /usr/share/nginx/html/conf/config.js ]; then
cp /app/config.js /usr/share/nginx/html/conf
fi
if [ $API_URL ]; then
echo "当前 API 地址为: $API_URL"
sed -i "s#http://127.0.0.1:25500#$API_URL#g" /usr/share/nginx/html/conf/config.js
else
echo "当前为默认本地 API 地址: http://127.0.0.1:25500"
echo "如需修改请在容器启动时使用 -e API_URL='https://sub.ops.ci' 传递环境变量"
fi
if [ $SITE_NAME ]; then
sed -i "s#Subconverter Web#$SITE_NAME#g" /usr/share/nginx/html/conf/config.js
fi
nohup /base/subconverter & echo "启动成功"
sed -i '$d' /etc/nginx/conf.d/default.conf
sed -i '$d' /etc/nginx/conf.d/default.conf
sed -i '$d' /etc/nginx/conf.d/default.conf
cat >> /etc/nginx/conf.d/default.conf <<EOF
location /sub {
proxy_redirect off;
proxy_pass http://127.0.0.1:25500;
}
}
EOF
nginx -g "daemon off;"