From b2e9b74333c257ab0f47ba9b7d3b25ea37ad315f Mon Sep 17 00:00:00 2001 From: Vinnie Marone Date: Fri, 21 Feb 2025 15:09:52 -0500 Subject: [PATCH 1/2] allow for customized self signed cert --- .../init-unifi-network-application-config/run | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run b/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run index fd28c3c..519933d 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run @@ -30,7 +30,7 @@ fi if [[ ! -e /config/data/system.properties ]]; then if [[ -z "${MONGO_HOST}" ]]; then echo "*** No MONGO_HOST set, cannot configure database settings. ***" - sleep infinity + exit 255 else echo "*** Waiting for MONGO_HOST ${MONGO_HOST} to be reachable. ***" DBCOUNT=0 @@ -41,7 +41,7 @@ if [[ ! -e /config/data/system.properties ]]; then DBCOUNT=$((DBCOUNT+1)) if [[ ${DBCOUNT} -gt 6 ]]; then echo "*** Defined MONGO_HOST ${MONGO_HOST} is not reachable, cannot proceed. ***" - sleep infinity + exit 255 fi sleep 5 done @@ -64,11 +64,20 @@ if [[ ! -e /config/data/system.properties ]]; then fi fi -# generate key +# configure keystore if [[ ! -f /config/data/keystore ]]; then - keytool -genkey -keyalg RSA -alias unifi -keystore /config/data/keystore \ - -storepass aircontrolenterprise -keypass aircontrolenterprise -validity 3650 \ - -keysize 4096 -dname "cn=unifi" -ext san=dns:unifi + if [[ -f /certs/keystore.jks ]]; then + echo "*** DETECTED certificate, adding to keystore, not generating unique ***" + + keytool -importkeystore -srckeystore /certs/keystore.jks -srcstoretype JKS -srcstorepass aircontrolenterprise -destkeystore /config/data/keystore -deststoretype PKCS12 -storepass aircontrolenterprise + + echo "*** Certificate inserted ***" + else + # generate key + keytool -genkey -keyalg RSA -alias unifi -keystore /config/data/keystore \ + -storepass aircontrolenterprise -keypass aircontrolenterprise -validity 3650 \ + -keysize 4096 -dname "cn=unifi" -ext san=dns:unifi + fi fi # permissions From 11724530f0ffbaa49835fbfa1396016423e3038b Mon Sep 17 00:00:00 2001 From: Vinnie Marone Date: Sun, 8 Feb 2026 14:11:38 -0500 Subject: [PATCH 2/2] revert sleep changes --- .../s6-rc.d/init-unifi-network-application-config/run | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run b/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run index 519933d..bc0177b 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run @@ -30,7 +30,7 @@ fi if [[ ! -e /config/data/system.properties ]]; then if [[ -z "${MONGO_HOST}" ]]; then echo "*** No MONGO_HOST set, cannot configure database settings. ***" - exit 255 + sleep infinity else echo "*** Waiting for MONGO_HOST ${MONGO_HOST} to be reachable. ***" DBCOUNT=0 @@ -41,7 +41,7 @@ if [[ ! -e /config/data/system.properties ]]; then DBCOUNT=$((DBCOUNT+1)) if [[ ${DBCOUNT} -gt 6 ]]; then echo "*** Defined MONGO_HOST ${MONGO_HOST} is not reachable, cannot proceed. ***" - exit 255 + sleep infinity fi sleep 5 done