Commit b57520e1 authored by name's avatar name
Browse files

优化启动脚本

parent afbf46c8
...@@ -12,7 +12,6 @@ RUN set -ex \ ...@@ -12,7 +12,6 @@ RUN set -ex \
&& rm -rf /acme_src /var/cache/apk/* \ && rm -rf /acme_src /var/cache/apk/* \
&& mkdir /etc/nginx/ssl \ && mkdir /etc/nginx/ssl \
&& mkdir /etc/nginx/ssl/app \ && mkdir /etc/nginx/ssl/app \
&& mkdir /etc/nginx/ssl/default
COPY ./nginx.conf /etc/nginx/nginx.conf COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./default.conf /etc/nginx/conf.d/default.conf COPY ./default.conf /etc/nginx/conf.d/default.conf
......
...@@ -4,25 +4,24 @@ ...@@ -4,25 +4,24 @@
DOMAINS=$(echo "$DOMAINS" | tr -s ' ') DOMAINS=$(echo "$DOMAINS" | tr -s ' ')
SslServer="$SslServer" SslServer="$SslServer"
mail="$mail" mail="$mail"
SSL_DIR="/etc/nginx/ssl/app/"
if [ -z "$DOMAINS" ]; then if [ -z "$DOMAINS" ]; then
echo "[$(date)] Empty env var DOMAINS" echo "[$(date)] Empty env var DOMAINS"
# exit 1 # exit 1
fi fi
mkdir -p /etc/nginx/ssl/default/ mkdir -p ${SSL_DIR}/
mkdir -p /etc/nginx/ssl/app/
function CreateDefault() { function CreateDefault() {
if [ -e "/etc/nginx/ssl/app/cert.pem" ]; then if [ -e "${SSL_DIR}/cert.pem" ]; then
echo "[$(date)] default cert exists" echo "[$(date)] default cert exists"
else else
openssl req -x509 -newkey rsa:4096 -nodes -days 365 \ openssl req -x509 -newkey rsa:4096 -nodes -days 365 \
-subj "/C=CA/ST=QC/O=Company Inc/CN=example.com" \ -subj "/C=CA/ST=QC/O=Company Inc/CN=example.com" \
-out /etc/nginx/ssl/default/cert.pem \ -out ${SSL_DIR}/cert.pem \
-keyout /etc/nginx/ssl/default/key.pem -keyout ${SSL_DIR}/key.pem
cp /etc/nginx/ssl/default/*.pem /etc/nginx/ssl/app/ chmod +w ${SSL_DIR}/*
chmod +w /etc/nginx/ssl/app/*
fi fi
} }
...@@ -59,9 +58,9 @@ function StartAcmesh() { ...@@ -59,9 +58,9 @@ function StartAcmesh() {
echo "[$(date)] acme.sh install-cert .." echo "[$(date)] acme.sh install-cert .."
/root/.acme.sh/acme.sh --install-cert $ACME_DOMAIN_OPTION \ /root/.acme.sh/acme.sh --install-cert $ACME_DOMAIN_OPTION \
--fullchain-file /etc/nginx/ssl/app/fullchain.pem \ --fullchain-file ${SSL_DIR}/fullchain.pem \
--cert-file /etc/nginx/ssl/app/cert.pem \ --cert-file ${SSL_DIR}/cert.pem \
--key-file /etc/nginx/ssl/app/key.pem \ --key-file ${SSL_DIR}/key.pem \
--reloadcmd "nginx -s reload" --reloadcmd "nginx -s reload"
echo "[$(date)] Start cron" echo "[$(date)] Start cron"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment