2
0
Fork 0

zio-update-caddy: add script

main
Ducky 2023-08-12 18:44:48 +01:00
parent 571b21326c
commit 2122f81fe8
2 changed files with 31 additions and 0 deletions

1
.gitignore vendored
View File

@ -27,4 +27,5 @@
!/usr/local/bin/
/usr/local/bin/*
!/usr/local/bin/zio-backup
!/usr/local/bin/zio-update-caddy
!/usr/local/bin/zio-update-rootfs

View File

@ -0,0 +1,30 @@
#!/bin/bash
if [[ $UID != 0 ]]; then
exit 255
fi
caddy_tmp_install="/tmp/caddy"
caddy_install="/usr/local/bin/caddy"
if [[ -f "$caddy_tmp_install" ]]; then
rm "$caddy_tmp_install"
fi
wget "https://caddyserver.com/api/download?os=linux&arch=amd64&p=github.com%2Fcaddy-dns%2Fcloudflare" -O "$caddy_tmp_install"
chmod +x "$caddy_tmp_install"
caddy_version="$(/tmp/caddy version)"
caddy_version_array=($caddy_version)
caddy_version="${caddy_version_array[0]}"
mv "$caddy_tmp_install" "$caddy_install-$caddy_version"
if
ln -s -f "$caddy_install-$caddy_version" "$caddy_install"
if [[ ! -L "$caddy_install" ]] && [[ ! -e "$caddy_install" ]]; then
rm -f "$caddy_install"
ln -s -f "$caddy_install-$caddy_version" "$caddy_install"
chmod +x "$caddy_install"
fi