docker-unifi-network-applic.../root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run

53 lines
1.4 KiB
Plaintext
Raw Normal View History

2023-09-05 09:07:14 -07:00
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
# create our folders
mkdir -p \
2023-11-16 01:08:59 -08:00
/run/unifi/work/ROOT \
2023-09-05 09:07:14 -07:00
/config/{data,logs}
# create symlinks for config
symlinks=( \
/usr/lib/unifi/data \
/usr/lib/unifi/logs )
for i in "${symlinks[@]}"; do
if [[ -L "$i" && ! "$i" -ef /config/"$(basename "$i")" ]]; then
unlink "$i"
fi
if [[ ! -L "$i" ]]; then
ln -s /config/"$(basename "$i")" "$i"
fi
done
2023-11-16 01:08:59 -08:00
if [[ -L "/usr/lib/unifi/run" && ! "/usr/lib/unifi/run" -ef "/run/unifi" ]]; then
unlink "/usr/lib/unifi/run"
fi
if [[ ! -L "/usr/lib/unifi/run" ]]; then
ln -s "/run/unifi" "/usr/lib/unifi/run"
fi
2023-09-05 09:07:14 -07:00
if [[ ! -e /config/data/system.properties ]]; then
if [[ -z "${MONGO_URI}" || -z "${STAT_MONGO_URI}" || -z "${MONGO_DBNAME}" ]]; then
2024-02-24 10:55:31 -08:00
echo "*** Required environment variables are not set, cannot configure database settings. ***"
2023-10-16 08:53:03 -07:00
sleep infinity
2023-09-05 09:07:14 -07:00
else
envsubst < /defaults/system.properties > /config/data/system.properties
2023-09-05 09:07:14 -07:00
fi
fi
# generate key
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
fi
# permissions
lsiown -R abc:abc \
/config \
/run/unifi
lsiown abc:abc \
/config/data/keystore