53 lines
1.2 KiB
Bash
Executable File
53 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
echo loading caddy script library of functions
|
|
function show-ver () {
|
|
if [ -f "$1" ]; then
|
|
CUR_VER=$("$1" version)
|
|
if [ "$CUR_VER" ]; then
|
|
echo Installed Version for $1 is $CUR_VER
|
|
else
|
|
echo WARNING unable to determine version for $1. Maybe wrong os/arch binary was installed
|
|
fi
|
|
else
|
|
echo No executable file at $1, unable to check version
|
|
fi
|
|
}
|
|
|
|
# sets global $OS
|
|
function get-OS () {
|
|
case "$OSTYPE" in
|
|
darwin*) OS=mac ;;
|
|
linux*) OS=linux ;;
|
|
bsd*) OS=freebsd ;;
|
|
msys*) OS=windows ;;
|
|
*)
|
|
echo "no caddy release for : $OSTYPE"
|
|
exit 0
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# sets global $ARCH
|
|
function get-architecture () {
|
|
echo determining system architecture
|
|
declare -A ARCHES
|
|
ARCHES=( ["arm64"]="arm64" ["aarch64"]="arm64" ["x86_64"]="amd64" ["armv61"]="armv6" ["armv71"]="armv7" ["arm32"]="armv7" ["armhf"]="armv7" )
|
|
ARCH=${ARCHES[$(uname -m)]}
|
|
if [ ! $ARCH ]; then
|
|
echo Your machine kernel architecture $(uname -m) has no caddy release
|
|
echo see https://github.com/caddyserver/caddy/releases
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
function get-caddy-name () {
|
|
get-OS
|
|
get-architecture
|
|
echo caddy binary name is $OS-$ARCH
|
|
CADDY_BIN=$OS-$ARCH
|
|
}
|
|
|
|
function set-env () {
|
|
for f in $1/*.env; do source $f; done
|
|
}
|