OpenRC init script example, please upstream

294 views
Skip to first unread message

Tom

unread,
Apr 18, 2021, 5:38:20 PM4/18/21
to Prosody IM Users Group, Prosody IM Developers Group
Hello. I wanted to share my OpenRC example init script I made with
other prosody users that might find it useful if they are also running
OpenRC on their servers. I also think it would be useful to package
this script in the /usr/share/doc/prosody/ folder. Not this one
exactly, but a proper one I could send that uses tabs. I'm not sure my
formatting will come through properly on email.

# cat /etc/init.d/prosody
#!/usr/sbin/openrc-run

description="Prosody XMPP server"
extra_started_commands="reload signal healthcheck debug"
extra_commands="checkconfig"
command="/usr/bin/prosody"
commandctl="/usr/bin/prosodyctl"
command_args="--config ${PROSODY_CONFIG:-/etc/prosody/prosody.cfg.lua}"
command_args_foreground="-F"
command_user="${PROSODY_USER:-prosody}"
supervisor="supervise-daemon"
healthcheck_timer=10
healthcheck_delay=25

healthcheck() {
/usr/lib/nagios/plugins/check_http -H www.example.tld -I [::1]
-u /host_status_check -p 5280 return $?
}

unhealthy() { debug }

checkconfig() {
${commandctl} check config
return $?
}

reload() {
checkconfig || return 1
ebegin "Reloading configuration"
${supervisor} ${RC_SVCNAME} --signal HUP
eend $?
}

signal() {
ebegin "Reloading configuration"
${supervisor} ${RC_SVCNAME} --signal SIGUSR1
eend $?
}

debug() {
ebegin "Dumping debug ringbuffer"
${supervisor} ${RC_SVCNAME} --signal SIGUSR2
eend $?
}


start_pre() {
checkconfig || return 1

checkpath -d -m 0750 -o "${PROSODY_USER:-prosody}" -q
/var/log/prosody checkpath -d -m 0750 -o
"${PROSODY_USER:-prosody}":adm -q /run/prosody
}

--
_________________________________________
/ Superior ability breeds superior \
| ambition. |
| |
\ -- Spock, "Space Seed", stardate 3141.9 /
-----------------------------------------
\
\
/\ /\
//\\_//\\ ____
\_ _/ / /
/ * * \ /^^^]
\_\O/_/ [ ]
/ \_ [ /
\ \_ / /
[ [ / \/ _/
_[ [ \ /_/
Reply all
Reply to author
Forward
0 new messages