Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:fchua:ubuntu
ais
debian.ais-service.aissvc.init
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File debian.ais-service.aissvc.init of Package ais
#!/bin/bash # Analytic Information System start/stop script. # Usually this is put in /etc/init.d (at least on machines SYSV R4 based # systems) and linked to /etc/rc3.d/S99aissvc and /etc/rc0.d/K01aissvc. # When this is done the ais service will be started when the machine is # started and shut down when the systems goes down. # Comments to support chkconfig on RedHat Linux # chkconfig: 2345 70 30 # description: Analytic Information System. # Comments to support LSB init script conventions ### BEGIN INIT INFO # Provides: aissvc # Required-Start: $local_fs $network $remote_fs # Required-Stop: $local_fs $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start and stop AIS # Description: Analytic Information System. ### END INIT INFO service_startup_timeout=900 user=ais datadir=/var/lib/ais bindir=/usr/bin aissvc=aissvcdevexe pid_file=$datadir/ais.pid startup_file=$datadir/AStartup.sl # # Use LSB init script functions for printing messages, if possible # lsb_functions="/lib/lsb/init-functions" if test -f $lsb_functions ; then . $lsb_functions else log_success_msg() { echo " SUCCESS! $@" } log_failure_msg() { echo " ERROR! $@" } fi mode=$1 PATH=/sbin:/usr/sbin:/bin:/usr/bin:$bindir export PATH case `echo "testing\c"`,`echo -n testing` in *c*,-n*) echo_n= echo_c= ;; *c*,*) echo_n=-n echo_c= ;; *) echo_n= echo_c='\c' ;; esac wait_for_pid () { verb="$1" manager_pid="$2" # process ID of the program operating on the pid-file i=0 avoid_race_condition="by checking again" while test $i -ne $service_startup_timeout ; do case "$verb" in 'created') # wait for a PID-file to pop into existence. test -s $pid_file && i='' && break ;; 'removed') # wait for this PID-file to disappear test ! -s $pid_file && i='' && break ;; *) echo "wait_for_pid () usage: wait_for_pid created|removed manager_pid" exit 1 ;; esac # if manager isn't running, then pid-file will never be updated if test -n "$manager_pid"; then if kill -0 "$manager_pid" 2>/dev/null; then : # the manager still runs else # The manager may have exited between the last pid-file check and now. if test -n "$avoid_race_condition"; then avoid_race_condition="" continue # Check again. fi # there's nothing that will affect the file. log_failure_msg "Manager of pid-file quit without updating file." return 1 # not waiting any more. fi fi echo $echo_n ".$echo_c" i=`expr $i + 1` sleep 1 done if test -z "$i" ; then log_success_msg return 0 else log_failure_msg return 1 fi } # # Set pid file if not given # if test -z "$pid_file" then pid_file=$datadir/`/bin/hostname`.pid else case "$pid_file" in /* ) ;; * ) pid_file="$datadir/$pid_file" ;; esac fi case "$mode" in 'start') # Start daemon echo $echo_n "Starting AIS" if test -x $bindir/$aissvc then nohup $bindir/$aissvc --pidfile $pid_file --user $user $startup_file > /dev/null 2>&1 & wait_for_pid created $!; return_value=$? # Make lock for RedHat / SuSE if test -w /var/lock/subsys then touch /var/lock/subsys/aissvc fi exit $return_value else log_failure_msg "Couldn't find AIS Service ($bindir/$aissvc)" fi ;; 'stop') # Stop daemon # The RedHat / SuSE lock directory to remove lock_dir=/var/lock/subsys/aissvc if test -s "$pid_file" then aissvc_pid=`cat $pid_file` echo $echo_n "Shutting down AIS" kill $aissvc_pid # aissvc should remove the pid_file when it exits, so wait for it. wait_for_pid removed "$aissvc_pid"; return_value=$? # delete lock for RedHat / SuSE if test -f $lock_dir then rm -f $lock_dir fi exit $return_value else log_failure_msg "AIS PID file could not be found!" fi ;; 'restart') # Stop the service and regardless of whether it was # running or not, start it again. if $0 stop; then $0 start else log_failure_msg "Failed to stop running server, so refusing to try to start." exit 1 fi ;; 'status') # First, check to see if pid file exists if test -s "$pid_file" ; then read aissvc_pid < $pid_file if kill -0 $aissvc_pid 2>/dev/null ; then log_success_msg "AIS running ($aissvc_pid)" exit 0 else log_failure_msg "AIS is not running, but PID file exists" exit 1 fi else # Try to find appropriate aissvc process aissvc_pid=`pidof $bindir/$aissvc` if test -z $aissvc_pid ; then lockfile=/var/lock/subsys/aissvc if test -f $lockfile ; then log_failure_msg "AIS is not running, but lock exists" exit 2 fi log_failure_msg "AIS is not running" exit 3 else log_failure_msg "AIS is running but PID file could not be found" exit 4 fi fi ;; *) # usage echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit 0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor