make params required, disable service if not configured conrrectly

This commit is contained in:
aptalca
2022-02-07 12:41:35 -05:00
parent 62797fce98
commit fe641afd86
2 changed files with 15 additions and 40 deletions
+5 -20
View File
@@ -70,10 +70,11 @@ else
fi
cloudflared -v
echo "**** Checking for optional cloudflare tunnel parameters... ****"
if [[ ${#CF_ACCOUNT_ID} -gt 0 ]] && [[ ${#CF_API_TOKEN} -gt 0 ]] && [[ ${#CF_TUNNEL_NAME} -gt 0 ]]; then
echo "**** Checking for cloudflare tunnel parameters... ****"
if [[ ${#CF_ZONE_ID} -gt 0 ]] && [[ ${#CF_ACCOUNT_ID} -gt 0 ]] && [[ ${#CF_API_TOKEN} -gt 0 ]] && [[ ${#CF_TUNNEL_NAME} -gt 0 ]] && [[ ${#CF_TUNNEL_CONFIG} -gt 0 ]]; then
if [[ ${#CF_TUNNEL_PASSWORD} -le 32 ]]; then
echo "**** Cloudflare tunnel password must be at least 32 characters long, exiting... ****"
rm -rf /etc/services.d/cloudflared
exit 1
else
echo "**** Cloudflare tunnel parameters found, starting cloudflare tunnel setup... ****"
@@ -162,24 +163,8 @@ if [[ ${#CF_ACCOUNT_ID} -gt 0 ]] && [[ ${#CF_API_TOKEN} -gt 0 ]] && [[ ${#CF_TUN
done
fi
else
echo "**** Optional parameters blank or missing, skipped cloudflare tunnel setup ****"
echo "**** Cloudflare parameters blank or missing, skipped cloudflare tunnel setup ****"
rm -rf /etc/services.d/cloudflared
fi
echo "**** Cleaning up cloudflared setup script dependencies if required... ****"
for PKG in "${!CLEANUP[@]}"; do
if [ "${CLEANUP[$PKG]}" = true ]; then
CLEANUP[$PKG]=false
echo "**** Uninstalling ${PKG}... ****"
if $ALPINE; then
apk del ${PKG}
elif $UBUNTU; then
apt-get -qqy remove ${PKG}
apt-get -qqy autoremove
fi
fi
done
echo "**** Uninstalling /tmp/yq... ****"
rm /tmp/yq
echo "**** Cloudflared setup script done, exiting... ****"