freedombone-app-batman 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # batman adv mesh functions
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
  17. #
  18. # This program is free software: you can redistribute it and/or modify
  19. # it under the terms of the GNU Affero General Public License as published by
  20. # the Free Software Foundation, either version 3 of the License, or
  21. # (at your option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. # GNU Affero General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU Affero General Public License
  29. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. VARIANTS='mesh'
  31. ENABLE_BATMAN="no"
  32. BATMAN_CELLID='any'
  33. function configure_firewall_for_batma {
  34. if grep -Fxq "configure_firewall_for_batman" $COMPLETION_FILE; then
  35. return
  36. fi
  37. if [[ $ENABLE_BATMAN != "yes" ]]; then
  38. return
  39. fi
  40. function_check save_firewall_settings
  41. save_firewall_settings
  42. echo 'configure_firewall_for_batman' >> $COMPLETION_FILE
  43. }
  44. function reconfigure_batman {
  45. echo -n ''
  46. }
  47. function upgrade_batman {
  48. echo -n ''
  49. }
  50. function backup_local_batman {
  51. echo -n ''
  52. }
  53. function restore_local_batman {
  54. echo -n ''
  55. }
  56. function backup_remote_batman {
  57. echo -n ''
  58. }
  59. function restore_remote_batman {
  60. echo -n ''
  61. }
  62. function remove_batman {
  63. if ! grep -Fxq "install_batman" $COMPLETION_FILE; then
  64. return
  65. fi
  66. ${PROJECT_NAME}-mesh-install -f batman --remove yes
  67. if [ ! "$?" = "0" ]; then
  68. echo $'Failed to remove batman'
  69. exit 79353
  70. fi
  71. sed -i '/install_batman/d' $COMPLETION_FILE
  72. sed -i '/configure_firewall_for_batman/d' $COMPLETION_FILE
  73. }
  74. function install_batman {
  75. if grep -Fxq "install_batman" $COMPLETION_FILE; then
  76. return
  77. fi
  78. if [[ $ENABLE_BATMAN != "yes" ]]; then
  79. return
  80. fi
  81. ${PROJECT_NAME}-mesh-install -f batman
  82. if [ ! "$?" = "0" ]; then
  83. echo $'Failed to install batman'
  84. exit 72524
  85. fi
  86. if ! grep -q "Mesh Networking (B.A.T.M.A.N)" /home/$MY_USERNAME/README; then
  87. echo '' >> /home/$MY_USERNAME/README
  88. echo '' >> /home/$MY_USERNAME/README
  89. echo 'Mesh Networking (B.A.T.M.A.N)' >> /home/$MY_USERNAME/README
  90. echo '=============================' >> /home/$MY_USERNAME/README
  91. echo "Mesh ESSID: $WIFI_SSID" >> /home/$MY_USERNAME/README
  92. echo "Mesh cell ID: $BATMAN_CELLID" >> /home/$MY_USERNAME/README
  93. echo "Mesh wifi channel: $WIFI_CHANNEL" >> /home/$MY_USERNAME/README
  94. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
  95. chmod 600 /home/$MY_USERNAME/README
  96. fi
  97. function_check configure_firewall_for_batman
  98. configure_firewall_for_batman
  99. echo 'install_batman' >> $COMPLETION_FILE
  100. }
  101. # NOTE: deliberately no exit 0