2020-11-08 22:32:11 -08:00
|
|
|
#!/bin/bash
|
|
|
|
SDIR=$(dirname "$(readlink -f "$0")") || exit
|
|
|
|
DIR=$(dirname "$SDIR") || exit
|
2020-11-27 14:42:53 -08:00
|
|
|
echo Caddy Reposity Root: $DIR
|
2020-11-08 22:32:11 -08:00
|
|
|
source $SDIR/library
|
|
|
|
CONF=$DIR/conf/${1:-caddy}.conf
|
2020-11-27 14:42:53 -08:00
|
|
|
CMD=${2:-run}
|
|
|
|
get-caddy-bin # this sets $CADDY_BIN
|
2020-11-08 22:32:11 -08:00
|
|
|
BIN=$DIR/bin/$CADDY_BIN
|
|
|
|
[ ! -f "$BIN" ] && echo binary file $BIN does not exist && exit 1
|
|
|
|
[ ! -x "$BIN" ] && echo binary file $BIN is not executable && exit 1
|
|
|
|
[ ! -f "$CONF" ] && echo no configuration file $CONF && exit 1
|
2020-11-27 14:42:53 -08:00
|
|
|
# source any need environment files in $DIR/env
|
|
|
|
for f in $DIR/env/*.env; do source $f; done
|
|
|
|
echo Running caddy binary $BIN with configuration $CONF and command $CMD as user $USER
|
|
|
|
$BIN $CMD --config $CONF --adapter caddyfile
|