PKGBUILDs/extra/martian-utils/martian
2009-10-09 21:23:22 -05:00

50 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
MARTIAN_TTY=
MARTIAN_USER=
MARTIAN_GROUP=
MARTIAN_COUNTRY=
[ -f /etc/conf.d/martian ] && . /etc/conf.d/martian
. /etc/rc.conf
. /etc/rc.d/functions
PIDFILE="/var/run/martian.pid"
PID=`pidof -o %PPID /usr/sbin/martian_modem`
case "$1" in
start)
stat_busy "Starting Martian Drivers"
[ -z "$PID" ] && martian_modem --daemon \
${MARTIAN_USER:+--user=${MARTIAN_USER}} \
${MARTIAN_GROUP:+--group=${MARTIAN_GROUP}} \
${MARTIAN_COUNTRY:+--country=${MARTIAN_COUNTRY}} \
${MARTIAN_TTY:+${MARTIAN_TTY}} &>/dev/null &
if [ $? -gt 0 ]; then
stat_fail
else
pidof -o %PPID /usr/sbin/martian_modem > "$PIDFILE"
add_daemon martian
stat_done
fi
;;
stop)
stat_busy "Stopping Martian Drivers"
[ -f "$PIDFILE" ] && kill `cat $PIDFILE` &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm -f "$PIDFILE" &> /dev/null
rm_daemon martian
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage $0 {start|stop|restart}"
;;
esac