new caddy script which is used to launch caddy either from commandline or systemd
parent
aaa5ff0ae2
commit
b9f310d461
|
@ -6,6 +6,5 @@
|
|||
env/
|
||||
conf/
|
||||
user/
|
||||
caddy
|
||||
build/
|
||||
user/
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
SDIR=$(dirname "$(readlink -f "$0")") || exit
|
||||
DIR=$(dirname "$SDIR") || exit
|
||||
source $SDIR/library
|
||||
CONF=$DIR/conf/${1:-caddy}.conf
|
||||
get-caddy-name # this sets $CADDY_BIN
|
||||
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 [ $INVOCATION_ID ]; then
|
||||
echo running under systemd service
|
||||
else
|
||||
CAP="cap_net_bind_service+eip"
|
||||
ISSET=$(getcap $BIN | grep $CAP )
|
||||
echo before $ISSET
|
||||
if [ ! "$ISSET" ]; then
|
||||
echo binary 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
|
||||
fi
|
||||
echo $BIN run --config $CONF --adapter caddyfile
|
||||
set-env $DIR/env
|
||||
su -c "for f in $DIR/env/*.env; do source $f; done && $BIN run --config $CONF --adapter caddyfile" - caddy
|
Loading…
Reference in New Issue