Attention en cours d'écriture

Création de la carte mémoire

  • Télécharger l'image de la carte mémoire:
    Aller sur http://www.raspberrypi.org/downloads et télécharger le fichier:
    2012-07-15-wheezy-raspbian.zip
  • Déziper le fichier ce qui donne un fichier image de la carte mémoire:
    2012-07-15-wheezy-raspbian.img
  • Ecrire le fichier img sur la carte mémoire SD
Sur Mac OS X Sur Windows
Dans un terminal:
Faire une comparaison du résultat de:
df -h
Sans la carte et avec la carte pour avoir le nom du disque.
Par exemple /dev/disk1s1
Démonter la carte:
diskutil unmount /dev/disk1s1
Copier l'image sur la carte:
sudo dd bs=1m if=2012-07-15-wheezy-raspbian.img of=/dev/rdisk1
Attention /dev/rdisk1 et pas /dev/disk1s1 pour la copie de l'image
Ejection de la carte:
diskutil eject /dev/rdisk1
Télécharger l'outil Win32DiskImager
Insérer la carte SD dans le lecteur et bien noter sa lettre (par exemple E:)
Formater la carte si elle n'est pas vierge.
Lancer Win32DiskImager avec les droits administrateur
Sélectionner le fichier img: 2012-07-15-wheezy-raspbian.img
Sélectionner le lecteur correspondant à la carte !!! Attention pas d'erreur ici !!!
Cliquer sur Write et attendre la fin de l'écriture
Quitter Win32DiskImager
Ejecter la carte puis la retirer

