Tidying
This commit is contained in:
parent
390c1c6a44
commit
e581c487ea
4
Makefile
4
Makefile
|
@ -28,8 +28,6 @@ install:
|
|||
cp img/avatars/* ${DESTDIR}/usr/share/${APP}/avatars
|
||||
cp src/* ${DESTDIR}${PREFIX}/bin
|
||||
cp src/${APP}-mesh-batman ${DESTDIR}${PREFIX}/bin/batman
|
||||
cp src/${APP}-mesh-bmx6 ${DESTDIR}${PREFIX}/bin/bmx
|
||||
cp src/${APP}-mesh-bmx7 ${DESTDIR}${PREFIX}/bin/bmxsec
|
||||
cp src/${APP}-backup-local ${DESTDIR}${PREFIX}/bin/backup
|
||||
cp src/${APP}-backup-local ${DESTDIR}${PREFIX}/bin/backup2friends
|
||||
cp src/${APP}-restore-local ${DESTDIR}${PREFIX}/bin/restore
|
||||
|
@ -62,8 +60,6 @@ uninstall:
|
|||
rm -f ${PREFIX}/bin/restore
|
||||
rm -f ${PREFIX}/bin/restorefromfriend
|
||||
rm -f ${PREFIX}/bin/batman
|
||||
rm -f ${PREFIX}/bin/bmx
|
||||
rm -f ${PREFIX}/bin/bmxsec
|
||||
rm -rf /etc/${APP}
|
||||
rm -f ${PREFIX}/bin/control
|
||||
rm -f ${PREFIX}/bin/controluser
|
||||
|
|
|
@ -1,315 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# .---. . .
|
||||
# | | |
|
||||
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
||||
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
||||
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
||||
#
|
||||
# Freedom in the Cloud
|
||||
#
|
||||
# Used to enable or disable BMX6 mesh protocol on wlanX
|
||||
#
|
||||
# License
|
||||
# =======
|
||||
#
|
||||
# Copyright (C) 2018 Bob Mottram <bob@freedombone.net>
|
||||
#
|
||||
# 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'
|
||||
COMPLETION_FILE=/root/${PROJECT_NAME}-completed.txt
|
||||
|
||||
# hotspot passphrase must be 5 characters or longer
|
||||
HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
|
||||
|
||||
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
|
||||
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
|
||||
|
||||
mesh_protocol_init
|
||||
|
||||
update_wifi_adaptors
|
||||
|
||||
if [ ! $IFACE ]; then
|
||||
echo $'No wlan adaptor'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
function status {
|
||||
bmx6 -cd8
|
||||
}
|
||||
|
||||
function stop {
|
||||
if [ -z "$IFACE" ]; then
|
||||
echo 'error: unable to find wifi interface, not enabling BMX6 mesh'
|
||||
return
|
||||
fi
|
||||
|
||||
systemctl stop dnsmasq
|
||||
systemctl disable dnsmasq
|
||||
systemctl stop bmx6
|
||||
systemctl disable bmx6
|
||||
|
||||
if [ "$EIFACE" ]; then
|
||||
ethernet_connected=$(cat /sys/class/net/$EIFACE/carrier)
|
||||
if [[ "$ethernet_connected" != "0" ]]; then
|
||||
systemctl stop hostapd
|
||||
ifconfig $EIFACE down -promisc
|
||||
fi
|
||||
fi
|
||||
|
||||
ifconfig $IFACE down -promisc
|
||||
|
||||
ifconfig $IFACE mtu 1500
|
||||
ifconfig $IFACE down
|
||||
iwconfig $IFACE mode managed
|
||||
|
||||
if [ $IFACE_SECONDARY ]; then
|
||||
systemctl stop hostapd
|
||||
systemctl disable hostapd
|
||||
ifconfig $IFACE_SECONDARY mtu 1500
|
||||
ifconfig $IFACE_SECONDARY down
|
||||
iwconfig $IFACE_SECONDARY mode managed
|
||||
fi
|
||||
|
||||
disable_mesh_firewall
|
||||
|
||||
systemctl restart network-manager
|
||||
|
||||
if [ -f $MESH_CURRENT_PROTOCOL ]; then
|
||||
rm $MESH_CURRENT_PROTOCOL
|
||||
fi
|
||||
}
|
||||
|
||||
function verify {
|
||||
# TODO
|
||||
echo -n ''
|
||||
}
|
||||
|
||||
function add_wifi_interface {
|
||||
ifname=$1
|
||||
ifssid=$WIFI_SSID
|
||||
if [ $2 ]; then
|
||||
ifssid=$2
|
||||
fi
|
||||
ifmode=ad-hoc
|
||||
if [ $3 ]; then
|
||||
ifmode=$3
|
||||
fi
|
||||
ifchannel=$CHANNEL
|
||||
if [ $4 ]; then
|
||||
ifchannel=$4
|
||||
fi
|
||||
|
||||
ifconfig $ifname down
|
||||
ifconfig $ifname mtu 1500
|
||||
peermac=$(assign_peer_address)
|
||||
if [ ! $peermac ]; then
|
||||
echo $"Unable to obtain MAC address for $peermac on $ifname"
|
||||
return
|
||||
fi
|
||||
ifconfig $ifname hw ether $peermac
|
||||
echo $"$ifname assigned MAC address $peermac"
|
||||
iwconfig $ifname enc off
|
||||
iwconfig $ifname mode $ifmode essid $ifssid channel $ifchannel
|
||||
#iwconfig wlan0 mode ad-hoc ap 02:ca:ff:ee:ba:be channel 11 essid my-mesh-network
|
||||
|
||||
ifconfig $ifname up
|
||||
}
|
||||
|
||||
function start {
|
||||
update_wifi_adaptors
|
||||
|
||||
if [ -z "$IFACE" ] ; then
|
||||
echo 'error: unable to find wifi interface, not enabling BMX6 mesh'
|
||||
exit 723657
|
||||
fi
|
||||
echo "info: enabling BMX6 mesh network $WIFI_SSID on $IFACE"
|
||||
|
||||
systemctl stop network-manager
|
||||
sleep 5
|
||||
|
||||
systemctl stop dnsmasq
|
||||
systemctl disable dnsmasq
|
||||
|
||||
# remove an avahi service which isn't used
|
||||
if [ -f /etc/avahi/services/udisks.service ]; then
|
||||
sudo rm /etc/avahi/services/udisks.service
|
||||
fi
|
||||
|
||||
global_rate_limit
|
||||
|
||||
# Might have to re-enable wifi
|
||||
rfkill unblock $(rfkill list|awk -F: "/phy/ {print $1}") || true
|
||||
|
||||
secondary_wifi_available=
|
||||
if [ $IFACE_SECONDARY ]; then
|
||||
if [[ $IFACE != $IFACE_SECONDARY ]]; then
|
||||
if [ -d /etc/hostapd ]; then
|
||||
if [ ${#HOTSPOT_PASSPHRASE} -gt 4 ]; then
|
||||
secondary_wifi_available=1
|
||||
else
|
||||
echo $'Hotspot passphrase is too short'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
add_wifi_interface $IFACE $WIFI_SSID ad-hoc $CHANNEL
|
||||
ifconfig $IFACE up promisc
|
||||
|
||||
if [ ! $secondary_wifi_available ]; then
|
||||
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx6 dev=${IFACE}|g" /etc/systemd/system/bmx6.service
|
||||
else
|
||||
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx6 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx6.service
|
||||
fi
|
||||
|
||||
# avahi on ipv6
|
||||
sed -i 's|use-ipv4=.*|use-ipv4=no|g' /etc/avahi/avahi-daemon.conf
|
||||
sed -i 's|use-ipv6=.*|use-ipv6=yes|g' /etc/avahi/avahi-daemon.conf
|
||||
sed -i 's|#disallow-other-stacks=.*|disallow-other-stacks=no|g' /etc/avahi/avahi-daemon.conf
|
||||
sed -i 's|disallow-other-stacks=.*|disallow-other-stacks=no|g' /etc/avahi/avahi-daemon.conf
|
||||
sed -i 's|#publish-a-on-ipv6=.*|publish-a-on-ipv6=yes|g' /etc/avahi/avahi-daemon.conf
|
||||
sed -i 's|publish-a-on-ipv6=.*|publish-a-on-ipv6=yes|g' /etc/avahi/avahi-daemon.conf
|
||||
systemctl restart avahi-daemon
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable bmx6
|
||||
|
||||
# NOTE: Don't connect the secondary wifi device. hostapd will handle that by itself
|
||||
|
||||
ethernet_connected='0'
|
||||
if [ "$EIFACE" ] ; then
|
||||
ethernet_connected=$(cat /sys/class/net/$EIFACE/carrier)
|
||||
if [[ "$ethernet_connected" != "0" ]]; then
|
||||
echo $'Trying ethernet bridge to the internet'
|
||||
ifconfig $EIFACE up promisc
|
||||
echo $'End of ethernet bridge'
|
||||
else
|
||||
echo $"$EIFACE is not connected"
|
||||
fi
|
||||
fi
|
||||
|
||||
enable_mesh_seconary_wifi
|
||||
|
||||
enable_mesh_firewall
|
||||
|
||||
systemctl restart avahi-daemon
|
||||
|
||||
enable_mesh_scuttlebot
|
||||
enable_mesh_tor
|
||||
|
||||
|
||||
sed -i "s|server_name .*|server_name ${HOSTNAME}.local;|g" /etc/nginx/sites-available/git_ssb
|
||||
|
||||
systemctl restart nginx
|
||||
systemctl restart bmx6
|
||||
|
||||
verify
|
||||
|
||||
echo "bmx6" > $MESH_CURRENT_PROTOCOL
|
||||
}
|
||||
|
||||
function monitor {
|
||||
if [ -z "$IFACE" ] ; then
|
||||
echo 'error: unable to find wifi interface, not enabling BMX6 mesh'
|
||||
exit 723657
|
||||
fi
|
||||
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Stopping network ***'
|
||||
echo ''
|
||||
|
||||
stop
|
||||
|
||||
echo "info: monitoring mesh network $WIFI_SSID on $IFACE"
|
||||
|
||||
systemctl stop network-manager
|
||||
sleep 5
|
||||
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Setting firewall rate limit ***'
|
||||
echo ''
|
||||
|
||||
global_rate_limit
|
||||
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Enabling wifi adaptor in monitor mode ***'
|
||||
echo ''
|
||||
|
||||
# Might have to re-enable wifi
|
||||
rfkill unblock $(rfkill list|awk -F: "/phy/ {print $1}") || true
|
||||
|
||||
ifconfig $IFACE down
|
||||
ifconfig $IFACE mtu 1500
|
||||
ifconfig $IFACE hw ether $(assign_peer_address)
|
||||
iwconfig $IFACE enc off
|
||||
iwconfig $IFACE mode monitor channel $CHANNEL
|
||||
sleep 1
|
||||
iwconfig $IFACE ap $CELLID
|
||||
|
||||
ifconfig $IFACE up
|
||||
|
||||
horst -i $IFACE
|
||||
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Restarting the network daemon. This may take a while. ***'
|
||||
echo ''
|
||||
|
||||
start
|
||||
}
|
||||
|
||||
if ! grep -q "$IFACE" /proc/net/dev; then
|
||||
echo 'Interface $IFACE was not found'
|
||||
stop
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start|stop|status|monitor)
|
||||
$1
|
||||
;;
|
||||
restart)
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Stopping BMX6 mesh network connection ***'
|
||||
echo ''
|
||||
stop
|
||||
sleep 10
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Starting BMX6 mesh network connection ***'
|
||||
echo ''
|
||||
start
|
||||
;;
|
||||
ping)
|
||||
traceroute6 -n -q 1 $2
|
||||
;;
|
||||
data)
|
||||
bmx6 -lc traffic=$IFACE
|
||||
;;
|
||||
ls|list)
|
||||
avahi-browse -atl
|
||||
;;
|
||||
*)
|
||||
echo "error: invalid parameter $1"
|
||||
echo 'usage: $0 {start|stop|restart|status|ping|ls|list}'
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
exit 0
|
|
@ -1,313 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# .---. . .
|
||||
# | | |
|
||||
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
||||
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
||||
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
||||
#
|
||||
# Freedom in the Cloud
|
||||
#
|
||||
# Used to enable or disable BMX7 mesh protocol on wlanX
|
||||
#
|
||||
# License
|
||||
# =======
|
||||
#
|
||||
# Copyright (C) 2018 Bob Mottram <bob@freedombone.net>
|
||||
#
|
||||
# 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'
|
||||
COMPLETION_FILE=/root/${PROJECT_NAME}-completed.txt
|
||||
|
||||
# hotspot passphrase must be 5 characters or longer
|
||||
HOTSPOT_PASSPHRASE="${PROJECT_NAME}"
|
||||
|
||||
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-wifi
|
||||
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-mesh
|
||||
|
||||
mesh_protocol_init
|
||||
update_wifi_adaptors
|
||||
|
||||
if [ ! $IFACE ]; then
|
||||
echo $'No wlan adaptor'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
function status {
|
||||
bmx7 -cd8
|
||||
}
|
||||
|
||||
function stop {
|
||||
if [ -z "$IFACE" ]; then
|
||||
echo 'error: unable to find wifi interface, not enabling BMX7 mesh'
|
||||
return
|
||||
fi
|
||||
|
||||
systemctl stop dnsmasq
|
||||
systemctl disable dnsmasq
|
||||
systemctl stop bmx7
|
||||
systemctl disable bmx7
|
||||
|
||||
if [ "$EIFACE" ]; then
|
||||
ethernet_connected=$(cat /sys/class/net/$EIFACE/carrier)
|
||||
if [[ "$ethernet_connected" != "0" ]]; then
|
||||
systemctl stop hostapd
|
||||
ifconfig $EIFACE down -promisc
|
||||
fi
|
||||
fi
|
||||
|
||||
ifconfig $IFACE down -promisc
|
||||
|
||||
ifconfig $IFACE mtu 1500
|
||||
ifconfig $IFACE down
|
||||
iwconfig $IFACE mode managed
|
||||
|
||||
if [ $IFACE_SECONDARY ]; then
|
||||
systemctl stop hostapd
|
||||
systemctl disable hostapd
|
||||
ifconfig $IFACE_SECONDARY mtu 1500
|
||||
ifconfig $IFACE_SECONDARY down
|
||||
iwconfig $IFACE_SECONDARY mode managed
|
||||
fi
|
||||
|
||||
disable_mesh_firewall
|
||||
|
||||
systemctl restart network-manager
|
||||
|
||||
if [ -f $MESH_CURRENT_PROTOCOL ]; then
|
||||
rm $MESH_CURRENT_PROTOCOL
|
||||
fi
|
||||
}
|
||||
|
||||
function verify {
|
||||
# TODO
|
||||
echo -n ''
|
||||
}
|
||||
|
||||
function add_wifi_interface {
|
||||
ifname=$1
|
||||
ifssid=$WIFI_SSID
|
||||
if [ $2 ]; then
|
||||
ifssid=$2
|
||||
fi
|
||||
ifmode=ad-hoc
|
||||
if [ $3 ]; then
|
||||
ifmode=$3
|
||||
fi
|
||||
ifchannel=$CHANNEL
|
||||
if [ $4 ]; then
|
||||
ifchannel=$4
|
||||
fi
|
||||
|
||||
ifconfig $ifname down
|
||||
ifconfig $ifname mtu 1500
|
||||
peermac=$(assign_peer_address)
|
||||
if [ ! $peermac ]; then
|
||||
echo $"Unable to obtain MAC address for $peermac on $ifname"
|
||||
return
|
||||
fi
|
||||
ifconfig $ifname hw ether $peermac
|
||||
echo $"$ifname assigned MAC address $peermac"
|
||||
iwconfig $ifname enc off
|
||||
iwconfig $ifname mode $ifmode essid $ifssid channel $ifchannel
|
||||
|
||||
ifconfig $ifname up
|
||||
}
|
||||
|
||||
function start {
|
||||
update_wifi_adaptors
|
||||
|
||||
if [ -z "$IFACE" ] ; then
|
||||
echo 'error: unable to find wifi interface, not enabling BMX7 mesh'
|
||||
exit 723657
|
||||
fi
|
||||
echo "info: enabling BMX7 mesh network $WIFI_SSID on $IFACE"
|
||||
|
||||
systemctl stop network-manager
|
||||
sleep 5
|
||||
|
||||
systemctl stop dnsmasq
|
||||
systemctl disable dnsmasq
|
||||
|
||||
# remove an avahi service which isn't used
|
||||
if [ -f /etc/avahi/services/udisks.service ]; then
|
||||
sudo rm /etc/avahi/services/udisks.service
|
||||
fi
|
||||
|
||||
global_rate_limit
|
||||
|
||||
# Might have to re-enable wifi
|
||||
rfkill unblock $(rfkill list|awk -F: "/phy/ {print $1}") || true
|
||||
|
||||
secondary_wifi_available=
|
||||
if [ $IFACE_SECONDARY ]; then
|
||||
if [[ $IFACE != $IFACE_SECONDARY ]]; then
|
||||
if [ -d /etc/hostapd ]; then
|
||||
if [ ${#HOTSPOT_PASSPHRASE} -gt 4 ]; then
|
||||
secondary_wifi_available=1
|
||||
else
|
||||
echo $'Hotspot passphrase is too short'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
add_wifi_interface $IFACE $WIFI_SSID ad-hoc $CHANNEL
|
||||
ifconfig $IFACE up promisc
|
||||
|
||||
if [ ! $secondary_wifi_available ]; then
|
||||
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE}|g" /etc/systemd/system/bmx7.service
|
||||
else
|
||||
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx7.service
|
||||
fi
|
||||
|
||||
# avahi on ipv6
|
||||
sed -i 's|use-ipv4=.*|use-ipv4=no|g' /etc/avahi/avahi-daemon.conf
|
||||
sed -i 's|use-ipv6=.*|use-ipv6=yes|g' /etc/avahi/avahi-daemon.conf
|
||||
sed -i 's|#disallow-other-stacks=.*|disallow-other-stacks=no|g' /etc/avahi/avahi-daemon.conf
|
||||
sed -i 's|disallow-other-stacks=.*|disallow-other-stacks=no|g' /etc/avahi/avahi-daemon.conf
|
||||
sed -i 's|#publish-a-on-ipv6=.*|publish-a-on-ipv6=yes|g' /etc/avahi/avahi-daemon.conf
|
||||
sed -i 's|publish-a-on-ipv6=.*|publish-a-on-ipv6=yes|g' /etc/avahi/avahi-daemon.conf
|
||||
systemctl restart avahi-daemon
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable bmx7
|
||||
|
||||
# NOTE: Don't connect the secondary wifi device. hostapd will handle that by itself
|
||||
|
||||
ethernet_connected='0'
|
||||
if [ "$EIFACE" ] ; then
|
||||
ethernet_connected=$(cat /sys/class/net/$EIFACE/carrier)
|
||||
if [[ "$ethernet_connected" != "0" ]]; then
|
||||
echo $'Trying ethernet bridge to the internet'
|
||||
ifconfig $EIFACE up promisc
|
||||
echo $'End of ethernet bridge'
|
||||
else
|
||||
echo $"$EIFACE is not connected"
|
||||
fi
|
||||
fi
|
||||
|
||||
enable_mesh_seconary_wifi
|
||||
|
||||
enable_mesh_firewall
|
||||
|
||||
systemctl restart avahi-daemon
|
||||
|
||||
enable_mesh_scuttlebot
|
||||
enable_mesh_tor
|
||||
|
||||
|
||||
sed -i "s|server_name .*|server_name ${HOSTNAME}.local;|g" /etc/nginx/sites-available/git_ssb
|
||||
|
||||
systemctl restart nginx
|
||||
systemctl restart bmx7
|
||||
|
||||
verify
|
||||
|
||||
echo "bmx7" > $MESH_CURRENT_PROTOCOL
|
||||
}
|
||||
|
||||
function monitor {
|
||||
if [ -z "$IFACE" ] ; then
|
||||
echo 'error: unable to find wifi interface, not enabling BMX7 mesh'
|
||||
exit 723657
|
||||
fi
|
||||
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Stopping network ***'
|
||||
echo ''
|
||||
|
||||
stop
|
||||
|
||||
echo "info: monitoring mesh network $WIFI_SSID on $IFACE"
|
||||
|
||||
systemctl stop network-manager
|
||||
sleep 5
|
||||
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Setting firewall rate limit ***'
|
||||
echo ''
|
||||
|
||||
global_rate_limit
|
||||
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Enabling wifi adaptor in monitor mode ***'
|
||||
echo ''
|
||||
|
||||
# Might have to re-enable wifi
|
||||
rfkill unblock $(rfkill list|awk -F: "/phy/ {print $1}") || true
|
||||
|
||||
ifconfig $IFACE down
|
||||
ifconfig $IFACE mtu 1500
|
||||
ifconfig $IFACE hw ether $(assign_peer_address)
|
||||
iwconfig $IFACE enc off
|
||||
iwconfig $IFACE mode monitor channel $CHANNEL
|
||||
sleep 1
|
||||
iwconfig $IFACE ap $CELLID
|
||||
|
||||
ifconfig $IFACE up
|
||||
|
||||
horst -i $IFACE
|
||||
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Restarting the network daemon. This may take a while. ***'
|
||||
echo ''
|
||||
|
||||
start
|
||||
}
|
||||
|
||||
if ! grep -q "$IFACE" /proc/net/dev; then
|
||||
echo 'Interface $IFACE was not found'
|
||||
stop
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start|stop|status|monitor)
|
||||
$1
|
||||
;;
|
||||
restart)
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Stopping BMX7 mesh network connection ***'
|
||||
echo ''
|
||||
stop
|
||||
sleep 10
|
||||
clear
|
||||
echo ''
|
||||
echo $'*** Starting BMX7 mesh network connection ***'
|
||||
echo ''
|
||||
start
|
||||
;;
|
||||
ping)
|
||||
traceroute6 -n -q 1 $2
|
||||
;;
|
||||
data)
|
||||
bmx7 -lc traffic=$IFACE
|
||||
;;
|
||||
ls|list)
|
||||
avahi-browse -atl
|
||||
;;
|
||||
*)
|
||||
echo "error: invalid parameter $1"
|
||||
echo 'usage: $0 {start|stop|restart|status|ping|ls|list}'
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
exit 0
|
|
@ -99,12 +99,12 @@ function mesh_avahi {
|
|||
sed -i "s|#host-name=.*|host-name=P$PEER_ID|g" $rootdir/etc/avahi/avahi-daemon.conf
|
||||
|
||||
if [ ! -d $rootdir/etc/avahi/services ]; then
|
||||
mkdir -p $rootdir/etc/avahi/services
|
||||
mkdir -p $rootdir/etc/avahi/services
|
||||
fi
|
||||
|
||||
# remove an avahi service which isn't used
|
||||
if [ -f $rootdir/etc/avahi/services/udisks.service ]; then
|
||||
rm $rootdir/etc/avahi/services/udisks.service
|
||||
rm $rootdir/etc/avahi/services/udisks.service
|
||||
fi
|
||||
|
||||
# Add an ssh service
|
||||
|
@ -143,15 +143,15 @@ function install_batman {
|
|||
$CHROOT_PREFIX apt-get -yq install wireless-tools rfkill
|
||||
|
||||
if ! grep -q "batman_adv" $rootdir/etc/modules; then
|
||||
echo 'batman_adv' >> $rootdir/etc/modules
|
||||
echo 'batman_adv' >> $rootdir/etc/modules
|
||||
fi
|
||||
|
||||
BATMAN_SCRIPT=$rootdir/var/lib/batman
|
||||
|
||||
if [ -f /usr/local/bin/${PROJECT_NAME}-mesh-batman ]; then
|
||||
cp /usr/local/bin/${PROJECT_NAME}-mesh-batman $BATMAN_SCRIPT
|
||||
cp /usr/local/bin/${PROJECT_NAME}-mesh-batman $BATMAN_SCRIPT
|
||||
else
|
||||
cp /usr/bin/${PROJECT_NAME}-mesh-batman $BATMAN_SCRIPT
|
||||
cp /usr/bin/${PROJECT_NAME}-mesh-batman $BATMAN_SCRIPT
|
||||
fi
|
||||
|
||||
BATMAN_DAEMON=$rootdir/etc/systemd/system/batman.service
|
||||
|
@ -271,29 +271,29 @@ do
|
|||
key="$1"
|
||||
|
||||
case $key in
|
||||
-h|--help)
|
||||
show_help
|
||||
;;
|
||||
-f|--function)
|
||||
shift
|
||||
FN="$1"
|
||||
;;
|
||||
-r|--rootdir)
|
||||
shift
|
||||
rootdir="$1"
|
||||
CHROOT_PREFIX='chroot "${rootdir}"'
|
||||
;;
|
||||
-w|--wifi|--interface)
|
||||
shift
|
||||
WIFI_INTERFACE="$1"
|
||||
;;
|
||||
--remove)
|
||||
shift
|
||||
REMOVE="$1"
|
||||
;;
|
||||
*)
|
||||
# unknown option
|
||||
;;
|
||||
-h|--help)
|
||||
show_help
|
||||
;;
|
||||
-f|--function)
|
||||
shift
|
||||
FN="$1"
|
||||
;;
|
||||
-r|--rootdir)
|
||||
shift
|
||||
rootdir="$1"
|
||||
CHROOT_PREFIX='chroot "${rootdir}"'
|
||||
;;
|
||||
-w|--wifi|--interface)
|
||||
shift
|
||||
WIFI_INTERFACE="$1"
|
||||
;;
|
||||
--remove)
|
||||
shift
|
||||
REMOVE="$1"
|
||||
;;
|
||||
*)
|
||||
# unknown option
|
||||
;;
|
||||
|
||||
esac
|
||||
shift
|
||||
|
@ -307,9 +307,9 @@ if [[ $FN == 'firewall' ]]; then
|
|||
fi
|
||||
if [[ $FN == 'batman' ]]; then
|
||||
if [[ $REMOVE != 'yes' ]]; then
|
||||
install_batman
|
||||
install_batman
|
||||
else
|
||||
install_batman_remove
|
||||
install_batman_remove
|
||||
fi
|
||||
fi
|
||||
if [[ $FN == 'qtox' ]]; then
|
||||
|
|
Loading…
Reference in New Issue