Bonjour à tous !
Voilà j'ai un petit problème avec un script de démarrage que j'ai fait juste pour tester.
Voici la procédure que j'ai faite:
--> D'abord, j'ai copié le script skeleton dans /etc/init.d/skeleton vers /etc/init.d/myscript
--> J'ai ensuite édité myscript comme ceci:
#! /bin/sh
### BEGIN INIT INFO
# Provides: myscript
# Required-Start: $remote_fs $syslog $network cron
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
### END INIT INFO
# Author: Foo Bar <foobar@baz.org>
#
# Please remove the "Author" lines above and replace them
# with your own name if you copy and modify this script.
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Description of the service"
NAME=daemonexecutablename
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS="--options args"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
ping -c 5 www.google.fr
}
#
# Function that stops the daemon/service
#
do_stop()
{
echo "Le script stoppe"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:
--> Je rends mon script exécutable par la commande chmod 755 /etc/init.d/myscript
--> Je fais la commande update-rc.d myscript defaults.
--> En vérifiant, je vois bien mon script dans /etc/rc2.d :
README S16rsyslog S18atd S18speech-dispatcher S20cups S21vmware-tools-thinprint
S01motd S16sudo S18cron S19avahi-daemon S20gdm3 S22minissdpd
S13rpcbind S17apache2 S18dbus S19bluetooth S20pulseaudio S22rc.local
S14nfs-common S18acpid S18exim4 S19myscript S20saned S22rmnologin
S16binfmt-support S18anacron S18mpt-statusd S19network-manager S21bootlogs
Et après avoir fait la commande service myscript start et ben rien ne se passe...
J'avais déjà suivi cette procédure pendant un stage... mais manque de bol la doc que j'avais faite pour moi n'était pas assez détaillée ! \o/
Du coup, je voudrais savoir ce qui cloche dans mon script et savoir si je suis une méthode pas trop foireuse.
Je vous remercie beaucoup pour votre aide et je suis désolé par avance s'il y a eu d'autres postes à ce sujet j'ai pas eu le temps d'explorer le forum en détail ^^'.
Script de démarrage sur debian
0 commentaires:
Enregistrer un commentaire