- #!/bin/bash
-
- VER="$(curl -s https://api.github.com/repos/caddyserver/caddy/releases/latest | sed ‘y/,/n/’ | grep tag_name | awk -F ‘"’ ‘{print $4}’)"
- CUR_VER="$($HOME/caddy/caddy version | cut -d " " -f1)"
-
-
- if [[ "$VER" == "$CUR_VER" ]] ; then
- echo "Lastest version $VER is already installed,exiting…"
- exit
- fi
-
- ARCH=$(uname -m)
- VDIS="amd64"
-
- if [[ "$ARCH" == "i686" ]] || [[ "$ARCH" == "i386" ]]; then
- VDIS="386"
- elif [[ "$ARCH" == *"armv8"* ]] || [[ "$ARCH" == "aarch64" ]]; then
- VDIS="arm64"
- fi
-
- mkdir -p /tmp/caddy
-
- echo "Installing Caddy ${VER} on ${ARCH}"
- DOWNLOAD_LINK="https://github.com/caddyserver/caddy/releases/download/${VER}/caddy_${VER##*v}_linux_${VDIS}.tar.gz"
-
- echo "Downloading ${DOWNLOAD_LINK} directly."
- curl -L -H "Cache-Control: no-cache" -o "/tmp/caddy/caddy.tar.gz" ${DOWNLOAD_LINK}
-
- echo "Extracting Caddy package to /tmp/caddy/."
- tar zxvf "/tmp/caddy/caddy.tar.gz" -C "/tmp/caddy/"
-
- rm $HOME/caddy/caddy
-
- cp "/tmp/caddy/caddy" "$HOME/caddy/caddy"
复制代码
|