freedombone-app-babel 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Babel 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. # Babel mesh
  31. ENABLE_BABEL="no"
  32. BABEL_PORT=6696
  33. function upgrade_babel {
  34. echo ''
  35. }
  36. function backup_local_babel {
  37. echo ''
  38. }
  39. function backup_remote_babel {
  40. echo ''
  41. }
  42. function remove_babel {
  43. if ! grep -Fxq "install_babel" $COMPLETION_FILE; then
  44. return
  45. fi
  46. ${PROJECT_NAME}-mesh-install -f babel --remove yes
  47. if [ ! "$?" = "0" ]; then
  48. echo $'Failed to remove babel'
  49. exit 83658
  50. fi
  51. iptables -D INPUT -i $WIFI_INTERFACE -p udp --dport $BABEL_PORT -j ACCEPT
  52. function_check save_firewall_settings
  53. save_firewall_settings
  54. sed -i '/install_babel/d' $COMPLETION_FILE
  55. sed -i '/configure_firewall_for_babel/d' $COMPLETION_FILE
  56. }
  57. function configure_firewall_for_babel {
  58. if grep -Fxq "configure_firewall_for_babel" $COMPLETION_FILE; then
  59. return
  60. fi
  61. if [[ $ENABLE_BABEL != "yes" ]]; then
  62. return
  63. fi
  64. iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $BABEL_PORT -j ACCEPT
  65. function_check save_firewall_settings
  66. save_firewall_settings
  67. OPEN_PORTS+=("Babel $BABEL_PORT")
  68. echo 'configure_firewall_for_babel' >> $COMPLETION_FILE
  69. }
  70. function install_babel {
  71. if grep -Fxq "install_babel" $COMPLETION_FILE; then
  72. return
  73. fi
  74. if [[ $ENABLE_BABEL != "yes" ]]; then
  75. return
  76. fi
  77. ${PROJECT_NAME}-mesh-install -f babel
  78. if [ ! "$?" = "0" ]; then
  79. echo $'Failed to install babel'
  80. exit 67242
  81. fi
  82. function_check configure_firewall_for_babel
  83. configure_firewall_for_babel
  84. echo 'install_babel' >> $COMPLETION_FILE
  85. }
  86. # NOTE: deliberately there is no "exit 0"