Don't assume pidfile location

When configuring the dir for the pidfiles in our init scripts don't
assume the path is /var/run/$NAME. The defaults are now /var/run/zuul
now and could be set to other values as well. Instead of assuming
/var/run/$NAME we instead take the dirname of $PIDFILE and configure
whatever that dir is instead.

Change-Id: Idfd5d19e5171278b9bb7005edb4ae927a01f3615
This commit is contained in:
Clark Boylan 2018-01-02 16:30:53 -08:00
parent 22c76841cb
commit b513d9845e
5 changed files with 45 additions and 15 deletions

View File

@ -33,6 +33,8 @@ USER=root
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
PIDFILE_DIR=$(dirname $PIDFILE)
#
# Function that starts the daemon/service
#
@ -44,8 +46,10 @@ do_start()
# 2 if daemon could not be started
# 3 if pid file already exist
mkdir -p /var/run/$NAME
chown $USER /var/run/$NAME
if [ ! -d "$PIDFILE_DIR" ] ; then
mkdir -p $PIDFILE_DIR
chown $USER $PIDFILE_DIR
fi
ulimit -n 8192
ulimit -c unlimited
if [ -f $PIDFILE ]; then
@ -68,7 +72,9 @@ do_start()
do_stop()
{
$DAEMON stop
rm -f /var/run/$NAME/*
if [ -f "$PIDFILE" ] ; then
rm -f $PIDFILE
fi
return 0
}

View File

@ -33,6 +33,8 @@ USER=root
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
PIDFILE_DIR=$(dirname $PIDFILE)
#
# Function that starts the daemon/service
#
@ -44,8 +46,10 @@ do_start()
# 2 if daemon could not be started
# 3 if pid file already exist
mkdir -p /var/run/$NAME
chown $USER /var/run/$NAME
if [ ! -d "$PIDFILE_DIR" ] ; then
mkdir -p $PIDFILE_DIR
chown $USER $PIDFILE_DIR
fi
ulimit -n 8192
if [ -f $PIDFILE ]; then
return 3
@ -74,7 +78,9 @@ do_stop()
start-stop-daemon --stop --signal 9 --pidfile $PIDFILE
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
rm -f /var/run/$NAME/*
if [ -f "$PIDFILE" ] ; then
rm -f $PIDFILE
fi
return "$RETVAL"
}

View File

@ -33,6 +33,8 @@ USER=zuul
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
PIDFILE_DIR=$(dirname $PIDFILE)
#
# Function that starts the daemon/service
#
@ -44,8 +46,10 @@ do_start()
# 2 if daemon could not be started
# 3 if pid file already exist
mkdir -p /var/run/$NAME
chown $USER /var/run/$NAME
if [ ! -d "$PIDFILE_DIR" ] ; then
mkdir -p $PIDFILE_DIR
chown $USER $PIDFILE_DIR
fi
ulimit -n 8192
if [ -f $PIDFILE ]; then
return 3
@ -74,7 +78,9 @@ do_stop()
start-stop-daemon --stop --signal 9 --pidfile $PIDFILE
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
rm -f /var/run/$NAME/*
if [ -f "$PIDFILE" ] ; then
rm -f $PIDFILE
fi
return "$RETVAL"
}

View File

@ -33,6 +33,8 @@ USER=zuul
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
PIDFILE_DIR=$(dirname $PIDFILE)
#
# Function that starts the daemon/service
#
@ -44,8 +46,10 @@ do_start()
# 2 if daemon could not be started
# 3 if pid file exits already
mkdir -p /var/run/$NAME
chown $USER /var/run/$NAME
if [ ! -d "$PIDFILE_DIR" ] ; then
mkdir -p $PIDFILE_DIR
chown $USER $PIDFILE_DIR
fi
ulimit -n 8192
if [ -f $PIDFILE ]; then
return 3
@ -74,7 +78,9 @@ do_stop()
start-stop-daemon --stop --signal 9 --pidfile $PIDFILE
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
rm -f /var/run/$NAME/*
if [ -f "$PIDFILE" ] ; then
rm -f $PIDFILE
fi
return "$RETVAL"
}

View File

@ -33,6 +33,8 @@ USER=zuul
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
PIDFILE_DIR=$(dirname $PIDFILE)
#
# Function that starts the daemon/service
#
@ -44,8 +46,10 @@ do_start()
# 2 if daemon could not be started
# 3 if pid file already exist
mkdir -p /var/run/$NAME
chown $USER /var/run/$NAME
if [ ! -d "$PIDFILE_DIR" ] ; then
mkdir -p $PIDFILE_DIR
chown $USER $PIDFILE_DIR
fi
ulimit -n 8192
if [ -f $PIDFILE ]; then
return 3
@ -74,7 +78,9 @@ do_stop()
start-stop-daemon --stop --signal 9 --pidfile $PIDFILE
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
rm -f /var/run/$NAME/*
if [ -f "$PIDFILE" ] ; then
rm -f $PIDFILE
fi
return "$RETVAL"
}