X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=raspberrypi_gpio_relay_licht%2Frc.local;fp=raspberrypi_gpio_relay_licht%2Frc.local;h=918e2172a24e79f15b8061ce48ffc41121dd29b6;hb=2630563d5a886a22c24e39d355a0f60558c996ee;hp=0000000000000000000000000000000000000000;hpb=2e3568aad15008c643a11d9a2dec3cc977751a82;p=svn42.git diff --git a/raspberrypi_gpio_relay_licht/rc.local b/raspberrypi_gpio_relay_licht/rc.local new file mode 100644 index 0000000..918e217 --- /dev/null +++ b/raspberrypi_gpio_relay_licht/rc.local @@ -0,0 +1,39 @@ +#!/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. + +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 + + +# Print the IP address +_IP=$(hostname -I) || true +if [ "$_IP" ]; then + printf "My IP address is %s\n" "$_IP" +fi + +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 + +su realraum -s /bin/sh -c "sleep 10 && /home/realraum/play-sound-status.py /home/realraum/play-sound-status.cfg &>/dev/null &" & + +exit 0