diff --git a/image/rc.local b/image/rc.local new file mode 100644 index 00000000..c063ee3e --- /dev/null +++ b/image/rc.local @@ -0,0 +1,22 @@ +#!/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. + +# Print the IP address +_IP=$(hostname -I) || true +if [ "$_IP" ]; then + printf "My IP address is %s\n" "$_IP" +fi + +nohup /usr/sbin/wifi_watch.sh 0<&- &> /var/log/stratux/wifi_watch.log & + +exit 0 diff --git a/image/spindle/wheezy-stage4 b/image/spindle/wheezy-stage4 index 53f4305a..508dd491 100755 --- a/image/spindle/wheezy-stage4 +++ b/image/spindle/wheezy-stage4 @@ -60,6 +60,8 @@ scp_in_to_qemu /root/spindle/sshd_config /tmp/sshd_config.in scp_in_to_qemu /root/spindle/libdump978.so /tmp/libdump978.so.in scp_in_to_qemu /root/spindle/libimu.so /tmp/libimu.so.in scp_in_to_qemu /root/spindle/go.tgz /mnt/root/go.tgz +scp_in_to_qemu /root/spindle/rc.local /tmp/rc.local.in +scp_in_to_qemu /root/spindle/wifi_watch.sh /tmp/wifi_watch.sh.in ssh_in_to_qemu chroot /mnt sh -l -ex - <<\EOF @@ -79,6 +81,9 @@ mv -f /tmp/dhcpd.conf.in /etc/dhcp/dhcpd.conf mv -f /tmp/hostapd.conf.in /etc/hostapd/hostapd.conf mv -f /tmp/isc-dhcp-server.in /etc/default/isc-dhcp-server mv -f /tmp/sshd_config.in /etc/ssh/sshd_config +mv -f /tmp/wifi_watch.sh.in /usr/sbin/wifi_watch.sh +chmod +x /usr/sbin/wifi_watch.sh +mv -f /tmp/rc.local.in /etc/rc.local rm -f /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service echo "DAEMON_CONF=\"/etc/hostapd/hostapd.conf\"" >/etc/default/hostapd diff --git a/image/wifi_watch.sh b/image/wifi_watch.sh new file mode 100755 index 00000000..d4dcf20d --- /dev/null +++ b/image/wifi_watch.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +while true ; do + if ifconfig wlan0 | grep -q "UP BROADCAST RUNNING MULTICAST" ; then + sleep 30 + else + echo "Wi-Fi connection down! Attempting reconnection." + service hostapd restart + service isc-dhcp-server restart + sleep 10 + fi +done diff --git a/selfupdate/makeupdate.sh b/selfupdate/makeupdate.sh index 4e4fc5bd..8ff11057 100755 --- a/selfupdate/makeupdate.sh +++ b/selfupdate/makeupdate.sh @@ -20,6 +20,8 @@ cp libdump978.so work/bin/ cp linux-mpu9150/libimu.so work/bin/ cp init.d-stratux work/bin/ cp dump1090/dump1090 work/bin/ +cp image/rc.local work/bin/ +cp image/wifi_watch.sh work/bin/ cp -r web work/bin/ #TODO: librtlsdr. cd work/ diff --git a/selfupdate/update_footer.sh b/selfupdate/update_footer.sh index f224f0d0..69ca07df 100755 --- a/selfupdate/update_footer.sh +++ b/selfupdate/update_footer.sh @@ -9,6 +9,11 @@ chmod 755 /etc/init.d/stratux ln -fs /etc/init.d/stratux /etc/rc2.d/S01stratux ln -fs /etc/init.d/stratux /etc/rc6.d/K01stratux +# Wifi watcher. +cp -f rc.local /etc/rc.local +cp -f wifi_watch.sh /usr/sbin/wifi_watch.sh +chmod +x /usr/sbin/wifi_watch.sh + cp -f dump1090 /usr/bin/ # Web files install.