Files
hassio-addons/nextcloud/root/etc/cont-init.d/30-keygen
2021-09-22 09:58:02 +02:00

30 lines
1.2 KiB
Plaintext

#!/usr/bin/with-contenv bashio
/defaults/nextcloud-perms.sh
#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')
#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
bashio::log.info "... done"
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