> camlgrenouille

  Directory revision date: 2015/09/16 22:34:40 CEST.
 

Show/Download this file as plain text ]

#!/bin/sh
#
# /etc/rc.d/init.d/camlgrenouille
#
# Fichier de lancement de camlgrenouille au demarragé de GNU/Linux
#
# Réalisé par Loic Prouveze, le 24 mars 2003
# Adapté par PixEye

# chkconfig: 2345 96 16
# description: Démarrage et/ou arrêt de CamlGrenouille

# Debug :
#set -x

#DAEMON=/usr/local/bin/camlgrenouille/camlgrenouille
DAEMON=/usr/bin/camlgrenouille/camlgrenouille

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin

export PATH
cd "`dirname $DAEMON`" || exit $?
cmd=`basename $DAEMON`

function status()
{
	#ps axwww|grep "[0-9]:[0-9][0-9] $DAEMON" | \
	#( while read pid tt stat time command; do echo "$command"; done)
	demon=`basename $DAEMON`
	pid=`pidof $demon`
	if test -z "$pid"
	then echo "$demon est arrêté."
	else echo "$demon est lancé avec comme numéro de processus : $pid."
	fi
}

# Renvoie true s'il y a au moins un pid existant :
function alive()
{
	if [ -z "$*" ]; then return 1;fi
	for i in $* ; do
		if kill -0 $i 2> /dev/null ; then return 0 ; fi
	done

	return 1
}

function start()
{
	RETVAL=0
	# Vérification que CamlGrenouille ne soit pas déjà lancé :
	#if [ ! -f /var/lock/camlgrenouille ]; then
	pid=`pidof camlgrenouille`
	if [ -z "$pid" ]; then
		echo 'Starting CamlGrenouille...'

		# Rotation des logs :
		mv -f camlgrenouille.log camlgrenouille.log~

		# Lancement du démon :
		#nohup $DAEMON -t -d >> camlgrenouille.log &	# pour debug
		nohup $DAEMON -t >> camlgrenouille.log &

		pid=`pidof camlgrenouille`
		echo "$pid" > /var/lock/camlgrenouille
	else
		echo "camlgrenouille est déjà lancé avec le pid : $pid !"
	fi
	return $RETVAL
}

function stop()
{
	echo "Stopping CamlGrenouille..."
	pids=$(/bin/pidof $DAEMON)
	kill -TERM $pids 2> /dev/null && sleep 1
	RETVAL=$?
	count=1
	while alive $pids; do
		sleep 5
		count=$(expr $count + 1)
		if [ $count -gt 10 ]; then
		echo "Arret de CamlGrenouille"
		break;
		fi
		echo "CamlGrenouille n'est pas encore arrete : nouvel essais... (attempt $count)"
	done
	rm -f /var/lock/camlgrenouille
	return $RETVAL
}

# See how we were called.

case "$1" in
	start) start ;;
	stop) stop ;;
	reload|restart)
		if [ ! -f /var/lock/camlgrenouille ]; then
			echo "CamlGrenouille ne tournait pas."
			exit 1
		fi
		echo "Vérification des changements de /etc/grenouille.conf ...."
		if [ -f /var/lock/camlgrenouille ] ; then
			stop
			start
		fi
		;;
	status) status ;;
	*)	echo "Usage: camlgrenouille {start|stop|restart|reload|status}"
		exit 1
esac

exit 0		# Nouvelle fin. Ce qui suit date de la version précédente :

/etc/camlgrenouille.conf \
	1>> /var/log/camlgrenouille \
	2>> /var/log/messages &

sleep 1
echo "Pour voir les traces de $cmd, taper :"
echo ' tail -f /var/log/camlgrenouille'
echo 'ou :'
echo ' less /var/log/camlgrenouille'


nerim.sh
(1320B)

script_demarrage.sh
(2731B)

shell_ifconfig.sh
(1055B)

Powered by Web File Viewer W3C XHTML 1.1 certified W3C CSS valid WFV revision date: 2015/09/16 22:34:40 CEST.