freedombone-mesh-routing 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Select the mesh routing protocol
  12. #
  13. # License
  14. # =======
  15. #
  16. # This program is free software: you can redistribute it and/or modify
  17. # it under the terms of the GNU Affero General Public License as published by
  18. # the Free Software Foundation, either version 3 of the License, or
  19. # (at your option) any later version.
  20. #
  21. # This program is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU Affero General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU Affero General Public License
  27. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. PROJECT_NAME='freedombone'
  29. export TEXTDOMAIN=${PROJECT_NAME}-mesh-routing
  30. export TEXTDOMAINDIR="/usr/share/locale"
  31. source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
  32. source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
  33. bmx6_peers=$(avahi-browse -at | grep routing | grep bmx6 | wc -l)
  34. olsr2_peers=$(avahi-browse -at | grep routing | grep olsr2 | wc -l)
  35. data=$(zenity --list 1 $"BMX6 ($bmx6_peers)" 2 $"OLSR2 ($olsr2_peers)" $"Select Mesh Protocol" --column="id" --title $"Mesh Protocol" --column=$"Choose the mesh protocol:" --hide-column=1 --print-column=1 --height=150)
  36. sel=$?
  37. case $sel in
  38. 1) exit 1;;
  39. 255) exit 1;;
  40. esac
  41. echo '#!/bin/bash' > /tmp/change_routing
  42. echo "echo '$1' > $MESH_DEFAULT_PROTOCOL" >> /tmp/change_routing
  43. echo "echo '$1' > $MESH_CURRENT_PROTOCOL" >> /tmp/change_routing
  44. chmod +x /tmp/change_routing
  45. case $data in
  46. 1) sudo /tmp/change_routing 'bmx6'
  47. sudo systemctl stop bmx7
  48. sudo systemctl disable bmx7
  49. sudo systemctl stop olsr2
  50. sudo systemctl disable olsr2
  51. sudo systemctl enable bmx6
  52. sudo systemctl start bmx6
  53. ;;
  54. 2) sudo /tmp/change_routing 'olsr2'
  55. sudo systemctl stop bmx7
  56. sudo systemctl disable bmx7
  57. sudo systemctl stop bmx6
  58. sudo systemctl disable bmx6
  59. sudo systemctl enable olsr2
  60. sudo systemctl start olsr2
  61. ;;
  62. esac
  63. rm /tmp/change_routing
  64. exit 0