File sfcb.init.generic of Package sblim-sfcb

#!/bin/bash
#
# chkconfig: - 91 35
# description: Starts and stops the sfcbd daemon \
#              used to provide CIMOM services.
#
# pidfile: /var/run/sfcbd.pid
#
# $Id: sfcb.init-suse.in,v 1.3 2005/07/28 08:09:38 mihajlov Exp $
#
### BEGIN INIT INFO
# Provides:          sfcb
# Required-Start:    $syslog $remote_fs
# Required-Stop:     $syslog $remote_fs
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Small Footprint CIM Broker Service
# Description:       Manage the sfcb Service
### END INIT INFO

# Source function library.
if [ -f /etc/redhat-release ]; then
	if [ -f /etc/init.d/functions ] ; then
  		. /etc/init.d/functions
	elif [ -f /etc/rc.d/init.d/functions ] ; then
  		. /etc/rc.d/init.d/functions
	else
	  	exit 1
	fi
elif [ -f /etc/SuSE-release ]; then
	if [ -f /etc/rc.status ]; then
		. /etc/rc.status
	else
		exit 1
	fi
else
	exit 1
fi

function preload_pam_misc_so()
{
    for dir in /lib64 /lib;
    do if test -e $dir/libpam_misc.so.0; then
        export LD_PRELOAD=$dir/libpam_misc.so.0
        break;
    fi;
    done;
}

echo $PATH | grep -q /usr/sbin ||PATH=/usr/sbin:$PATH

if [ -z "$LD_LIBRARY_PATH" ] || echo $LD_LIBRARY_PATH | grep -qv /usr/lib
then
    LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH
fi


start() {
	echo -n "Starting sfcb: "

    preload_pam_misc_so
    
    # generate certificate
    if [ ! -f "/etc/sfcb/server.pem" ]; then
        if [ -f "/etc/ssl/servercerts/servercert.pem" \
                -a -f "/etc/ssl/servercerts/serverkey.pem" ]; then
            echo "Using common server certificate /etc/ssl/servercerts/servercert.pem"
            ln -s /etc/ssl/servercerts/servercert.pem /etc/sfcb/server.pem
            ln -s /etc/ssl/servercerts/servercert.pem /etc/sfcb/client.pem
            ln -s /etc/ssl/servercerts/serverkey.pem /etc/sfcb/file.pem
        else
            echo "Generating SFCB server public certificate and private key"
            FQDN=`hostname --fqdn`
            if [ "x${FQDN}" = "x" ]; then
                FQDN=localhost.localdomain
            fi
            /usr/share/sfcb/genSslCert.sh /etc/sfcb
#cat << EOF | sh /usr/share/sfcb/genSslCert.sh /etc/sfcb > /dev/null 2>&1
#--
#SomeState
#SomeCity
#SomeOrganization
#SomeOrganizationalUnit
#${FQDN}
#root@${FQDN}
#EOF
        fi
    fi
    # end generate certificate
	if [ -f /etc/SuSE-release ]; then
		startproc /usr/sbin/sfcbd -d
		rc_status -v
	else
		daemon	/usr/sbin/sfcbd -d
	fi
	if [ $? -eq 0 ]; then
		touch /var/lock/subsys/sfcb
	fi	
}	

stop() {
	echo -n "Shutting down sfcb: "
	killproc sfcbd
	if [ -f /etc/SuSE-release ]; then
		rc_status -v
	fi
}

reload() {
	echo -n "Reloading sfcb configuration: "
	killproc -HUP sfcbd
	if [ -f /etc/SuSE-release ]; then
                rc_status -v
        fi

}
rhstatus(){
	echo -e "Checking sfcb status: "
	status sfcbd
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	if [ -f /etc/SuSE-release ]; then 
		checkproc sfcbd
		rc_status -v
	else
		rhstatus
	fi
	
	;;
    restart)
    	stop
	start
	;;
    reload)
	reload
	;;
    condrestart)
	[ -f /var/lock/subsys/sfcb ] && restart || :
	;;
    *)
	echo "Usage: sfcb {start|stop|status|reload|restart|condrestart}"
	exit 1
	;;
esac
exit $?
openSUSE Build Service is sponsored by