82 lines
2.5 KiB
Bash
82 lines
2.5 KiB
Bash
#!/usr/bin/sh
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: pironman5
|
|
# Required-Start: $local_fs $network $remote_fs
|
|
# Required-Stop: $local_fs $network $remote_fs
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: Sunfounder Pironman5 Daemon
|
|
# Description: The Pironman5 project is software specifically designed
|
|
# for use with the Raspberry Pi 5. The software includes
|
|
# functionalities for controlling and monitoring the
|
|
# Raspberry Pi within a specialized case aimed at optimal
|
|
# cooling and user-friendliness.
|
|
|
|
NAME='pironman5'
|
|
DESC='Sunfounder Pironman5 Daemon'
|
|
USER='root'
|
|
GROUP='root'
|
|
PIDFOLDER="/run/${NAME}"
|
|
PIDFILE="${PIDFOLDER}/${NAME}.pid"
|
|
DAEMON='/usr/sbin/pironman5-service'
|
|
|
|
set -e
|
|
|
|
. /lib/lsb/init-functions
|
|
|
|
[ -x "${DAEMON}" ]
|
|
|
|
case "${1}" in
|
|
start)
|
|
/usr/bin/install --directory --group="${GROUP}" ---mode='0755' --owner="${USER}" "${PIDFOLDER}"
|
|
log_daemon_msg "Starting ${DESC}" "${NAME}"
|
|
/usr/sbin/pironman5-service 'normal'
|
|
if /usr/sbin/start-stop-daemon --quiet \
|
|
--start \
|
|
--oknodo \
|
|
--make-pidfile \
|
|
--pidfile "${PIDFILE}" \
|
|
--user "${USER}" \
|
|
--group "${GROUP}" \
|
|
--exec "${DAEMON}"; then
|
|
log_end_msg 0
|
|
else
|
|
log_end_msg 1
|
|
/usr/bin/test -f "${PIDFILE}" && \
|
|
/usr/bin/rm --force "${PIDFILE}"
|
|
fi
|
|
;;
|
|
stop)
|
|
log_daemon_msg "Stopping ${DESC}" "${NAME}"
|
|
if /usr/sbin/start-stop-daemon --quiet \
|
|
--stop \
|
|
--oknodo \
|
|
--retry 30 \
|
|
--remove-pidfile \
|
|
--pidfile "${PIDFILE}" \
|
|
--user "${USER}" \
|
|
--group "${GROUP}" \
|
|
--exec "${DAEMON}"; then
|
|
/usr/bin/test -f "${PIDFILE}" && \
|
|
/usr/bin/rm --force "${PIDFILE}"
|
|
log_end_msg 0
|
|
else
|
|
log_end_msg 1
|
|
fi
|
|
;;
|
|
restart)
|
|
"${0}" stop
|
|
"${0}" start
|
|
;;
|
|
status)
|
|
status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}" && \
|
|
exit 0 || \
|
|
exit "${?}"
|
|
;;
|
|
*)
|
|
echo "Usage: /etc/init.d/${NAME} {start|stop|restart|status}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|