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
+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 -20
View File
@@ -70,10 +70,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} -le 32 ]]; then if [[ ${#CF_TUNNEL_PASSWORD} -le 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 +163,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... ****"