Last active
June 6, 2020 13:43
-
-
Save fusetim/7d12c875bd8fac8a10359fb23c333758 to your computer and use it in GitHub Desktop.
Openrc service description for Caddy2 (caddyserver)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# caddy options file | |
CADDY_OPTS="--config /etc/Caddyfile" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/sbin/openrc-run | |
name="Caddy webserver" | |
command=/usr/sbin/caddy | |
command_args="start $CADDY_OPTS" | |
command_user=caddy:caddy | |
extra_commands="checkconfig" | |
extra_started_commands="reload" | |
depend() { | |
need net localmount | |
after firewall | |
} | |
checkconfig() { | |
ebegin "Checking configuration for $RC_SVCNAME" | |
su -s /bin/sh ${command_user%:*} -c "$command validate $CADDY_OPTS" | |
eend $? | |
} | |
reload() { | |
checkconfig || return $? | |
ebegin "Reloading $RC_SVCNAME" | |
su -s /bin/sh ${command_user%:*} -c "$command reload $CADDY_OPTS" | |
eend $? | |
} | |
start_pre() { | |
if [ "$RC_CMD" != "restart" ]; then | |
checkconfig || return $? | |
fi | |
} | |
stop_pre() { | |
if [ "$RC_CMD" == "restart" ]; then | |
checkconfig || return $? | |
fi | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*:80 | |
respond "Hello, world!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment