erlug
[Top] [All Lists]

[Erlug] initscript

To: Erlug <erlug@xxxxxxxxxxxxxx>
Subject: [Erlug] initscript
From: xpicio <xpicio@xxxxxxxxx>
Date: Sat, 10 Apr 2004 12:21:31 +0200
Salve a tutti.

Sto provando a fare qualche esperimento con gli initscript su Fedora 1.
In pratica ho fatto uno script da inserire in /etc/init.d in modo tale
che parta e si fermi all'avvio e allo spegnimento del PC.
Nelle prime righe ho messo il codice necessario per la compatibilità con
chkconfig:

#!/bin/bash

# chkconfig: 345 20 20
# description: Startup-Shutdown script for the icm (Internet \
#               Connections Monitor)

Per quanto riguarda la partenza, tutto OK. Quando mi sposto nel livello
3 viene fatto partire. Ma quando spengo il PC o provo da shell a
cambiare livello come ad esempio nel 1 non viene invocato lo script che
interrompe il servizio. Perchè non parte???

Questo è uno stralcio del codice, se magari qualcuno nota qualcosa che
non va:

#!/bin/bash

# chkconfig: 345 20 20
# description: Startup-Shutdown script for the icm (Internet \
#               Connections Monitor)

PROG=icm

# include librerie delle funzioni
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 0
fi

start() {
...
}

stop() {
...
}

restart() {
        stop
        start
}

case $1 in
        start)
                echo -n "Starting $PROG: "
                if [ 1 = `grep -c "/usr/bin/icverify" /etc/crontab` ]; then
                        echo_success
                        echo
                        exit 1
                else
                        start
                fi
                ;;
        stop)
                echo -n "Stopping $PROG: "
                if [ 1 = `grep -c "/usr/bin/icverify" /etc/crontab` ]; then
                        stop
                else
                        echo_failure
                        echo
                        exit 1
                fi
                ;;
        restart)
                #stop
                echo -n "Stopping $PROG: "
                if [ 1 = `grep -c "/usr/bin/icverify" /etc/crontab` ]; then
                        stop
                else
                        echo_failure
                        echo
                fi
                #start
                echo -n "Starting $PROG: "
                if [ 1 = `grep -c "/usr/bin/icverify" /etc/crontab` ]; then
                        echo_failure
                        echo
                else
                        start
                fi

                ;;
        status)
                if [ 1 = `grep -c "/usr/bin/icverify" /etc/crontab` ]; then
                        echo "$PROG run"
                else
                        echo "$PROG stop"
                fi
                ;;
        *)
                echo $"Usage: $PROG{start|stop|restart|status}"
                exit 1
                ;;
esac
exit 0

Attachment: signature.asc
Description: Questa parte del messaggio =?ISO-8859-1?Q?=E8?= firmata

<Prev in Thread] Current Thread [Next in Thread>