kebler.net
6567658636
- put commandline option back int - supports instance folder in conf/ - supports _shared conf folder -- supports instance script moved instance specific conf to branches moved things around and updated gitigonre in support of refactored script
35 lines
No EOL
1.1 KiB
Bash
Executable file
35 lines
No EOL
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
SDIR=$(dirname "$(readlink -f "$0")") || exit
|
|
DIR=$(dirname "$SDIR") || exit
|
|
INSTANCE=${1:-default}
|
|
source $SDIR/library
|
|
echo $SDIR
|
|
get-caddy-bin # this sets $CADDY_BIN
|
|
CONF_DIR=$DIR/conf/$INSTANCE
|
|
CONF_SHARED_DIR=$DIR/conf/_shared
|
|
CONF=$CONF_DIR/caddy.conf
|
|
SCRIPT=$CONF_DIR/script
|
|
BIN=$DIR/bin/$CADDY_BIN
|
|
echo running 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
|
|
if [ -f "$SCRIPT" ]; then
|
|
source $SCRIPT
|
|
fi
|
|
if [ ! $INVOCATION_ID ]; then
|
|
CAP="cap_net_bind_service+eip"
|
|
ISSET=$(getcap $BIN | grep $CAP )
|
|
if [ ! "$ISSET" ]; then
|
|
echo binary $BIN not set for binding port 80 by non-root users, attempting to set
|
|
sudo setcap $CAP $BIN
|
|
ISSET=$(getcap $BIN | grep $CAP)
|
|
echo after $ISSET
|
|
[ ! "$ISSET" ] && echo unable to set port binding && exit 1
|
|
fi
|
|
echo running caddy from commandline, enter caddy user password
|
|
su -c "$BIN run --config $CONF --adapter caddyfile" caddy
|
|
else
|
|
echo running caddy via systemd service
|
|
$BIN run --config $CONF --adapter caddyfile
|
|
fi |