pleroma/installation/netbsd/rc.d/pleroma

61 lines
1.0 KiB
Plaintext
Raw Normal View History

2018-12-16 04:33:50 -08:00
#!/bin/sh
# PROVIDE: pleroma
2024-06-19 16:40:02 -07:00
# REQUIRE: DAEMON pgsql nginx
2018-12-16 04:33:50 -08:00
if [ -f /etc/rc.subr ]; then
. /etc/rc.subr
fi
2024-06-19 16:40:02 -07:00
pleroma_home="/home/pleroma"
pleroma_user="pleroma"
2018-12-16 04:33:50 -08:00
name="pleroma"
rcvar=${name}
command="/usr/pkg/bin/elixir"
2018-12-16 05:11:17 -08:00
command_args="--detached -S /usr/pkg/bin/mix phx.server"
2018-12-16 04:33:50 -08:00
start_precmd="ulimit -n unlimited"
2018-12-16 05:11:17 -08:00
pidfile="/dev/null"
2018-12-16 04:33:50 -08:00
pleroma_chdir="${pleroma_home}/pleroma"
pleroma_env="HOME=${pleroma_home} MIX_ENV=prod"
check_pidfile()
{
2018-12-16 05:11:17 -08:00
pid=$(pgrep -U "${pleroma_user}" /bin/beam.smp$)
2024-06-19 16:40:02 -07:00
printf '%s' "${pid}"
2018-12-16 04:33:50 -08:00
}
2024-06-19 16:40:02 -07:00
if [ -f /etc/rc.subr ] && [ -d /etc/rc.d ] && [ -f /etc/rc.d/DAEMON ]; then
2018-12-16 05:11:17 -08:00
# newer NetBSD
2018-12-16 04:33:50 -08:00
load_rc_config ${name}
run_rc_command "$1"
2018-12-16 05:11:17 -08:00
else
# ancient NetBSD, Solaris and illumos, Linux, etc...
2018-12-16 04:33:50 -08:00
cmd=${1:-start}
case ${cmd} in
start)
echo "Starting ${name}."
${start_cmd}
;;
stop)
echo "Stopping ${name}."
2018-12-16 05:11:17 -08:00
check_pidfile
2024-06-19 16:40:02 -07:00
! [ -n "${pid}" ] && kill "${pid}"
2018-12-16 04:33:50 -08:00
;;
restart)
( $0 stop )
sleep 5
$0 start
;;
*)
echo 1>&2 "Usage: $0 [start|stop|restart]"
exit 1
;;
esac
exit 0
fi