mirror of
https://github.com/ShaYmez/MMDVM_CM.git
synced 2024-11-05 15:41:17 -05:00
77 lines
1.9 KiB
Desktop File
77 lines
1.9 KiB
Desktop File
#!/bin/bash
|
|
#########################################################
|
|
# #
|
|
# YSF2DMR Service Handler #
|
|
# #
|
|
# Written for Pi-Star (http://www.mw0mwz.co.uk/pi-star) #
|
|
# By Andy Taylor (MW0MWZ) #
|
|
# #
|
|
# Version 0.1 #
|
|
# #
|
|
#########################################################
|
|
|
|
# Service Config
|
|
DAEMON=YSF2DMR
|
|
DAEMON_PATH=/usr/local/bin/
|
|
CONFIG=/etc/YSF2DMR.ini
|
|
DAEMON_OPTS=$CONFIG
|
|
PGREP=/usr/bin/pgrep
|
|
KILL=/bin/kill
|
|
SLEEP=/bin/sleep
|
|
|
|
# Pre-flight checks...
|
|
test -x ${DAEMON_PATH}${DAEMON} || exit 1
|
|
test -r $CONFIG || exit 1
|
|
|
|
case "$1" in
|
|
start)
|
|
if [ `${PGREP} ${DAEMON}` ]; then
|
|
echo -e "$DAEMON is already running as PID "`$PGREP $DAEMON`
|
|
exit 1;
|
|
else
|
|
nice -n -5 ${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}
|
|
echo -e "$DAEMON started as PID "`$PGREP $DAEMON`
|
|
exit 0;
|
|
fi
|
|
;;
|
|
|
|
stop)
|
|
if [ `${PGREP} ${DAEMON}` ]; then
|
|
echo -e "Killing $DAEMON PID "`$PGREP $DAEMON`
|
|
$KILL `${PGREP} ${DAEMON}`
|
|
exit 0;
|
|
else
|
|
echo -e "$DAEMON is not running"
|
|
exit 1;
|
|
fi
|
|
;;
|
|
|
|
restart)
|
|
if [ `$PGREP $DAEMON` ]; then
|
|
echo -e "Killing $DAEMON PID "`$PGREP $DAEMON`
|
|
$KILL `${PGREP} ${DAEMON}`
|
|
$SLEEP 3
|
|
nice -n -5 ${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}
|
|
echo -e "$DAEMON re-started as PID "`${PGREP} ${DAEMON}`
|
|
exit 0;
|
|
else
|
|
echo -e "$DAEMON is not running"
|
|
nice -n -5 ${DAEMON_PATH}${DAEMON} ${DAEMON_OPTS}
|
|
echo -e "$DAEMON started as PID "`${PGREP} ${DAEMON}`
|
|
exit 0;
|
|
fi
|
|
;;
|
|
|
|
status)
|
|
if [ `${PGREP} ${DAEMON}` ]; then
|
|
echo -e "$DAEMON is running as PID "`${PGREP} ${DAEMON}`
|
|
else
|
|
echo -e "$DAEMON is not running"
|
|
fi
|
|
;;
|
|
|
|
*)
|
|
echo $"Usage: $0 {start|stop|restart|status}"
|
|
exit 1
|
|
esac
|