Changeset 1767
- Timestamp:
- 12/03/08 19:43:54 (1 month ago)
- Files:
-
- trunk/opsview-web/debian/init.d (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/opsview-web/debian/init.d
r1521 r1767 27 27 # processname: opsview_web_server.pl 28 28 29 piddir="/var/run/opsview" 30 pidfile="${piddir}/opsview-web.pid" 31 29 32 # Switch to nagios if run as root 30 if [ `id -u` = "0" ] ; then 31 case "$0" in 32 /*) cmd="$0" ;; 33 *) cmd=`which $0` 34 case "$cmd" in 35 /*) ;; 36 *) cmd="$PWD/$cmd";; 37 esac 38 ;; 39 esac 40 exec su - nagios -c "$cmd $@" 33 id | grep "uid=0(" 1>/dev/null 34 if [ $? = "0" ] ; then 35 test -d $piddir || ( mkdir $piddir && chown nagios:nagios $piddir) 36 case "$0" in 37 /*) cmd="$0" ;; 38 *) cmd=`which $0` 39 case "$cmd" in 40 /*) ;; 41 *) cmd="$PWD/$cmd";; 42 esac 43 ;; 44 esac 45 exec su - nagios -c "$cmd $@" 41 46 fi 42 47 43 48 if [ -r /etc/rc.d/init.d/functions ]; then 44 . /etc/rc.d/init.d/functions49 . /etc/rc.d/init.d/functions 45 50 fi 46 51 47 52 die() { echo $1; exit 1; } 48 53 54 if [ ! -d /var/run/opsview ]; then 55 echo "/var/run/opsview is missing; please re-run this script as root" 56 exit 1 57 fi 58 49 59 start() { 50 60 if [ ! -f $pidfile ] ; then 51 echo -n "Starting opsview-web: " 52 script/opsview_web_server.pl -f -b -pidfile $pidfile 61 printf "Starting opsview-web: " 62 if [ "$USE_LIGHTTPD" = "0" ]; then 63 64 script/opsview_web_server.pl -f -b --pidfile $pidfile 65 else 66 script/opsview_web_fastcgi.pl -e -d -n $LIGHTTPD_DAEMONS -p $pidfile -l $LIGHTTPD_SOCKET 67 fi 53 68 RETVAL=$? 54 69 echo 55 70 else 56 # Check if process is still running57 pid=`cat $pidfile`58 proc_name=`ps -p $pid -o comm=`59 if ! [ "$proc_name"= "opsview_web_ser" ]; then60 (rm -f $pidfile && start)61 fi71 # Check if process is still running 72 pid=`cat $pidfile` 73 proc_name=`ps -p $pid -o comm=` 74 if [ "$proc_name" != "opsview_web_ser" ]; then 75 (rm -f $pidfile && start) 76 fi 62 77 fi 63 78 return $RETVAL … … 75 90 return 1 76 91 fi 77 echo -n "Stopping opsview-web: " 92 proc_name=`ps -p $pid -o comm=` 93 if [ "$proc_name" != "opsview_web_ser" ] && [ "$proc_name" != "opsview_web_fas" ]; then 94 echo "Incorrect pid in pid file. Ignoring" 95 rm -f $pidfile 96 return 1 97 fi 98 printf "Stopping opsview-web: " 78 99 kill $pid > /dev/null 2>&1 79 100 sleep 5 … … 107 128 } 108 129 130 # Redirect fd3 which is left open by Debian's apt-get install process 131 exec 3>/dev/null 132 109 133 RETVAL=0 110 134 111 pidfile="/usr/local/nagios/var/opsview-web.pid" 135 eval `/usr/local/nagios/bin/opsview.sh` 136 test "x$USE_LIGHTTPD" = "x" && die "Couldn't run opsview.sh" 137 138 if [ "$USE_HTTPS" -eq 1 ]; then 139 HTTPS=on 140 export HTTPS 141 fi 112 142 113 143 cd /usr/local/opsview-web || die "Cannot chdir" … … 124 154 125 155 exit $RETVAL 126 127
