%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /etc/rc.d/rc3.d/
Upload File :
Create Path :
Current File : //etc/rc.d/rc3.d/S80libcare

#!/bin/bash
#
# libcare      Libcare Server
#
# chkconfig: 2345 80 30
# description: LibCare Server is a program that live patches libraries
# processname: libcare-server
# pidfile: /var/run/libcare-server.pid
#

### BEGIN INIT INFO
# Provides: libcare
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop libcare
# Description: LibCare Server is a program that live patches libraries
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

RETVAL=0
prog="libcare-server"
server="/usr/libexec/kcare/$prog"
client="/usr/libexec/kcare/libcare-client"
lockfile=/var/lock/subsys/$prog
pidfile=/var/run/${prog}.pid
logfile=/var/log/libcare/server.log
socket=/var/run/libcare.sock

start() {
	[ "$EUID" != "0" ] && exit 4
	# Start daemons.
	echo -n $"Starting libcare: "
	if pidofproc -p $pidfile $prog >/dev/null; then
		failure $"Already running"
		echo
		return 3
	fi

	rm -f $socket # FIXME
	daemon $server -v -o $logfile -d $socket
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch $lockfile
        echo
	return $RETVAL
}

stop() {
	[ "$EUID" != "0" ] && exit 4
        # Stop daemons.
	echo -n $"Shutting down libcare: "

	PID=$(pidofproc -p $pidfile $prog)
	RETVAL=$?
	if [ $RETVAL -ne 0 ]; then
		success $"Not running"
		echo
		return 0
	fi

	$client stop
	RETVAL=$?
	if [ $RETVAL -ne 0 ]; then
		kill -9 $PID
	fi

	for i in $(seq 1 10); do
		pidofproc -p $pidfile $pro > /dev/null
		RETVAL=$?

		if [ $RETVAL -ne 0 ]; then
			break
		fi
		sleep 0.5
	done

	if [ $RETVAL -eq 0 ]; then
		failure $"is not stopping"
		echo
		return 1
	fi

	rm -f $lockfile $pidfile
	success $"stopped"
	echo
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	stop
	start
	;;
  reload)
	reload
	;;
  status)
	status -p $pidfile -l $(basename $lockfile) -b $server $prog
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|status}"
	exit 2
esac

exit $?

Zerion Mini Shell 1.0