added service scripts for openrc

This commit is contained in:
Johannes Schmelz 2022-01-15 14:04:11 +01:00
parent 6efdac2391
commit 7aef16ee93
2 changed files with 124 additions and 0 deletions

64
hub-service Normal file
View File

@ -0,0 +1,64 @@
#!/sbin/openrc-run
description="SFS Minecraft hub server"
extra_started_commands="console"
console() {
hub-console -f
}
_hub_status() {
hub-status > /dev/null
}
depend() {
need waterfall-service
}
start_pre() {
mark_service_starting
}
start() {
hub-start
}
start_post() {
mark_service_started
}
status() {
if service_stopping; then
ewarn "status: stopping"
return 4
elif service_starting; then
ewarn "status: starting"
return 8
elif service_inactive; then
ewarn "status: inactive"
return 16
elif service_crashed; then
eerror "status: crashed"
return 32
elif ! _hub_status; then
mark_service_stopped
einfo "status: stopped"
return 3
else
mark_service_started
einfo "status: started"
return 0
fi
}
stop_pre() {
if _hub_status; then
mark_service_started
else
mark_service_stopped
fi
}
stop() {
service_started && eend "use \`rc-service $RC_SVCNAME console\` and enter the \`stop\` command manually"
}

60
waterfall-service Normal file
View File

@ -0,0 +1,60 @@
#!/sbin/openrc-run
description="SFS Waterfall proxy"
extra_started_commands="console"
console() {
waterfall-console -f
}
_waterfall_status() {
waterfall-status > /dev/null
}
start_pre() {
mark_service_starting
}
start() {
waterfall-start
}
start_post() {
mark_service_started
}
status() {
if service_stopping; then
ewarn "status: stopping"
return 4
elif service_starting; then
ewarn "status: starting"
return 8
elif service_inactive; then
ewarn "status: inactive"
return 16
elif service_crashed; then
eerror "status: crashed"
return 32
elif ! _waterfall_status; then
mark_service_stopped
einfo "status: stopped"
return 3
else
mark_service_started
einfo "status: started"
return 0
fi
}
stop_pre() {
if _waterfall_status; then
mark_service_started
else
mark_service_stopped
fi
}
stop() {
service_started && eend "use \`rc-service $RC_SVCNAME console\` and enter the \`end\` command manually"
}