freedombone/src/freedombone-app-batman

102 lines
2.8 KiB
Plaintext
Raw Normal View History

2016-07-03 17:13:34 +02:00
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# batman adv mesh functions
#
# License
# =======
#
# Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# B.A.T.M.A.N settings
ENABLE_BATMAN="no"
BATMAN_CELLID='any'
2016-07-06 15:43:20 +02:00
function configure_firewall_for_batma {
if grep -Fxq "configure_firewall_for_batman" $COMPLETION_FILE; then
return
fi
if [[ $ENABLE_BATMAN != "yes" ]]; then
return
fi
function_check save_firewall_settings
save_firewall_settings
echo 'configure_firewall_for_batman' >> $COMPLETION_FILE
2016-07-03 20:54:48 +02:00
}
2016-07-06 15:55:09 +02:00
function backup_local_batman {
echo ''
}
function backup_remote_batman {
2016-07-04 22:02:22 +02:00
echo ''
}
2016-07-03 20:54:48 +02:00
function remove_batman {
2016-07-05 09:22:33 +02:00
if ! grep -Fxq "install_batman" $COMPLETION_FILE; then
2016-07-03 20:54:48 +02:00
return
fi
${PROJECT_NAME}-mesh-install -f batman --remove yes
if [ ! "$?" = "0" ]; then
echo $'Failed to remove batman'
exit 79353
fi
2016-07-05 09:22:33 +02:00
sed -i '/install_batman/d' $COMPLETION_FILE
2016-07-03 20:54:48 +02:00
sed -i '/configure_firewall_for_batman/d' $COMPLETION_FILE
}
2016-07-05 09:22:33 +02:00
function install_batman {
if grep -Fxq "install_batman" $COMPLETION_FILE; then
2016-07-03 17:13:34 +02:00
return
fi
if [[ $ENABLE_BATMAN != "yes" ]]; then
return
fi
${PROJECT_NAME}-mesh-install -f batman
if [ ! "$?" = "0" ]; then
echo $'Failed to install batman'
exit 72524
fi
if ! grep -q "Mesh Networking (B.A.T.M.A.N)" /home/$MY_USERNAME/README; then
echo '' >> /home/$MY_USERNAME/README
echo '' >> /home/$MY_USERNAME/README
echo 'Mesh Networking (B.A.T.M.A.N)' >> /home/$MY_USERNAME/README
echo '=============================' >> /home/$MY_USERNAME/README
echo "Mesh ESSID: $WIFI_SSID" >> /home/$MY_USERNAME/README
echo "Mesh cell ID: $BATMAN_CELLID" >> /home/$MY_USERNAME/README
echo "Mesh wifi channel: $WIFI_CHANNEL" >> /home/$MY_USERNAME/README
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
chmod 600 /home/$MY_USERNAME/README
fi
function_check configure_firewall_for_batman
configure_firewall_for_batman
2016-07-05 09:22:33 +02:00
echo 'install_batman' >> $COMPLETION_FILE
2016-07-03 17:13:34 +02:00
}
# NOTE: deliberately no exit 0