123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- #!/bin/bash
- #
- # .---. . .
- # | | |
- # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
- # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
- # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
- #
- # Freedom in the Cloud
- #
- # Select the mesh routing protocol
- #
- # License
- # =======
- #
- # 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/>.
-
- PROJECT_NAME='freedombone'
-
- export TEXTDOMAIN=${PROJECT_NAME}-mesh-routing
- export TEXTDOMAINDIR="/usr/share/locale"
-
- source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
- source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
-
- function mesh_stop_daemon {
- daemon_name=$1
-
- clear
- echo ''
- echo $"Stopping $1..."
- sudo systemctl stop $1
- echo $"Disabling $1..."
- sudo systemctl disable $1
- }
-
- clear
- echo ''
- echo $'Scanning for BMX6 protocol...'
- bmx6_peers=$(avahi-browse -at | grep routing | grep bmx6 | wc -l)
-
- clear
- echo ''
- echo $'Scanning for OLSR2 protocol...'
- olsr2_peers=$(avahi-browse -at | grep routing | grep olsr2 | wc -l)
-
- clear
- echo ''
- echo $'Scanning for Babel protocol...'
- babel_peers=$(avahi-browse -at | grep routing | grep babel | wc -l)
-
- clear
-
- data=$(zenity --list 1 $"BMX6 ($bmx6_peers)" 2 $"OLSR2 ($olsr2_peers)" 3 $"Babel ($babel_peers)" $"Select Mesh Protocol" --column="id" --title $"Mesh Protocol" --column=$"Choose the mesh protocol:" --hide-column=1 --print-column=1 --height=150)
-
- sel=$?
- case $sel in
- 1) exit 1;;
- 255) exit 1;;
- esac
-
- temp_script=$HOME/.change_routing
- echo '#!/bin/bash' > $temp_script
- echo "echo \"\$1\" > $MESH_DEFAULT_PROTOCOL" >> $temp_script
- echo "echo \"\$1\" > $MESH_CURRENT_PROTOCOL" >> $temp_script
- echo "sed -i \"s|<type>.*|<type>_\${1}._tcp</type>|g\" /etc/avahi/services/routing.service" >> $temp_script
- echo 'systemctl restart avahi-daemon' >> $temp_script
- echo "IFACE=\$(cat /etc/systemd/system/\${1}.service | grep ExecStart | awk -F ' ' '{print \$2}')" >> $temp_script
- echo 'network=fd66:66:66' >> $temp_script
- echo 'search_ipv6=$(ifconfig $1 | grep $network)' >> $temp_script
- echo 'if [ $search_ipv6 ]; then' >> $temp_script
- echo " result=\$(ifconfig \$1 | grep \$network | awk -F ' ' '{print \$2}')" >> $temp_script
- echo ' ip -6 addr add ${result}/128 dev $1' >> $temp_script
- echo 'else' >> $temp_script
- echo ' ipv6_array=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )' >> $temp_script
- echo ' a=${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}' >> $temp_script
- echo ' b=${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}' >> $temp_script
- echo ' c=${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}' >> $temp_script
- echo ' d=${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}' >> $temp_script
- echo ' e=${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}${ipv6_array[$RANDOM%16]}' >> $temp_script
- echo ' result=$network:$a:$b:$c:$d:$e' >> $temp_script
- echo ' ip -6 addr add ${result}/128 dev $1' >> $temp_script
- echo 'fi' >> $temp_script
- chmod +x $temp_script
-
- clear
- echo ''
- echo $'Authentication to change mesh protocol'
- echo ''
-
- case $data in
- 1) sudo $temp_script 'bmx6'
- mesh_stop_daemon 'bmx7'
- mesh_stop_daemon 'olsr2'
- mesh_stop_daemon 'babel'
- clear
- echo ''
- echo $'Enabling BMX6...'
- sudo systemctl enable bmx6
- echo $'Starting BMX6...'
- sudo systemctl start bmx6
- ;;
- 2) sudo $temp_script 'olsr2'
- mesh_stop_daemon 'bmx6'
- mesh_stop_daemon 'bmx7'
- mesh_stop_daemon 'babel'
- clear
- echo ''
- echo $'Enabling OLSR2...'
- sudo systemctl enable olsr2
- echo $'Starting OLSR2...'
- sudo systemctl start olsr2
- ;;
- 3) sudo $temp_script 'babel'
- mesh_stop_daemon 'bmx6'
- mesh_stop_daemon 'bmx7'
- mesh_stop_daemon 'olsr2'
- clear
- echo ''
- echo $'Enabling Babel...'
- sudo systemctl enable babel
- echo $'Starting Babel...'
- sudo systemctl start babel
- ;;
- esac
-
- rm $temp_script
-
- exit 0
|