X-Git-Url: https://git.realraum.at/?p=svn42.git;a=blobdiff_plain;f=raspberrypi_gpio_relay_licht%2Frc.local;h=33672c72c6dafcf90a583da8bbece0000a6568f7;hp=254a5569d421163ce7b0d38e9ae3ee004386a120;hb=cdd9cf8f41352f1f707c53f464cd19be334c5578;hpb=12b3f1162fd89d6c8598333df6a0bf4e1de8246d diff --git a/raspberrypi_gpio_relay_licht/rc.local b/raspberrypi_gpio_relay_licht/rc.local index 254a556..33672c7 100644 --- a/raspberrypi_gpio_relay_licht/rc.local +++ b/raspberrypi_gpio_relay_licht/rc.local @@ -1,40 +1,41 @@ -#!/bin/sh -e -# -# rc.local -# -# This script is executed at the end of each multiuser runlevel. -# Make sure that the script will "exit 0" on success or any other -# value on error. -# -# In order to enable or disable this script just change the execution -# bits. -# -# By default this script does nothing. +#! /bin/sh +### BEGIN INIT INFO +# Provides: rc.local +# Required-Start: $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Run /etc/rc.local if it exist +### END INIT INFO -for gpio in 4 17 18 21 22 23; do - echo $gpio > /sys/class/gpio/export - echo out > /sys/class/gpio/gpio$gpio/direction - chown www-data /sys/class/gpio/gpio$gpio/value -done +PATH=/sbin:/usr/sbin:/bin:/usr/bin -# Print the IP address -_IP=$(hostname -I) || true -if [ "$_IP" ]; then - printf "My IP address is %s\n" "$_IP" -fi +. /lib/init/vars.sh +. /lib/lsb/init-functions -MAX_TRIES=20 -if ! ifconfig eth0 && ifconfig wlan0 ; then - sleep 6 - while ((MAX_TRIES-- > 0)) && ! /sbin/wpa_cli status | grep -q wpa_state=COMPLETED; do - /sbin/wpa_cli status - ifdown wlan0 - ifup wlan0 - done -fi +do_start() { + if [ -x /etc/rc.local ]; then + [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)" + /etc/rc.local + ES=$? + [ "$VERBOSE" != no ] && log_end_msg $ES + return $ES + fi +} -su realraum -s /bin/sh -c "sleep 10 && /home/realraum/play-sound-status.py /home/realraum/play-sound-status.cfg &>/dev/null &" & -su realraum -s /bin/sh -c "sleep 10 && /home/realraum/stuff.py &>/dev/null &" & - -exit 0 +case "$1" in + start) + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac