Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

New path to PID file #18

Closed
wants to merge 2 commits into from

2 participants

Johan Ryberg Sven Nierlein
Johan Ryberg
Collaborator

No description provided.

Sven Nierlein sni closed this
Sven Nierlein
Owner
sni commented

thanks. should be updated now. please also rebase your fork, it doesn't match the upstream anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 8, 2014
  1. Johan Ryberg

    Added Debian init script

    jryberg authored
  2. Johan Ryberg

    New path to PID

    jryberg authored
This page is out of date. Refresh to see the latest.
Showing with 206 additions and 1 deletion.
  1. +205 −0 debian/naemon-core.init
  2. +1 −1  debian/rules
205 debian/naemon-core.init
View
@@ -0,0 +1,205 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: naemon
+# Required-Start: $local_fs $remote_fs $syslog $network
+# Required-Stop: $local_fs $remote_fs $syslog $network
+# Should-Start:
+# Should-Stop:
+# Default-Start: 3 5
+# Default-Stop: 0 1 2 6
+# Short-Description: start and stop Naemon monitoring server
+# Description: Naemon is is a service monitoring system
+### END INIT INFO
+
+# Source function library.
+
+. /lib/lsb/init-functions
+
+status() {
+ [ ! -e $pidfile ] && return 1;
+ PID=`cat $pidfile`;
+ kill -0 $PID
+ return $?
+}
+
+pidof_naemon() {
+ if [ -e "$pidfile" ]; then
+ if pidof $prog | tr ' ' '\n' | grep -w $(cat $pidfile); then
+ return 0
+ fi
+ fi
+ return 1
+}
+
+prefix="/usr"
+exec_prefix="${prefix}"
+exec="/usr/bin/naemon"
+prog="naemon"
+config="/etc/naemon/naemon.cfg"
+pidfile="/var/run/naemon/naemon.pid"
+pidfolder="`dirname $pidfile`"
+user="naemon"
+group="naemon"
+checkconfig="false"
+
+# Default nice for performance, change in sysconfig file not here!
+NICELEVEL=0
+
+lockfile=/var/lock/subsys/$prog
+
+check_config() {
+ TMPFILE=$(mktemp /tmp/.configtest.XXXXXXXX)
+ $0 configtest > "$TMPFILE"
+ WARN=`grep ^"Total Warnings:" "$TMPFILE" |awk -F: '{print \$2}' |sed s/' '//g`
+ ERR=`grep ^"Total Errors:" "$TMPFILE" |awk -F: '{print \$2}' |sed s/' '//g`
+
+ if test "$WARN" = "0" && test "${ERR}" = "0"; then
+ echo "OK - Configuration check verified" > /var/cache/naemon/naemon.configtest
+ retval=0
+ chmod 0644 /var/cache/naemon/naemon.configtest
+ /bin/rm "$TMPFILE"
+ return 0
+ else
+ # We'll write out the errors to a file we can have a
+ # script watching for
+ echo "WARNING: Errors in config files - see log for details: $TMPFILE" > /var/cache/naemon/naemon.configtest
+ egrep -i "(^warning|^error)" "$TMPFILE" >> /var/cache/naemon/naemon.configtest
+ chmod 0644 /var/cache/naemon/naemon.configtest
+ cat "$TMPFILE"
+ log_failure_msg "Error parsing configuration"
+ log_end_msg 8
+ exit 8
+ fi
+}
+
+naemon_wait_stop() {
+ stop
+ # wait until really stopped
+ if [ -n "${pid:-}" ]; then
+ i=0
+ while kill -0 "${pid:-}" 2> /dev/null; do
+ if [ $i = '60' ]; then
+ break;
+ else
+ if [ $i = '0' ]; then
+ echo -n " ... waiting "
+ else
+ echo -n "."
+ fi
+ i=$(($i+1))
+ sleep 1
+ fi
+ done
+ fi
+}
+
+start() {
+ retval=0
+ log_daemon_msg "Starting $prog: "
+ if [ ! -x $exec ]; then
+ log_failure_msg "Executable $exec does not exists or execute (or search) permission is denied"
+ log_end_msg 5
+ exit 5
+ fi
+ if [ ! -f $config ]; then
+ log_failure_msg "Config file $config does not exist"
+ log_end_msg 6
+ exit 6
+ fi
+ if [ "$checkconfig" = "false" ]; then
+ check_config
+ fi
+ # Create PID folder if it does not exist
+ if [ ! -d $pidfolder ]; then
+ mkdir $pidfolder
+ chown $user:$group $pidfolder
+ fi
+ # We need to _make sure_ the precache is there and verified
+ # Raise priority to make it run better
+ if type start-stop-daemon >/dev/null 2>&1; then
+ NICE_OPT=""
+ if [ $NICELEVEL != "0" ]; then NICE_OPT="--nicelevel $NICELEVEL"; fi
+ start-stop-daemon $NICE_OPT --start --user $user --name $prog --pidfile $pidfile --exec $exec -- -d $config
+ else
+ daemon --user=$user $exec -d $config
+ fi
+ retval=$?
+ log_end_msg $retval
+ return $retval
+ if [ -d /var/lock/subsys ]; then
+ test $retval -eq 0 && touch $lockfile
+ fi
+}
+
+stop() {
+ log_daemon_msg "Stopping $prog: "
+ retval=0
+ start-stop-daemon --oknodo --stop --quiet --exec $exec
+ retval=$?
+ test $retval -eq 0 && rm -f $lockfile
+ log_end_msg $retval
+ return $retval
+}
+
+
+restart() {
+ check_config
+ checkconfig="true"
+ pid=$(pidof_naemon) || true
+ naemon_wait_stop
+ echo
+ start
+}
+
+reload() {
+ log_daemon_msg "Reloading $prog: "
+ retval=0
+ pkill -HUP -u ${user} -f ${exec}
+ retval=$?
+ log_end_msg $retval
+}
+
+force_reload() {
+ restart
+}
+
+case "$1" in
+ start)
+ status $prog && exit 0
+ $1
+ ;;
+ stop)
+ status $prog || exit 0
+ $1
+ ;;
+ restart)
+ $1
+ ;;
+ reload)
+ status $prog || exit 7
+ $1
+ ;;
+ force-reload)
+ force_reload
+ ;;
+ status)
+ status_of_proc "$exec" "$prog" && exit 0 || exit $?
+ ;;
+ condrestart|try-restart)
+ status $prog|| exit 0
+ restart
+ ;;
+ configtest|check|checkconfig)
+ if type runuser >/dev/null 2>&1; then
+ runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $exec -vp $config"
+ else
+ /bin/su - -s /bin/sh $user -c "$corelimit >/dev/null 2>&1 ; $exec -vp $config"
+ fi
+ retval=$?
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
+ exit 3
+esac
+exit $?
2  debian/rules
View
@@ -25,7 +25,7 @@ override_dh_auto_configure:
--with-logrotatedir="/etc/logrotate.d" \
--with-naemon-user="naemon" \
--with-naemon-group="naemon" \
- --with-lockfile="/var/run/naemon/naemon.pid" \
+ --with-lockfile="/var/cache/naemon/naemon.pid" \
--with-thruk-user="www-data" \
--with-thruk-group="naemon" \
--with-thruk-libs="/usr/lib/naemon/perl5" \
Something went wrong with that request. Please try again.