Public
Snippet $239 authored by Rafael Monnerat

prepare_grandenet_for_crouton.sh

Edited
#!/bin/bash
# interactively run re6stnet on SlapOS

# shill should not care about these interfaces
blacklist_option="re6stnet-tcp,re6stnet10,re6stnet9,re6stnet8,re6stnet7,re6stnet6,re6stnet5,re6stnet4,re6stnet3,re6stnet2,re6stnet1,tun0,tun1,tun2"
logfile="/var/log/grandenet"

# Require script to be run via sudo, but not as root
if [[ $EUID != 0 ]]; then
    echo "This script requires root privileges! However, it may fail if running with root user. Please, run it again and prefix the command by 'sudo'."
    exit 1
fi

# setup shill network manager
if [[ $( pgrep -a shill | grep ${blacklist_option} ) ]] ; then
    echo "shill was started with the right blacklist." >> ${logfile}
else
    read -p "The network manager shill was not started with the right blacklisted devices list. Restart it [Y/n]? " confirm
    if [ "$confirm" != "n" -a "$confirm" != "N" ] ; then
        if [[ $( status shill_respawn | grep running ) ]] ; then
            # shill_respawn job does not allow to pass arguments to shill
            stop shill_respawn
        fi
        if [[ $( status shill | grep running ) ]] ; then
            stop shill
        fi
        start shill BLACKLISTED_DEVICES="${blacklist_option}"
        # wait a bit for the interfaces to be back
        for i in {0..4} ; do
            echo -n "." ; sleep 1
        done
        echo ""
    fi
fi

ip6tables -P FORWARD ACCEPT
ip6tables -A OUTPUT -p udp --dport 6696 -j ACCEPT
ip6tables -A OUTPUT -p udp --dport 326 -j ACCEPT
ip6tables -A INPUT -p udp --dport 6696 -j ACCEPT
ip6tables -A INPUT -p udp --dport 326 -j ACCEPT

# Accept ports needed for running any webrunner
ip6tables  -A INPUT -p tcp --dport 9684 -j ACCEPT
ip6tables  -A INPUT -p tcp --dport 50005 -j ACCEPT

sysctl net.ipv6.conf.all.accept_ra=1  
sysctl net.ipv6.conf.all.forwarding=1