Created
November 24, 2015 23:35
-
-
Save garret-smith/1caa9664f669ae18fcb5 to your computer and use it in GitHub Desktop.
FreeBSD style daemon wrapper around relx start script
This file contains 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
#!/bin/sh | |
# PROVIDE: service_name | |
# REQUIRE: LOGIN ntpd | |
# KEYWORD: shutdown | |
. /etc/rc.subr | |
name=service_name | |
rcvar=${name}_enable | |
start_cmd="${name}_start" | |
stop_cmd="${name}_stop" | |
stop_postcmd="kill_epmd" | |
attach_cmd="${name}_attach" | |
extra_commands="attach" | |
load_rc_config $name | |
: ${service_user:=username} | |
: ${service_enable:=no} | |
erts_bin=/path/to/erts-*/bin | |
relx_script=/path/to/bin/${name} | |
service_name() { | |
C="$relx_script $*" | |
su -m $service_user -c "$C" | |
} | |
service_start() { | |
service start | |
} | |
service_stop() { | |
service stop | |
} | |
service_attach() { | |
service attach | |
} | |
run_rc_command "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment