mcst-linux-kernel/patches-2024.06.26/ofono-1.25/files/etc.mcst/init.d/ofono

93 lines
1.4 KiB
Bash
Executable File

#! /bin/sh
### BEGIN INIT INFO
# Provides: ofono
# Required-Start: $syslog $remote_fs dbus
# Required-Stop: $syslog $remote_fs dbus
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: oFono Mobile Telephony Daemon
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/ofonod
NAME=ofonod
PIDFILE=/var/run/$NAME.pid
DESC="oFono Mobile Telephony Daemon"
test -x $DAEMON || exit 0
. /etc/rc.d/init.d/functions
# allow the admin to set DAEMON_OPTS
if [ -f /etc/default/ofono ]; then
. /etc/default/ofono
fi
do_start()
{
start-stop-daemon -S -q -b --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- -n
}
do_stop()
{
start-stop-daemon -K -q --remove-pidfile --pidfile $PIDFILE
}
checkrc() {
if [ $? = 0 ]; then
success
else
failure
fi
}
success()
{
echo -e "[ OK ]\r"
}
failure()
{
echo -e "[FAILED]\r"
}
case "$1" in
start)
echo "Starting $DESC: $NAME"
pid=$( pidofproc -p $PIDFILE $DAEMON )
if [ -n "$pid" ] ; then
echo "Already running"
exit 0
fi
do_start
checkrc
;;
stop)
echo "Stopping $DESC: $NAME"
do_stop
checkrc
;;
restart|force-reload)
echo "Restarting $DESC: $NAME"
echo "Stopping $NAME..."
do_stop
checkrc
sleep 1
echo "Starting $NAME..."
do_start
checkrc
;;
status)
statusproc $DAEMON
exit $?
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
;;
esac
exit 0