Merge pull request #136 from rhansen/init-script-cleanup
This commit is contained in:
commit
d5c4895115
1 changed files with 59 additions and 50 deletions
|
@ -34,11 +34,23 @@ export PATH
|
|||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
# Start daemon.
|
||||
DELAY=`grep -v '^\s*#' $CONF | grep -i -m 1 "daemon" | awk -F '=' '{print $2}'`
|
||||
if [ -z "$DELAY" ] ; then
|
||||
# See if daemon=value is specified in the config file.
|
||||
# Assumptions:
|
||||
# * there are no quoted "#" characters before "daemon="
|
||||
# (if there is a "#" it starts a comment)
|
||||
# * "daemon=" does not appear in a password or value
|
||||
# * if the interval value is 0, it is not quoted
|
||||
INTERVAL=$(sed -e '
|
||||
s/^\([^#]*[,[:space:]]\)\{0,1\}daemon=\([^,[:space:]]*\).*$/\2/
|
||||
t quit
|
||||
d
|
||||
:quit
|
||||
q
|
||||
' "$CONF")
|
||||
if [ -z "$DELAY" ] || [ "$DELAY" = "0" ]; then
|
||||
DELAY="-daemon 300"
|
||||
else
|
||||
# use the interval specified in the config file
|
||||
DELAY=''
|
||||
fi
|
||||
echo -n "Starting ddclient: "
|
||||
|
@ -52,7 +64,7 @@ case "$1" in
|
|||
stop)
|
||||
# Stop daemon.
|
||||
echo -n "Shutting down ddclient: "
|
||||
if [ -n "$PID" ] ; then
|
||||
if [ -n "$PID" ]; then
|
||||
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
|
||||
killproc $program
|
||||
else
|
||||
|
@ -71,10 +83,8 @@ case "$1" in
|
|||
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
|
||||
status $program
|
||||
else
|
||||
if test "$PID"
|
||||
then
|
||||
for p in $PID
|
||||
do
|
||||
if test "$PID"; then
|
||||
for p in $PID; do
|
||||
echo "$program (pid $p) is running"
|
||||
done
|
||||
else
|
||||
|
@ -88,4 +98,3 @@ case "$1" in
|
|||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
|
|
Loading…
Reference in a new issue