Update and rename 30-keygen to 30-certs_keygen

This commit is contained in:
Alexandre
2021-09-21 20:24:33 +02:00
committed by GitHub
parent 7b58c855be
commit f0e705bd14
2 changed files with 28 additions and 10 deletions

View File

@@ -0,0 +1,28 @@
#!/usr/bin/with-contenv bashio
/defaults/nextcloud-perms.sh
#Check if files exist
if bashio::config.has_value 'certfile'; then
bashio::log.info "Using referenced ssl certificates..."
CERTFILE=$(bashio::config 'certfile')
KEYFILE=$(bashio::config 'keyfile')
#Check if files exist
[ ! -f /ssl/$CERTFILE ] && bashio::log.fatal "Certificate /ssl/$CERTFILE not found" && exit 1
[ ! -f /ssl/$KEYFILE ] && bashio::log.fatal "Certificate /ssl/$KEYFILE not found" && exit 1
#Sets certificates
sed -i "s|nextcloud/keys/cert.crt|$CERTFILE|g" /defaults/default
sed -i "s|nextcloud/keys/cert.key|$KEYFILE|g" /defaults/default
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=*"
if [[ -f /ssl/nextcloud/keys/cert.key && -f /ssl/nextcloud/keys/cert.crt ]]; then
bashio::log.info "using keys found in /ssl/nextcloud/keys"
else
bashio::log.info "generating self-signed keys in /ssl/nextcloud/keys, you can replace these with your own keys if required"
openssl req -new -x509 -days 3650 -nodes -out /ssl/nextcloud/keys/cert.crt -keyout /ssl/nextcloud/keys/cert.key -subj "$SUBJECT"
fi
fi

View File

@@ -1,10 +0,0 @@
#!/usr/bin/with-contenv bash
/defaults/nextcloud-perms.sh
SUBJECT="/C=US/ST=CA/L=Carlsbad/O=Linuxserver.io/OU=LSIO Server/CN=*"
if [[ -f /ssl/nextcloud/keys/cert.key && -f /ssl/nextcloud/keys/cert.crt ]]; then
echo "using keys found in /ssl/nextcloud/keys"
else
echo "generating self-signed keys in /ssl/nextcloud/keys, you can replace these with your own keys if required"
openssl req -new -x509 -days 3650 -nodes -out /ssl/nextcloud/keys/cert.crt -keyout /ssl/nextcloud/keys/cert.key -subj "$SUBJECT"
fi