freedombone-app-babel 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. VARIANTS=''
  31. ENABLE_BABEL="no"
  32. BABEL_PORT=6696
  33. function install_interactive_babel {
  34. echo -n ''
  35. }
  36. function change_password_babel {
  37. echo -n ''
  38. }
  39. function reconfigure_babel {
  40. echo -n ''
  41. }
  42. function upgrade_babel {
  43. echo -n ''
  44. }
  45. function backup_local_babel {
  46. echo -n ''
  47. }
  48. function restore_local_babel {
  49. echo -n ''
  50. }
  51. function backup_remote_babel {
  52. echo -n ''
  53. }
  54. function restore_remote_babel {
  55. echo -n ''
  56. }
  57. function remove_babel {
  58. if ! grep -Fxq "install_babel" $COMPLETION_FILE; then
  59. return
  60. fi
  61. ${PROJECT_NAME}-mesh-install -f babel --remove yes
  62. if [ ! "$?" = "0" ]; then
  63. echo $'Failed to remove babel'
  64. exit 83658
  65. fi
  66. iptables -D INPUT -i $WIFI_INTERFACE -p udp --dport $BABEL_PORT -j ACCEPT
  67. function_check save_firewall_settings
  68. save_firewall_settings
  69. sed -i '/install_babel/d' $COMPLETION_FILE
  70. sed -i '/configure_firewall_for_babel/d' $COMPLETION_FILE
  71. }
  72. function configure_firewall_for_babel {
  73. if grep -Fxq "configure_firewall_for_babel" $COMPLETION_FILE; then
  74. return
  75. fi
  76. if [[ $ENABLE_BABEL != "yes" ]]; then
  77. return
  78. fi
  79. iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $BABEL_PORT -j ACCEPT
  80. function_check save_firewall_settings
  81. save_firewall_settings
  82. OPEN_PORTS+=("Babel $BABEL_PORT")
  83. echo 'configure_firewall_for_babel' >> $COMPLETION_FILE
  84. }
  85. function install_babel {
  86. if grep -Fxq "install_babel" $COMPLETION_FILE; then
  87. return
  88. fi
  89. if [[ $ENABLE_BABEL != "yes" ]]; then
  90. return
  91. fi
  92. ${PROJECT_NAME}-mesh-install -f babel
  93. if [ ! "$?" = "0" ]; then
  94. echo $'Failed to install babel'
  95. exit 67242
  96. fi
  97. function_check configure_firewall_for_babel
  98. configure_firewall_for_babel
  99. echo 'install_babel' >> $COMPLETION_FILE
  100. }
  101. # NOTE: deliberately there is no "exit 0"