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
+10 -20
View File
@@ -14,29 +14,19 @@ Here an example snippet to help you get started using this docker mod.
```yaml ```yaml
swag: swag:
image: ghcr.io/linuxserver/swag image: lscr.io/linuxserver/nginx
container_name: swag container_name: nginx
cap_add:
- NET_ADMIN
environment: environment:
PUID: 1000 PUID: 1000
PGID: 1000 PGID: 1000
TZ: Europe/London TZ: Europe/London
URL: yourdomain.url
SUBDOMAINS: test,
VALIDATION: dns
DNSPLUGIN: cloudflare #optional
ONLY_SUBDOMAINS: true #optional
EMAIL: #optional
EXTRA_DOMAINS: #optional
STAGING: false #optional
DOCKER_MODS: linuxserver/mods:universal-cloudflared DOCKER_MODS: linuxserver/mods:universal-cloudflared
CF_ZONE_ID: #optional CF_ZONE_ID: zone_id
CF_ACCOUNT_ID: #optional CF_ACCOUNT_ID: acct_id
CF_API_TOKEN: #optional CF_API_TOKEN: token
CF_TUNNEL_NAME: example #optional CF_TUNNEL_NAME: example
CF_TUNNEL_PASSWORD: pleasedontusethisexamplepassword #optional CF_TUNNEL_PASSWORD: pleasedontusethisexamplepassword
CF_TUNNEL_CONFIG: | #optional CF_TUNNEL_CONFIG: |
ingress: ingress:
- hostname: test.yourdomain.url - hostname: test.yourdomain.url
service: http://localhost:80 service: http://localhost:80
@@ -54,7 +44,7 @@ Container images/mods are configured using parameters passed at runtime (such as
| :----: | --- | --- | | :----: | --- | --- |
| `DOCKER_MODS` | Enable this docker mod with `linuxserver/mods:universal-cloudflared` | If adding multiple mods, enter them in an array separated by `\|`, such as `DOCKER_MODS: linuxserver/mods:universal-cloudflared\|linuxserver/mods:universal-mod2` | | `DOCKER_MODS` | Enable this docker mod with `linuxserver/mods:universal-cloudflared` | If adding multiple mods, enter them in an array separated by `\|`, such as `DOCKER_MODS: linuxserver/mods:universal-cloudflared\|linuxserver/mods:universal-mod2` |
### Optional tunnel parameters ### Cloudflare tunnel parameters
| Parameter | Function | Notes | | Parameter | Function | Notes |
| :----: | --- | --- | | :----: | --- | --- |
@@ -72,7 +62,7 @@ Container images/mods are configured using parameters passed at runtime (such as
If you're using a method that doesn't allow you to enter a properly formatted yaml into an environment variable (e.g. `docker run`, or the compose yaml format we recommend in our samples, or a web gui manager) you can alternatively use a yaml file to set the `CF_TUNNEL_CONFIG` variable. If you're using a method that doesn't allow you to enter a properly formatted yaml into an environment variable (e.g. `docker run`, or the compose yaml format we recommend in our samples, or a web gui manager) you can alternatively use a yaml file to set the `CF_TUNNEL_CONFIG` variable.
Create a properly formatted yaml file in the `/config` folder of your container (e.g. `/config/tunnelconfig.yaml`): Create a properly formatted yaml file in the `/config` folder of your container (e.g. `/config/tunnelconfig.yml`):
```shell ```shell
ingress: ingress:
+5 -48
View File
@@ -16,19 +16,6 @@ else
fi fi
echo "**** Linux architecture found: ${ARCH} ****" 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... ****" echo "**** Checking for cloudflared setup script dependencies... ****"
YQARCH="${ARCH}" YQARCH="${ARCH}"
if [ "${YQ_ARCH}" = "armhf" ]; then 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} curl -sLo /tmp/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${YQARCH}
chmod +x /tmp/yq 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...****" echo "**** Installing cloudflared...****"
if [ -d "/cloudflared/" ]; then if [ -d "/cloudflared/" ]; then
echo "**** Moving /cloudflared/cloudflared-${ARCH} to /usr/local/bin/cloudflared... ****" echo "**** Moving /cloudflared/cloudflared-${ARCH} to /usr/local/bin/cloudflared... ****"
@@ -70,10 +42,11 @@ else
fi fi
cloudflared -v cloudflared -v
echo "**** Checking for optional cloudflare tunnel parameters... ****" echo "**** Checking for cloudflare tunnel parameters... ****"
if [[ ${#CF_ACCOUNT_ID} -gt 0 ]] && [[ ${#CF_API_TOKEN} -gt 0 ]] && [[ ${#CF_TUNNEL_NAME} -gt 0 ]]; then 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 if [[ ${#CF_TUNNEL_PASSWORD} -lt 32 ]]; then
echo "**** Cloudflare tunnel password must be at least 32 characters long, exiting... ****" echo "**** Cloudflare tunnel password must be at least 32 characters long, exiting... ****"
rm -rf /etc/services.d/cloudflared
exit 1 exit 1
else else
echo "**** Cloudflare tunnel parameters found, starting cloudflare tunnel setup... ****" 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 done
fi fi
else 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 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... ****" echo "**** Cloudflared setup script done, exiting... ****"