Fix babel script

This commit is contained in:
Bob Mottram 2015-08-08 15:36:27 +01:00
parent 72878e6511
commit c98cecc97f
2 changed files with 43 additions and 9 deletions

View File

@ -1672,18 +1672,49 @@ function mesh_babel {
babel_script=/var/lib/babel babel_script=/var/lib/babel
echo '#!/bin/sh' > $babel_script echo '#!/bin/bash' > $babel_script
echo 'IFACE=wlan0' >> $babel_script
echo 'IFACE_EXISTS=$(grep "$IFACE" /proc/net/dev)' >> $babel_script
echo '' >> $babel_script echo '' >> $babel_script
echo 'if [[ ! $IFACE_EXISTS || $1 == "stop" ]]; then' >> $babel_script echo 'if [[ $1 == "ls" || $1 == "list" ]]; then' >> $babel_script
echo ' avahi-browse --all' >> $babel_script
echo ' exit 0' >> $babel_script
echo 'fi' >> $babel_script
echo '' >> $babel_script
echo 'if [[ $1 == "start" ]]; then' >> $babel_script
echo ' sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
echo ' sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
echo ' if [ -f /bin/systemctl ]; then' >> $babel_script
echo ' systemctl restart avahi-daemon' >> $babel_script
echo ' else' >> $babel_script
echo ' service avahi-daemon restart' >> $babel_script
echo ' fi' >> $babel_script
echo 'fi' >> $babel_script
echo '' >> $babel_script
echo 'IFACE=wlan0' >> $babel_script
echo 'if grep -q "wlan1" /proc/net/dev; then' >> $babel_script
echo ' IFACE=wlan1' >> $babel_script
echo 'fi' >> $babel_script
echo '' >> $babel_script
echo 'if [[ ! grep -q "$IFACE" /proc/net/dev || $1 == "stop" ]]; then' >> $babel_script
echo ' if ! grep -q "$IFACE" /proc/net/dev; then' >> $babel_script
echo ' echo "Interface $IFACE was not found"' >> $babel_script echo ' echo "Interface $IFACE was not found"' >> $babel_script
echo ' else' >> $babel_script
echo ' echo "Stopping"' >> $babel_script
echo ' fi' >> $babel_script
echo ' ifconfig $IFACE down' >> $babel_script echo ' ifconfig $IFACE down' >> $babel_script
echo ' pkill babeld' >> $babel_script
echo ' if [ -f /bin/systemctl ]; then' >> $babel_script
echo ' systemctl restart network-manager' >> $babel_script echo ' systemctl restart network-manager' >> $babel_script
echo ' else' >> $babel_script
echo ' service network-manager restart' >> $babel_script
echo ' fi' >> $babel_script
echo ' exit 1' >> $babel_script echo ' exit 1' >> $babel_script
echo 'fi' >> $babel_script echo 'fi' >> $babel_script
echo '' >> $babel_script echo '' >> $babel_script
echo 'systemctl stop network-manager' >> $babel_script echo 'if [ -f /bin/systemctl ]; then' >> $babel_script
echo ' systemctl stop network-manager' >> $babel_script
echo 'else' >> $babel_script
echo ' service network-manager stop' >> $babel_script
echo 'fi' >> $babel_script
echo 'ifconfig $IFACE down' >> $babel_script echo 'ifconfig $IFACE down' >> $babel_script
echo -n 'iwconfig $IFACE mode ad-hoc channel ' >> $babel_script echo -n 'iwconfig $IFACE mode ad-hoc channel ' >> $babel_script
echo "$WIFI_CHANNEL essid \"$ESSID\"" >> $babel_script echo "$WIFI_CHANNEL essid \"$ESSID\"" >> $babel_script
@ -1693,7 +1724,8 @@ function mesh_babel {
echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script
echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script
echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script
echo "$BABEL_PORT -d 5 wlan0" >> $babel_script echo -n "$BABEL_PORT -d 5 " >> $babel_script
echo '$IFACE' >> $babel_script
echo 'exit 0' >> $babel_script echo 'exit 0' >> $babel_script
chmod +x $babel_script chmod +x $babel_script
@ -1781,6 +1813,7 @@ function mesh_batman_bridge {
echo ' modprobe batman-adv' >> $batman_script echo ' modprobe batman-adv' >> $batman_script
echo ' batctl if add $IFACE' >> $batman_script echo ' batctl if add $IFACE' >> $batman_script
echo ' ifconfig $IFACE up' >> $batman_script echo ' ifconfig $IFACE up' >> $batman_script
echo ' avahi-autoipd $IFACE' >> $batman_script
echo ' ifconfig bat0 up promisc' >> $batman_script echo ' ifconfig bat0 up promisc' >> $batman_script
echo '' >> $batman_script echo '' >> $batman_script
echo ' #Use persistent HWAddr' >> $batman_script echo ' #Use persistent HWAddr' >> $batman_script

View File

@ -147,7 +147,8 @@ function mesh_babel {
echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script
echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script
echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script
echo "$BABEL_PORT -d 5 wlan0" >> $babel_script echo -n "$BABEL_PORT -d 5 " >> $babel_script
echo '$IFACE' >> $babel_script
echo 'exit 0' >> $babel_script echo 'exit 0' >> $babel_script
chmod +x $babel_script chmod +x $babel_script
sudo mv $babel_script /usr/bin/babel sudo mv $babel_script /usr/bin/babel