diff --git a/hub-service b/hub-service new file mode 100644 index 0000000..30be7f5 --- /dev/null +++ b/hub-service @@ -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" +} diff --git a/waterfall-service b/waterfall-service new file mode 100644 index 0000000..bcc919f --- /dev/null +++ b/waterfall-service @@ -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" +}