Commit 37b63740 authored by iv's avatar iv

Quotes!

parent 408e181b
......@@ -6,25 +6,25 @@ configdir="/home/chronos/user/.re6stconf"
configfile="${configdir}/re6stnet.conf"
options=()
install -d ${configdir}
install -d "${configdir}"
echo "After having run this script, you will be able to join the Grandenet network, based on re6st, a resilient overlay mesh network providing IPv6."
read -p "token (you can get one on http://www.grandenet.cn): " token
read -p "registry [http://re6stnet.grandenet.cn]: " registry
if [ "$registry" == "" ] ; then
if [ "${registry}" == "" ] ; then
registry="http://re6stnet.grandenet.cn"
fi
read -p "set re6st route as default [Y/n]? " default
if [ "$default" == "y" -o "$default" == "Y" -o "$default" == "" ] ; then
if [ "${default}" == "y" -o "${default}" == "Y" -o "${default}" == "" ] ; then
options+=('default')
fi
read -p "save configuration on an external device [Y/n]? " save
if [ "$save" == "y" -o "$save" == "Y" -o "$save" == "" ] ; then
save=1
if [[ $(ls -d ${mountpoint}/*) ]]; then
if [[ $(ls -d "${mountpoint}"/*) ]]; then
echo "Detected external partitions:"
for mnt in /media/removable/* ; do
echo " * $mnt"
......@@ -40,11 +40,11 @@ else
echo "Configuration will be placed in ${configfile}, please do manually backup later or you could lose your access."
fi
#re6st-conf --registry "${registry}" --token "${token}" --dir ${configdir}
#re6st-conf --registry "${registry}" --token "${token}" --dir "${configdir}"
printf '%s\n' "${options[@]}" >> ${configfile}
printf '%s\n' "${options[@]}" >> "${configfile}"
echo """
echo "
*filter
:FORWARD ACCEPT [0:0]
:OUTPUT DROP [0:0]
......@@ -55,12 +55,12 @@ echo """
-A OUTPUT -p udp -m udp --dport 6696 -j ACCEPT
-A OUTPUT -p udp -m udp --dport 326 -j ACCEPT
COMMIT
""" > ${configdir}/ip6tables.conf
" > "${configdir}/ip6tables.conf"
if [ $save -a $place ] ; then
sudo install -d "${place}"
for file in "${configdir}"/* ; do
install ${file} "${place}"
install "${file}" "${place}"
done
fi
......
......@@ -20,13 +20,13 @@ if [[ $(pgrep re6stnet) ]] ; then
fi
# get configuration
if [ -r ${configfile} -a -r ${configdir}/cert.crt -a -r ${configdir}/cert.key -a -r ${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..."
path=""
if [[ $(find ${mountpoint} -type d | grep re6stconf) ]] ; then
tempath=$(find ${mountpoint} -type d | grep -m 1 re6stconf)
if [[ $(find "${mountpoint}" -type d | grep re6stconf) ]] ; then
tempath=$(find "${mountpoint}" -type d | grep -m 1 re6stconf)
read -p "Use configuration directory found at: ${tempath} [Y/n]? " confirm
if [ "${confirm}" == "y" -o "${confirm}" == "Y" -o "${confirm}" == "" ] ; then
path=$tempath
......@@ -46,10 +46,10 @@ else
echo "Invalid path ${path}, you can generate a valid configuration using grdn-cfg command. Exiting."
exit 1
fi
if [ -r ${path}/re6stnet.conf -a -r ${path}/cert.crt -a -r ${path}/cert.key -a -r ${path}/ca.crt ]; then
install -d ${configdir}
if [ -r "${path}/re6stnet.conf" -a -r "${path}/cert.crt" -a -r "${path}/cert.key" -a -r "${path}/ca.crt" ]; then
install -d "${configdir}"
for file in "${path}"; do
install -m 600 "${path}"/* ${configdir}
install -m 600 "${file}" "${configdir}"
done
else
echo "Missing some configuration files in ${path}, you can generate a valid configuration using grdn-cfg command. Exiting."
......@@ -60,15 +60,15 @@ fi
# setup
# saving firewall configuration
ip6tables-save > ${configdir}/ip6tables.save
ip6tables-save > "${configdir}/ip6tables.save"
# clean before exiting
cleanup() {
printf "\nCleaning up and exiting...\n"
if [ -r ${configdir}/ip6tables.save ] ; then
if [ -r "${configdir}/ip6tables.save" ] ; then
echo "Removing changes in ip6tables rules"
ip6tables-restore < ${configdir}/ip6tables.save
rm ${configdir}/ip6tables.save
ip6tables-restore < "${configdir}/ip6tables.save"
rm "${configdir}/ip6tables.save"
fi
echo ""
exit 0
......@@ -77,8 +77,8 @@ cleanup() {
trap cleanup SIGHUP SIGINT SIGTERM
# firewall configuration
if [ -r "${configdir}"/ip6tables.conf ] ; then
ip6tables-restore < "${configdir}"/ip6tables.conf
if [ -r "${configdir}/ip6tables.conf" ] ; then
ip6tables-restore < "${configdir}/ip6tables.conf"
else
# accept ports needed for re6stnet
ip6tables -P FORWARD ACCEPT
......@@ -113,7 +113,7 @@ read -p "Should the interface accept router advertisement via IPv6 [y/N]? " acce
interface_names="$( ip -o link show | awk -F': ' '{print $2}' )"
interface="$( ip -o link show | grep 'state UP' | awk -F': ' '{print $2}' || echo ${interface_names} | grep 0 || echo ${interface_names} | grep 1)"
read -p "Is $interface the name of the interface that is used to access the Internet (via IPv4) [Y/n]? " confirm
read -p "Is '${interface}' the name of the interface that is used to access the Internet (via IPv4) [Y/n]? " confirm
if [ "$confirm" != "y" -a "$confirm" != "Y" -a "$confirm" != "" ] ; then
printf "running interfaces found:\n${interface_names}\n"
......@@ -133,7 +133,7 @@ for i in {0..2} ; do
done
echo ""
while [[ $( grep default ${configfile} ) && $( ip -6 r | grep default ) ]] ; do
while [[ $( grep default "${configfile}" ) && $( ip -6 r | grep default ) ]] ; do
printf "Default route was found for interface '${interface}':\n $( ip -6 r | grep default )\nwhereas option 'default' is in ${configfile}.\n"
read -p "Use ip route (i) or try restarting shill (s) [I/s]: " choice
if [ "$choice" != "s" -a "$confirm" != "S" ] ; then
......@@ -146,5 +146,5 @@ while [[ $( grep default ${configfile} ) && $( ip -6 r | grep default ) ]] ; do
done
# join re6st network
cd ${configdir}
cd "${configdir}"
re6stnet @re6stnet.conf
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