caddy-retired/scripts/library
David Kebler e24be310ae reworked caddy script - removed cmdline support for netbind
systemd service install now uses sed to insert the repo directory into the call service script before deploying.
renamed install script to fetch as to avoid confusion as it fetches the basic binary.
2020-11-27 15:52:32 -08:00

52 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-bin () {
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
}