Clean up error messages and internal variables
This commit is contained in:
parent
564ed8db87
commit
b7b0213fa8
@ -58,14 +58,12 @@ unifi_deploy() {
|
|||||||
# Space-separated list of environments detected and installed:
|
# Space-separated list of environments detected and installed:
|
||||||
_services_updated=""
|
_services_updated=""
|
||||||
|
|
||||||
# Default reload commands are accumulated in an &&-separated string
|
# Default reload commands accumulated as we auto-detect environments:
|
||||||
# as we auto-detect environments:
|
_reload_cmd=""
|
||||||
DEFAULT_UNIFI_RELOAD=""
|
|
||||||
|
|
||||||
# Unifi Controller environment (self hosted or any Cloud Key) --
|
# Unifi Controller environment (self hosted or any Cloud Key) --
|
||||||
# auto-detect by file /usr/lib/unifi/data/keystore:
|
# auto-detect by file /usr/lib/unifi/data/keystore:
|
||||||
DEFAULT_UNIFI_KEYSTORE="/usr/lib/unifi/data/keystore"
|
_unifi_keystore="${DEPLOY_UNIFI_KEYSTORE:-/usr/lib/unifi/data/keystore}"
|
||||||
_unifi_keystore="${DEPLOY_UNIFI_KEYSTORE:-$DEFAULT_UNIFI_KEYSTORE}"
|
|
||||||
if [ -f "$_unifi_keystore" ]; then
|
if [ -f "$_unifi_keystore" ]; then
|
||||||
_info "Installing certificate for Unifi Controller (Java keystore)"
|
_info "Installing certificate for Unifi Controller (Java keystore)"
|
||||||
_debug _unifi_keystore "$_unifi_keystore"
|
_debug _unifi_keystore "$_unifi_keystore"
|
||||||
@ -78,15 +76,14 @@ unifi_deploy() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DEFAULT_UNIFI_KEYPASS="aircontrolenterprise"
|
_unifi_keypass="${DEPLOY_UNIFI_KEYPASS:-aircontrolenterprise}"
|
||||||
_unifi_keypass="${DEPLOY_UNIFI_KEYPASS:-$DEFAULT_UNIFI_KEYPASS}"
|
|
||||||
|
|
||||||
_debug "Generate import pkcs12"
|
_debug "Generate import pkcs12"
|
||||||
_import_pkcs12="$(_mktemp)"
|
_import_pkcs12="$(_mktemp)"
|
||||||
_toPkcs "$_import_pkcs12" "$_ckey" "$_ccert" "$_cca" "$_unifi_keypass" unifi root
|
_toPkcs "$_import_pkcs12" "$_ckey" "$_ccert" "$_cca" "$_unifi_keypass" unifi root
|
||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
_err "Oops, error creating import pkcs12, please report bug to us."
|
_err "Error generating pkcs12. Please re-run with --debug and report a bug."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -105,7 +102,7 @@ unifi_deploy() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if systemctl -q is-active unifi; then
|
if systemctl -q is-active unifi; then
|
||||||
DEFAULT_UNIFI_RELOAD="${DEFAULT_UNIFI_RELOAD}${DEFAULT_UNIFI_RELOAD:+ && }service unifi restart"
|
_reload_cmd="${_reload_cmd:+$_reload_cmd && }service unifi restart"
|
||||||
fi
|
fi
|
||||||
_services_updated="${_services_updated} unifi"
|
_services_updated="${_services_updated} unifi"
|
||||||
_info "Install Unifi Controller certificate success!"
|
_info "Install Unifi Controller certificate success!"
|
||||||
@ -116,8 +113,7 @@ unifi_deploy() {
|
|||||||
|
|
||||||
# Cloud Key environment (non-UnifiOS -- nginx serves admin pages) --
|
# Cloud Key environment (non-UnifiOS -- nginx serves admin pages) --
|
||||||
# auto-detect by file /etc/ssl/private/cloudkey.key:
|
# auto-detect by file /etc/ssl/private/cloudkey.key:
|
||||||
DEFAULT_DEPLOY_UNIFI_CLOUDKEY_CERTDIR="/etc/ssl/private"
|
_cloudkey_certdir="${DEPLOY_UNIFI_CLOUDKEY_CERTDIR:-/etc/ssl/private}"
|
||||||
_cloudkey_certdir="${DEPLOY_UNIFI_CLOUDKEY_CERTDIR:-$DEFAULT_DEPLOY_UNIFI_CLOUDKEY_CERTDIR}"
|
|
||||||
if [ -f "${_cloudkey_certdir}/cloudkey.key" ]; then
|
if [ -f "${_cloudkey_certdir}/cloudkey.key" ]; then
|
||||||
_info "Installing certificate for Cloud Key Gen1 (nginx admin pages)"
|
_info "Installing certificate for Cloud Key Gen1 (nginx admin pages)"
|
||||||
_debug _cloudkey_certdir "$_cloudkey_certdir"
|
_debug _cloudkey_certdir "$_cloudkey_certdir"
|
||||||
@ -138,7 +134,7 @@ unifi_deploy() {
|
|||||||
(cd "$_cloudkey_certdir" && tar -cf cert.tar cloudkey.crt cloudkey.key unifi.keystore.jks)
|
(cd "$_cloudkey_certdir" && tar -cf cert.tar cloudkey.crt cloudkey.key unifi.keystore.jks)
|
||||||
|
|
||||||
if systemctl -q is-active nginx; then
|
if systemctl -q is-active nginx; then
|
||||||
DEFAULT_UNIFI_RELOAD="${DEFAULT_UNIFI_RELOAD}${DEFAULT_UNIFI_RELOAD:+ && }service nginx restart"
|
_reload_cmd="${_reload_cmd:+$_reload_cmd && }service nginx restart"
|
||||||
fi
|
fi
|
||||||
_info "Install Cloud Key Gen1 certificate success!"
|
_info "Install Cloud Key Gen1 certificate success!"
|
||||||
_services_updated="${_services_updated} nginx"
|
_services_updated="${_services_updated} nginx"
|
||||||
@ -148,8 +144,7 @@ unifi_deploy() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# UnifiOS environment -- auto-detect by /data/unifi-core/config/unifi-core.key:
|
# UnifiOS environment -- auto-detect by /data/unifi-core/config/unifi-core.key:
|
||||||
DEFAULT_DEPLOY_UNIFI_CORE_CONFIG="/data/unifi-core/config"
|
_unifi_core_config="${DEPLOY_UNIFI_CORE_CONFIG:-/data/unifi-core/config}"
|
||||||
_unifi_core_config="${DEPLOY_UNIFI_CORE_CONFIG:-$DEFAULT_DEPLOY_UNIFI_CORE_CONFIG}"
|
|
||||||
if [ -f "${_unifi_core_config}/unifi-core.key" ]; then
|
if [ -f "${_unifi_core_config}/unifi-core.key" ]; then
|
||||||
_info "Installing certificate for UnifiOS"
|
_info "Installing certificate for UnifiOS"
|
||||||
_debug _unifi_core_config "$_unifi_core_config"
|
_debug _unifi_core_config "$_unifi_core_config"
|
||||||
@ -162,7 +157,7 @@ unifi_deploy() {
|
|||||||
cp "$_ckey" "${_unifi_core_config}/unifi-core.key"
|
cp "$_ckey" "${_unifi_core_config}/unifi-core.key"
|
||||||
|
|
||||||
if systemctl -q is-active unifi-core; then
|
if systemctl -q is-active unifi-core; then
|
||||||
DEFAULT_UNIFI_RELOAD="${DEFAULT_UNIFI_RELOAD}${DEFAULT_UNIFI_RELOAD:+ && }systemctl restart unifi-core"
|
_reload_cmd="${_reload_cmd:+$_reload_cmd && }systemctl restart unifi-core"
|
||||||
fi
|
fi
|
||||||
_info "Install UnifiOS certificate success!"
|
_info "Install UnifiOS certificate success!"
|
||||||
_services_updated="${_services_updated} unifi-core"
|
_services_updated="${_services_updated} unifi-core"
|
||||||
@ -181,15 +176,15 @@ unifi_deploy() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_reload="${DEPLOY_UNIFI_RELOAD:-$DEFAULT_UNIFI_RELOAD}"
|
_reload_cmd="${DEPLOY_UNIFI_RELOAD:-$_reload_cmd}"
|
||||||
if [ -z "$_reload" ]; then
|
if [ -z "$_reload_cmd" ]; then
|
||||||
_err "Certificates were installed for services:${_services_updated},"
|
_err "Certificates were installed for services:${_services_updated},"
|
||||||
_err "but none appear to be active. Please set DEPLOY_UNIFI_RELOAD"
|
_err "but none appear to be active. Please set DEPLOY_UNIFI_RELOAD"
|
||||||
_err "to a command that will restart the necessary services."
|
_err "to a command that will restart the necessary services."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
_info "Reload services (this may take some time): $_reload"
|
_info "Reload services (this may take some time): $_reload_cmd"
|
||||||
if eval "$_reload"; then
|
if eval "$_reload_cmd"; then
|
||||||
_info "Reload success!"
|
_info "Reload success!"
|
||||||
else
|
else
|
||||||
_err "Reload error"
|
_err "Reload error"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user