0b15456
#! /bin/sh
0b15456
#
0425b96
# chkconfig: - 90 10
0b15456
# description: Start the cpu hotplug daemon for Linux on System z
0b15456
# processname: cpuplugd
0b15456
# config: /etc/sysconfig/cpuplugd
0b15456
# pidfile: /var/run/cpuplugd.pid
0b15456
0b15456
### BEGIN INIT INFO
0b15456
# Provides: cpuplugd
0b15456
# Required-Start: $local_fs $remote_fs
0b15456
# Required-Stop: $local_fs $remote_fs
0425b96
# Default-Start:
0425b96
# Default-Stop: 0 1 2 3 4 5 6
0b15456
# Short-Description: Start the cpu hotplug daemon for Linux on System z
0b15456
# Description: Starts the cpuplugd. It uses the configuration
0b15456
#              file /etc/sysconfig/cpuplugd
0b15456
### END INIT INFO
0b15456
0b15456
# Source function library.
0b15456
. /etc/rc.d/init.d/functions
0b15456
0b15456
exec="/usr/sbin/cpuplugd"
0b15456
prog="cpuplugd"
0b15456
config="/etc/sysconfig/cpuplugd"
0b15456
0b15456
lockfile=/var/lock/subsys/$prog
0b15456
0b15456
start() {
0b15456
    [ -x $exec ] || exit 5
0b15456
    [ -f $config ] || exit 6
0b15456
    [ `id -u` -eq 0 ] || exit 4
0b15456
    echo -n $"Starting $prog: "
0b15456
    daemon $exec -c $config
0b15456
    retval=$?
0b15456
    echo
0b15456
    [ $retval -eq 0 ] && touch $lockfile
0b15456
    return $retval
0b15456
}
0b15456
0b15456
stop() {
0b15456
    [ `id -u` -eq 0 ] || exit 4
0b15456
    echo -n $"Stopping $prog: "
0b15456
    killproc $exec
0b15456
    retval=$?
0b15456
    echo
0b15456
    [ $retval -eq 0 ] && rm -f $lockfile
0b15456
    return $retval
0b15456
}
0b15456
0b15456
restart() {
0b15456
    stop
0b15456
    #
0b15456
    # We have to wait 2-3 seconds here. When the daemon is stopped it takes
0b15456
    # the time we sleep to reactivate cpus. If we restart to fast and
0b15456
    # cpuplugd wasn't able to restore some settings we may get a undesired
0b15456
    # online cpu count after cpuplugd shutdown
0b15456
    #
0b15456
    sleep 4
0b15456
    start
0b15456
}
0b15456
0b15456
reload() {
0b15456
    restart
0b15456
}
0b15456
0b15456
force_reload() {
0b15456
    restart
0b15456
}
0b15456
0b15456
rh_status() {
0b15456
    # run checks to determine if the service is running or use generic status
0b15456
#    status -l $prog $exec
0b15456
    status $exec
0b15456
}
0b15456
0b15456
rh_status_q() {
0b15456
    rh_status >/dev/null 2>&1
0b15456
}
0b15456
0b15456
0b15456
case "$1" in
0b15456
    start)
0b15456
        rh_status_q && exit 0
0b15456
        $1
0b15456
        ;;
0b15456
    stop)
0b15456
        rh_status_q || exit 0
0b15456
        $1
0b15456
        ;;
0b15456
    restart)
0b15456
        $1
0b15456
        ;;
0b15456
    reload)
0b15456
        rh_status_q || exit 7
0b15456
        $1
0b15456
        ;;
0b15456
    force-reload)
0b15456
        force_reload
0b15456
        ;;
0b15456
    status)
0b15456
        rh_status
0b15456
        ;;
0b15456
    condrestart|try-restart)
0b15456
        rh_status_q || exit 0
0b15456
        restart
0b15456
        ;;
0b15456
    *)
0b15456
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
0b15456
        exit 2
0b15456
esac
0b15456
exit $?