diff --git a/src/freedombone-mesh-install b/src/freedombone-mesh-install
index 9da7bdf4..a7ce0e85 100755
--- a/src/freedombone-mesh-install
+++ b/src/freedombone-mesh-install
@@ -76,990 +76,988 @@ ZERONET_PORT=
INSTALL_DIR=$HOME/build
function show_help {
- echo ''
- echo $"${PROJECT_NAME}-mesh-install -f [function] -r [rootdir]"
- echo ''
- echo $'Runs a mesh network install function'
- echo ''
- echo $' -h --help Show help'
- echo $' -f --function [name] Name of the function to be run'
- echo $' -r --rootdir [directory] Root directory'
- echo $' -w --wifi [interface] e.g. wlan0'
- echo ''
- exit 0
+ echo ''
+ echo $"${PROJECT_NAME}-mesh-install -f [function] -r [rootdir]"
+ echo ''
+ echo $'Runs a mesh network install function'
+ echo ''
+ echo $' -h --help Show help'
+ echo $' -f --function [name] Name of the function to be run'
+ echo $' -r --rootdir [directory] Root directory'
+ echo $' -w --wifi [interface] e.g. wlan0'
+ echo ''
+ exit 0
}
function git_clone {
- repo_url="$1"
- destination_dir="$2"
- if [[ "$repo_url" == "ssh:"* ]]; then
- if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
- if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
- if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
- if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
- sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone "$repo_url" "$destination_dir"
- return
- fi
- fi
- fi
- fi
- fi
- git clone "$repo_url" "$destination_dir"
+ repo_url="$1"
+ destination_dir="$2"
+ if [[ "$repo_url" == "ssh:"* ]]; then
+ if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
+ if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
+ if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
+ if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
+ sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone "$repo_url" "$destination_dir"
+ return
+ fi
+ fi
+ fi
+ fi
+ fi
+ git clone "$repo_url" "$destination_dir"
}
function mesh_babel {
- $CHROOT_PREFIX apt-get -y install babeld
+ $CHROOT_PREFIX apt-get -y install babeld
- babel_script=${rootdir}/var/lib/babel
+ babel_script=${rootdir}/var/lib/babel
- echo '#!/bin/bash' > $babel_script
- echo '' >> $babel_script
- echo 'if [[ $1 == "ls" || $1 == "list" ]]; then' >> $babel_script
- echo ' avahi-browse -atl' >> $babel_script
- echo ' exit 0' >> $babel_script
- echo 'fi' >> $babel_script
- echo '' >> $babel_script
- echo 'if [[ $1 == "start" ]]; then' >> $babel_script
- echo ' sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
- echo ' sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
- echo ' sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
- echo ' sed -i "s|use-ipv6=.*|use-ipv6=no|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
- echo ' sed -i "s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf' >> $babel_script
- echo ' systemctl restart avahi-daemon' >> $babel_script
- echo 'fi' >> $babel_script
- echo '' >> $babel_script
- echo "IFACE=$WIFI_INTERFACE" >> $babel_script
- echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
- echo ' if grep -q "wlan1" /proc/net/dev; then' >> $babel_script
- echo ' IFACE=wlan1' >> $babel_script
- echo ' fi' >> $babel_script
- echo 'fi' >> $babel_script
- echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
- echo ' if grep -q "wlan2" /proc/net/dev; then' >> $babel_script
- echo ' IFACE=wlan2' >> $babel_script
- echo ' fi' >> $babel_script
- echo 'fi' >> $babel_script
- echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
- echo ' if grep -q "wlan3" /proc/net/dev; then' >> $babel_script
- echo ' IFACE=wlan3' >> $babel_script
- echo ' fi' >> $babel_script
- echo 'fi' >> $babel_script
- echo '' >> $babel_script
- echo 'if [[ ! grep -q "$IFACE" /proc/net/dev || $1 == "stop" ]]; then' >> $babel_script
- echo ' if ! grep -q "$IFACE" /proc/net/dev; then' >> $babel_script
- echo ' echo "Interface $IFACE was not found"' >> $babel_script
- echo ' else' >> $babel_script
- echo ' echo "Stopping"' >> $babel_script
- echo ' fi' >> $babel_script
- echo ' ifconfig $IFACE down' >> $babel_script
- echo ' pkill babeld' >> $babel_script
- echo ' systemctl restart network-manager' >> $babel_script
- echo ' exit 1' >> $babel_script
- echo 'fi' >> $babel_script
- echo '' >> $babel_script
- echo 'systemctl stop network-manager' >> $babel_script
- echo 'ifconfig $IFACE down' >> $babel_script
- echo -n 'iwconfig $IFACE mode ad-hoc channel ' >> $babel_script
- echo "$WIFI_CHANNEL essid \"$WIFI_SSID\"" >> $babel_script
- echo 'ifconfig $IFACE up' >> $babel_script
- echo -n 'ifconfig $IFACE:avahi ' >> $babel_script
- echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script
- echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script
- echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script
- echo -n "$BABEL_PORT -d 5 " >> $babel_script
- echo '$IFACE' >> $babel_script
- echo 'exit 0' >> $babel_script
- chmod +x $babel_script
+ echo '#!/bin/bash' > $babel_script
+ echo '' >> $babel_script
+ echo 'if [[ $1 == "ls" || $1 == "list" ]]; then' >> $babel_script
+ echo ' avahi-browse -atl' >> $babel_script
+ echo ' exit 0' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo '' >> $babel_script
+ echo 'if [[ $1 == "start" ]]; then' >> $babel_script
+ echo ' sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
+ echo ' sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
+ echo ' sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
+ echo ' sed -i "s|use-ipv6=.*|use-ipv6=no|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
+ echo ' sed -i "s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf' >> $babel_script
+ echo ' systemctl restart avahi-daemon' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo '' >> $babel_script
+ echo "IFACE=$WIFI_INTERFACE" >> $babel_script
+ echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
+ echo ' if grep -q "wlan1" /proc/net/dev; then' >> $babel_script
+ echo ' IFACE=wlan1' >> $babel_script
+ echo ' fi' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
+ echo ' if grep -q "wlan2" /proc/net/dev; then' >> $babel_script
+ echo ' IFACE=wlan2' >> $babel_script
+ echo ' fi' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
+ echo ' if grep -q "wlan3" /proc/net/dev; then' >> $babel_script
+ echo ' IFACE=wlan3' >> $babel_script
+ echo ' fi' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo '' >> $babel_script
+ echo 'if [[ ! grep -q "$IFACE" /proc/net/dev || $1 == "stop" ]]; then' >> $babel_script
+ echo ' if ! grep -q "$IFACE" /proc/net/dev; then' >> $babel_script
+ echo ' echo "Interface $IFACE was not found"' >> $babel_script
+ echo ' else' >> $babel_script
+ echo ' echo "Stopping"' >> $babel_script
+ echo ' fi' >> $babel_script
+ echo ' ifconfig $IFACE down' >> $babel_script
+ echo ' pkill babeld' >> $babel_script
+ echo ' systemctl restart network-manager' >> $babel_script
+ echo ' exit 1' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo '' >> $babel_script
+ echo 'systemctl stop network-manager' >> $babel_script
+ echo 'ifconfig $IFACE down' >> $babel_script
+ echo -n 'iwconfig $IFACE mode ad-hoc channel ' >> $babel_script
+ echo "$WIFI_CHANNEL essid \"$WIFI_SSID\"" >> $babel_script
+ echo 'ifconfig $IFACE up' >> $babel_script
+ echo -n 'ifconfig $IFACE:avahi ' >> $babel_script
+ echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script
+ echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script
+ echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script
+ echo -n "$BABEL_PORT -d 5 " >> $babel_script
+ echo '$IFACE' >> $babel_script
+ echo 'exit 0' >> $babel_script
+ chmod +x $babel_script
- echo '[Unit]' > ${rootdir}/etc/systemd/system/babel.service
- echo 'Description=Babel Mesh' >> ${rootdir}/etc/systemd/system/babel.service
- echo '' >> ${rootdir}/etc/systemd/system/babel.service
- echo '[Service]' >> ${rootdir}/etc/systemd/system/babel.service
- echo 'Type=oneshot' >> ${rootdir}/etc/systemd/system/babel.service
- echo "ExecStart=$babel_script start" >> ${rootdir}/etc/systemd/system/babel.service
- echo "ExecStop=$babel_script stop" >> ${rootdir}/etc/systemd/system/babel.service
- echo 'RemainAfterExit=yes' >> ${rootdir}/etc/systemd/system/babel.service
- echo '' >> ${rootdir}/etc/systemd/system/babel.service
- echo '# Allow time for the server to start/stop' >> ${rootdir}/etc/systemd/system/babel.service
- echo 'TimeoutSec=300' >> ${rootdir}/etc/systemd/system/babel.service
- echo '' >> ${rootdir}/etc/systemd/system/babel.service
- echo '[Install]' >> /etc/systemd/system/babel.service
- echo 'WantedBy=multi-user.target' >> ${rootdir}/etc/systemd/system/babel.service
- $CHROOT_PREFIX systemctl enable babel
+ echo '[Unit]' > ${rootdir}/etc/systemd/system/babel.service
+ echo 'Description=Babel Mesh' >> ${rootdir}/etc/systemd/system/babel.service
+ echo '' >> ${rootdir}/etc/systemd/system/babel.service
+ echo '[Service]' >> ${rootdir}/etc/systemd/system/babel.service
+ echo 'Type=oneshot' >> ${rootdir}/etc/systemd/system/babel.service
+ echo "ExecStart=$babel_script start" >> ${rootdir}/etc/systemd/system/babel.service
+ echo "ExecStop=$babel_script stop" >> ${rootdir}/etc/systemd/system/babel.service
+ echo 'RemainAfterExit=yes' >> ${rootdir}/etc/systemd/system/babel.service
+ echo '' >> ${rootdir}/etc/systemd/system/babel.service
+ echo '# Allow time for the server to start/stop' >> ${rootdir}/etc/systemd/system/babel.service
+ echo 'TimeoutSec=300' >> ${rootdir}/etc/systemd/system/babel.service
+ echo '' >> ${rootdir}/etc/systemd/system/babel.service
+ echo '[Install]' >> /etc/systemd/system/babel.service
+ echo 'WantedBy=multi-user.target' >> ${rootdir}/etc/systemd/system/babel.service
+ $CHROOT_PREFIX systemctl enable babel
}
function mesh_avahi {
- $CHROOT_PREFIX apt-get -y install avahi-utils avahi-autoipd avahi-dnsconfd
+ $CHROOT_PREFIX apt-get -y install avahi-utils avahi-autoipd avahi-dnsconfd
- decarray=( 1 2 3 4 5 6 7 8 9 0 )
- PEER_ID=${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}
- sed -i "s|#host-name=.*|host-name=P$PEER_ID|g" $rootdir/etc/avahi/avahi-daemon.conf
+ decarray=( 1 2 3 4 5 6 7 8 9 0 )
+ PEER_ID=${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}
+ 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
- fi
+ if [ ! -d $rootdir/etc/avahi/services ]; then
+ 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
- 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
+ fi
- # Add an ssh service
- echo '' > $rootdir/etc/avahi/services/ssh.service
- echo '' >> $rootdir/etc/avahi/services/ssh.service
- echo '' >> $rootdir/etc/avahi/services/ssh.service
- echo ' %h SSH' >> $rootdir/etc/avahi/services/ssh.service
- echo ' ' >> $rootdir/etc/avahi/services/ssh.service
- echo ' _ssh._tcp' >> $rootdir/etc/avahi/services/ssh.service
- echo " $SSH_PORT" >> $rootdir/etc/avahi/services/ssh.service
- echo ' ' >> $rootdir/etc/avahi/services/ssh.service
- echo '' >> $rootdir/etc/avahi/services/ssh.service
+ # Add an ssh service
+ echo '' > $rootdir/etc/avahi/services/ssh.service
+ echo '' >> $rootdir/etc/avahi/services/ssh.service
+ echo '' >> $rootdir/etc/avahi/services/ssh.service
+ echo ' %h SSH' >> $rootdir/etc/avahi/services/ssh.service
+ echo ' ' >> $rootdir/etc/avahi/services/ssh.service
+ echo ' _ssh._tcp' >> $rootdir/etc/avahi/services/ssh.service
+ echo " $SSH_PORT" >> $rootdir/etc/avahi/services/ssh.service
+ echo ' ' >> $rootdir/etc/avahi/services/ssh.service
+ echo '' >> $rootdir/etc/avahi/services/ssh.service
- # keep the daemon running
- WATCHDOG_SCRIPT_NAME="keepon"
- echo '' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
- echo '# keep avahi daemon running' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
- echo 'AVAHI_RUNNING=$(pgrep avahi-daemon > /dev/null && echo Running)' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
- echo 'if [ ! $AVAHI_RUNNING ]; then' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
- echo ' systemctl start avahi-daemon' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
- echo ' echo -n $CURRENT_DATE >> $LOGFILE' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
- echo ' echo " Avahi daemon restarted" >> $LOGFILE' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
- echo 'fi' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
- chmod +x $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
+ # keep the daemon running
+ WATCHDOG_SCRIPT_NAME="keepon"
+ echo '' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
+ echo '# keep avahi daemon running' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
+ echo 'AVAHI_RUNNING=$(pgrep avahi-daemon > /dev/null && echo Running)' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
+ echo 'if [ ! $AVAHI_RUNNING ]; then' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
+ echo ' systemctl start avahi-daemon' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
+ echo ' echo -n $CURRENT_DATE >> $LOGFILE' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
+ echo ' echo " Avahi daemon restarted" >> $LOGFILE' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
+ echo 'fi' >> $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
+ chmod +x $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
}
function mesh_babel_client {
- # TODO to be fixed
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
- else
- TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
- fi
+ # TODO to be fixed
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
+ else
+ TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
+ fi
- if [ ! -f ${rootdir}/tmp/meshtype ]; then
- $CHROOT_PREFIX sudo apt-get -y install babeld
- $CHROOT_PREFIX sudo apt-get -y install irssi mumble
- if [ ! -f $TOXIC_FILE ]; then
- $CHROOT_PREFIX sudo apt-get -y install toxic
- echo "n
+ if [ ! -f ${rootdir}/tmp/meshtype ]; then
+ $CHROOT_PREFIX sudo apt-get -y install babeld
+ if [ ! -f $TOXIC_FILE ]; then
+ $CHROOT_PREFIX sudo apt-get -y install toxic
+ echo "n
/nick $USER
/exit
-" | ${rootdir}$TOXIC_FILE -d
- fi
+" | toxic -d
+ fi
- CURR_DIR=$(pwd)
- if [ ! -f ~/develop/toxid ]; then
- if [ ! -f ~/develop ]; then
- mkdir ~/develop
- fi
- cd ~/develop
- git_clone $TOXID_REPO ~/develop/toxid
- fi
- cd ~/develop/toxid
- sudo make install
- cd $CURR_DIR
- fi
+ CURR_DIR=$(pwd)
+ if [ ! -f ~/develop/toxid ]; then
+ if [ ! -f ~/develop ]; then
+ mkdir ~/develop
+ fi
+ cd ~/develop
+ git_clone $TOXID_REPO ~/develop/toxid
+ fi
+ cd ~/develop/toxid
+ sudo make install
+ cd $CURR_DIR
+ fi
- babel_script=${rootdir}/tmp/babel
+ babel_script=${rootdir}/tmp/babel
- echo '#!/bin/bash' > $babel_script
- echo '' >> $babel_script
- echo 'if [[ $1 == "ls" || $1 == "list" ]]; then' >> $babel_script
- echo ' avahi-browse -atl' >> $babel_script
- echo ' exit 0' >> $babel_script
- echo 'fi' >> $babel_script
- echo '' >> $babel_script
- echo 'if [[ $1 == "start" ]]; then' >> $babel_script
- echo ' if [ -f /tmp/meshtype ] ; then' >> $babel_script
- echo ' echo "Mesh already running"' >> $babel_script
- echo ' return' >> $babel_script
- echo ' fi' >> $batman_script
- echo ' # install avahi' >> $babel_script
- echo ' apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd bittornado' >> $babel_script
- echo ' sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
- echo ' sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
- echo ' if [ -f /bin/systemctl ]; then' >> $babel_script
- echo ' systemctl restart avahi-daemon' >> $babel_script
- echo ' else' >> $babel_script
- echo ' service avahi-daemon restart' >> $babel_script
- echo ' fi' >> $babel_script
- echo ' echo "babel" > /tmp/meshtype' >> $babel_script
- echo 'fi' >> $babel_script
- echo '' >> $babel_script
- echo "IFACE=$WIFI_INTERFACE" >> $babel_script
- echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
- echo ' if grep -q "wlan1" /proc/net/dev; then' >> $babel_script
- echo ' IFACE=wlan1' >> $babel_script
- echo ' fi' >> $babel_script
- echo 'fi' >> $babel_script
- echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
- echo ' if grep -q "wlan2" /proc/net/dev; then' >> $babel_script
- echo ' IFACE=wlan2' >> $babel_script
- echo ' fi' >> $babel_script
- echo 'fi' >> $babel_script
- echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
- echo ' if grep -q "wlan3" /proc/net/dev; then' >> $babel_script
- echo ' IFACE=wlan3' >> $babel_script
- echo ' fi' >> $babel_script
- echo 'fi' >> $babel_script
- echo '' >> $babel_script
- echo 'if [[ ! grep -q "$IFACE" /proc/net/dev || $1 == "stop" ]]; then' >> $babel_script
- echo ' if ! grep -q "$IFACE" /proc/net/dev; then' >> $babel_script
- echo ' echo "Interface $IFACE was not found"' >> $babel_script
- echo ' else' >> $babel_script
- echo ' echo "Stopping"' >> $babel_script
- echo ' fi' >> $babel_script
- echo ' ifconfig $IFACE down' >> $babel_script
- echo ' pkill babeld' >> $babel_script
- echo ' if [ -f /bin/systemctl ]; then' >> $babel_script
- echo ' systemctl restart network-manager' >> $babel_script
- echo ' else' >> $babel_script
- echo ' service network-manager restart' >> $babel_script
- echo ' fi' >> $babel_script
- echo ' exit 1' >> $babel_script
- echo 'fi' >> $babel_script
- echo '' >> $babel_script
- echo 'if [ -f /bin/systemctl ]; then' >> $babel_script
- echo ' systemctl stop network-manager' >> $babel_script
- echo 'else' >> $babel_script
- echo ' service network-manager stop' >> $babel_script
- echo 'fi' >> $babel_script
- echo 'ifconfig $IFACE down' >> $babel_script
- echo -n 'iwconfig $IFACE mode ad-hoc channel ' >> $babel_script
- echo "$WIFI_CHANNEL essid \"$WIFI_SSID\"" >> $babel_script
- echo 'ifconfig $IFACE up' >> $babel_script
- echo -n 'ifconfig $IFACE:avahi ' >> $babel_script
- echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script
- echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script
- echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script
- echo -n "$BABEL_PORT -d 5 " >> $babel_script
- echo '$IFACE' >> $babel_script
- echo 'exit 0' >> $babel_script
- chmod +x $babel_script
- sudo mv $babel_script ${rootdir}/usr/bin/babel
+ echo '#!/bin/bash' > $babel_script
+ echo '' >> $babel_script
+ echo 'if [[ $1 == "ls" || $1 == "list" ]]; then' >> $babel_script
+ echo ' avahi-browse -atl' >> $babel_script
+ echo ' exit 0' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo '' >> $babel_script
+ echo 'if [[ $1 == "start" ]]; then' >> $babel_script
+ echo ' if [ -f /tmp/meshtype ] ; then' >> $babel_script
+ echo ' echo "Mesh already running"' >> $babel_script
+ echo ' return' >> $babel_script
+ echo ' fi' >> $batman_script
+ echo ' # install avahi' >> $babel_script
+ echo ' apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd bittornado' >> $babel_script
+ echo ' sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
+ echo ' sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
+ echo ' if [ -f /bin/systemctl ]; then' >> $babel_script
+ echo ' systemctl restart avahi-daemon' >> $babel_script
+ echo ' else' >> $babel_script
+ echo ' service avahi-daemon restart' >> $babel_script
+ echo ' fi' >> $babel_script
+ echo ' echo "babel" > /tmp/meshtype' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo '' >> $babel_script
+ echo "IFACE=$WIFI_INTERFACE" >> $babel_script
+ echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
+ echo ' if grep -q "wlan1" /proc/net/dev; then' >> $babel_script
+ echo ' IFACE=wlan1' >> $babel_script
+ echo ' fi' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
+ echo ' if grep -q "wlan2" /proc/net/dev; then' >> $babel_script
+ echo ' IFACE=wlan2' >> $babel_script
+ echo ' fi' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo 'if [[ $IFACE == "wlan0" ]]; then' >> $babel_script
+ echo ' if grep -q "wlan3" /proc/net/dev; then' >> $babel_script
+ echo ' IFACE=wlan3' >> $babel_script
+ echo ' fi' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo '' >> $babel_script
+ echo 'if [[ ! grep -q "$IFACE" /proc/net/dev || $1 == "stop" ]]; then' >> $babel_script
+ echo ' if ! grep -q "$IFACE" /proc/net/dev; then' >> $babel_script
+ echo ' echo "Interface $IFACE was not found"' >> $babel_script
+ echo ' else' >> $babel_script
+ echo ' echo "Stopping"' >> $babel_script
+ echo ' fi' >> $babel_script
+ echo ' ifconfig $IFACE down' >> $babel_script
+ echo ' pkill babeld' >> $babel_script
+ echo ' if [ -f /bin/systemctl ]; then' >> $babel_script
+ echo ' systemctl restart network-manager' >> $babel_script
+ echo ' else' >> $babel_script
+ echo ' service network-manager restart' >> $babel_script
+ echo ' fi' >> $babel_script
+ echo ' exit 1' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo '' >> $babel_script
+ echo 'if [ -f /bin/systemctl ]; then' >> $babel_script
+ echo ' systemctl stop network-manager' >> $babel_script
+ echo 'else' >> $babel_script
+ echo ' service network-manager stop' >> $babel_script
+ echo 'fi' >> $babel_script
+ echo 'ifconfig $IFACE down' >> $babel_script
+ echo -n 'iwconfig $IFACE mode ad-hoc channel ' >> $babel_script
+ echo "$WIFI_CHANNEL essid \"$WIFI_SSID\"" >> $babel_script
+ echo 'ifconfig $IFACE up' >> $babel_script
+ echo -n 'ifconfig $IFACE:avahi ' >> $babel_script
+ echo -n "$LOCAL_NETWORK_STATIC_IP_ADDRESS netmask " >> $babel_script
+ echo '255.255.255.0 broadcast 192.168.13.255' >> $babel_script
+ echo -n 'babeld -D $IFACE:avahi -p ' >> $babel_script
+ echo -n "$BABEL_PORT -d 5 " >> $babel_script
+ echo '$IFACE' >> $babel_script
+ echo 'exit 0' >> $babel_script
+ chmod +x $babel_script
+ sudo mv $babel_script ${rootdir}/usr/bin/babel
}
function mesh_batman {
- $CHROOT_PREFIX apt-get -y install iproute bridge-utils libnetfilter-conntrack3 batctl
- $CHROOT_PREFIX apt-get -y install python-dev libevent-dev ebtables python-pip git
- $CHROOT_PREFIX apt-get -y install wireless-tools rfkill
+ $CHROOT_PREFIX apt-get -y install iproute bridge-utils libnetfilter-conntrack3 batctl
+ $CHROOT_PREFIX apt-get -y install python-dev libevent-dev ebtables python-pip git
+ $CHROOT_PREFIX apt-get -y install wireless-tools rfkill
- if ! grep -q "batman_adv" $rootdir/etc/modules; then
- echo 'batman_adv' >> $rootdir/etc/modules
- fi
+ if ! grep -q "batman_adv" $rootdir/etc/modules; then
+ echo 'batman_adv' >> $rootdir/etc/modules
+ fi
- BATMAN_SCRIPT=$rootdir/var/lib/batman
+ 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
- else
- cp /usr/bin/${PROJECT_NAME}-mesh-batman $BATMAN_SCRIPT
- fi
+ if [ -f /usr/local/bin/${PROJECT_NAME}-mesh-batman ]; then
+ cp /usr/local/bin/${PROJECT_NAME}-mesh-batman $BATMAN_SCRIPT
+ else
+ cp /usr/bin/${PROJECT_NAME}-mesh-batman $BATMAN_SCRIPT
+ fi
- BATMAN_DAEMON=$rootdir/etc/systemd/system/batman.service
- echo '[Unit]' > $BATMAN_DAEMON
- echo 'Description=B.A.T.M.A.N. Advanced' >> $BATMAN_DAEMON
- echo '' >> $BATMAN_DAEMON
- echo '[Service]' >> $BATMAN_DAEMON
- echo 'Type=oneshot' >> $BATMAN_DAEMON
- echo "ExecStart=/var/lib/batman start" >> $BATMAN_DAEMON
- echo "ExecStop=/var/lib/batman stop" >> $BATMAN_DAEMON
- echo 'RemainAfterExit=yes' >> $BATMAN_DAEMON
- echo '' >> $BATMAN_DAEMON
- echo '# Allow time for the server to start/stop' >> $BATMAN_DAEMON
- echo 'TimeoutSec=300' >> $BATMAN_DAEMON
- echo '' >> $BATMAN_DAEMON
- echo '[Install]' >> $BATMAN_DAEMON
- echo 'WantedBy=multi-user.target' >> $BATMAN_DAEMON
- $CHROOT_PREFIX systemctl enable batman
+ BATMAN_DAEMON=$rootdir/etc/systemd/system/batman.service
+ echo '[Unit]' > $BATMAN_DAEMON
+ echo 'Description=B.A.T.M.A.N. Advanced' >> $BATMAN_DAEMON
+ echo '' >> $BATMAN_DAEMON
+ echo '[Service]' >> $BATMAN_DAEMON
+ echo 'Type=oneshot' >> $BATMAN_DAEMON
+ echo "ExecStart=/var/lib/batman start" >> $BATMAN_DAEMON
+ echo "ExecStop=/var/lib/batman stop" >> $BATMAN_DAEMON
+ echo 'RemainAfterExit=yes' >> $BATMAN_DAEMON
+ echo '' >> $BATMAN_DAEMON
+ echo '# Allow time for the server to start/stop' >> $BATMAN_DAEMON
+ echo 'TimeoutSec=300' >> $BATMAN_DAEMON
+ echo '' >> $BATMAN_DAEMON
+ echo '[Install]' >> $BATMAN_DAEMON
+ echo 'WantedBy=multi-user.target' >> $BATMAN_DAEMON
+ $CHROOT_PREFIX systemctl enable batman
}
function mesh_firewall {
- FIREWALL_FILENAME=${rootdir}/etc/systemd/system/meshfirewall.service
- MESH_FIREWALL_SCRIPT=${rootdir}/usr/bin/mesh-firewall
+ FIREWALL_FILENAME=${rootdir}/etc/systemd/system/meshfirewall.service
+ MESH_FIREWALL_SCRIPT=${rootdir}/usr/bin/mesh-firewall
- echo '#!/bin/bash' > $MESH_FIREWALL_SCRIPT
- echo 'iptables -P INPUT ACCEPT' >> $MESH_FIREWALL_SCRIPT
- echo 'ip6tables -P INPUT ACCEPT' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -F' >> $MESH_FIREWALL_SCRIPT
- echo 'ip6tables -F' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -t nat -F' >> $MESH_FIREWALL_SCRIPT
- echo 'ip6tables -t nat -F' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -X' >> $MESH_FIREWALL_SCRIPT
- echo 'ip6tables -X' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -P INPUT DROP' >> $MESH_FIREWALL_SCRIPT
- echo 'ip6tables -P INPUT DROP' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -A INPUT -i lo -j ACCEPT' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT' >> $MESH_FIREWALL_SCRIPT
- echo '' >> $MESH_FIREWALL_SCRIPT
- echo '# Make sure incoming tcp connections are SYN packets' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP' >> $MESH_FIREWALL_SCRIPT
- echo '' >> $MESH_FIREWALL_SCRIPT
- echo '# Drop packets with incoming fragments' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -A INPUT -f -j DROP' >> $MESH_FIREWALL_SCRIPT
- echo '' >> $MESH_FIREWALL_SCRIPT
- echo '# Drop bogons' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP' >> $MESH_FIREWALL_SCRIPT
- echo '' >> $MESH_FIREWALL_SCRIPT
- echo '# Incoming malformed NULL packets:' >> $MESH_FIREWALL_SCRIPT
- echo 'iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP' >> $MESH_FIREWALL_SCRIPT
- echo '' >> $MESH_FIREWALL_SCRIPT
- echo "iptables -A INPUT -p tcp --dport $TOX_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
- echo "iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $ZERONET_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
- echo "iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
- echo "iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $TRACKER_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
- echo "iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
- echo "iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport 1900 -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
- chmod +x $MESH_FIREWALL_SCRIPT
+ echo '#!/bin/bash' > $MESH_FIREWALL_SCRIPT
+ echo 'iptables -P INPUT ACCEPT' >> $MESH_FIREWALL_SCRIPT
+ echo 'ip6tables -P INPUT ACCEPT' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -F' >> $MESH_FIREWALL_SCRIPT
+ echo 'ip6tables -F' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -t nat -F' >> $MESH_FIREWALL_SCRIPT
+ echo 'ip6tables -t nat -F' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -X' >> $MESH_FIREWALL_SCRIPT
+ echo 'ip6tables -X' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -P INPUT DROP' >> $MESH_FIREWALL_SCRIPT
+ echo 'ip6tables -P INPUT DROP' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -A INPUT -i lo -j ACCEPT' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT' >> $MESH_FIREWALL_SCRIPT
+ echo '' >> $MESH_FIREWALL_SCRIPT
+ echo '# Make sure incoming tcp connections are SYN packets' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP' >> $MESH_FIREWALL_SCRIPT
+ echo '' >> $MESH_FIREWALL_SCRIPT
+ echo '# Drop packets with incoming fragments' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -A INPUT -f -j DROP' >> $MESH_FIREWALL_SCRIPT
+ echo '' >> $MESH_FIREWALL_SCRIPT
+ echo '# Drop bogons' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP' >> $MESH_FIREWALL_SCRIPT
+ echo '' >> $MESH_FIREWALL_SCRIPT
+ echo '# Incoming malformed NULL packets:' >> $MESH_FIREWALL_SCRIPT
+ echo 'iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP' >> $MESH_FIREWALL_SCRIPT
+ echo '' >> $MESH_FIREWALL_SCRIPT
+ echo "iptables -A INPUT -p tcp --dport $TOX_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
+ echo "iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $ZERONET_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
+ echo "iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
+ echo "iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $TRACKER_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
+ echo "iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
+ echo "iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport 1900 -j ACCEPT" >> $MESH_FIREWALL_SCRIPT
+ chmod +x $MESH_FIREWALL_SCRIPT
- echo '[Unit]' > $FIREWALL_FILENAME
- echo 'Description=Mesh Firewall' >> $FIREWALL_FILENAME
- echo '' >> $FIREWALL_FILENAME
- echo '[Service]' >> $FIREWALL_FILENAME
- echo 'Type=oneshot' >> $FIREWALL_FILENAME
- echo 'ExecStart=/usr/bin/mesh-firewall' >> $FIREWALL_FILENAME
- echo 'RemainAfterExit=no' >> $FIREWALL_FILENAME
- echo '' >> $FIREWALL_FILENAME
- echo 'TimeoutSec=30' >> $FIREWALL_FILENAME
- echo '' >> $FIREWALL_FILENAME
- echo '[Install]' >> $FIREWALL_FILENAME
- echo 'WantedBy=multi-user.target' >> $FIREWALL_FILENAME
- $CHROOT_PREFIX systemctl enable meshfirewall
+ echo '[Unit]' > $FIREWALL_FILENAME
+ echo 'Description=Mesh Firewall' >> $FIREWALL_FILENAME
+ echo '' >> $FIREWALL_FILENAME
+ echo '[Service]' >> $FIREWALL_FILENAME
+ echo 'Type=oneshot' >> $FIREWALL_FILENAME
+ echo 'ExecStart=/usr/bin/mesh-firewall' >> $FIREWALL_FILENAME
+ echo 'RemainAfterExit=no' >> $FIREWALL_FILENAME
+ echo '' >> $FIREWALL_FILENAME
+ echo 'TimeoutSec=30' >> $FIREWALL_FILENAME
+ echo '' >> $FIREWALL_FILENAME
+ echo '[Install]' >> $FIREWALL_FILENAME
+ echo 'WantedBy=multi-user.target' >> $FIREWALL_FILENAME
+ $CHROOT_PREFIX systemctl enable meshfirewall
}
function mesh_tox_node {
- # obtain commits from the main file
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- TOXCORE_COMMIT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
- else
- TOXCORE_COMMIT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
- fi
- if [ ${#TOXCORE_COMMIT_MAIN} -gt 10 ]; then
- TOXCORE_COMMIT=$TOXCORE_COMMIT_MAIN
- fi
- if [ ! $TOXCORE_COMMIT ]; then
- echo $'No Tox commit was specified'
- exit 76325
- fi
+ # obtain commits from the main file
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ TOXCORE_COMMIT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
+ else
+ TOXCORE_COMMIT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
+ fi
+ if [ ${#TOXCORE_COMMIT_MAIN} -gt 10 ]; then
+ TOXCORE_COMMIT=$TOXCORE_COMMIT_MAIN
+ fi
+ if [ ! $TOXCORE_COMMIT ]; then
+ echo $'No Tox commit was specified'
+ exit 76325
+ fi
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- TOXID_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXID_REPO=" | head -n 1 | awk -F '"' '{print $2}')
- else
- TOXID_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXID_REPO=" | head -n 1 | awk -F '"' '{print $2}')
- fi
- if [ ${#TOXID_REPO_MAIN} -gt 5 ]; then
- TOXID_REPO=$TOXID_REPO_MAIN
- fi
- if [ ! $TOXID_REPO ]; then
- echo $'No ToxID repo was specified'
- exit 78252
- fi
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ TOXID_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXID_REPO=" | head -n 1 | awk -F '"' '{print $2}')
+ else
+ TOXID_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXID_REPO=" | head -n 1 | awk -F '"' '{print $2}')
+ fi
+ if [ ${#TOXID_REPO_MAIN} -gt 5 ]; then
+ TOXID_REPO=$TOXID_REPO_MAIN
+ fi
+ if [ ! $TOXID_REPO ]; then
+ echo $'No ToxID repo was specified'
+ exit 78252
+ fi
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- TOX_PORT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOX_PORT=" | head -n 1 | awk -F '=' '{print $2}')
- else
- TOX_PORT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOX_PORT=" | head -n 1 | awk -F '=' '{print $2}')
- fi
- if [ ${#TOX_PORT_MAIN} -gt 2 ]; then
- TOX_PORT=$TOX_PORT_MAIN
- fi
- if [ ! $TOX_PORT ]; then
- echo $'No Tox port was specified'
- exit 32856
- fi
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ TOX_PORT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOX_PORT=" | head -n 1 | awk -F '=' '{print $2}')
+ else
+ TOX_PORT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOX_PORT=" | head -n 1 | awk -F '=' '{print $2}')
+ fi
+ if [ ${#TOX_PORT_MAIN} -gt 2 ]; then
+ TOX_PORT=$TOX_PORT_MAIN
+ fi
+ if [ ! $TOX_PORT ]; then
+ echo $'No Tox port was specified'
+ exit 32856
+ fi
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- TOXCORE_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXCORE_REPO=" | head -n 1 | awk -F '"' '{print $2}')
- else
- TOXCORE_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXCORE_REPO=" | head -n 1 | awk -F '"' '{print $2}')
- fi
- if [ ${#TOXCORE_REPO_MAIN} -gt 10 ]; then
- TOXCORE_REPO=$TOXCORE_REPO_MAIN
- fi
- if [ ! $TOXCORE_REPO ]; then
- echo $'No Tox repo was specified'
- exit 16865
- fi
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ TOXCORE_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXCORE_REPO=" | head -n 1 | awk -F '"' '{print $2}')
+ else
+ TOXCORE_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXCORE_REPO=" | head -n 1 | awk -F '"' '{print $2}')
+ fi
+ if [ ${#TOXCORE_REPO_MAIN} -gt 10 ]; then
+ TOXCORE_REPO=$TOXCORE_REPO_MAIN
+ fi
+ if [ ! $TOXCORE_REPO ]; then
+ echo $'No Tox repo was specified'
+ exit 16865
+ fi
- $CHROOT_PREFIX apt-get -y install build-essential libtool autotools-dev
- $CHROOT_PREFIX apt-get -y install automake checkinstall check git yasm
- $CHROOT_PREFIX apt-get -y install libsodium13 libsodium-dev libcap2-bin
- $CHROOT_PREFIX apt-get -y install libconfig9 libconfig-dev
+ $CHROOT_PREFIX apt-get -y install build-essential libtool autotools-dev
+ $CHROOT_PREFIX apt-get -y install automake checkinstall check git yasm
+ $CHROOT_PREFIX apt-get -y install libsodium13 libsodium-dev libcap2-bin
+ $CHROOT_PREFIX apt-get -y install libconfig9 libconfig-dev
- $CHROOT_PREFIX git_clone $TOXCORE_REPO $INSTALL_DIR/toxcore
- $CHROOT_PREFIX cd $INSTALL_DIR/toxcore
- $CHROOT_PREFIX git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT
+ $CHROOT_PREFIX git_clone $TOXCORE_REPO $INSTALL_DIR/toxcore
+ $CHROOT_PREFIX cd $INSTALL_DIR/toxcore
+ $CHROOT_PREFIX git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT
- $CHROOT_PREFIX autoreconf -i
- $CHROOT_PREFIX ./configure --enable-daemon --disable-av
- if [ ! "$?" = "0" ]; then
- return
- fi
- $CHROOT_PREFIX make
- if [ ! "$?" = "0" ]; then
- return
- fi
- $CHROOT_PREFIX make install
- $CHROOT_PREFIX cp /usr/local/lib/libtoxcore* /usr/lib/
+ $CHROOT_PREFIX autoreconf -i
+ $CHROOT_PREFIX ./configure --enable-daemon --disable-av
+ if [ ! "$?" = "0" ]; then
+ return
+ fi
+ $CHROOT_PREFIX make
+ if [ ! "$?" = "0" ]; then
+ return
+ fi
+ $CHROOT_PREFIX make install
+ $CHROOT_PREFIX cp /usr/local/lib/libtoxcore* /usr/lib/
- if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
- echo $"File not found /usr/local/bin/tox-bootstrapd"
- return
- fi
+ if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
+ echo $"File not found /usr/local/bin/tox-bootstrapd"
+ return
+ fi
- $CHROOT_PREFIX useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment $"Account to run Tox's DHT bootstrap daemon" --user-group tox-bootstrapd
- $CHROOT_PREFIX chmod 700 /var/lib/tox-bootstrapd
- if [ ! -f $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf ]; then
- echo $"File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf"
- fi
- # remove Maildir
- if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then
- rm -rf $rootdir/var/lib/tox-bootstrapd/Maildir
- fi
+ $CHROOT_PREFIX useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment $"Account to run Tox's DHT bootstrap daemon" --user-group tox-bootstrapd
+ $CHROOT_PREFIX chmod 700 /var/lib/tox-bootstrapd
+ if [ ! -f $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf ]; then
+ echo $"File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf"
+ fi
+ # remove Maildir
+ if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then
+ rm -rf $rootdir/var/lib/tox-bootstrapd/Maildir
+ fi
- # create configuration file
- TOX_BOOTSTRAP_CONFIG=${rootdir}/etc/tox-bootstrapd.conf
- echo "port = $TOX_PORT" > $TOX_BOOTSTRAP_CONFIG
- echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"' >> $TOX_BOOTSTRAP_CONFIG
- echo 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"' >> $TOX_BOOTSTRAP_CONFIG
- echo 'enable_ipv6 = true' >> $TOX_BOOTSTRAP_CONFIG
- echo 'enable_ipv4_fallback = true' >> $TOX_BOOTSTRAP_CONFIG
- echo 'enable_lan_discovery = true' >> $TOX_BOOTSTRAP_CONFIG
- echo 'enable_tcp_relay = true' >> $TOX_BOOTSTRAP_CONFIG
- echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> $TOX_BOOTSTRAP_CONFIG
- echo 'enable_motd = true' >> $TOX_BOOTSTRAP_CONFIG
- echo 'motd = "tox-bootstrapd"' >> $TOX_BOOTSTRAP_CONFIG
+ # create configuration file
+ TOX_BOOTSTRAP_CONFIG=${rootdir}/etc/tox-bootstrapd.conf
+ echo "port = $TOX_PORT" > $TOX_BOOTSTRAP_CONFIG
+ echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"' >> $TOX_BOOTSTRAP_CONFIG
+ echo 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"' >> $TOX_BOOTSTRAP_CONFIG
+ echo 'enable_ipv6 = true' >> $TOX_BOOTSTRAP_CONFIG
+ echo 'enable_ipv4_fallback = true' >> $TOX_BOOTSTRAP_CONFIG
+ echo 'enable_lan_discovery = true' >> $TOX_BOOTSTRAP_CONFIG
+ echo 'enable_tcp_relay = true' >> $TOX_BOOTSTRAP_CONFIG
+ echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> $TOX_BOOTSTRAP_CONFIG
+ echo 'enable_motd = true' >> $TOX_BOOTSTRAP_CONFIG
+ echo 'motd = "tox-bootstrapd"' >> $TOX_BOOTSTRAP_CONFIG
- if [ $TOX_NODES ]; then
- echo 'bootstrap_nodes = (' >> $TOX_BOOTSTRAP_CONFIG
- toxcount=0
- while [ "x${TOX_NODES[toxcount]}" != "x" ]
- do
- toxval_ipv4=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $1}')
- toxval_ipv6=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $2}')
- toxval_port=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $3}')
- toxval_pubkey=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $4}')
- toxval_maintainer=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $5}')
- echo "{ // $toxval_maintainer" >> $TOX_BOOTSTRAP_CONFIG
- if [[ $toxval_ipv6 != 'NONE' ]]; then
- echo " address = \"$toxval_ipv6\"" >> $TOX_BOOTSTRAP_CONFIG
- else
- echo " address = \"$toxval_ipv4\"" >> $TOX_BOOTSTRAP_CONFIG
- fi
- echo " port = $toxval_port" >> $TOX_BOOTSTRAP_CONFIG
- echo " public_key = \"$toxval_pubkey\"" >> $TOX_BOOTSTRAP_CONFIG
- toxcount=$(( $toxcount + 1 ))
- if [ "x${TOX_NODES[toxcount]}" != "x" ]; then
- echo "}," >> $TOX_BOOTSTRAP_CONFIG
- else
- echo "}" >> $TOX_BOOTSTRAP_CONFIG
- fi
- done
- echo ')' >> $TOX_BOOTSTRAP_CONFIG
- fi
+ if [ $TOX_NODES ]; then
+ echo 'bootstrap_nodes = (' >> $TOX_BOOTSTRAP_CONFIG
+ toxcount=0
+ while [ "x${TOX_NODES[toxcount]}" != "x" ]
+ do
+ toxval_ipv4=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $1}')
+ toxval_ipv6=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $2}')
+ toxval_port=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $3}')
+ toxval_pubkey=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $4}')
+ toxval_maintainer=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $5}')
+ echo "{ // $toxval_maintainer" >> $TOX_BOOTSTRAP_CONFIG
+ if [[ $toxval_ipv6 != 'NONE' ]]; then
+ echo " address = \"$toxval_ipv6\"" >> $TOX_BOOTSTRAP_CONFIG
+ else
+ echo " address = \"$toxval_ipv4\"" >> $TOX_BOOTSTRAP_CONFIG
+ fi
+ echo " port = $toxval_port" >> $TOX_BOOTSTRAP_CONFIG
+ echo " public_key = \"$toxval_pubkey\"" >> $TOX_BOOTSTRAP_CONFIG
+ toxcount=$(( $toxcount + 1 ))
+ if [ "x${TOX_NODES[toxcount]}" != "x" ]; then
+ echo "}," >> $TOX_BOOTSTRAP_CONFIG
+ else
+ echo "}" >> $TOX_BOOTSTRAP_CONFIG
+ fi
+ done
+ echo ')' >> $TOX_BOOTSTRAP_CONFIG
+ fi
- if [ ! -f $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service ]; then
- echo $"File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service"
- return
- fi
- cp $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service $rootdir/etc/systemd/system/
- sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
+ if [ ! -f $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service ]; then
+ echo $"File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service"
+ return
+ fi
+ cp $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service $rootdir/etc/systemd/system/
+ sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
- $CHROOT_PREFIX systemctl daemon-reload
- $CHROOT_PREFIX systemctl enable tox-bootstrapd.service
+ $CHROOT_PREFIX systemctl daemon-reload
+ $CHROOT_PREFIX systemctl enable tox-bootstrapd.service
}
function mesh_tox_client {
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
- else
- TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
- fi
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
+ else
+ TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
+ fi
- # obtain commits from the main file
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- TOXIC_COMMIT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
- else
- TOXIC_COMMIT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
- fi
- if [ ${#TOXIC_COMMIT_MAIN} -gt 10 ]; then
- TOXIC_COMMIT=$TOXIC_COMMIT_MAIN
- fi
+ # obtain commits from the main file
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ TOXIC_COMMIT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
+ else
+ TOXIC_COMMIT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
+ fi
+ if [ ${#TOXIC_COMMIT_MAIN} -gt 10 ]; then
+ TOXIC_COMMIT=$TOXIC_COMMIT_MAIN
+ fi
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- TOXIC_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_REPO=" | head -n 1 | awk -F '"' '{print $2}')
- else
- TOXIC_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_REPO=" | head -n 1 | awk -F '"' '{print $2}')
- fi
- if [ ${#TOXIC_REPO_MAIN} -gt 5 ]; then
- TOXIC_REPO=$TOXIC_REPO_MAIN
- fi
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ TOXIC_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_REPO=" | head -n 1 | awk -F '"' '{print $2}')
+ else
+ TOXIC_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_REPO=" | head -n 1 | awk -F '"' '{print $2}')
+ fi
+ if [ ${#TOXIC_REPO_MAIN} -gt 5 ]; then
+ TOXIC_REPO=$TOXIC_REPO_MAIN
+ fi
- $CHROOT_PREFIX apt-get -y install libncursesw5-dev libconfig-dev libqrencode-dev
- $CHROOT_PREFIX apt-get -y install libcurl4-openssl-dev libvpx-dev libopenal-dev
+ $CHROOT_PREFIX apt-get -y install libncursesw5-dev libconfig-dev libqrencode-dev
+ $CHROOT_PREFIX apt-get -y install libcurl4-openssl-dev libvpx-dev libopenal-dev
- $CHROOT_PREFIX git_clone $TOXIC_REPO $INSTALL_DIR/toxic
- $CHROOT_PREFIX cd $INSTALL_DIR/toxic
- $CHROOT_PREFIX git checkout $TOXIC_COMMIT -b $TOXIC_COMMIT
- if ! grep -q "Toxic commit" $rootdir$COMPLETION_FILE; then
- echo "Toxic commit:$TOXIC_COMMIT" >> $rootdir$COMPLETION_FILE
- else
- sed -i "s|Toxic commit.*|Toxic commit:$TOXIC_COMMIT|g" $rootdir$COMPLETION_FILE
- fi
+ $CHROOT_PREFIX git_clone $TOXIC_REPO $INSTALL_DIR/toxic
+ $CHROOT_PREFIX cd $INSTALL_DIR/toxic
+ $CHROOT_PREFIX git checkout $TOXIC_COMMIT -b $TOXIC_COMMIT
+ if ! grep -q "Toxic commit" $rootdir$COMPLETION_FILE; then
+ echo "Toxic commit:$TOXIC_COMMIT" >> $rootdir$COMPLETION_FILE
+ else
+ sed -i "s|Toxic commit.*|Toxic commit:$TOXIC_COMMIT|g" $rootdir$COMPLETION_FILE
+ fi
- $CHROOT_PREFIX make
- if [ ! -f $INSTALL_DIR/toxic/build/toxic ]; then
- exit 74872
- fi
- $CHROOT_PREFIX make install
- if [ ! -f $TOXIC_FILE ]; then
- echo $'Tox client was not installed'
- exit 63278
- fi
+ $CHROOT_PREFIX make
+ if [ ! -f $INSTALL_DIR/toxic/build/toxic ]; then
+ exit 74872
+ fi
+ $CHROOT_PREFIX make install
+ if [ ! -f $TOXIC_FILE ]; then
+ echo $'Tox client was not installed'
+ exit 63278
+ fi
}
function mesh_zeronet {
- # obtain commits from the main file
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- ZERONET_COMMIT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "ZERONET_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
- else
- ZERONET_COMMIT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "ZERONET_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
- fi
- if [ ${#ZERONET_COMMIT_MAIN} -gt 10 ]; then
- ZERONET_COMMIT=$ZERONET_COMMIT_MAIN
- fi
- if [ ! $ZERONET_COMMIT ]; then
- echo $'No Tox commit was specified'
- exit 37046
- fi
+ # obtain commits from the main file
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ ZERONET_COMMIT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "ZERONET_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
+ else
+ ZERONET_COMMIT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "ZERONET_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
+ fi
+ if [ ${#ZERONET_COMMIT_MAIN} -gt 10 ]; then
+ ZERONET_COMMIT=$ZERONET_COMMIT_MAIN
+ fi
+ if [ ! $ZERONET_COMMIT ]; then
+ echo $'No Tox commit was specified'
+ exit 37046
+ fi
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- ZERONET_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "ZERONET_REPO=" | head -n 1 | awk -F '"' '{print $2}')
- else
- ZERONET_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "ZERONET_REPO=" | head -n 1 | awk -F '"' '{print $2}')
- fi
- if [ ${#ZERONET_REPO_MAIN} -gt 5 ]; then
- ZERONET_REPO=$ZERONET_REPO_MAIN
- fi
- if [ ! $ZERONET_REPO ]; then
- echo $'No Tox commit was specified'
- exit 37046
- fi
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ ZERONET_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "ZERONET_REPO=" | head -n 1 | awk -F '"' '{print $2}')
+ else
+ ZERONET_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "ZERONET_REPO=" | head -n 1 | awk -F '"' '{print $2}')
+ fi
+ if [ ${#ZERONET_REPO_MAIN} -gt 5 ]; then
+ ZERONET_REPO=$ZERONET_REPO_MAIN
+ fi
+ if [ ! $ZERONET_REPO ]; then
+ echo $'No Tox commit was specified'
+ exit 37046
+ fi
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- ZERONET_PORT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "ZERONET_PORT=" | head -n 1 | awk -F '=' '{print $2}')
- else
- ZERONET_PORT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "ZERONET_PORT=" | head -n 1 | awk -F '=' '{print $2}')
- fi
- if [ ${#ZERONET_PORT_MAIN} -gt 1 ]; then
- ZERONET_PORT=$ZERONET_PORT_MAIN
- fi
- if [ ! $ZERONET_PORT ]; then
- echo $'No zeronet port was specified'
- exit 67433
- fi
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ ZERONET_PORT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "ZERONET_PORT=" | head -n 1 | awk -F '=' '{print $2}')
+ else
+ ZERONET_PORT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "ZERONET_PORT=" | head -n 1 | awk -F '=' '{print $2}')
+ fi
+ if [ ${#ZERONET_PORT_MAIN} -gt 1 ]; then
+ ZERONET_PORT=$ZERONET_PORT_MAIN
+ fi
+ if [ ! $ZERONET_PORT ]; then
+ echo $'No zeronet port was specified'
+ exit 67433
+ fi
- $CHROOT_PREFIX apt-get -y install python python-msgpack python-gevent
- $CHROOT_PREFIX apt-get -y install python-pip bittornado
- $CHROOT_PREFIX pip install msgpack-python --upgrade
+ $CHROOT_PREFIX apt-get -y install python python-msgpack python-gevent
+ $CHROOT_PREFIX apt-get -y install python-pip bittornado
+ $CHROOT_PREFIX pip install msgpack-python --upgrade
- $CHROOT_PREFIX useradd -d /opt/zeronet/ -s /bin/false zeronet
- git_clone $ZERONET_REPO $rootdir/opt/zeronet
- if [ ! -d $rootdir/opt/zeronet ]; then
- echo 'WARNING: Unable to clone zeronet'
- return
- fi
- cd $rootdir/opt/zeronet
- git checkout $ZERONET_COMMIT -b $ZERONET_COMMIT
- if ! grep -q "ZeroNet commit" $COMPLETION_FILE; then
- echo "ZeroNet commit:$ZERONET_COMMIT" >> $rootdir$COMPLETION_FILE
- else
- sed -i "s/ZeroNet commit.*/ZeroNet commit:$ZERONET_COMMIT/g" $COMPLETION_FILE
- fi
- chown -R zeronet:zeronet $rootdir/opt/zeronet
+ $CHROOT_PREFIX useradd -d /opt/zeronet/ -s /bin/false zeronet
+ git_clone $ZERONET_REPO $rootdir/opt/zeronet
+ if [ ! -d $rootdir/opt/zeronet ]; then
+ echo 'WARNING: Unable to clone zeronet'
+ return
+ fi
+ cd $rootdir/opt/zeronet
+ git checkout $ZERONET_COMMIT -b $ZERONET_COMMIT
+ if ! grep -q "ZeroNet commit" $COMPLETION_FILE; then
+ echo "ZeroNet commit:$ZERONET_COMMIT" >> $rootdir$COMPLETION_FILE
+ else
+ sed -i "s/ZeroNet commit.*/ZeroNet commit:$ZERONET_COMMIT/g" $COMPLETION_FILE
+ fi
+ chown -R zeronet:zeronet $rootdir/opt/zeronet
- # Hack to ensure that the file access port is opened
- # This is because zeronet normally relies on an internet site
- # to do this, but on a purely local mesh the internet isn't available
- sed -i 's|fileserver_port = 0|fileserver_port = config.fileserver_port\n sys.modules["main"].file_server.port_opened = True|g' $rootdir/opt/zeronet/src/Site/Site.py
+ # Hack to ensure that the file access port is opened
+ # This is because zeronet normally relies on an internet site
+ # to do this, but on a purely local mesh the internet isn't available
+ sed -i 's|fileserver_port = 0|fileserver_port = config.fileserver_port\n sys.modules["main"].file_server.port_opened = True|g' $rootdir/opt/zeronet/src/Site/Site.py
- ZERPNET_DAEMON=$rootdir/etc/systemd/system/zeronet.service
- echo '[Unit]' > $ZERONET_DAEMON
- echo 'Description=Zeronet Server' >> $ZERONET_DAEMON
- echo 'After=syslog.target' >> $ZERONET_DAEMON
- echo 'After=network.target' >> $ZERONET_DAEMON
- echo '[Service]' >> $ZERONET_DAEMON
- echo 'Type=simple' >> $ZERONET_DAEMON
- echo 'User=zeronet' >> $ZERONET_DAEMON
- echo 'Group=zeronet' >> $ZERONET_DAEMON
- echo 'WorkingDirectory=/opt/zeronet' >> $ZERONET_DAEMON
- echo 'ExecStart=/usr/bin/python zeronet.py --ip_external replace.local --trackers_file /opt/zeronet/bootstrap' >> $ZERONET_DAEMON
- echo '' >> $ZERONET_DAEMON
- echo 'TimeoutSec=300' >> $ZERONET_DAEMON
- echo '' >> $ZERONET_DAEMON
- echo '[Install]' >> $ZERONET_DAEMON
- echo 'WantedBy=multi-user.target' >> $ZERONET_DAEMON
+ ZERPNET_DAEMON=$rootdir/etc/systemd/system/zeronet.service
+ echo '[Unit]' > $ZERONET_DAEMON
+ echo 'Description=Zeronet Server' >> $ZERONET_DAEMON
+ echo 'After=syslog.target' >> $ZERONET_DAEMON
+ echo 'After=network.target' >> $ZERONET_DAEMON
+ echo '[Service]' >> $ZERONET_DAEMON
+ echo 'Type=simple' >> $ZERONET_DAEMON
+ echo 'User=zeronet' >> $ZERONET_DAEMON
+ echo 'Group=zeronet' >> $ZERONET_DAEMON
+ echo 'WorkingDirectory=/opt/zeronet' >> $ZERONET_DAEMON
+ echo 'ExecStart=/usr/bin/python zeronet.py --ip_external replace.local --trackers_file /opt/zeronet/bootstrap' >> $ZERONET_DAEMON
+ echo '' >> $ZERONET_DAEMON
+ echo 'TimeoutSec=300' >> $ZERONET_DAEMON
+ echo '' >> $ZERONET_DAEMON
+ echo '[Install]' >> $ZERONET_DAEMON
+ echo 'WantedBy=multi-user.target' >> $ZERONET_DAEMON
- TRACKER_DAEMON=$rootdir/etc/systemd/system/tracker.service
- echo '[Unit]' > $TRACKER_DAEMON
- echo 'Description=Torrent Tracker' >> $TRACKER_DAEMON
- echo 'After=syslog.target' >> $TRACKER_DAEMON
- echo 'After=network.target' >> $TRACKER_DAEMON
- echo '[Service]' >> $TRACKER_DAEMON
- echo 'Type=simple' >> $TRACKER_DAEMON
- echo 'User=tracker' >> $TRACKER_DAEMON
- echo 'Group=tracker' >> $TRACKER_DAEMON
- echo 'WorkingDirectory=/opt/tracker' >> $TRACKER_DAEMON
- echo "ExecStart=/usr/bin/bttrack --port $TRACKER_PORT --dfile /opt/tracker/dstate --logfile /opt/tracker/tracker.log --nat_check 0 --scrape_allowed full --ipv6_enabled 0" >> $TRACKER_DAEMON
- echo '' >> $TRACKER_DAEMON
- echo 'TimeoutSec=300' >> $TRACKER_DAEMON
- echo '' >> $TRACKER_DAEMON
- echo '[Install]' >> $TRACKER_DAEMON
- echo 'WantedBy=multi-user.target' >> $TRACKER_DAEMON
+ TRACKER_DAEMON=$rootdir/etc/systemd/system/tracker.service
+ echo '[Unit]' > $TRACKER_DAEMON
+ echo 'Description=Torrent Tracker' >> $TRACKER_DAEMON
+ echo 'After=syslog.target' >> $TRACKER_DAEMON
+ echo 'After=network.target' >> $TRACKER_DAEMON
+ echo '[Service]' >> $TRACKER_DAEMON
+ echo 'Type=simple' >> $TRACKER_DAEMON
+ echo 'User=tracker' >> $TRACKER_DAEMON
+ echo 'Group=tracker' >> $TRACKER_DAEMON
+ echo 'WorkingDirectory=/opt/tracker' >> $TRACKER_DAEMON
+ echo "ExecStart=/usr/bin/bttrack --port $TRACKER_PORT --dfile /opt/tracker/dstate --logfile /opt/tracker/tracker.log --nat_check 0 --scrape_allowed full --ipv6_enabled 0" >> $TRACKER_DAEMON
+ echo '' >> $TRACKER_DAEMON
+ echo 'TimeoutSec=300' >> $TRACKER_DAEMON
+ echo '' >> $TRACKER_DAEMON
+ echo '[Install]' >> $TRACKER_DAEMON
+ echo 'WantedBy=multi-user.target' >> $TRACKER_DAEMON
- $CHROOT_PREFIX useradd -d /opt/tracker/ -s /bin/false tracker
- if [ ! -d $rootdir/opt/tracker ]; then
- mkdir $rootdir/opt/tracker
- fi
- chown -R tracker:tracker $rootdir/opt/tracker
+ $CHROOT_PREFIX useradd -d /opt/tracker/ -s /bin/false tracker
+ if [ ! -d $rootdir/opt/tracker ]; then
+ mkdir $rootdir/opt/tracker
+ fi
+ chown -R tracker:tracker $rootdir/opt/tracker
- # publish regularly
- echo "* * * * * root zeronetavahi > /dev/null" >> $rootdir/etc/crontab
+ # publish regularly
+ echo "* * * * * root zeronetavahi > /dev/null" >> $rootdir/etc/crontab
- $CHROOT_PREFIX systemctl enable tracker.service
- $CHROOT_PREFIX systemctl enable zeronet.service
+ $CHROOT_PREFIX systemctl enable tracker.service
+ $CHROOT_PREFIX systemctl enable zeronet.service
}
function mesh_batman_client {
- if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
- TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
- else
- TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
- fi
+ if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
+ TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
+ else
+ TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
+ fi
- if [ ! -f ${rootdir}/tmp/meshtype ]; then
- $CHROOT_PREFIX sudo apt-get -y install iproute bridge-utils libnetfilter-conntrack3 batctl
- $CHROOT_PREFIX sudo apt-get -y install python-dev libevent-dev ebtables python-pip
- $CHROOT_PREFIX sudo apt-get -y install wireless-tools rfkill
- $CHROOT_PREFIX sudo apt-get -y install irssi mumble
- if [ ! -f $TOXIC_FILE ]; then
- $CHROOT_PREFIX sudo apt-get -y install toxic
- echo "n
- /nick $USER
- /exit
- " | ${rootdir}$TOXIC_FILE -d
- fi
- fi
+ if [ ! -f ${rootdir}/tmp/meshtype ]; then
+ $CHROOT_PREFIX sudo apt-get -y install iproute bridge-utils libnetfilter-conntrack3 batctl
+ $CHROOT_PREFIX sudo apt-get -y install python-dev libevent-dev ebtables python-pip
+ $CHROOT_PREFIX sudo apt-get -y install wireless-tools rfkill
+ if [ ! -f $TOXIC_FILE ]; then
+ $CHROOT_PREFIX sudo apt-get -y install toxic
+ echo "n
+ /nick $USER
+ /exit
+ " | toxic -d
+ fi
+ fi
- BATMAN_SCRIPT=${rootdir}/tmp/batman
+ BATMAN_SCRIPT=${rootdir}/tmp/batman
- echo '#!/bin/bash' > $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo 'if [[ $1 == "start" ]]; then' >> $BATMAN_SCRIPT
- echo ' # install avahi' >> $BATMAN_SCRIPT
- echo ' apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd bittornado' >> $BATMAN_SCRIPT
- echo ' sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $BATMAN_SCRIPT
- echo ' sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $BATMAN_SCRIPT
- echo ' sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf' >> $BATMAN_SCRIPT
- echo ' sed -i "s|use-ipv6=.*|use-ipv6=no|g" /etc/avahi/avahi-daemon.conf' >> $BATMAN_SCRIPT
- echo ' sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" /etc/avahi/avahi-daemon.conf' >> $BATMAN_SCRIPT
- echo ' sed -i "s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf' >> $BATMAN_SCRIPT
- echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
- echo ' systemctl restart avahi-daemon' >> $BATMAN_SCRIPT
- echo ' else' >> $BATMAN_SCRIPT
- echo ' service avahi-daemon restart' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo 'fi' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo '# Mesh definition' >> $BATMAN_SCRIPT
- echo "WIFI_SSID=$WIFI_SSID" >> $BATMAN_SCRIPT
- echo "CELLID=$BATMAN_CELLID" >> $BATMAN_SCRIPT
- echo "CHANNEL=$WIFI_CHANNEL" >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo '# Ethernet bridge definition (bridged to bat0)' >> $BATMAN_SCRIPT
- echo 'BRIDGE=br-mesh' >> $BATMAN_SCRIPT
- echo "IFACE=$WIFI_INTERFACE" >> $BATMAN_SCRIPT
- echo 'EIFACE=eth0' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo 'if [[ $IFACE == "wlan0" ]]; then' >> $BATMAN_SCRIPT
- echo ' if grep -q "wlan1" /proc/net/dev; then' >> $BATMAN_SCRIPT
- echo ' IFACE=wlan1' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo 'fi' >> $BATMAN_SCRIPT
- echo 'if [[ $IFACE == "wlan0" ]]; then' >> $BATMAN_SCRIPT
- echo ' if grep -q "wlan2" /proc/net/dev; then' >> $BATMAN_SCRIPT
- echo ' IFACE=wlan2' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo 'fi' >> $BATMAN_SCRIPT
- echo 'if [[ $IFACE == "wlan0" ]]; then' >> $BATMAN_SCRIPT
- echo ' if grep -q "wlan3" /proc/net/dev; then' >> $BATMAN_SCRIPT
- echo ' IFACE=wlan3' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo 'fi' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo 'if [ -e /etc/default/batctl ]; then' >> $BATMAN_SCRIPT
- echo ' . /etc/default/batctl' >> $BATMAN_SCRIPT
- echo 'fi' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo 'start() {' >> $BATMAN_SCRIPT
- echo ' if [ -f /tmp/meshtype ] ; then' >> $BATMAN_SCRIPT
- echo ' echo "Mesh already running"' >> $BATMAN_SCRIPT
- echo ' return' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo ' if [ -z "$IFACE" ] ; then' >> $BATMAN_SCRIPT
- echo ' echo "error: unable to find wifi interface, not enabling batman-adv mesh"' >> $BATMAN_SCRIPT
- echo ' return' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo ' echo "info: enabling batman-adv mesh network $WIFI_SSID on $IFACE"' >> $BATMAN_SCRIPT
+ echo '#!/bin/bash' > $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo 'if [[ $1 == "start" ]]; then' >> $BATMAN_SCRIPT
+ echo ' # install avahi' >> $BATMAN_SCRIPT
+ echo ' apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd bittornado' >> $BATMAN_SCRIPT
+ echo ' sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $BATMAN_SCRIPT
+ echo ' sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $BATMAN_SCRIPT
+ echo ' sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf' >> $BATMAN_SCRIPT
+ echo ' sed -i "s|use-ipv6=.*|use-ipv6=no|g" /etc/avahi/avahi-daemon.conf' >> $BATMAN_SCRIPT
+ echo ' sed -i "s|#disallow-other-stacks=.*|disallow-other-stacks=yes|g" /etc/avahi/avahi-daemon.conf' >> $BATMAN_SCRIPT
+ echo ' sed -i "s|hosts:.*|hosts: files mdns4_minimal dns mdns4 mdns|g" /etc/nsswitch.conf' >> $BATMAN_SCRIPT
+ echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
+ echo ' systemctl restart avahi-daemon' >> $BATMAN_SCRIPT
+ echo ' else' >> $BATMAN_SCRIPT
+ echo ' service avahi-daemon restart' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo 'fi' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo '# Mesh definition' >> $BATMAN_SCRIPT
+ echo "WIFI_SSID=$WIFI_SSID" >> $BATMAN_SCRIPT
+ echo "CELLID=$BATMAN_CELLID" >> $BATMAN_SCRIPT
+ echo "CHANNEL=$WIFI_CHANNEL" >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo '# Ethernet bridge definition (bridged to bat0)' >> $BATMAN_SCRIPT
+ echo 'BRIDGE=br-mesh' >> $BATMAN_SCRIPT
+ echo "IFACE=$WIFI_INTERFACE" >> $BATMAN_SCRIPT
+ echo 'EIFACE=eth0' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo 'if [[ $IFACE == "wlan0" ]]; then' >> $BATMAN_SCRIPT
+ echo ' if grep -q "wlan1" /proc/net/dev; then' >> $BATMAN_SCRIPT
+ echo ' IFACE=wlan1' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo 'fi' >> $BATMAN_SCRIPT
+ echo 'if [[ $IFACE == "wlan0" ]]; then' >> $BATMAN_SCRIPT
+ echo ' if grep -q "wlan2" /proc/net/dev; then' >> $BATMAN_SCRIPT
+ echo ' IFACE=wlan2' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo 'fi' >> $BATMAN_SCRIPT
+ echo 'if [[ $IFACE == "wlan0" ]]; then' >> $BATMAN_SCRIPT
+ echo ' if grep -q "wlan3" /proc/net/dev; then' >> $BATMAN_SCRIPT
+ echo ' IFACE=wlan3' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo 'fi' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo 'if [ -e /etc/default/batctl ]; then' >> $BATMAN_SCRIPT
+ echo ' . /etc/default/batctl' >> $BATMAN_SCRIPT
+ echo 'fi' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo 'start() {' >> $BATMAN_SCRIPT
+ echo ' if [ -f /tmp/meshtype ] ; then' >> $BATMAN_SCRIPT
+ echo ' echo "Mesh already running"' >> $BATMAN_SCRIPT
+ echo ' return' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo ' if [ -z "$IFACE" ] ; then' >> $BATMAN_SCRIPT
+ echo ' echo "error: unable to find wifi interface, not enabling batman-adv mesh"' >> $BATMAN_SCRIPT
+ echo ' return' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo ' echo "info: enabling batman-adv mesh network $WIFI_SSID on $IFACE"' >> $BATMAN_SCRIPT
- echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
- echo ' systemctl stop network-manager' >> $BATMAN_SCRIPT
- echo ' else' >> $BATMAN_SCRIPT
- echo ' service network-manager stop' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo ' sleep 5' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo " # remove an avahi service which isn't used" >> $BATMAN_SCRIPT
- echo ' if [ -f /etc/avahi/services/udisks.service ]; then' >> $BATMAN_SCRIPT
- echo ' sudo rm /etc/avahi/services/udisks.service' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' # Might have to re-enable wifi' >> $BATMAN_SCRIPT
- echo ' rfkill unblock $(rfkill list|awk -F: "/phy/ {print $1}") || true' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' ifconfig $IFACE down' >> $BATMAN_SCRIPT
- echo ' ifconfig $IFACE mtu 1532' >> $BATMAN_SCRIPT
- echo ' iwconfig $IFACE enc off' >> $BATMAN_SCRIPT
- echo ' iwconfig $IFACE mode ad-hoc essid $WIFI_SSID channel $CHANNEL' >> $BATMAN_SCRIPT
- echo ' sleep 1' >> $BATMAN_SCRIPT
- echo ' iwconfig $IFACE ap $CELLID' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' modprobe batman-adv' >> $BATMAN_SCRIPT
- echo ' batctl if add $IFACE' >> $BATMAN_SCRIPT
- echo ' ifconfig $IFACE up' >> $BATMAN_SCRIPT
- echo ' avahi-autoipd --force-bind --daemonize --wait $BRIDGE' >> $BATMAN_SCRIPT
- echo ' avahi-autoipd --force-bind --daemonize --wait $IFACE' >> $BATMAN_SCRIPT
- echo ' ifconfig bat0 up promisc' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' #Use persistent HWAddr' >> $BATMAN_SCRIPT
- echo ' ether_new=$(ifconfig eth0 | grep HWaddr | sed -e "s/.*HWaddr //")' >> $BATMAN_SCRIPT
- echo ' if [ ! -f /var/lib/mesh-node/bat0 ]; then' >> $BATMAN_SCRIPT
- echo ' mkdir /var/lib/mesh-node' >> $BATMAN_SCRIPT
- echo ' echo "${ether_new}" > /var/lib/mesh-node/bat0' >> $BATMAN_SCRIPT
- echo ' else' >> $BATMAN_SCRIPT
- echo ' ether=$(cat /var/lib/mesh-node/bat0)' >> $BATMAN_SCRIPT
- echo ' ifconfig bat0 hw ether ${ether}' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' if [ "$EIFACE" ] ; then' >> $BATMAN_SCRIPT
- echo ' brctl addbr $BRIDGE' >> $BATMAN_SCRIPT
- echo ' brctl addif $BRIDGE bat0' >> $BATMAN_SCRIPT
- echo ' brctl addif $BRIDGE $EIFACE' >> $BATMAN_SCRIPT
- echo ' ifconfig bat0 0.0.0.0' >> $BATMAN_SCRIPT
- echo ' ifconfig $EIFACE 0.0.0.0' >> $BATMAN_SCRIPT
- echo ' ifconfig $EIFACE up promisc' >> $BATMAN_SCRIPT
- echo ' ifconfig $BRIDGE up' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' iptables -A INPUT -p tcp --dport 548 -j ACCEPT' >> $BATMAN_SCRIPT
- echo ' iptables -A INPUT -p udp --dport 548 -j ACCEPT' >> $BATMAN_SCRIPT
- echo ' iptables -A INPUT -p tcp --dport 5353 -j ACCEPT' >> $BATMAN_SCRIPT
- echo ' iptables -A INPUT -p udp --dport 5353 -j ACCEPT' >> $BATMAN_SCRIPT
- echo ' iptables -A INPUT -p tcp --dport 5354 -j ACCEPT' >> $BATMAN_SCRIPT
- echo ' iptables -A INPUT -p udp --dport 5354 -j ACCEPT' >> $BATMAN_SCRIPT
- echo " iptables -A INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -A INPUT -p udp --dport $ZERONET_PORT -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -A INPUT -p udp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -A INPUT -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -A INPUT -p tcp --dport $IPFS_PORT -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -A INPUT -p udp --dport 1900 -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -A INPUT -p tcp --dport 80 -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -A INPUT -p udp -m udp -j ACCEPT" >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
- echo ' systemctl restart avahi-daemon' >> $BATMAN_SCRIPT
- echo ' else' >> $BATMAN_SCRIPT
- echo ' service avahi-daemon restart' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo ' echo "batman" > /tmp/meshtype' >> $BATMAN_SCRIPT
- echo '}' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo 'stop() {' >> $BATMAN_SCRIPT
- echo ' if [ -z "$IFACE" ]; then' >> $BATMAN_SCRIPT
- echo ' echo "error: unable to find wifi interface, not enabling batman-adv mesh"' >> $BATMAN_SCRIPT
- echo ' return' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo ' if [ "$EIFACE" ]; then' >> $BATMAN_SCRIPT
- echo ' brctl delif $BRIDGE bat0' >> $BATMAN_SCRIPT
- echo ' brctl delif $BRIDGE $EIFACE' >> $BATMAN_SCRIPT
- echo ' ifconfig $BRIDGE down || true' >> $BATMAN_SCRIPT
- echo ' brctl delbr $BRIDGE' >> $BATMAN_SCRIPT
- echo ' ifconfig $EIFACE down -promisc' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' avahi-autoipd -k $BRIDGE' >> $BATMAN_SCRIPT
- echo ' avahi-autoipd -k $IFACE' >> $BATMAN_SCRIPT
- echo ' ifconfig bat0 down -promisc' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' batctl if del $IFACE' >> $BATMAN_SCRIPT
- echo ' rmmod batman-adv' >> $BATMAN_SCRIPT
- echo ' ifconfig $IFACE mtu 1500' >> $BATMAN_SCRIPT
- echo ' ifconfig $IFACE down' >> $BATMAN_SCRIPT
- echo ' iwconfig $IFACE mode managed' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' iptables -D INPUT -p tcp --dport 548 -j ACCEPT' >> $BATMAN_SCRIPT
- echo ' iptables -D INPUT -p udp --dport 548 -j ACCEPT' >> $BATMAN_SCRIPT
- echo ' iptables -D INPUT -p tcp --dport 5353 -j ACCEPT' >> $BATMAN_SCRIPT
- echo ' iptables -D INPUT -p udp --dport 5353 -j ACCEPT' >> $BATMAN_SCRIPT
- echo ' iptables -D INPUT -p tcp --dport 5354 -j ACCEPT' >> $BATMAN_SCRIPT
- echo ' iptables -D INPUT -p udp --dport 5354 -j ACCEPT' >> $BATMAN_SCRIPT
- echo " iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -D INPUT -p udp --dport $ZERONET_PORT -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -D INPUT -p udp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -D INPUT -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -D INPUT -p tcp --dport $IPFS_PORT -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -D INPUT -p udp --dport 1900 -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -D INPUT -p tcp --dport 80 -j ACCEPT" >> $BATMAN_SCRIPT
- echo " iptables -D INPUT -p udp -m udp -j ACCEPT" >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
- echo ' systemctl restart network-manager' >> $BATMAN_SCRIPT
- echo ' else' >> $BATMAN_SCRIPT
- echo ' service network-manager restart' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo ' ' >> $BATMAN_SCRIPT
- echo ' # restore tox bootstrap nodes for the internet' >> $BATMAN_SCRIPT
- echo ' if [ -f /usr/share/toxic/DHTnodes.internet ]; then' >> $BATMAN_SCRIPT
- echo ' mv /usr/share/toxic/DHTnodes.internet /usr/share/toxic/DHTnodes' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo ' if [ -f /usr/local/share/toxic/DHTnodes.internet ]; then' >> $BATMAN_SCRIPT
- echo ' mv /usr/local/share/toxic/DHTnodes.internet /usr/local/share/toxic/DHTnodes' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
- echo ' systemctl stop avahi-daemon' >> $BATMAN_SCRIPT
- echo ' else' >> $BATMAN_SCRIPT
- echo ' service avahi-daemon stop' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' sudo rm -f /tmp/meshtype' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo ' # kill processes' >> $BATMAN_SCRIPT
- echo ' zeronet_proc=$(ps aux | grep zeronet | grep -v grep | awk -F " " "{print $2}" | head -n1)' >> $BATMAN_SCRIPT
- echo ' if [ "$zeronet_proc" ]; then' >> $BATMAN_SCRIPT
- echo ' kill -9 $zeronet_proc 2> /dev/null' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo ' tracker_proc=$(ps aux | grep bttrack | grep -v grep | awk -F " " "{print $2}" | head -n1)' >> $BATMAN_SCRIPT
- echo ' if [ "$tracker_proc" ]; then' >> $BATMAN_SCRIPT
- echo ' kill -9 $tracker_proc 2> /dev/null' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo ' if [ ! -f /etc/systemd/system/ipfs.service ]; then' >> $BATMAN_SCRIPT
- echo ' ipfs_proc=$(ps aux | grep ipfs | grep -v grep | awk -F " " "{print $2}" | head -n1)' >> $BATMAN_SCRIPT
- echo ' if [ "$ipfs_proc" ]; then' >> $BATMAN_SCRIPT
- echo ' kill -9 $ipfs_proc 2> /dev/null' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo ' fi' >> $BATMAN_SCRIPT
- echo '}' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo 'if ! grep -q "$IFACE" /proc/net/dev; then' >> $BATMAN_SCRIPT
- echo ' echo "Interface $IFACE was not found"' >> $BATMAN_SCRIPT
- echo ' stop' >> $BATMAN_SCRIPT
- echo ' exit 1' >> $BATMAN_SCRIPT
- echo 'fi' >> $BATMAN_SCRIPT
- echo '' >> $BATMAN_SCRIPT
- echo 'case "$1" in' >> $BATMAN_SCRIPT
- echo ' start|stop)' >> $BATMAN_SCRIPT
- echo ' $1' >> $BATMAN_SCRIPT
- echo ' ;;' >> $BATMAN_SCRIPT
- echo ' restart)' >> $BATMAN_SCRIPT
- echo ' stop' >> $BATMAN_SCRIPT
- echo ' sleep 10' >> $BATMAN_SCRIPT
- echo ' start' >> $BATMAN_SCRIPT
- echo ' ;;' >> $BATMAN_SCRIPT
- echo ' status)' >> $BATMAN_SCRIPT
- echo ' batctl o' >> $BATMAN_SCRIPT
- echo ' ;;' >> $BATMAN_SCRIPT
- echo ' ping)' >> $BATMAN_SCRIPT
- echo ' batctl ping $2' >> $BATMAN_SCRIPT
- echo ' ;;' >> $BATMAN_SCRIPT
- echo ' ls|list)' >> $BATMAN_SCRIPT
- echo ' avahi-browse -atl' >> $BATMAN_SCRIPT
- echo ' ;;' >> $BATMAN_SCRIPT
- echo ' *)' >> $BATMAN_SCRIPT
- echo ' echo "error: invalid parameter $1"' >> $BATMAN_SCRIPT
- echo ' echo "usage: $0 {start|stop|restart|status|ping|ls|list}"' >> $BATMAN_SCRIPT
- echo ' exit 2' >> $BATMAN_SCRIPT
- echo ' ;;' >> $BATMAN_SCRIPT
- echo 'esac' >> $BATMAN_SCRIPT
- echo 'exit 0' >> $BATMAN_SCRIPT
- chmod +x $BATMAN_SCRIPT
- sudo cp -f $BATMAN_SCRIPT /usr/bin/batman
- rm $BATMAN_SCRIPT
+ echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
+ echo ' systemctl stop network-manager' >> $BATMAN_SCRIPT
+ echo ' else' >> $BATMAN_SCRIPT
+ echo ' service network-manager stop' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo ' sleep 5' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo " # remove an avahi service which isn't used" >> $BATMAN_SCRIPT
+ echo ' if [ -f /etc/avahi/services/udisks.service ]; then' >> $BATMAN_SCRIPT
+ echo ' sudo rm /etc/avahi/services/udisks.service' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' # Might have to re-enable wifi' >> $BATMAN_SCRIPT
+ echo ' rfkill unblock $(rfkill list|awk -F: "/phy/ {print $1}") || true' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' ifconfig $IFACE down' >> $BATMAN_SCRIPT
+ echo ' ifconfig $IFACE mtu 1532' >> $BATMAN_SCRIPT
+ echo ' iwconfig $IFACE enc off' >> $BATMAN_SCRIPT
+ echo ' iwconfig $IFACE mode ad-hoc essid $WIFI_SSID channel $CHANNEL' >> $BATMAN_SCRIPT
+ echo ' sleep 1' >> $BATMAN_SCRIPT
+ echo ' iwconfig $IFACE ap $CELLID' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' modprobe batman-adv' >> $BATMAN_SCRIPT
+ echo ' batctl if add $IFACE' >> $BATMAN_SCRIPT
+ echo ' ifconfig $IFACE up' >> $BATMAN_SCRIPT
+ echo ' avahi-autoipd --force-bind --daemonize --wait $BRIDGE' >> $BATMAN_SCRIPT
+ echo ' avahi-autoipd --force-bind --daemonize --wait $IFACE' >> $BATMAN_SCRIPT
+ echo ' ifconfig bat0 up promisc' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' #Use persistent HWAddr' >> $BATMAN_SCRIPT
+ echo ' ether_new=$(ifconfig eth0 | grep HWaddr | sed -e "s/.*HWaddr //")' >> $BATMAN_SCRIPT
+ echo ' if [ ! -f /var/lib/mesh-node/bat0 ]; then' >> $BATMAN_SCRIPT
+ echo ' mkdir /var/lib/mesh-node' >> $BATMAN_SCRIPT
+ echo ' echo "${ether_new}" > /var/lib/mesh-node/bat0' >> $BATMAN_SCRIPT
+ echo ' else' >> $BATMAN_SCRIPT
+ echo ' ether=$(cat /var/lib/mesh-node/bat0)' >> $BATMAN_SCRIPT
+ echo ' ifconfig bat0 hw ether ${ether}' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' if [ "$EIFACE" ] ; then' >> $BATMAN_SCRIPT
+ echo ' brctl addbr $BRIDGE' >> $BATMAN_SCRIPT
+ echo ' brctl addif $BRIDGE bat0' >> $BATMAN_SCRIPT
+ echo ' brctl addif $BRIDGE $EIFACE' >> $BATMAN_SCRIPT
+ echo ' ifconfig bat0 0.0.0.0' >> $BATMAN_SCRIPT
+ echo ' ifconfig $EIFACE 0.0.0.0' >> $BATMAN_SCRIPT
+ echo ' ifconfig $EIFACE up promisc' >> $BATMAN_SCRIPT
+ echo ' ifconfig $BRIDGE up' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' iptables -A INPUT -p tcp --dport 548 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo ' iptables -A INPUT -p udp --dport 548 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo ' iptables -A INPUT -p tcp --dport 5353 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo ' iptables -A INPUT -p udp --dport 5353 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo ' iptables -A INPUT -p tcp --dport 5354 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo ' iptables -A INPUT -p udp --dport 5354 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo " iptables -A INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -A INPUT -p udp --dport $ZERONET_PORT -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -A INPUT -p udp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -A INPUT -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -A INPUT -p tcp --dport $IPFS_PORT -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -A INPUT -p udp --dport 1900 -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -A INPUT -p tcp --dport 80 -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -A INPUT -p udp -m udp -j ACCEPT" >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
+ echo ' systemctl restart avahi-daemon' >> $BATMAN_SCRIPT
+ echo ' else' >> $BATMAN_SCRIPT
+ echo ' service avahi-daemon restart' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo ' echo "batman" > /tmp/meshtype' >> $BATMAN_SCRIPT
+ echo '}' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo 'stop() {' >> $BATMAN_SCRIPT
+ echo ' if [ -z "$IFACE" ]; then' >> $BATMAN_SCRIPT
+ echo ' echo "error: unable to find wifi interface, not enabling batman-adv mesh"' >> $BATMAN_SCRIPT
+ echo ' return' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo ' if [ "$EIFACE" ]; then' >> $BATMAN_SCRIPT
+ echo ' brctl delif $BRIDGE bat0' >> $BATMAN_SCRIPT
+ echo ' brctl delif $BRIDGE $EIFACE' >> $BATMAN_SCRIPT
+ echo ' ifconfig $BRIDGE down || true' >> $BATMAN_SCRIPT
+ echo ' brctl delbr $BRIDGE' >> $BATMAN_SCRIPT
+ echo ' ifconfig $EIFACE down -promisc' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' avahi-autoipd -k $BRIDGE' >> $BATMAN_SCRIPT
+ echo ' avahi-autoipd -k $IFACE' >> $BATMAN_SCRIPT
+ echo ' ifconfig bat0 down -promisc' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' batctl if del $IFACE' >> $BATMAN_SCRIPT
+ echo ' rmmod batman-adv' >> $BATMAN_SCRIPT
+ echo ' ifconfig $IFACE mtu 1500' >> $BATMAN_SCRIPT
+ echo ' ifconfig $IFACE down' >> $BATMAN_SCRIPT
+ echo ' iwconfig $IFACE mode managed' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' iptables -D INPUT -p tcp --dport 548 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo ' iptables -D INPUT -p udp --dport 548 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo ' iptables -D INPUT -p tcp --dport 5353 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo ' iptables -D INPUT -p udp --dport 5353 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo ' iptables -D INPUT -p tcp --dport 5354 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo ' iptables -D INPUT -p udp --dport 5354 -j ACCEPT' >> $BATMAN_SCRIPT
+ echo " iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -D INPUT -p udp --dport $ZERONET_PORT -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -D INPUT -p udp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -D INPUT -p tcp --dport $TRACKER_PORT -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -D INPUT -p tcp --dport $IPFS_PORT -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -D INPUT -p udp --dport 1900 -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -D INPUT -p tcp --dport 80 -j ACCEPT" >> $BATMAN_SCRIPT
+ echo " iptables -D INPUT -p udp -m udp -j ACCEPT" >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
+ echo ' systemctl restart network-manager' >> $BATMAN_SCRIPT
+ echo ' else' >> $BATMAN_SCRIPT
+ echo ' service network-manager restart' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo ' ' >> $BATMAN_SCRIPT
+ echo ' # restore tox bootstrap nodes for the internet' >> $BATMAN_SCRIPT
+ echo ' if [ -f /usr/share/toxic/DHTnodes.internet ]; then' >> $BATMAN_SCRIPT
+ echo ' mv /usr/share/toxic/DHTnodes.internet /usr/share/toxic/DHTnodes' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo ' if [ -f /usr/local/share/toxic/DHTnodes.internet ]; then' >> $BATMAN_SCRIPT
+ echo ' mv /usr/local/share/toxic/DHTnodes.internet /usr/local/share/toxic/DHTnodes' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' if [ -f /bin/systemctl ]; then' >> $BATMAN_SCRIPT
+ echo ' systemctl stop avahi-daemon' >> $BATMAN_SCRIPT
+ echo ' else' >> $BATMAN_SCRIPT
+ echo ' service avahi-daemon stop' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' sudo rm -f /tmp/meshtype' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo ' # kill processes' >> $BATMAN_SCRIPT
+ echo ' zeronet_proc=$(ps aux | grep zeronet | grep -v grep | awk -F " " "{print $2}" | head -n1)' >> $BATMAN_SCRIPT
+ echo ' if [ "$zeronet_proc" ]; then' >> $BATMAN_SCRIPT
+ echo ' kill -9 $zeronet_proc 2> /dev/null' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo ' tracker_proc=$(ps aux | grep bttrack | grep -v grep | awk -F " " "{print $2}" | head -n1)' >> $BATMAN_SCRIPT
+ echo ' if [ "$tracker_proc" ]; then' >> $BATMAN_SCRIPT
+ echo ' kill -9 $tracker_proc 2> /dev/null' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo ' if [ ! -f /etc/systemd/system/ipfs.service ]; then' >> $BATMAN_SCRIPT
+ echo ' ipfs_proc=$(ps aux | grep ipfs | grep -v grep | awk -F " " "{print $2}" | head -n1)' >> $BATMAN_SCRIPT
+ echo ' if [ "$ipfs_proc" ]; then' >> $BATMAN_SCRIPT
+ echo ' kill -9 $ipfs_proc 2> /dev/null' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo ' fi' >> $BATMAN_SCRIPT
+ echo '}' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo 'if ! grep -q "$IFACE" /proc/net/dev; then' >> $BATMAN_SCRIPT
+ echo ' echo "Interface $IFACE was not found"' >> $BATMAN_SCRIPT
+ echo ' stop' >> $BATMAN_SCRIPT
+ echo ' exit 1' >> $BATMAN_SCRIPT
+ echo 'fi' >> $BATMAN_SCRIPT
+ echo '' >> $BATMAN_SCRIPT
+ echo 'case "$1" in' >> $BATMAN_SCRIPT
+ echo ' start|stop)' >> $BATMAN_SCRIPT
+ echo ' $1' >> $BATMAN_SCRIPT
+ echo ' ;;' >> $BATMAN_SCRIPT
+ echo ' restart)' >> $BATMAN_SCRIPT
+ echo ' stop' >> $BATMAN_SCRIPT
+ echo ' sleep 10' >> $BATMAN_SCRIPT
+ echo ' start' >> $BATMAN_SCRIPT
+ echo ' ;;' >> $BATMAN_SCRIPT
+ echo ' status)' >> $BATMAN_SCRIPT
+ echo ' batctl o' >> $BATMAN_SCRIPT
+ echo ' ;;' >> $BATMAN_SCRIPT
+ echo ' ping)' >> $BATMAN_SCRIPT
+ echo ' batctl ping $2' >> $BATMAN_SCRIPT
+ echo ' ;;' >> $BATMAN_SCRIPT
+ echo ' ls|list)' >> $BATMAN_SCRIPT
+ echo ' avahi-browse -atl' >> $BATMAN_SCRIPT
+ echo ' ;;' >> $BATMAN_SCRIPT
+ echo ' *)' >> $BATMAN_SCRIPT
+ echo ' echo "error: invalid parameter $1"' >> $BATMAN_SCRIPT
+ echo ' echo "usage: $0 {start|stop|restart|status|ping|ls|list}"' >> $BATMAN_SCRIPT
+ echo ' exit 2' >> $BATMAN_SCRIPT
+ echo ' ;;' >> $BATMAN_SCRIPT
+ echo 'esac' >> $BATMAN_SCRIPT
+ echo 'exit 0' >> $BATMAN_SCRIPT
+ chmod +x $BATMAN_SCRIPT
+ sudo cp -f $BATMAN_SCRIPT /usr/bin/batman
+ rm $BATMAN_SCRIPT
}
while [[ $# > 1 ]]
do
- key="$1"
+ 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"
- ;;
- -m|--mirror)
- shift
- FRIENDS_MIRRORS_SERVER="$1"
- ;;
- *)
- # unknown option
- ;;
+ 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"
+ ;;
+ -m|--mirror)
+ shift
+ FRIENDS_MIRRORS_SERVER="$1"
+ ;;
+ *)
+ # unknown option
+ ;;
- esac
- shift
+ esac
+ shift
done
if [[ $FN == 'babel' ]]; then
- mesh_babel
+ mesh_babel
fi
if [[ $FN == 'babel_client' ]]; then
- mesh_babel_client
+ mesh_babel_client
fi
if [[ $FN == 'avahi' ]]; then
- mesh_avahi
+ mesh_avahi
fi
if [[ $FN == 'firewall' ]]; then
- mesh_firewall
+ mesh_firewall
fi
if [[ $FN == 'batman' ]]; then
- mesh_batman
+ mesh_batman
fi
if [[ $FN == 'batman_client' ]]; then
- mesh_batman_client
+ mesh_batman_client
fi
if [[ $FN == 'tox_node' ]]; then
- mesh_tox_node
+ mesh_tox_node
fi
if [[ $FN == 'tox_client' ]]; then
- mesh_tox_client
+ mesh_tox_client
fi
if [[ $FN == 'zeronet' ]]; then
- mesh_zeronet
+ mesh_zeronet
fi
exit 0