mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 18:31:02 +01:00
Update 30-keygen
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
#Check if files exist
|
||||
if bashio::config.true 'use_own_certs'; then
|
||||
|
||||
bashio::log.info "Using referenced ssl certificates..."
|
||||
CERTFILE=$(bashio::config 'certfile')
|
||||
KEYFILE=$(bashio::config 'keyfile')
|
||||
@@ -11,35 +11,27 @@ if bashio::config.true 'use_own_certs'; then
|
||||
[ ! -f /ssl/$CERTFILE ] && bashio::log.fatal "... Certificate /ssl/$CERTFILE not found" && exit 0
|
||||
[ ! -f /ssl/$KEYFILE ] && bashio::log.fatal "... Certificate /ssl/$KEYFILE not found" && exit 0
|
||||
|
||||
#Sets certificates
|
||||
echo "... adding ssl certs in files"
|
||||
NGINXFILE="/defaults/default"
|
||||
LINE=$(sed -n '/cert.crt/=' $NGINXFILE)
|
||||
sed -i "$LINE a ssl_certificate /ssl/${CERTFILE};" $NGINXFILE
|
||||
sed -i "$LINE d" $NGINXFILE
|
||||
|
||||
LINE=$(sed -n '/cert.key/=' $NGINXFILE)
|
||||
sed -i "$LINE a ssl_certificate_key /ssl/${KEYFILE};" $NGINXFILE
|
||||
sed -i "$LINE d" $NGINXFILE
|
||||
|
||||
#Sets certificates
|
||||
NGINXFILE="/config/nginx/site-confs/default"
|
||||
if [ -f $NGINXFILE ]; then
|
||||
LINE=$(sed -n '/cert.crt/=' $NGINXFILE) && \
|
||||
sed -i "$LINE a ssl_certificate /ssl/${CERTFILE};" $NGINXFILE && \
|
||||
sed -i "$LINE d" $NGINXFILE
|
||||
fi
|
||||
|
||||
if [ -f $NGINXFILE ]; then
|
||||
LINE=$(sed -n '/cert.key/=' $NGINXFILE) && \
|
||||
sed -i "$LINE a ssl_certificate_key /ssl/${KEYFILE};" $NGINXFILE && \
|
||||
sed -i "$LINE d" $NGINXFILE
|
||||
fi
|
||||
|
||||
bashio::log.info "... done"
|
||||
echo "#!/bin/bash" > /etc/cont-init.d/30-keygen
|
||||
else
|
||||
bashio::log.info "No ssl certificates set. Auto generating ones."
|
||||
SUBJECT="/C=US/ST=CA/L=Carlsbad/O=Linuxserver.io/OU=LSIO Server/CN=*"
|
||||
openssl req -new -x509 -days 3650 -nodes -out /ssl/nextcloud/keys/cert.crt -keyout /ssl/nextcloud/keys/cert.key -subj "$SUBJECT"
|
||||
bashio::log.info "No ssl certificates set. Auto generating ones..."
|
||||
SUBJECT="/C=US/ST=CA/L=Carlsbad/O=Linuxserver.io/OU=LSIO Server/CN=*"
|
||||
openssl req -new -x509 -days 3650 -nodes -out /ssl/nextcloud/keys/cert.crt -keyout /ssl/nextcloud/keys/cert.key -subj "$SUBJECT"
|
||||
CERTFILE="/ssl/nextcloud/keys/cert.crt"
|
||||
KEYFILE="/ssl/nextcloud/keys/cert.key"
|
||||
|
||||
fi
|
||||
|
||||
#Sets certificates
|
||||
echo "... adding ssl certs in files"
|
||||
#Sets certificates
|
||||
for NGINXFILE is "/defaults/default" "/config/nginx/site-confs/default" "/data/config/nginx/site-confs/default"; do
|
||||
if [ -f $NGINXFILE ]; then
|
||||
LINE=$(sed -n '/cert.crt/=' $NGINXFILE) && \
|
||||
sed -i "$LINE a ssl_certificate /ssl/${CERTFILE};" $NGINXFILE && \
|
||||
sed -i "$LINE d" $NGINXFILE && \
|
||||
\
|
||||
LINE=$(sed -n '/cert.key/=' $NGINXFILE) && \
|
||||
sed -i "$LINE a ssl_certificate_key /ssl/${KEYFILE};" $NGINXFILE && \
|
||||
sed -i "$LINE d" $NGINXFILE || true
|
||||
fi
|
||||
done
|
||||
bashio::log.info "... done"
|
||||
|
||||
Reference in New Issue
Block a user