Pour les impatients - comme moi :-) - Prenez en compte les temps de téléchargement (~450Mo d'image !) et de flashage. Par expérience, préférez le téléchargement via torrent, environ 5 fois plus rapide lors de mon test.

Mettre la carte sur le Raspberry Pi et le brancher pour démarrer.

Mise à jour de l'OS et des packages du Raspberry Pi:

(Login/Password par défaut: pi/raspberry. Connectez vous en ssh avec putty par exemple)

  • Mise à jour du clavier:
    sudo dpkg-reconfigure keyboard-configuration
    sélectionner: Generic 105-key (Intl) PC
    sélectionner: French
    puis sélectionner les valeurs par défaut
  • Mise à jour du fuseau horaire:
    sudo dpkg-reconfigure tzdata
  • Mise à jour des locales:
    sudo dpkg-reconfigure locales
    Générer la locale: fr_FR.UTF-8 UTF-8
    Et la sélectionner par défaut.
  • Mise à jour des packages:
    sudo apt-get update
    sudo apt-get dist-upgrade

Installation d'eibd, linknx, lighttpd et php5 et enfin knxweb2:

  • Installation de libxml et liblua:
    sudo apt-get install libxml2-dev liblua5.1-0-dev
  • Compilation de pthsem:
    wget http://www.auto.tuwien.ac.at/~mkoegler/pth/pthsem_2.0.8.tar.gz
    tar xvfz pthsem_2.0.8.tar.gz
    cd pthsem-2.0.8
    ./configure –with-mctx-mth=sjlj –with-mctx-dsp=ssjlj –with-mctx-stk=sas –disable-shared
    make
    sudo make install
    cd ..
  • Compilation de eibd:
    wget http://www.auto.tuwien.ac.at/~mkoegler/eib/bcusdk_0.0.5.tar.gz
    tar xvfz bcusdk_0.0.5.tar.gz
    cd bcusdk-0.0.5
    ./configure –without-pth-test –enable-onlyeibd –enable-eibnetip –enable-eibnetiptunnel –enable-eibnetipserver –enable-groupcache –enable-usb
    make
    sudo make install
    cd ..
  • Création du fichier de démarrage de eibd à copier dans /etc/init.d (voir le fichier en bas de page à coller dans le presse papier) avec la commande “vi /etc/init.d/eibd”, puis tapez “i”, puis copier le presse papier, puis touche “echap” puis ”:wq” et enfin “chmod 755 /etc/init.d/eibd”
  • (vous ferez la même chose plus bas avec /etc/init.d/linknx)
  • Lancement automatique de eibd au démarrage:
    sudo update-rc.d eibd defaults
  • Configuration de eibd:
    Créer le fichier /etc/default/eibd
    DAEMON_ARGS="--daemon=/var/log/eibd.log --pid-file=/var/run/eibd.pid --listen-tcp"
    EIBD_BACKEND="ipt"
    EIBD_PORT_IPT="<adresse ip passerelle knx-ip>"
  • Installation de libcurl (optionnel pour avoir envoyer des SMS avec linknx):
    sudo apt-get install libcurl4-openssl-dev
  • Installation de libesmtp (optionnel pour pouvoir envoyer des mails avec linknx):
    sudo apt-get install libesmtp-dev
  • Installation de mysql (optionnel pour pouvoir utiliser mysql avec linknx):
    sudo apt-get install mysql-server mysql-client libmysqlclient-dev
  • Installation de log4cpp (optionnel pour pouvoir utiliser log4cpp pour générer les logs):
    sudo apt-get install liblog4cpp5-dev
  • Compilation de linknx:
    wget http://downloads.sourceforge.net/project/linknx/linknx/linknx-0.0.1.30/linknx-0.0.1.30.tar.gz
    tar xvfz linknx-0.0.1.30.tar.gz
    Si vous voulez utilisez mysql avec linknx:
    ./configure –without-pth-test –with-mysql=/usr/bin/mysql_config
    Sinon:
    ./configure –without-pth-test
    Puis:
    make
    sudo make install
  • Création du fichier de démarrage de linknx à copier dans /etc/init.d (voir le fichier en bas de page)
    Si vous faite une installation avec mysql ajouter en fin de cette ligne “mysql” pour que la base de données démarre avant linknx
    # Required-Start:    $local_fs $remote_fs eibd mysql
  • Lancement automatique de linknx au démarrage:
    sudo update-rc.d linknx defaults
  • Installation de lighttpd et php5:
    sudo apt-get install lighttpd php5-cgi
    sudo lighttpd-enable-mod cgi fastcgi fastcgi-php
  • Installation de knxweb2:
    cd /var/www/
    sudo wget -O knxweb2.tar “http://linknx.cvs.sourceforge.net/viewvc/linknx/knxweb/knxweb2/?view=tar
    sudo tar xvf knxweb2.tar
    sudo rm knxweb2.tar
    sudo /etc/init.d/lighttpd restart
    cd knxweb2
    sudo chown -R www-data:www-data pictures
    sudo chown -R www-data:www-data design
    sudo chown -R www-data:www-data include
    cd template
    sudo mkdir template_c
    sudo chown www-data:www-data template_c

Création de la base de données mysql (optionnel)

mysql -u root -p

CREATE DATABASE linknx;
use linknx;

CREATE TABLE `log` (\\ 
  `ts` timestamp NOT NULL default CURRENT_TIMESTAMP,\\ 
  `object` varchar(256) NOT NULL,\\ 
  `value` varchar(256) NOT NULL,\\ 
  KEY `object` (`object`,`ts`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `persist` (
  `object` varchar(256) NOT NULL,
  `value` varchar(256) NOT NULL,
  `ts` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`object`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE USER 'linknx'@'localhost' IDENTIFIED BY 'linknx';
GRANT SELECT,INSERT,UPDATE,DELETE ON linknx.* TO 'linknx'@'localhost';
exit

Lancer votre navigateur sur http://<adresse ip du raspberry pi>/knxweb2/

Fichier de démarrage d'eibd:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          eibd
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: eibd initscript
# Description:       based on init-script from knx-user-forum.de and setup-eibd.sh from KNXlive-project
#                    Pending: check tpuarts, check KNXnet/IP-Response
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="EIB/KNX daemon"
NAME=eibd
DAEMON=/usr/local/bin/$NAME
DAEMON_ARGS="-d -u --eibaddr=1.1.100 -c -DTS -R -i --pid-file=/var/run/$NAME.pid"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Default URL, config read from default later
# !!! DO NOT CHANGE DEFAULTS HERE - use /etc/default/eibd !!!
# AUTO scans and saves as default
EIBD_BACKEND="AUTO"

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
# Temp-fix! remove surrounding whitespaces from seperator '='
[ -r /etc/default/$NAME ] && cat /etc/default/$NAME | sed 's/ =/=/' | sed 's/= /=/' > /etc/default/$NAME.out
[ -r /etc/default/$NAME.out ] && . /etc/default/$NAME.out

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions


do_init()
{
    # Auto-Detection Backend-interface
    if [ "$EIBD_BACKEND" = "AUTO" -o "$EIBD_BACKEND" = "usb" ]; then
        [ "$VERBOSE" != no ] && log_daemon_msg "Autodetecting eibd-Backend"
        echo -ne "\t *** $NAME: Autodetecting Interface ."
        # try USB
        # old EIBD_USBPORT=$(findknxusb | sed -e '1 d' -e 's/device //' | cut -d':' -f1-2)
        EIBD_USBPORT=$(findknxusb | sed -e '1 d' -e 's/device //' | cut -d ' ' -f 2 | cut -d':' -f1-2); echo $EIBD_USBPORT
        if [ -n "$EIBD_USBPORT" ]
            then
            EIBD_BACKEND=usb
            EIBD_URL=$EIBD_BACKEND:$EIBD_USBPORT
            [ "$VERBOSE" != no ] && log_daemon_msg " success on $EIBD_URL"
            echo -e " success on $EIBD_URL"
        fi
    fi

    if [ "$EIBD_BACKEND" = "AUTO" -a -e /dev/ttyS0 ]; then
        # try FT1.2 on /dev/ttyS0
        echo -n " ."
        setserial /dev/ttyS0 autoconfig
        if bcuaddrtab -T 10 ft12:/dev/ttyS0 >/dev/null ;    then
            EIBD_BACKEND=ft12
            EIBD_URL=$EIBD_BACKEND:/dev/ttyS0
            [ "$VERBOSE" != no ] && log_daemon_msg " success on $EIBD_URL"
            echo -e " success on $EIBD_URL"
        fi
    fi

    if [ "$EIBD_BACKEND" = "AUTO" -a -e /dev/eib0 ]; then
        # try BCU1 Kernel-Driver on /dev/ttyS0
        echo -n " ."
        setserial /dev/ttyS0 uart none
        if bcuaddrtab -T 10 bcu1:/dev/eib0 >/dev/null ; then
            EIBD_BACKEND=bcu1
            EIBD_URL=$EIBD_BACKEND:/dev/eib0
            [ "$VERBOSE" != no ] && log_daemon_msg " success on $EIBD_URL"
            echo -e " success on $EIBD_URL"
        fi
    fi

    if [ "$EIBD_BACKEND" = "AUTO" ]; then
        # try KNXnet/IP Routing with default Multicast 224.0.23.12
        echo -n " ."
        EIBNETTMP=`mktemp`
        eibnetsearch - > $EIBNETTMP
        EIBD_NET_MCAST=`grep Multicast $EIBNETTMP | cut -d' ' -f2`
        EIBD_NET_HOST=`grep Answer $EIBNETTMP | cut -d' ' -f3`
        EIBD_NET_NAME=`grep Name $EIBNETTMP | cut -d' ' -f2`
        EIBD_MY_IP=`ifconfig eth0 | grep 'inet addr' | sed -e 's/:/ /' | awk '{print $3}'`
        rm $EIBNETTMP
        if [ "$EIBD_NET_MCAST" != "" -a "$EIBD_NET_HOST" != "$EIBD_MY_IP" ]; then
            EIBD_BACKEND=ip
            EIBD_URL=$EIBD_BACKEND:
            [ "$VERBOSE" != no ] && log_daemon_msg "Found KNXnet/IP Router $EIBD_NET_NAME on $EIBD_NET_HOST with $EIBD_NET_MCAST"
            echo -e "Found KNXnet/IP Router $EIBD_NET_NAME on $EIBD_NET_HOST with $EIBD_NET_MCAST"
        fi
    fi

    if [ "$EIBD_BACKEND" = "AUTO" -a -e /dev/ttyS1 ]; then
        # try FT1.2 on /dev/ttyS1
        echo -n " ."
        setserial /dev/ttyS1 autoconfig
        if bcuaddrtab -T 10 ft12:/dev/ttyS1 >/dev/null ; then
            EIBD_BACKEND=ft12
            EIBD_URL=$EIBD_BACKEND:/dev/ttyS1
            [ "$VERBOSE" != no ] && log_daemon_msg " success on $EIBD_URL"
            echo -e " success on $EIBD_URL"
        fi
    fi

    if [ "$EIBD_BACKEND" = "AUTO" -a -e /dev/eib1 ]; then
        # try BCU1 Kernel-Driver on /dev/ttyS1
        echo -n " ."
        setserial /dev/ttyS1 uart none
        if bcuaddrtab -T 10 bcu1:/dev/eib1 >/dev/null ; then
            EIBD_BACKEND=bcu1
            EIBD_URL=$EIBD_BACKEND:/dev/eib1
            [ "$VERBOSE" != no ] && log_daemon_msg " success on $EIBD_URL"
            echo -e " success on $EIBD_URL"
        fi
    fi

    if [ "$EIBD_BACKEND" = "AUTO" ]; then
        # Autodetect failed - bailout
        echo -e "\t *** $NAME: Autodetect failed - exiting !"
        exit 0
    fi

    # concat urls
    if [ "$EIBD_BACKEND" = "ip" -a -n "$EIBD_PORT_IP" ]; then
        EIBD_URL=$EIBD_BACKEND:$EIBD_PORT_IP
    fi
    if [ "$EIBD_BACKEND" = "ipt" -a -n "$EIBD_PORT_IPT" ]; then
        EIBD_URL=$EIBD_BACKEND:$EIBD_PORT_IPT
    fi
    # init serial port accordingly
    if [ "$EIBD_BACKEND" = "ft12" -a -n "$EIBD_PORT_SERIAL" ]; then
        setserial $EIBD_PORT_SERIAL autoconfig
        EIBD_URL=$EIBD_BACKEND:$EIBD_PORT_SERIAL
    fi
    if [ "$EIBD_BACKEND" = "bcu1" -a "$EIBD_PORT_SERIAL" = "/dev/eib0" ]; then
        setserial /dev/ttyS0 uart none
        EIBD_URL=$EIBD_BACKEND:$EIBD_PORT_SERIAL
    fi
    if [ "$EIBD_BACKEND" = "bcu1" -a "$EIBD_PORT_SERIAL" = "/dev/eib1" ]; then
        setserial /dev/ttyS1 uart none
        EIBD_URL=$EIBD_BACKEND:$EIBD_PORT_SERIAL
    fi
    if [ "$EIBD_BACKEND" = "tpuarts" -a -n "$EIBD_PORT_SERIAL" ]; then
        setserial $EIBD_PORT_SERIAL autoconfig
        EIBD_URL=$EIBD_BACKEND:$EIBD_PORT_SERIAL
    fi

    # concat EIBD_URL (obsolete!)
    if [ -z "$EIBD_URL" -a -n "$EIBD_PORT" ]; then
        EIBD_URL=$EIBD_BACKEND:$EIBD_PORT
    fi


    # check/write bcuaddrtab
    if [ "$EIBD_BACKEND" = "usb" -o "$EIBD_BACKEND" = "ft12" -o "$EIBD_BACKEND" = "bcu1" -a -n "$EIBD_URL" ]; then
        EIBD_BCUADDRTAB=`bcuaddrtab -T 10 $EIBD_URL | cut -d ' ' -f 2`
        if [ "$EIBD_BCUADDRTAB" = "expected" -o "$EIBD_BCUADDRTAB" = "failed" -o "$EIBD_BCUADDRTAB" = "timed" ]; then
            # retry 1
            echo -n "Unable to read BCU address table - retrying 1"
            sleep 2
            EIBD_BCUADDRTAB=`bcuaddrtab -T 10 $EIBD_URL | cut -d ' ' -f 2`
            if [ "$EIBD_BCUADDRTAB" = "expected" -o "$EIBD_BCUADDRTAB" = "failed" -o "$EIBD_BCUADDRTAB" = "timed" ]; then
                # retry 2
                echo -n " - retrying 2 .."
                sleep 2
                EIBD_BCUADDRTAB=`bcuaddrtab -T 10 $EIBD_URL | cut -d ' ' -f 2`
                if [ "$EIBD_BCUADDRTAB" = "expected" -o "$EIBD_BCUADDRTAB" = "failed" -o "$EIBD_BCUADDRTAB" = "timed" ]; then
                    echo -n " - FAILED on $EIBD_BACKEND (url $EIBD_URL) (size $EIBD_BCUADDRTAB) ! "
                    # only fail on usb/FT12 as bcu1 might still be ok
                    if [ "$EIBD_BACKEND" = "bcu1" ]; then
                        EIBD_BCUADDRTAB=0
                    else
                        log_end_msg 2
                        exit 2
                    fi
                fi
            fi
        fi
        if [ "$EIBD_BCUADDRTAB" -gt 0 ]; then
            echo "Resetting BCU address table length! Old value $EIBD_BCUADDRTAB"
            bcuaddrtab -T 30 -w 0 $EIBD_URL
        fi
        # fix for broken ABB/BJ USB-If
        USBNAME=`findknxusb | grep ^device | cut -d '(' -f 2,3`
        if [ "$EIBD_BACKEND" = "usb" -a "$USBNAME" = "ABB STOTZ-KONTAKT GmbH:KNX-USB Interface (MDRC))" ]; then
            echo "ABB-fix: Resetting BCU address table length! Old value $EIBD_BCUADDRTAB"
            bcuaddrtab -T 30 -w 0 $EIBD_URL
        fi
    fi

    # Concat ARGS
    if [ -n "$EIBD_R" ]; then
        DAEMON_ARGS=" -R $DAEMON_ARGS"
        EIBD_I=y
    fi
    if [ -n "$EIBD_T" ]; then
        DAEMON_ARGS=" -T $DAEMON_ARGS"
        EIBD_I=y
    fi
    if [ -n "$EIBD_I" ]; then
        DAEMON_ARGS=" -S -D -i $DAEMON_ARGS"
    fi
    if [ -n "$EIBD_C" ]; then
        DAEMON_ARGS=" -c $DAEMON_ARGS"
    fi
    # use -e option to set address
    if [ -n "$EIBD_BACKEND_ADDR" ]; then
        DAEMON_ARGS=" -e $EIBD_BACKEND_ADDR $DAEMON_ARGS"
    fi

    DAEMON_ARGS="$DAEMON_ARGS $EIBD_ADDTL_ARGS $EIBD_URL"
}

#
# Function that starts the daemon/service
#
do_start()
{
    route add 224.0.23.12 dev eth0
    #echo "DEBUG args: $DAEMON_ARGS eibdi: $EIBD_I eibdt: $EIBD_T eibdr: $EIBD_R backend: $EIBD_BACKEND url: $EIBD_URL port: $EIBD_PORT addrtab: $EIBD_BCUADDRTAB"
    # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
                || return 1
        do_init
    echo "*** Starting $DESC: $NAME using $EIBD_URL"
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
                $DAEMON_ARGS \
                || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
        sleep 2
        chmod a+rw /tmp/eib
}
#
# Function that stops the daemon/service
#
do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
        RETVAL="$?"
        [ "$RETVAL" = 2 ] && return 2
        # Wait for children to finish too if this is a daemon that forks
        # and if the daemon is only ever run from this initscript.
        # If the above conditions are not satisfied then add some other code
        # that waits for the process to drop all resources that could be
        # needed by services started subsequently.  A last resort is to
        # sleep for some time.
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
    [ "$?" = 2 ] && return 2
        # Many daemons don't delete their pidfiles when they exit.
        rm -f $PIDFILE
        route delete 224.0.23.12
        return "$RETVAL"
}

#
# 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 using $EIBD_URL" "$NAME"
        do_start
        case "$?" in
                0|1) log_end_msg 0 ;;
                2) [ log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
    echo "*** Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) log_end_msg 0 ;;
                2) [ log_end_msg 1 ;;
        esac
        ;;
  #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
        #
        echo "*** Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
        sleep 2
                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|restart|force-reload}" >&2
        exit 3
        ;;
esac

Fichier de démarrage de linknx:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          linknx
# Required-Start:    $local_fs $remote_fs eibd
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: linknx initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.
### END INIT INFO

# 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="service"
NAME=linknx
DAEMON=/usr/local/bin/$NAME
PIDFILE=/var/run/$NAME.pid
DAEMON_ARGS="-c/var/lib/linknx/linknx.xml -p $PIDFILE -d/var/log/linknx.log -w"
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
# Temp-fix! remove surrounding whitespaces from seperator '='
[ -r /etc/default/$NAME ] && cat /etc/default/$NAME | sed 's/ =/=/' | sed 's/= /=/' > /etc/default/$NAME.out
[ -r /etc/default/$NAME.out ] && . /etc/default/$NAME.out

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
                || return 1
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
                $DAEMON_ARGS \
                || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
}

#
# Function that stops the daemon/service
#
do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
        RETVAL="$?"
        [ "$RETVAL" = 2 ] && return 2
        # Wait for children to finish too if this is a daemon that forks
        # and if the daemon is only ever run from this initscript.
        # If the above conditions are not satisfied then add some other code
        # that waits for the process to drop all resources that could be
        # needed by services started subsequently.  A last resort is to
        # sleep for some time.
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
        [ "$?" = 2 ] && return 2
        # Many daemons don't delete their pidfiles when they exit.
        rm -f $PIDFILE
        return "$RETVAL"
}

#
# 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
        ;;
  #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|restart|force-reload}" >&2
        exit 3
        ;;
esac
installation_sur_raspberry_pi.txt · Dernière modification: 2013/02/19 18:25 par gil
 
Sauf mention contraire, le contenu de ce wiki est placé sous la licence suivante : CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki