Since we're moving to systemd, these files are not needed anymore. Other than controlling how to start the daemon, that we want to get rid of, /etc/default/ngcp-panel only contains NPROC. Moved now to the systemd-unit file, so it can be overriden if needed. Change-Id: Ibfd917431663dee53a4a26a9c69373cf3449e2f4changes/21/19821/2
parent
0093c332e9
commit
e001a97650
@ -1,2 +0,0 @@
|
||||
RUN_DAEMON="no"
|
||||
NPROC=1
|
@ -1,163 +0,0 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: ngcp-panel
|
||||
# Required-Start: $syslog $network $local_fs $remote_fs $time
|
||||
# Required-Stop: $syslog $network $local_fs $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Should-Start: mysql
|
||||
# Short-Description: Start the ngcp-panel webapp
|
||||
# Description: Start the ngcp-panel webapp
|
||||
### END INIT INFO
|
||||
|
||||
umask 0022
|
||||
# shellcheck disable=SC1091
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
INTERP=/usr/bin/perl
|
||||
DAEMON=/usr/share/ngcp-panel/ngcp_panel_fastcgi.pl
|
||||
HOMEDIR=/usr/share/ngcp-panel
|
||||
export HOME=$HOMEDIR
|
||||
HOMERUN=/var/run/fastcgi
|
||||
PIDFILE=$HOMERUN/ngcp-panel.pid
|
||||
USER=www-data
|
||||
GROUP=www-data
|
||||
NAME="ngcp-panel"
|
||||
DESC="NGCP-Panel Webapp"
|
||||
DEFAULTS=/etc/default/$NAME
|
||||
USOCKET=$HOMERUN/ngcp-panel.sock
|
||||
NPROC=1
|
||||
|
||||
if ! [ -x "$DAEMON" ] ; then
|
||||
log_warning_msg "File $DAEMON not available/executable."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
check_running() {
|
||||
if [ -s $PIDFILE ]; then
|
||||
/bin/kill -0 "$(cat $PIDFILE)" >/dev/null 2>&1
|
||||
else
|
||||
PID=$(pidofproc $DAEMON)
|
||||
if [ -z "$PID" ]; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# this is a workaround for slow startup of ngcp-panel and generation of its pidfile
|
||||
check_for_ongoing_startup() {
|
||||
# if no other ngcp-panel init script is running store our PID
|
||||
if ! [ -r "${PIDFILE}.startup" ] ; then
|
||||
echo "$$" > "${PIDFILE}.startup"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# another init script started up but didn't log a PID?
|
||||
startup_pid="$(cat ${PIDFILE}.startup)"
|
||||
if [ -z "$startup_pid" ] ; then
|
||||
log_progress_msg "starting up with invalid PID, forcing start"
|
||||
echo "$$" > "${PIDFILE}.startup"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# another init script started but was interrupted?
|
||||
# shellcheck disable=SC2009
|
||||
if ! ps -o pid "$startup_pid" | grep -q -- "$startup_pid" ; then
|
||||
log_progress_msg "interrupted during startup, forcing start"
|
||||
echo "$$" > "${PIDFILE}.startup"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_progress_msg "is already starting up, ignored"
|
||||
return 1
|
||||
}
|
||||
|
||||
_start() {
|
||||
if [ "$RUN_DAEMON" != "yes" ]; then
|
||||
log_failure_msg "$NAME not yet configured. Edit /etc/default/$NAME first."
|
||||
log_end_msg 0
|
||||
exit 0
|
||||
fi
|
||||
if check_running; then
|
||||
log_progress_msg "already running"
|
||||
log_end_msg 0
|
||||
exit 0
|
||||
fi
|
||||
check_for_ongoing_startup || return 0
|
||||
rm -f "$PIDFILE" 2>/dev/null
|
||||
# shellcheck disable=SC2086
|
||||
start-stop-daemon --start --quiet --oknodo \
|
||||
--startas $DAEMON \
|
||||
--pidfile $PIDFILE \
|
||||
--exec $INTERP --chdir $HOMEDIR \
|
||||
--user $USER --group $GROUP --chuid $USER:$GROUP \
|
||||
-- $OPTIONS >/dev/null 2>&1 || log_failure_msg "error"
|
||||
rm -f "${PIDFILE}.startup"
|
||||
sleep 1
|
||||
if check_running ; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
_stop() {
|
||||
if ! check_running ; then
|
||||
log_progress_msg " not running"
|
||||
return 0
|
||||
fi
|
||||
start-stop-daemon --stop --quiet --oknodo --retry 5 \
|
||||
--pidfile $PIDFILE \
|
||||
--exec $INTERP \
|
||||
--user $USER
|
||||
}
|
||||
|
||||
# Load startup options if available
|
||||
if [ -f $DEFAULTS ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. $DEFAULTS || true
|
||||
fi
|
||||
|
||||
OPTIONS="--listen $USOCKET --daemon --pidfile $PIDFILE --nproc $NPROC"
|
||||
|
||||
# $HOMERUN perms
|
||||
mkdir -p $HOMERUN && chown -R $USER:$GROUP $HOMERUN && chmod 0755 $HOMERUN
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
log_daemon_msg "Starting $DESC"
|
||||
_start; status="$?"
|
||||
log_end_msg $status
|
||||
exit $status
|
||||
;;
|
||||
stop)
|
||||
log_daemon_msg "Stopping $DESC: $NAME"
|
||||
_stop; status="$?"
|
||||
log_end_msg $status
|
||||
exit $status
|
||||
;;
|
||||
restart|force-reload)
|
||||
log_daemon_msg "Restarting web application" $NAME
|
||||
_stop; status="$?"
|
||||
if [ "$status" = 0 ]; then
|
||||
_start; status="$?"
|
||||
fi
|
||||
log_end_msg $status
|
||||
exit $status
|
||||
;;
|
||||
status)
|
||||
log_action_msg "Status of $DESC"
|
||||
if [ -s $PIDFILE ]; then
|
||||
status_of_proc -p$PIDFILE $DAEMON $NAME ; exit $?
|
||||
else
|
||||
status_of_proc $DAEMON $NAME; exit $?
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
N=/etc/init.d/$NAME
|
||||
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
@ -0,0 +1 @@
|
||||
ngcp-panel: init.d-script-not-included-in-package etc/init.d/ngcp-panel
|
@ -0,0 +1,2 @@
|
||||
rm_conffile /etc/default/ngcp-panel 6.3.0.0+0~ ngcp-panel
|
||||
rm_conffile /etc/init.d/ngcp-panel 6.3.0.0+0~ ngcp-panel
|
Loading…
Reference in new issue