Merge branch 'universal-cloudflared' into patch-1

This commit is contained in:
aptalca
2022-02-08 09:54:31 -05:00
committed by GitHub
2 changed files with 15 additions and 68 deletions
+5 -48
View File
@@ -16,19 +16,6 @@ else
fi
echo "**** Linux architecture found: ${ARCH} ****"
UBUNTU=false
ALPINE=false
if [ -f /usr/bin/apt ]; then
UBUNTU=true
echo "**** Linux distro found: ubuntu ****"
elif [ -f /sbin/apk ]; then
ALPINE=true
echo "**** Linux distro found: alpine ****"
else
echo "**** Unknown Linux distro, exiting... ****"
exit 1
fi
echo "**** Checking for cloudflared setup script dependencies... ****"
YQARCH="${ARCH}"
if [ "${YQ_ARCH}" = "armhf" ]; then
@@ -38,21 +25,6 @@ echo "**** Temporarily installing /tmp/yq... ****"
curl -sLo /tmp/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${YQARCH}
chmod +x /tmp/yq
declare -A CLEANUP=( [curl]=false [jq]=false )
for PKG in "${!CLEANUP[@]}"; do
if [ -x "$(command -v ${PKG})" ]; then
echo "**** ${PKG} already installed, skipping... ****"
else
CLEANUP[$PKG]=true
echo "**** Temporarily installing ${PKG}... ****"
if $ALPINE; then
apk add --no-cache ${PKG}
elif $UBUNTU; then
apt-get -qqy install --no-install-recommends ${PKG}
fi
fi
done
echo "**** Installing cloudflared...****"
if [ -d "/cloudflared/" ]; then
echo "**** Moving /cloudflared/cloudflared-${ARCH} to /usr/local/bin/cloudflared... ****"
@@ -70,10 +42,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} -lt 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 +135,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... ****"