Files
weewx/util/init.d/weewx.redhat
2020-04-22 17:27:48 -04:00

75 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
# Author: Mark Jenks <mjenks@netnet.net>
# Startup script for Redhat derivatives
#
# chkconfig: 2345 99 01
# description: start and stop the weewx weather system
#
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=weewx
WEEWX_BIN=/home/weewx/bin/weewxd
WEEWX_CFG=/home/weewx/weewx.conf
WEEWX_PID=/var/run/$NAME.pid
WEEWX_LOCK=/var/lock/subsys/$NAME
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Exit if the package is not installed
[ -x "$WEEWX_BIN" ] || exit 0
DAEMON_ARGS="--daemon --pidfile=$WEEWX_PID $WEEWX_CFG"
# Source function library.
. /etc/init.d/functions
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n $"Starting $NAME: "
daemon --pidfile $WEEWX_PID $WEEWX_BIN $DAEMON_ARGS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $WEEWX_LOCK
;;
stop)
# Stop daemon.
echo -n $"Shutting down $NAME: "
killproc $NAME
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $WEEWX_LOCK
;;
status)
echo -n $"Checking for $NAME: "
status $NAME
RETVAL=$?
;;
restart)
echo -n $"Restarting $NAME: "
$0 stop
$0 start
;;
reload)
echo -n $"Reloading $NAME: "
killproc $NAME -HUP
RETVAL=$?
echo
;;
condrestart)
[ -f $WEEWX_LOCK ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload}"
RETVAL=1
;;
esac
exit $RETVAL