Commit b1c404a3 authored by iv's avatar iv

Some corrections + iptables cleanup.

parent 29631424
......@@ -7,7 +7,6 @@ configfile="${configdir}/re6stnet.conf"
options=""
shill_options="BLACKLISTED_DEVICES=re6stnet-tcp,re6stnet10,re6stnet9,re6stnet8,re6stnet7,re6stnet6,re6stnet5,re6stnet4,re6stnet3,re6stnet2,re6stnet1,tun0,tun1,tun2"
echo "After having run this script, you will connect to the Grandenet network, based on re6st, a resilient overlay mesh network providing IPv6."
if [[ $(ps -A | grep re6stnet) ]] ; then
read -p "re6stnet is already running. Stop it [y/N] ?" stop
......@@ -16,11 +15,12 @@ if [[ $(ps -A | grep re6stnet) ]] ; then
killall re6stnet
else
echo "Exiting."
exit 0
fi
fi
# get configuration
if [ -f ${configfile} -a -f ${configdir}/cert.crt -a -f ${configdir}/cert.key -a -f ${configdir}/ca.crt ]; then
if [ -r ${configfile} -a -r ${configdir}/cert.crt -a -r ${configdir}/cert.key -a -r ${configdir}/ca.crt ]; then
echo "configuration was found in ${configdir}"
else
echo "no configuration was found in ${configdir}, looking for it elsewhere..."
......@@ -46,9 +46,11 @@ else
echo "Invalid path ${path}, you can generate a valid configuration using grdn-cfg command. Exiting."
exit 1
fi
if [ -f ${path}/re6stnet.conf -a -f ${path}/cert.crt -a -f ${path}/cert.key -a -f ${path}/ca.crt ]; then
if [ -r ${path}/re6stnet.conf -a -r ${path}/cert.crt -a -r ${path}/cert.key -a -r ${path}/ca.crt ]; then
install -d ${configdir}
cp -R ${path}/* ${configdir} && chmod 640 ${configdir}/* && chmod 600 ${configdir}/cert.key
for file in "${path}"; do
install -m 600 "${path}"/* ${configdir}
done
else
echo "Missing some configuration files in ${path}, you can generate a valid configuration using grdn-cfg command. Exiting."
exit 1
......@@ -56,9 +58,23 @@ else
fi
# setup
# saving firewall configuration
ip6tables-save > ${configdir}/ip6tables.save
# clean before exiting
cleanup() {
printf "\nCleaning up and exiting...\n"
if [ -r ${configdir}/ip6tables.save ] ; then
cat ${configdir}/ip6tables.save | ip6tables-restore
fi
rm ${configdir}/ip6tables.save
exit 0
}
trap cleanup SIGHUP SIGINT SIGTERM
# firewall configuration
# TODO check if not already accepted
# TODO only forward what comes from re6st
ip6tables -P FORWARD ACCEPT
ip6tables -A OUTPUT -p udp --dport 6696 -j ACCEPT
ip6tables -A OUTPUT -p udp --dport 326 -j ACCEPT
......@@ -82,12 +98,11 @@ if [ "$confirm" != "y" -a "$confirm" != "Y" ] ; then
start shill ${shill_options}
fi
# TODO get interface name with netstat -i
read -p "Should the interface accept router advertisement via IPv6 [y/N]? " accept_ra
# give some time for interfaces to be back
for i in {0..2} ; do
printf "." && sleep 1
echo -n "." ; sleep 1
done
echo ""
......@@ -108,7 +123,7 @@ fi
echo "re6st will start, it may take a few minutes before beeing usable"
# wait a bit, so the user can see it and the message is not lost among re6st log
for i in {0..2} ; do
printf "." && sleep 1
echo -n "." ; sleep 1
done
echo ""
......@@ -125,4 +140,4 @@ done
# join re6st network
cd ${configdir}
exec re6stnet @re6stnet.conf
\ No newline at end of file
re6stnet @re6stnet.conf
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment