mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-13 19:31:01 +01:00
Correct code
This commit is contained in:
@@ -2,34 +2,35 @@
|
||||
|
||||
if bashio::config.true 'use_own_certs'; then
|
||||
|
||||
bashio::log.info "Using referenced ssl certificates..."
|
||||
CERTFILE=$(bashio::config 'certfile')
|
||||
KEYFILE=$(bashio::config 'keyfile')
|
||||
bashio::log.info "Using referenced ssl certificates..."
|
||||
CERTFILE=$(bashio::config 'certfile')
|
||||
KEYFILE=$(bashio::config 'keyfile')
|
||||
|
||||
#Check if files exist
|
||||
echo "... checking if referenced files exist"
|
||||
[ ! -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
|
||||
#Check if files exist
|
||||
echo "... checking if referenced files exist"
|
||||
[ ! -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
|
||||
|
||||
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"
|
||||
CERTFILE="/ssl/nextcloud/keys/cert.crt"
|
||||
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 in "/defaults/default" "/config/nginx/site-confs/default" "/data/config/nginx/site-confs/default"; do
|
||||
if [ -f $NGINXFILE ]; then
|
||||
LINE=$(sed -n "/ssl_certificate /=" $NGINXFILE)
|
||||
if [ ! -z $LINE ]; then
|
||||
sed -i "/ssl_certificate/ d" $NGINXFILE
|
||||
sed -i "$LINE a ssl_certificate_key /ssl/$KEYFILE;" $NGINXFILE
|
||||
sed -i "$LINE a ssl_certificate /ssl/$CERTFILE;" $NGINXFILE
|
||||
#Sets certificates
|
||||
echo "... adding ssl certs in files"
|
||||
#Sets certificates
|
||||
for NGINXFILE in "/defaults/default" "/config/nginx/site-confs/default" "/data/config/nginx/site-confs/default"; do
|
||||
if [ -f $NGINXFILE ]; then
|
||||
LINE=$(sed -n "/ssl_certificate /=" $NGINXFILE)
|
||||
if [ ! -z $LINE ]; then
|
||||
sed -i "/ssl_certificate/ d" $NGINXFILE
|
||||
sed -i "$LINE a ssl_certificate_key /ssl/$KEYFILE;" $NGINXFILE
|
||||
sed -i "$LINE a ssl_certificate /ssl/$CERTFILE;" $NGINXFILE
|
||||
fi
|
||||
done
|
||||
bashio::log.info "... done"
|
||||
fi
|
||||
done
|
||||
bashio::log.info "... done"
|
||||
|
||||
Reference in New Issue
Block a user