Merge pull request #136 from rhansen/init-script-cleanup

This commit is contained in:
Sandro 2020-05-29 03:23:57 +02:00 committed by GitHub
commit d5c4895115
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,59 +33,68 @@ export PATH
# See how we were called. # See how we were called.
case "$1" in case "$1" in
start) start)
# Start daemon. # See if daemon=value is specified in the config file.
DELAY=`grep -v '^\s*#' $CONF | grep -i -m 1 "daemon" | awk -F '=' '{print $2}'` # Assumptions:
if [ -z "$DELAY" ] ; then # * there are no quoted "#" characters before "daemon="
DELAY="-daemon 300" # (if there is a "#" it starts a comment)
else # * "daemon=" does not appear in a password or value
DELAY='' # * if the interval value is 0, it is not quoted
fi INTERVAL=$(sed -e '
echo -n "Starting ddclient: " s/^\([^#]*[,[:space:]]\)\{0,1\}daemon=\([^,[:space:]]*\).*$/\2/
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then t quit
daemon $program $DELAY d
else :quit
ddclient $DELAY q
fi ' "$CONF")
echo if [ -z "$DELAY" ] || [ "$DELAY" = "0" ]; then
;; DELAY="-daemon 300"
stop)
# Stop daemon.
echo -n "Shutting down ddclient: "
if [ -n "$PID" ] ; then
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
killproc $program
else else
kill $PID # use the interval specified in the config file
DELAY=''
fi fi
else echo -n "Starting ddclient: "
echo "ddclient is not running" if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
fi daemon $program $DELAY
echo else
;; ddclient $DELAY
restart)
$0 stop
$0 start
;;
status)
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
status $program
else
if test "$PID"
then
for p in $PID
do
echo "$program (pid $p) is running"
done
else
echo "$program is stopped"
fi fi
fi echo
;; ;;
*) stop)
echo "Usage: ddclient {start|stop|restart|status}" # Stop daemon.
exit 1 echo -n "Shutting down ddclient: "
if [ -n "$PID" ]; then
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
killproc $program
else
kill $PID
fi
else
echo "ddclient is not running"
fi
echo
;;
restart)
$0 stop
$0 start
;;
status)
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
status $program
else
if test "$PID"; then
for p in $PID; do
echo "$program (pid $p) is running"
done
else
echo "$program is stopped"
fi
fi
;;
*)
echo "Usage: ddclient {start|stop|restart|status}"
exit 1
esac esac
exit 0 exit 0