#!/bin/sh
#
# /etc/rc.d/rc.gem: start/stop/status gem daemon
#
# Written by G. Galdini <dioniso@disroot.org>

case "$1" in
 start)
	( /usr/sbin/gem -d /var/gmi/capsule -h localhost -aev \
	 >> /var/gmi/log 2>&1 ) &
	;;
 stop)
	pid="$(pidof gem)"
	[ -z "$pid" ] && { echo "already stop" ; exit 1 ;}
	kill -9 "$pid"
	;;
 restart)
	sh $0 stop
	sh $0 start
 	;;
 status)
	if &>/dev/null pidof 'gem' ; then
	 echo "running"
	else
	 echo "stop"
	fi
	;;
 *)
	echo "usage: $0 [start|stop|restart|status]"
	;;
esac
