ia64/xen-unstable

changeset 1122:6e6ef033e4fc

bitkeeper revision 1.748 (403b97dbiFb-AZhRznWy1vCMR3qzKA)

xendomains Sys-V init script now supports LSB-compliant systems
author mwilli2@equilibrium.research.intel-research.net
date Tue Feb 24 18:28:43 2004 +0000 (2004-02-24)
parents a39bbe7cddc4
children edb575655020 5640beab0342
files tools/examples/xendomains
line diff
     1.1 --- a/tools/examples/xendomains	Tue Feb 24 16:34:00 2004 +0000
     1.2 +++ b/tools/examples/xendomains	Tue Feb 24 18:28:43 2004 +0000
     1.3 @@ -6,7 +6,9 @@
     1.4  # chkconfig: 345 99 00
     1.5  # description: Start / stop Xen domains.
     1.6  #
     1.7 -# This script offers fairly basic functionality.
     1.8 +# This script offers fairly basic functionality.  It should work on Redhat
     1.9 +# but also on LSB-compliant SuSE releases and on Debian with the LSB package
    1.10 +# installed.  (LSB is the Linux Standard Base)
    1.11  #
    1.12  # Based on the example in the "Designing High Quality Integrated Linux
    1.13  # Applications HOWTO" by Avi Alkalay
    1.14 @@ -16,18 +18,38 @@
    1.15  RETVAL=0
    1.16  
    1.17  INITD=/etc/init.d/
    1.18 -. $INITD/functions
    1.19 +
    1.20 +if [ -e /lib/lsb ]; then
    1.21 +    # assume an LSB-compliant distro (Debian with LSB package,
    1.22 +    # recent-enough SuSE, others...)
    1.23 +
    1.24 +    . /lib/lsb/init-functions # source LSB standard functions
    1.25  
    1.26 -on_fn_exit()
    1.27 -{
    1.28 -    if [ $RETVAL -eq 0 ]; then
    1.29 -	success
    1.30 -    else
    1.31 -	failure
    1.32 -    fi
    1.33 -    
    1.34 -    echo
    1.35 -}
    1.36 +    on_fn_exit()
    1.37 +    {
    1.38 +	if [ $RETVAL -eq 0 ]; then
    1.39 +	    log_success_msg
    1.40 +	else
    1.41 +	    log_failure_msg
    1.42 +	fi
    1.43 +    }
    1.44 +else
    1.45 +    # assume a Redhat-like distro
    1.46 +    . $INITD/functions # source Redhat functions
    1.47 +
    1.48 +    on_fn_exit()
    1.49 +    {
    1.50 +	if [ $RETVAL -eq 0 ]; then
    1.51 +	    success
    1.52 +	else
    1.53 +	    failure
    1.54 +	fi
    1.55 +	
    1.56 +	echo
    1.57 +    }
    1.58 +fi
    1.59 +
    1.60 +
    1.61  
    1.62  start() {
    1.63      if [ -f /var/lock/subsys/xendomains ]; then return; fi
    1.64 @@ -36,7 +58,8 @@ start() {
    1.65  
    1.66      # we expect config scripts for auto starting domains to be in
    1.67      # /etc/xc/auto/ - they could just be symlinks to files elsewhere
    1.68 -    if [ $(ls /etc/xc/auto/ | wc -l) -gt 0 ]; then
    1.69 +    if [ -d /etc/xc/auto ] &&
    1.70 +	    [ $(ls /etc/xc/auto/ | wc -l) -gt 0 ]; then
    1.71  	
    1.72         # create all domains with config files in /etc/xc/auto
    1.73  	for dom in /etc/xc/auto/*; do
    1.74 @@ -45,10 +68,10 @@ start() {
    1.75  		RETVAL=$?
    1.76  	    fi
    1.77  	done
    1.78 +
    1.79 +	touch /var/lock/subsys/xendomains
    1.80      fi
    1.81  
    1.82 -    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xendomains
    1.83 -
    1.84      on_fn_exit
    1.85  }
    1.86  
    1.87 @@ -61,7 +84,8 @@ stop()
    1.88      
    1.89      echo -n $"Shutting down all Xen domains:"
    1.90  
    1.91 -    if [ $(ls /var/run/xendomains/ | wc -l) -gt 0 ]; then
    1.92 +    if [ -d /var/run/xendomains ] &&
    1.93 +	    [ $(ls /var/run/xendomains/ | wc -l) -gt 0 ]; then
    1.94  	
    1.95  	cd /var/run/xendomains/
    1.96