Changeset 1767

Show
Ignore:
Timestamp:
12/03/08 19:43:54 (1 month ago)
Author:
duncan
Message:

As updated by debian packaging process

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/opsview-web/debian/init.d

    r1521 r1767  
    2727# processname: opsview_web_server.pl 
    2828 
     29piddir="/var/run/opsview" 
     30pidfile="${piddir}/opsview-web.pid" 
     31 
    2932# 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 $@" 
     33id | grep "uid=0(" 1>/dev/null 
     34if [ $? = "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 $@" 
    4146fi 
    4247 
    4348if [ -r /etc/rc.d/init.d/functions ]; then 
    44   . /etc/rc.d/init.d/functions 
     49       . /etc/rc.d/init.d/functions 
    4550fi 
    4651 
    4752die() { echo $1; exit 1; } 
    4853 
     54if [ ! -d /var/run/opsview ]; then 
     55        echo "/var/run/opsview is missing; please re-run this script as root" 
     56        exit 1 
     57fi 
     58 
    4959start() { 
    5060        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 
    5368                RETVAL=$? 
    5469                echo 
    5570        else 
    56           # Check if process is still running 
    57           pid=`cat $pidfile` 
    58           proc_name=`ps -p $pid -o comm=` 
    59           if ! [ "$proc_name" = "opsview_web_ser" ]; then 
    60             (rm -f $pidfile && start) 
    61           fi 
     71               # 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 
    6277        fi 
    6378        return $RETVAL 
     
    7590                return 1 
    7691        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: " 
    7899        kill $pid > /dev/null 2>&1 
    79100        sleep 5 
     
    107128} 
    108129 
     130# Redirect fd3 which is left open by Debian's apt-get install process 
     131exec 3>/dev/null 
     132 
    109133RETVAL=0 
    110134 
    111 pidfile="/usr/local/nagios/var/opsview-web.pid" 
     135eval `/usr/local/nagios/bin/opsview.sh` 
     136test "x$USE_LIGHTTPD" = "x" && die "Couldn't run opsview.sh" 
     137 
     138if [ "$USE_HTTPS" -eq 1 ]; then 
     139        HTTPS=on 
     140        export HTTPS 
     141fi 
    112142 
    113143cd /usr/local/opsview-web || die "Cannot chdir" 
     
    124154 
    125155exit $RETVAL 
    126          
    127