From a417442f720a1590fc16af93af421a06a00200ea Mon Sep 17 00:00:00 2001 From: Lassulus Date: Fri, 7 Dec 2012 19:17:15 +0100 Subject: added new installer WIP --- retiolum/scripts/tinc_setup/new_install.sh | 158 +++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100755 retiolum/scripts/tinc_setup/new_install.sh (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh new file mode 100755 index 00000000..ab42aedc --- /dev/null +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -0,0 +1,158 @@ +#!/bin/sh + +usage() +{ +cat << EOF +usage $0 options +This script gets you into the KREBS Darknet +all parameters are optional + +Options: + -h Show this message(haha) + -4 \$ipv4 specify an ip(version 4), this also disables random ip mode, default is random + -t \$DIR Choose another Temporary directory, default is /tmp/tinc-install-fu + -o \$HOST Choose another Hostname, default is your system hostname + -n \$NET Choose another tincd netname,this also specifies the path to your tinc config, default is retiolum + -s \$SUBNET Choose another Subnet(version4), default is 10.243. + -m \$MASK Choose another Subnet Mask(version4), default is /16 + -u \$URL specify another hostsfiles.tar.gz url, default is euer.krebsco.de/retiolum/hosts.tar.gz +EOF +} + +#check if ip is valid ipv4 function +check_ip_valid4() +{ + if [ "$(echo $1 | awk -F"\." ' $0 ~ /^([0-9]{1,3}\.){3}[0-9]{1,3}$/ && $1 <=255 && $2 <= 255 && $3 <= 255 && $4 <= 255 ' 2>/dev/null)" == "$1" ] && [ ${1:0:${#SUBNET4}} == $SUBNET4 ] + then + return 0 + else + return 1 + fi +} + +#check if ip is taken function +check_ip_taken() +{ + if grep -q -E "$1(#|/)" $TEMPDIR/hosts/* ;then + echo $1 is taken + return 1 + else + echo $1 seems free + return 0 + fi +} + +#if hostname is taken, count upwards until it isn't taken function +check_hostname() +{ + TSTFILE=$TEMPDIR/hosts/$1 + LCOUNTER=0 + if test -e $TSTFILE; then + while test -e $TSTFILE; do + let LCOUNTER=LCOUNTER+1 + TSTFILE=$TEMPDIR/hosts/$1$LCOUNTER + done + HOSTN=$1$LCOUNTER + else + HOSTN=$1 + fi +} + +TEMPDIR=/tmp/tinc-install-fu +HOSTN=$(hostname) +NETNAME=retiolum +SUBNET4=10.243. +MASK4=/16 +RAND=1 +URL=euer.krebsco.de/retiolum/hosts.tar.gz + +#check if everything is installed +if $(! test -e "/usr/sbin/tincd"); then + echo "Please install tinc" + exit 1 +fi + +if $(! test -e /usr/bin/awk); then + echo "Please install awk" + exit 1 +fi + +if $(! test -e /usr/bin/curl); then + echo "Please install curl" + exit 1 +fi + +if $(! /bin/ping -c 1 euer.krebsco.de -W 5 &>/dev/null) ;then + echo "Cant reach euer, check if your internet is working" + exit 1 +fi + + +#parse options +while getopts "h4:t:o:n:s:m:u:" OPTION +do + case $OPTION in + h) + usage + exit 1 + ;; + 4) + IP4=$OPTARG + RAND=0 + if ! check_ip_valid4 $IP4; then echo "ip is invalid" && exit 1; fi + ;; + t) + TEMPDIR=$OPTARG + ;; + o) + HOSTN=$OPTARG + ;; + n) + NETNAME=$OPTARG + ;; + s) + SUBNET4=$OPTARG + ;; + m) + MASK4=$OPTARG + ;; + u) + URL=$OPTARG + if $(! curl -s --head $URL | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null); then + echo "url not reachable" + exit 1 + fi + ;; + + esac +done + +#test if tinc directory already exists +if test -e /etc/tinc/$NETNAME; then + echo "tinc config directory /etc/tinc/$NETNAME does already exist. (backup and) delete config directory and restart" + exit 1 +fi + +#get tinc-hostfiles +mkdir -p $TEMPDIR/hosts +curl euer.krebsco.de/retiolum/hosts.tar.gz | tar zx -C $TEMPDIR/hosts/ + +#check for free ip +until check_ip_taken $IP4; do + if [ $RAND -eq 1 ]; then + IP4="10.243.$((RANDOM%255)).$((RANDOM%255))" + else + printf 'choose new ip: ' + read IP4 + while ! check_ip_valid4 $IP4; do + printf 'the ip is invalid, retard, choose a valid ip: ' + read IP4 + done + fi +done + +#check for free hostname +check_hostname $HOSTN + +echo "your ip is $IP4" +echo "your hostname is $HOSTN" -- cgit v1.2.3 From ad09d521243d9275d2af99b5aa5b67b9f79d3a77 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 7 Dec 2012 22:34:39 +0100 Subject: write_channel.py rewritten to announce_pubkey announce_pubkey is a shell-only implementation of the now obsolete write_channel script to announce a hosts public key the only dependency of this script is telnet, haven't seen a system without it for a while now --- retiolum/scripts/tinc_setup/install.sh | 2 +- retiolum/scripts/tinc_setup/write_channel.py | 27 --------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 retiolum/scripts/tinc_setup/write_channel.py (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/install.sh b/retiolum/scripts/tinc_setup/install.sh index a6b50b8a..2e36b83a 100755 --- a/retiolum/scripts/tinc_setup/install.sh +++ b/retiolum/scripts/tinc_setup/install.sh @@ -73,7 +73,7 @@ if [ ! -e rsa_key.priv ] then echo "creating new keys" tincd -n $netname -K - python ${CURR}/write_channel.py $myname || \ + $MYBIN/announce_pubkey $myname || \ echo "cannot write public key to IRC, you are on your own. Good Luck" else echo "key files already exist, skipping" diff --git a/retiolum/scripts/tinc_setup/write_channel.py b/retiolum/scripts/tinc_setup/write_channel.py deleted file mode 100644 index 8299fa8d..00000000 --- a/retiolum/scripts/tinc_setup/write_channel.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python -import random, sys, time, socket -try: - myname=sys.argv[1] -except: - print("you are made of stupid") - exit (23) - -CHANNEL = '#krebsco' -HOST='irc.freenode.net' -FILE="/etc/tinc/retiolum/hosts/"+myname -PORT=6667 -NICK= myname+"_"+str(random.randint(23,666)) - -print("Connecting...") -sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) -sock.connect((HOST,PORT)) -print(NICK) -sock.send("NICK %s\r\n" % NICK) -sock.send("USER %s %s bla : %s\r\n" %(NICK,HOST,NICK)) -sock.send("JOIN %s\r\n" % CHANNEL) -time.sleep(23) -f = open(FILE,'r') -a = [ sock.send("PRIVMSG %s : %s" % ( CHANNEL,line)) for line in f] -time.sleep(5) #because irc is so lazy -print("closing socket") -sock.close() -- cgit v1.2.3 From 8c11e39a58e69de9b1912756082609f5ffb0dcb1 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Sun, 9 Dec 2012 03:06:10 +0100 Subject: new version, still WIP --- retiolum/scripts/tinc_setup/new_install.sh | 213 +++++++++++++++++++++++++---- 1 file changed, 188 insertions(+), 25 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index ab42aedc..52bb4ddb 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -1,5 +1,12 @@ #!/bin/sh +#get sudo +if test "${nosudo-false}" != true -a `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo "$0" "$@" + exit 23 # go to hell +fi + usage() { cat << EOF @@ -10,15 +17,35 @@ all parameters are optional Options: -h Show this message(haha) -4 \$ipv4 specify an ip(version 4), this also disables random ip mode, default is random + -6 \$ipv6 specify an ip(version 6), this also disables random ip mode, default is random + -s \$SUBNET Choose another Subnet(version4), default is 10.243 + -x \$SUBNET Choose another Subnet(version6), default is 42 + -m \$MASK Choose another Subnet Mask(version4), default is 16 + -j \$MASK Choose another Subnet Mask(version6), default is 16 -t \$DIR Choose another Temporary directory, default is /tmp/tinc-install-fu -o \$HOST Choose another Hostname, default is your system hostname -n \$NET Choose another tincd netname,this also specifies the path to your tinc config, default is retiolum - -s \$SUBNET Choose another Subnet(version4), default is 10.243. - -m \$MASK Choose another Subnet Mask(version4), default is /16 -u \$URL specify another hostsfiles.tar.gz url, default is euer.krebsco.de/retiolum/hosts.tar.gz + -l \$OS specify an OS, numeric parameter.0=Automatic 1=ArchLinux 2=OpenWRT, disables automatic OS-finding, default is 0 + -r \$ADDR give the node an reachable remote address, ipv4 or dns EOF } +#convert hostmask to subnetmask only version 4 +host2subnet() +{ + NEEDDOTSINSUB=$(expr 3 - $(echo $SUBNET4 | sed 's/[0-9]*//g')) + FULLSUBNET=$(echo $SUBNET4$(eval "printf '.0'%.0s {1..${#NEEDDOTSINSUB}}"s)) + + result=$(($(($((1 << $1)) - 1)) << $((32 - $1)))) + byte="" + for ((i=0;i<3;i+=1)); do + byte=.$(($result % 256))$byte + result=$(($result / 256)) + done + RETARDEDMASK=$result$byte +} + #check if ip is valid ipv4 function check_ip_valid4() { @@ -30,20 +57,29 @@ check_ip_valid4() fi } +#check if ip is valid ipv6 function +check_ip_valid6() +{ + if [ "$(echo $1 | awk -F"." ' $0 ~ /^([0-9a-fA-F]{1,4}\:){7}[0-9a-fA-F]{1,4}$/' 2>/dev/null)" == $1 ] && [ ${1:0:${#SUBNET6}} == $SUBNET6 ] + then + return 0 + else + return 1 + fi +} + #check if ip is taken function check_ip_taken() { if grep -q -E "$1(#|/)" $TEMPDIR/hosts/* ;then - echo $1 is taken return 1 else - echo $1 seems free return 0 fi } #if hostname is taken, count upwards until it isn't taken function -check_hostname() +get_hostname() { TSTFILE=$TEMPDIR/hosts/$1 LCOUNTER=0 @@ -58,38 +94,52 @@ check_hostname() fi } +#os autodetection +find_os() +{ + if grep -q "Arch Linux" /etc/*release; then + OS=1 + elif grep -q "OpenWrt" /etc/*release; then + OS=2 + fi +} + +SUBNET4=10.243 +SUBNET6=42 TEMPDIR=/tmp/tinc-install-fu HOSTN=$(hostname) NETNAME=retiolum -SUBNET4=10.243. -MASK4=/16 -RAND=1 +MASK4=16 +MASK6=16 +RAND4=1 +RAND6=1 URL=euer.krebsco.de/retiolum/hosts.tar.gz +OS=0 #check if everything is installed -if $(! test -e "/usr/sbin/tincd"); then +if ! which tincd&>/dev/null; then echo "Please install tinc" exit 1 fi -if $(! test -e /usr/bin/awk); then +if ! which awk&>/dev/null; then echo "Please install awk" exit 1 fi -if $(! test -e /usr/bin/curl); then +if ! which curl&>/dev/null; then echo "Please install curl" exit 1 fi -if $(! /bin/ping -c 1 euer.krebsco.de -W 5 &>/dev/null) ;then +if ! $(/bin/ping -c 1 euer.krebsco.de -W 5 &>/dev/null) ;then echo "Cant reach euer, check if your internet is working" exit 1 fi #parse options -while getopts "h4:t:o:n:s:m:u:" OPTION +while getopts "h4:6:s:x:m:j:t:o:n:u:l:" OPTION do case $OPTION in h) @@ -98,8 +148,25 @@ do ;; 4) IP4=$OPTARG - RAND=0 - if ! check_ip_valid4 $IP4; then echo "ip is invalid" && exit 1; fi + RAND4=0 + if ! check_ip_valid4 $IP4; then echo "ipv4 is invalid" && exit 1; fi + ;; + 6) + IP6=$OPTARG + RAND6=0 + if ! check_ip_valid6 $IP6; then echo "ipv6 is invalid" && exit 1; fi + ;; + s) + SUBNET4=$OPTARG + ;; + x) + SUBNET6=$OPTARG + ;; + m) + MASK4=$OPTARG + ;; + j) + MASK6=$OPTARG ;; t) TEMPDIR=$OPTARG @@ -110,12 +177,6 @@ do n) NETNAME=$OPTARG ;; - s) - SUBNET4=$OPTARG - ;; - m) - MASK4=$OPTARG - ;; u) URL=$OPTARG if $(! curl -s --head $URL | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null); then @@ -123,10 +184,22 @@ do exit 1 fi ;; + l) + OS=$OPTARG + if ! [ "$(echo $OS | awk -F"." ' $0 ~ /^[0-2]$/' )" == $OS ]; then + echo "invalid input for OS" + exit 1 + fi + ;; + r) + ADDR=$OPTARG + ;; esac done +#generate full subnet information for v4 + #test if tinc directory already exists if test -e /etc/tinc/$NETNAME; then echo "tinc config directory /etc/tinc/$NETNAME does already exist. (backup and) delete config directory and restart" @@ -138,9 +211,10 @@ mkdir -p $TEMPDIR/hosts curl euer.krebsco.de/retiolum/hosts.tar.gz | tar zx -C $TEMPDIR/hosts/ #check for free ip +#version 4 until check_ip_taken $IP4; do - if [ $RAND -eq 1 ]; then - IP4="10.243.$((RANDOM%255)).$((RANDOM%255))" + if [ $RAND4 -eq 1 ]; then + IP4="$SUBNET4.$((RANDOM%255)).$((RANDOM%255))" else printf 'choose new ip: ' read IP4 @@ -151,8 +225,97 @@ until check_ip_taken $IP4; do fi done +#version 6 +until check_ip_taken $IP6; do + if [ $RAND6 -eq 1 ]; then + IP6="$SUBNET6$(openssl rand -hex 14 | sed 's/..../:&/g')" #todo: generate ip length from hostmask + else + printf 'ip taken, choose new ip: ' + + read IP6 + while ! check_ip_valid6 $IP6; do + printf 'the ip is invalid, retard, choose a valid ip: ' + read IP6 + done + fi +done + + #check for free hostname -check_hostname $HOSTN +get_hostname $HOSTN -echo "your ip is $IP4" +#check for OS +if [ $OS -eq 0 ]; then + echo $OS + find_os +fi + +#create the configs +mkdir -p /etc/tinc/$NETNAME +cd /etc/tinc/$NETNAME + +mv $TEMPDIR/hosts ./ + +echo "Subnet = $IP4" > hosts/$HOSTN +echo "Subnet = $IP6" >> hosts/$HOSTN + +cat>tinc.conf</dev/null; then + echo 'dirname="`dirname "$0"`"' > tinc-up + echo '' >> tinc-up + echo 'conf=$dirname/tinc.conf' >> tinc-up + echo '' >> tinc-up + echo 'name=$(sed -n "s|^ *Name *= *\([^ ]*\) *$|\1|p " $conf)' >> tinc-up + echo '' >> tinc-up + echo 'host=$dirname/hosts/$name' >> tinc-up + echo '' >> tinc-up + echo 'ip link set $INTERFACE up' >> tinc-up + echo '' >> tinc-up + echo "addr4=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET4[.][^ ]*\\) *$|\\1|p\" \$host)" >> tinc-up + echo 'ip -4 addr add $addr4 dev $INTERFACE' >> tinc-up + echo "ip -4 route add $FULLSUBNET/$MASK4 dev \$INTERFACE" >> tinc-up + echo '' >> tinc-up + echo "addr6=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET6[:][^ ]*\\) *$|\\1|p\" \$host)" >> tinc-up + echo 'ip -6 addr add $addr6 dev $INTERFACE' >> tinc-up + echo "ip -6 route add $SUBNET6::/$MASK6 dev \$INTERFACE" >> tinc-up +else + echo 'dirname="`dirname "$0"`"' > tinc-up + echo '' >> tinc-up + echo 'conf=$dirname/tinc.conf' >> tinc-up + echo '' >> tinc-up + echo 'name=$(sed -n "s|^ *Name *= *\([^ ]*\) *$|\1|p " $conf)' >> tinc-up + echo '' >> tinc-up + echo 'host=$dirname/hosts/$name' >> tinc-up + echo '' >> tinc-up + echo "addr4=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET4[.][^ ]*\\) *$|\\1|p\" \$host)" >> tinc-up + echo 'ifconfig $INTERFACE $addr4' >> tinc-up + echo "route add -net $FULLSUBNET netmask $RETARDEDMASK dev $INTERFACE " >> tinc-up +fi + +chmod +x tinc-up +chown -R root:root . + +if which tincctl&>/dev/null; then + +fi + +echo "your ipv4 is $IP4" +echo "your ipv6 is $IP6" echo "your hostname is $HOSTN" +echo "your OS is $OS" + -- cgit v1.2.3 From 8e36e9942498b821ed3825d5f3b631e27aa4d265 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Sun, 9 Dec 2012 16:29:26 +0100 Subject: now working --- retiolum/scripts/tinc_setup/new_install.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 52bb4ddb..dcbb2670 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -116,6 +116,10 @@ RAND6=1 URL=euer.krebsco.de/retiolum/hosts.tar.gz OS=0 +IRCCHANNEL="#krebsco" +IRCSERVER="irc.freenode.net" +IRCPORT=6667 + #check if everything is installed if ! which tincd&>/dev/null; then echo "Please install tinc" @@ -307,15 +311,25 @@ else echo "route add -net $FULLSUBNET netmask $RETARDEDMASK dev $INTERFACE " >> tinc-up fi +#fix permissions chmod +x tinc-up chown -R root:root . +#generate keys with tinc if which tincctl&>/dev/null; then - + yes | tincctl -n $NETNAME generate-keys + cat rsa_key.pub >> hosts/$HOSTN +else + yes | tincd -n $NETNAME -K fi -echo "your ipv4 is $IP4" -echo "your ipv6 is $IP6" -echo "your hostname is $HOSTN" -echo "your OS is $OS" +#write to irc-channel +NICK="${HOSTN}_$((RANDOM%666))" + +( echo "NICK $NICK"; + echo "USER $NICK $IRCSERVER bla : $NICK"; + echo "JOIN $IRCCHANNEL"; + sleep 23; + sed "s/^\(.*\)/PRIVMSG $IRCCHANNEL : \1/" hosts/$HOSTN; + sleep 5; ) | telnet $IRCSERVER $IRCPORT -- cgit v1.2.3 From 1fbaa63834a649cf9c96aac9dca1bc566196d64b Mon Sep 17 00:00:00 2001 From: Lassulus Date: Sun, 9 Dec 2012 19:13:59 +0100 Subject: added variable stuff --- retiolum/scripts/tinc_setup/new_install.sh | 49 +++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index dcbb2670..3afae31a 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -104,21 +104,40 @@ find_os() fi } -SUBNET4=10.243 -SUBNET6=42 -TEMPDIR=/tmp/tinc-install-fu -HOSTN=$(hostname) -NETNAME=retiolum -MASK4=16 -MASK6=16 -RAND4=1 -RAND6=1 -URL=euer.krebsco.de/retiolum/hosts.tar.gz -OS=0 - -IRCCHANNEL="#krebsco" -IRCSERVER="irc.freenode.net" -IRCPORT=6667 +SUBNET4=${SUBNET4:-10.243} +SUBNET6=${SUBNET6:-42} +TEMPDIR=${TEMPDIR:-/tmp/tinc-install-fu} +HOSTN=${HOSTN:-$(hostname)} +NETNAME=${NETNAME:-retiolum} +MASK4=${MASK4:-16} +MASK6=${MASK6:-16} +URL=${URL:-euer.krebsco.de/retiolum/hosts.tar.gz} + +IRCCHANNEL=${IRCCHANNEL:-"#krebsco"} +IRCSERVER=${IRCSERVER:-"irc.freenode.net"} +IRCPORT=${IRCPORT:-6667} + +OS=${OS:-0} + +IP4=${IP4:-0} +IP6=${IP6:-0} + +RAND4=0 +RAND6=0 + +if [ $IP4 -eq 0 ]; then + RAND4=1 +elif ! check_ip_valid4 $IP4; then + echo 'ip4 is invalid' + exit 1 +fi +if [ $IP6 -eq 0 ]; then + RAND6=1 +elif ! check_ip_valid6 $IP6; then + echo 'ip6 is invalid' + exit 1 +fi + #check if everything is installed if ! which tincd&>/dev/null; then -- cgit v1.2.3 From c12143b68c9904a99e5e18f30db71fd4660733fd Mon Sep 17 00:00:00 2001 From: Lassulus Date: Sun, 9 Dec 2012 19:29:18 +0100 Subject: fixed sudo env --- retiolum/scripts/tinc_setup/new_install.sh | 45 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 3afae31a..bbf4475e 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -3,10 +3,32 @@ #get sudo if test "${nosudo-false}" != true -a `id -u` != 0; then echo "we're going sudo..." >&2 - exec sudo "$0" "$@" + exec sudo -E "$0" "$@" exit 23 # go to hell fi +# +SUBNET4=${SUBNET4:-10.243} +SUBNET6=${SUBNET6:-42} +TEMPDIR=${TEMPDIR:-/tmp/tinc-install-fu} +HOSTN=${HOSTN:-$(hostname)} +NETNAME=${NETNAME:-retiolum} +MASK4=${MASK4:-16} +MASK6=${MASK6:-16} +URL=${URL:-euer.krebsco.de/retiolum/hosts.tar.gz} + +IRCCHANNEL=${IRCCHANNEL:-"#krebsco"} +IRCSERVER=${IRCSERVER:-"irc.freenode.net"} +IRCPORT=${IRCPORT:-6667} + +OS=${OS:-0} + +IP4=${IP4:-0} +IP6=${IP6:-0} + +RAND4=0 +RAND6=0 + usage() { cat << EOF @@ -104,27 +126,6 @@ find_os() fi } -SUBNET4=${SUBNET4:-10.243} -SUBNET6=${SUBNET6:-42} -TEMPDIR=${TEMPDIR:-/tmp/tinc-install-fu} -HOSTN=${HOSTN:-$(hostname)} -NETNAME=${NETNAME:-retiolum} -MASK4=${MASK4:-16} -MASK6=${MASK6:-16} -URL=${URL:-euer.krebsco.de/retiolum/hosts.tar.gz} - -IRCCHANNEL=${IRCCHANNEL:-"#krebsco"} -IRCSERVER=${IRCSERVER:-"irc.freenode.net"} -IRCPORT=${IRCPORT:-6667} - -OS=${OS:-0} - -IP4=${IP4:-0} -IP6=${IP6:-0} - -RAND4=0 -RAND6=0 - if [ $IP4 -eq 0 ]; then RAND4=1 elif ! check_ip_valid4 $IP4; then -- cgit v1.2.3 From 88b6956f32ed74be82a401a7716398a622a9042f Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 10 Dec 2012 01:12:54 +0100 Subject: more checks, fixed loop --- retiolum/scripts/tinc_setup/new_install.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index bbf4475e..45316796 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -61,7 +61,7 @@ host2subnet() result=$(($(($((1 << $1)) - 1)) << $((32 - $1)))) byte="" - for ((i=0;i<3;i+=1)); do + for i in {0..2}; do byte=.$(($result % 256))$byte result=$(($result / 256)) done @@ -151,11 +151,26 @@ if ! which awk&>/dev/null; then exit 1 fi -if ! which curl&>/dev/null; then - echo "Please install curl" +if ! which hostname&>/dev/null; then + echo "Please install hostname" exit 1 fi +if ! which openssl&>/dev/null; then + echo "Please install openssl" + exit 1 +fi + +if ! which curl&>/dev/null; then + if ! which wget&>/dev/null; then + echo "Please install curl or wget" + exit 1 + else + LOADER='wget -O-' +else + LOADER=curl +fi + if ! $(/bin/ping -c 1 euer.krebsco.de -W 5 &>/dev/null) ;then echo "Cant reach euer, check if your internet is working" exit 1 @@ -232,7 +247,7 @@ fi #get tinc-hostfiles mkdir -p $TEMPDIR/hosts -curl euer.krebsco.de/retiolum/hosts.tar.gz | tar zx -C $TEMPDIR/hosts/ +$LOADER euer.krebsco.de/retiolum/hosts.tar.gz | tar zx -C $TEMPDIR/hosts/ #check for free ip #version 4 -- cgit v1.2.3 From 7fc8f37b2cd2203881deb27b6a757f6d82eeb118 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 10 Dec 2012 01:16:04 +0100 Subject: fixed typo --- retiolum/scripts/tinc_setup/new_install.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 45316796..94319bfd 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -167,6 +167,7 @@ if ! which curl&>/dev/null; then exit 1 else LOADER='wget -O-' + fi else LOADER=curl fi -- cgit v1.2.3 From bf7e7d7db64bb7c8827cb176d2ac6b8dd06741fc Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 10 Dec 2012 01:35:11 +0100 Subject: changed random source --- retiolum/scripts/tinc_setup/new_install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 94319bfd..049eeca5 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -254,7 +254,7 @@ $LOADER euer.krebsco.de/retiolum/hosts.tar.gz | tar zx -C $TEMPDIR/hosts/ #version 4 until check_ip_taken $IP4; do if [ $RAND4 -eq 1 ]; then - IP4="$SUBNET4.$((RANDOM%255)).$((RANDOM%255))" + IP4="$SUBNET4.$(( $(head /dev/urandom | tr -dc "123456789" | head -c3) %255)).$(( $(head /dev/urandom | tr -dc "123456789" | head -c3) %255))" else printf 'choose new ip: ' read IP4 @@ -360,7 +360,7 @@ else fi #write to irc-channel -NICK="${HOSTN}_$((RANDOM%666))" +NICK="${HOSTN}_$(head /dev/urandom | tr -dc "0123456789" | head -c3)" ( echo "NICK $NICK"; echo "USER $NICK $IRCSERVER bla : $NICK"; -- cgit v1.2.3 From bce2e977ba603a3fa27d77827263a99d2913482e Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 10 Dec 2012 01:48:25 +0100 Subject: removed openssl dependency --- retiolum/scripts/tinc_setup/new_install.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 049eeca5..275805a7 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -156,11 +156,6 @@ if ! which hostname&>/dev/null; then exit 1 fi -if ! which openssl&>/dev/null; then - echo "Please install openssl" - exit 1 -fi - if ! which curl&>/dev/null; then if ! which wget&>/dev/null; then echo "Please install curl or wget" @@ -268,7 +263,7 @@ done #version 6 until check_ip_taken $IP6; do if [ $RAND6 -eq 1 ]; then - IP6="$SUBNET6$(openssl rand -hex 14 | sed 's/..../:&/g')" #todo: generate ip length from hostmask + IP6="$SUBNET6$(head /dev/urandom | tr -dc "0123456789abcdef" | head -c28 | sed 's/..../:&/g')" #todo: generate ip length from hostmask else printf 'ip taken, choose new ip: ' -- cgit v1.2.3 From 8253b111a9d61ff9763bf6bf588c852a5a948c84 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 10 Dec 2012 01:58:30 +0100 Subject: added variable IPv6 length --- retiolum/scripts/tinc_setup/new_install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 275805a7..cc9746b5 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -263,7 +263,9 @@ done #version 6 until check_ip_taken $IP6; do if [ $RAND6 -eq 1 ]; then - IP6="$SUBNET6$(head /dev/urandom | tr -dc "0123456789abcdef" | head -c28 | sed 's/..../:&/g')" #todo: generate ip length from hostmask + NETLENGTH=$(expr $(expr 128 - $MASK6) / 4) + echo $NETLENGTH + IP6="$SUBNET6$(head /dev/urandom | tr -dc "0123456789abcdef" | head -c$NETLENGTH | sed 's/..../:&/g')" #todo: generate ip length from hostmask else printf 'ip taken, choose new ip: ' -- cgit v1.2.3 From 5390ca9c00a2a49b452329da9c1dc6d28cd49a6d Mon Sep 17 00:00:00 2001 From: Lassulus Date: Mon, 10 Dec 2012 02:01:05 +0100 Subject: removed debug output --- retiolum/scripts/tinc_setup/new_install.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index cc9746b5..e5f99f71 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -264,7 +264,6 @@ done until check_ip_taken $IP6; do if [ $RAND6 -eq 1 ]; then NETLENGTH=$(expr $(expr 128 - $MASK6) / 4) - echo $NETLENGTH IP6="$SUBNET6$(head /dev/urandom | tr -dc "0123456789abcdef" | head -c$NETLENGTH | sed 's/..../:&/g')" #todo: generate ip length from hostmask else printf 'ip taken, choose new ip: ' -- cgit v1.2.3 From 9ef1a44576b52a84b8f1b5fa2752253f0432f486 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 12 Dec 2012 02:13:23 +0100 Subject: added some stuff --- retiolum/scripts/tinc_setup/new_install.sh | 48 +++++++++++++++++++----------- 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index e5f99f71..1885d681 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -1,4 +1,4 @@ -#!/bin/sh + #get sudo if test "${nosudo-false}" != true -a `id -u` != 0; then @@ -10,8 +10,9 @@ fi # SUBNET4=${SUBNET4:-10.243} SUBNET6=${SUBNET6:-42} -TEMPDIR=${TEMPDIR:-/tmp/tinc-install-fu} -HOSTN=${HOSTN:-$(hostname)} +TEMPDIR=${TEMPDIR:-auto} +SYSHOSTN=${HOSTNAME:-$(hostname)} +HOSTN=${HOSTN:-$SYSHOSTN} NETNAME=${NETNAME:-retiolum} MASK4=${MASK4:-16} MASK6=${MASK6:-16} @@ -48,7 +49,7 @@ Options: -o \$HOST Choose another Hostname, default is your system hostname -n \$NET Choose another tincd netname,this also specifies the path to your tinc config, default is retiolum -u \$URL specify another hostsfiles.tar.gz url, default is euer.krebsco.de/retiolum/hosts.tar.gz - -l \$OS specify an OS, numeric parameter.0=Automatic 1=ArchLinux 2=OpenWRT, disables automatic OS-finding, default is 0 + -l \$OS specify an OS, numeric parameter.0=Automatic 1=Linux 2=Android, disables automatic OS-finding, default is 0 -r \$ADDR give the node an reachable remote address, ipv4 or dns EOF } @@ -119,9 +120,9 @@ get_hostname() #os autodetection find_os() { - if grep -q "Arch Linux" /etc/*release; then + if grep -qe '.*' /etc/*release 2>/dev/null; then OS=1 - elif grep -q "OpenWrt" /etc/*release; then + elif which getprop&>/dev/null; then OS=2 fi } @@ -139,23 +140,17 @@ elif ! check_ip_valid6 $IP6; then exit 1 fi - -#check if everything is installed -if ! which tincd&>/dev/null; then - echo "Please install tinc" - exit 1 +#find OS +if [ $OS -eq 0 ]; then + find_os fi +#check if everything is installed if ! which awk&>/dev/null; then echo "Please install awk" exit 1 fi -if ! which hostname&>/dev/null; then - echo "Please install hostname" - exit 1 -fi - if ! which curl&>/dev/null; then if ! which wget&>/dev/null; then echo "Please install curl or wget" @@ -233,6 +228,25 @@ do esac done +#check if everything is installed +if [ $OS -eq 2 ]; then + if ! test -e /data/data/org.poirsouille.tinc_gui/files/tincd; then + echo "Please install tinc-gui" + exit 1 + else + TINCBIN=/data/data/org.poirsouille.tinc_gui/files/tincd + if [ $TEMPDIR == 'auto' ]; then TEMPDIR=/data/secure/data ;fi + fi +else + if ! which tincd&>/dev/null; then + echo "Please install tinc" + exit 1 + else + TINCBIN=tincd + if [ $TEMPDIR == 'auto' ]; then TEMPDIR=/mnt/tinc-install-fu ;fi + fi +fi + #generate full subnet information for v4 #test if tinc directory already exists @@ -352,7 +366,7 @@ if which tincctl&>/dev/null; then yes | tincctl -n $NETNAME generate-keys cat rsa_key.pub >> hosts/$HOSTN else - yes | tincd -n $NETNAME -K + yes | $TINCBIN -n $NETNAME -K fi #write to irc-channel -- cgit v1.2.3 From 5d253ae8e4b712c95ff2b7c33457dad263928de0 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 12 Dec 2012 03:54:15 +0100 Subject: fixing for android --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 1885d681..aea97e90 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -162,7 +162,7 @@ else LOADER=curl fi -if ! $(/bin/ping -c 1 euer.krebsco.de -W 5 &>/dev/null) ;then +if ! $(ping -c 1 euer.krebsco.de -W 5 1>/dev/null) ;then echo "Cant reach euer, check if your internet is working" exit 1 fi -- cgit v1.2.3 From dcac6e109c6b8ec56c5106d11dad052b9ce34aca Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 12 Dec 2012 03:57:03 +0100 Subject: fixed find_os not executing --- retiolum/scripts/tinc_setup/new_install.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index aea97e90..1f750fca 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -228,6 +228,12 @@ do esac done +#check for OS +if [ $OS -eq 0 ]; then + echo $OS + find_os +fi + #check if everything is installed if [ $OS -eq 2 ]; then if ! test -e /data/data/org.poirsouille.tinc_gui/files/tincd; then @@ -294,11 +300,6 @@ done #check for free hostname get_hostname $HOSTN -#check for OS -if [ $OS -eq 0 ]; then - echo $OS - find_os -fi #create the configs mkdir -p /etc/tinc/$NETNAME -- cgit v1.2.3 From 3e14311b99f0cb6a304314fae02dab8a0bfb9eb6 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 12 Dec 2012 04:05:01 +0100 Subject: added #!/bin/sh --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 1f750fca..c6a572d2 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -1,4 +1,4 @@ - +#!/bin/sh #get sudo if test "${nosudo-false}" != true -a `id -u` != 0; then -- cgit v1.2.3 From 7bea72bbc15bbc0ae20726f928a64953fca547a4 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 12 Dec 2012 04:11:07 +0100 Subject: added different directory for android --- retiolum/scripts/tinc_setup/new_install.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index c6a572d2..7a62e13b 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -302,8 +302,13 @@ get_hostname $HOSTN #create the configs -mkdir -p /etc/tinc/$NETNAME -cd /etc/tinc/$NETNAME +if [ $OS -eq 2 ];then + mkdir -p /usr/local/etc/tinc/$NETNAME + cd /usr/local/etc/tinc/$NETNAME +else + mkdir -p /etc/tinc/$NETNAME + cd /etc/tinc/$NETNAME +fi mv $TEMPDIR/hosts ./ -- cgit v1.2.3 From 507a7e6cad2316938efee372e51c1d042a807495 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 12 Dec 2012 05:07:32 +0100 Subject: more android fixes --- retiolum/scripts/tinc_setup/new_install.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 7a62e13b..832fcd91 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -256,10 +256,16 @@ fi #generate full subnet information for v4 #test if tinc directory already exists -if test -e /etc/tinc/$NETNAME; then - echo "tinc config directory /etc/tinc/$NETNAME does already exist. (backup and) delete config directory and restart" - exit 1 -fi +if [ $OS -eq 2 ]; then + if test -e /usr/local/etc/tinc/$NETNAME; then + echo "tinc config directory /usr/local/etc/tinc/$NETNAME does already exist. (backup and) delete config directory and restart" + exit 1 + fi +else + if test -e /etc/tinc/$NETNAME; then + echo "tinc config directory /etc/tinc/$NETNAME does already exist. (backup and) delete config directory and restart" + exit 1 + fi #get tinc-hostfiles mkdir -p $TEMPDIR/hosts @@ -311,6 +317,7 @@ else fi mv $TEMPDIR/hosts ./ +rm -r $TEMDIR echo "Subnet = $IP4" > hosts/$HOSTN echo "Subnet = $IP6" >> hosts/$HOSTN -- cgit v1.2.3 From 883051176857575df7ec539da87117c0d24ab5a8 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 12 Dec 2012 05:09:24 +0100 Subject: forgot fi --- retiolum/scripts/tinc_setup/new_install.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 832fcd91..5f09bb15 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -266,6 +266,7 @@ else echo "tinc config directory /etc/tinc/$NETNAME does already exist. (backup and) delete config directory and restart" exit 1 fi +fi #get tinc-hostfiles mkdir -p $TEMPDIR/hosts -- cgit v1.2.3 From c8e87631c19d0eda9875e7d91c57fd9aef90863a Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 12 Dec 2012 05:13:06 +0100 Subject: fixed some more borken stuff --- retiolum/scripts/tinc_setup/new_install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 5f09bb15..0a2c3201 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -249,7 +249,7 @@ else exit 1 else TINCBIN=tincd - if [ $TEMPDIR == 'auto' ]; then TEMPDIR=/mnt/tinc-install-fu ;fi + if [ $TEMPDIR == 'auto' ]; then TEMPDIR=/tmp/tinc-install-fu ;fi fi fi @@ -318,7 +318,7 @@ else fi mv $TEMPDIR/hosts ./ -rm -r $TEMDIR +rm -r $TEMPDIR echo "Subnet = $IP4" > hosts/$HOSTN echo "Subnet = $IP6" >> hosts/$HOSTN -- cgit v1.2.3 From a8b2350b088245cdef0dfa0ede55f0354cb42e17 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Wed, 12 Dec 2012 05:21:11 +0100 Subject: added TINCDIR as possible value --- retiolum/scripts/tinc_setup/new_install.sh | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 0a2c3201..f686e34f 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -11,6 +11,7 @@ fi SUBNET4=${SUBNET4:-10.243} SUBNET6=${SUBNET6:-42} TEMPDIR=${TEMPDIR:-auto} +TINCDIR=${TINCDIR:-auto} SYSHOSTN=${HOSTNAME:-$(hostname)} HOSTN=${HOSTN:-$SYSHOSTN} NETNAME=${NETNAME:-retiolum} @@ -241,6 +242,7 @@ if [ $OS -eq 2 ]; then exit 1 else TINCBIN=/data/data/org.poirsouille.tinc_gui/files/tincd + if [ $TINCDIR == 'auto' ]; then TINCDIR=/usr/local/etc/tinc ;fi if [ $TEMPDIR == 'auto' ]; then TEMPDIR=/data/secure/data ;fi fi else @@ -249,6 +251,7 @@ else exit 1 else TINCBIN=tincd + if [ $TINCDIR == 'auto' ]; then TINCDIR=/etc/tinc ;fi if [ $TEMPDIR == 'auto' ]; then TEMPDIR=/tmp/tinc-install-fu ;fi fi fi @@ -256,16 +259,9 @@ fi #generate full subnet information for v4 #test if tinc directory already exists -if [ $OS -eq 2 ]; then - if test -e /usr/local/etc/tinc/$NETNAME; then - echo "tinc config directory /usr/local/etc/tinc/$NETNAME does already exist. (backup and) delete config directory and restart" - exit 1 - fi -else - if test -e /etc/tinc/$NETNAME; then - echo "tinc config directory /etc/tinc/$NETNAME does already exist. (backup and) delete config directory and restart" - exit 1 - fi +if test -e $TINCDIR/$NETNAME; then + echo "tinc config directory $TINCDIR/$NETNAME does already exist. (backup and) delete config directory and restart" + exit 1 fi #get tinc-hostfiles @@ -309,13 +305,8 @@ get_hostname $HOSTN #create the configs -if [ $OS -eq 2 ];then - mkdir -p /usr/local/etc/tinc/$NETNAME - cd /usr/local/etc/tinc/$NETNAME -else - mkdir -p /etc/tinc/$NETNAME - cd /etc/tinc/$NETNAME -fi +mkdir -p $TINCDIR/$NETNAME +cd $TINCDIR/$NETNAME mv $TEMPDIR/hosts ./ rm -r $TEMPDIR -- cgit v1.2.3 From 2e3888b44c2d8f7f5638d9824fd7f40fbeffe784 Mon Sep 17 00:00:00 2001 From: euer Date: Thu, 20 Dec 2012 02:38:25 +0100 Subject: tinc_setup/bootstrap.sh -> /boot/painload.sh --- retiolum/scripts/tinc_setup/bootstrap.sh | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 retiolum/scripts/tinc_setup/bootstrap.sh (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/bootstrap.sh b/retiolum/scripts/tinc_setup/bootstrap.sh deleted file mode 100644 index 32919e7d..00000000 --- a/retiolum/scripts/tinc_setup/bootstrap.sh +++ /dev/null @@ -1,11 +0,0 @@ -if [ ! `id -u` -eq "0" ] -then - echo "not root, trying sudo" - exec sudo "$0" "$@" -fi - -mkdir -p /etc/tinc/retiolum/ -git clone git://github.com/miefda/retiolum.git /etc/tinc/retiolum/hosts -cd /etc/tinc/retiolum/hosts/.scripts - -echo "use the build script of your choice from /etc/tinc/retiolum/hosts/.scripts" -- cgit v1.2.3 From a936a43ce4cb24b7dd13b8e45238861321cd8d38 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Thu, 20 Dec 2012 02:44:50 +0100 Subject: removed debug uouput --- retiolum/scripts/tinc_setup/new_install.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index f686e34f..4de20223 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -231,7 +231,6 @@ done #check for OS if [ $OS -eq 0 ]; then - echo $OS find_os fi -- cgit v1.2.3 From 19f1a122881503ca1266191496b639db3924a2de Mon Sep 17 00:00:00 2001 From: Lassulus Date: Fri, 21 Dec 2012 21:53:44 +0100 Subject: added supernodes only for openwrt --- retiolum/scripts/tinc_setup/new_install.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 4de20223..adc355bd 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -121,10 +121,12 @@ get_hostname() #os autodetection find_os() { - if grep -qe '.*' /etc/*release 2>/dev/null; then + if grep -qei 'linux' /etc/*release 2>/dev/null; then OS=1 elif which getprop&>/dev/null; then OS=2 + elif grep -qe 'OpenWrt' /etc/*release 2>/dev/null; then + OS=3 fi } @@ -307,7 +309,12 @@ get_hostname $HOSTN mkdir -p $TINCDIR/$NETNAME cd $TINCDIR/$NETNAME -mv $TEMPDIR/hosts ./ +if [ $OS -eq 3 ]; then + $LOADER http://euer.krebsco.de/retiolum/supernodes.tar.gz | tar xz -C $TINCDIR/$NETNAME/hosts/ +else + mv $TEMPDIR/hosts ./ +fi + rm -r $TEMPDIR echo "Subnet = $IP4" > hosts/$HOSTN @@ -322,6 +329,7 @@ LocalDiscovery = yes AutoConnect = 3 #ConnectTos +ConnectTo = supernode ConnectTo = euer ConnectTo = pico EOF -- cgit v1.2.3 From 668526a3082e9d67a62193cc8577da4940cc1dfe Mon Sep 17 00:00:00 2001 From: Lassulus Date: Fri, 21 Dec 2012 22:19:03 +0100 Subject: fixed OS detections --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index adc355bd..15c4fefb 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -121,7 +121,7 @@ get_hostname() #os autodetection find_os() { - if grep -qei 'linux' /etc/*release 2>/dev/null; then + if grep -qe 'Linux' /etc/*release 2>/dev/null; then OS=1 elif which getprop&>/dev/null; then OS=2 -- cgit v1.2.3 From 62b9254d0a3dc4d3100840ac7b21b6c60d730834 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Fri, 21 Dec 2012 22:21:49 +0100 Subject: fixed bugs on OpenWrt --- retiolum/scripts/tinc_setup/new_install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 15c4fefb..1227912e 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -310,7 +310,8 @@ mkdir -p $TINCDIR/$NETNAME cd $TINCDIR/$NETNAME if [ $OS -eq 3 ]; then - $LOADER http://euer.krebsco.de/retiolum/supernodes.tar.gz | tar xz -C $TINCDIR/$NETNAME/hosts/ + mkdir hosts + $LOADER http://euer.krebsco.de/retiolum/supernodes.tar.gz | tar xz -C hosts/ else mv $TEMPDIR/hosts ./ fi -- cgit v1.2.3 From b298094174d3e06045c98bff441206a806896cfb Mon Sep 17 00:00:00 2001 From: EUcancER Date: Thu, 27 Dec 2012 19:05:55 +0100 Subject: fix new installer, tested with debian install --- retiolum/scripts/tinc_setup/new_install.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 1227912e..994e16fc 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -60,7 +60,6 @@ host2subnet() { NEEDDOTSINSUB=$(expr 3 - $(echo $SUBNET4 | sed 's/[0-9]*//g')) FULLSUBNET=$(echo $SUBNET4$(eval "printf '.0'%.0s {1..${#NEEDDOTSINSUB}}"s)) - result=$(($(($((1 << $1)) - 1)) << $((32 - $1)))) byte="" for i in {0..2}; do @@ -121,9 +120,9 @@ get_hostname() #os autodetection find_os() { - if grep -qe 'Linux' /etc/*release 2>/dev/null; then + if grep -qe 'Linux' /etc/*release 2>/dev/null || grep -qe 'Linux' /etc/issue ; then OS=1 - elif which getprop&>/dev/null; then + elif type getprop >/dev/null; then OS=2 elif grep -qe 'OpenWrt' /etc/*release 2>/dev/null; then OS=3 @@ -149,13 +148,13 @@ if [ $OS -eq 0 ]; then fi #check if everything is installed -if ! which awk&>/dev/null; then +if ! type awk >/dev/null; then echo "Please install awk" exit 1 fi -if ! which curl&>/dev/null; then - if ! which wget&>/dev/null; then +if ! type curl >/dev/null; then + if ! type wget >/dev/null; then echo "Please install curl or wget" exit 1 else @@ -243,17 +242,17 @@ if [ $OS -eq 2 ]; then exit 1 else TINCBIN=/data/data/org.poirsouille.tinc_gui/files/tincd - if [ $TINCDIR == 'auto' ]; then TINCDIR=/usr/local/etc/tinc ;fi - if [ $TEMPDIR == 'auto' ]; then TEMPDIR=/data/secure/data ;fi + if [ $TINCDIR = 'auto' ]; then TINCDIR=/usr/local/etc/tinc ;fi + if [ $TEMPDIR = 'auto' ]; then TEMPDIR=/data/secure/data ;fi fi else - if ! which tincd&>/dev/null; then + if ! type tincd >/dev/null; then echo "Please install tinc" exit 1 else TINCBIN=tincd - if [ $TINCDIR == 'auto' ]; then TINCDIR=/etc/tinc ;fi - if [ $TEMPDIR == 'auto' ]; then TEMPDIR=/tmp/tinc-install-fu ;fi + if [ $TINCDIR = 'auto' ]; then TINCDIR=/etc/tinc ;fi + if [ $TEMPDIR = 'auto' ]; then TEMPDIR=/tmp/tinc-install-fu ;fi fi fi @@ -338,7 +337,7 @@ EOF host2subnet $MASK4 #check if ip is installed -if which ip&>/dev/null; then +if type ip >/dev/null; then echo 'dirname="`dirname "$0"`"' > tinc-up echo '' >> tinc-up echo 'conf=$dirname/tinc.conf' >> tinc-up @@ -375,7 +374,7 @@ chmod +x tinc-up chown -R root:root . #generate keys with tinc -if which tincctl&>/dev/null; then +if type tincctl >/dev/null; then yes | tincctl -n $NETNAME generate-keys cat rsa_key.pub >> hosts/$HOSTN else -- cgit v1.2.3 From 40d9d06aeb49c900aec886b0249596817ac828e4 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Thu, 27 Dec 2012 22:46:05 +0100 Subject: fixed url --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 1227912e..e83bcbc7 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -17,7 +17,7 @@ HOSTN=${HOSTN:-$SYSHOSTN} NETNAME=${NETNAME:-retiolum} MASK4=${MASK4:-16} MASK6=${MASK6:-16} -URL=${URL:-euer.krebsco.de/retiolum/hosts.tar.gz} +URL=${URL:-http://euer.krebsco.de/retiolum/hosts.tar.gz} IRCCHANNEL=${IRCCHANNEL:-"#krebsco"} IRCSERVER=${IRCSERVER:-"irc.freenode.net"} -- cgit v1.2.3 From a6f33dfc31f64a3f8db4e80587f1fad82dcbebbe Mon Sep 17 00:00:00 2001 From: EUcancER Date: Thu, 27 Dec 2012 23:03:20 +0100 Subject: fix problems in new installer --- retiolum/scripts/tinc_setup/new_install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 994e16fc..1555858f 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -6,7 +6,7 @@ if test "${nosudo-false}" != true -a `id -u` != 0; then exec sudo -E "$0" "$@" exit 23 # go to hell fi - +set -euf # SUBNET4=${SUBNET4:-10.243} SUBNET6=${SUBNET6:-42} @@ -17,7 +17,7 @@ HOSTN=${HOSTN:-$SYSHOSTN} NETNAME=${NETNAME:-retiolum} MASK4=${MASK4:-16} MASK6=${MASK6:-16} -URL=${URL:-euer.krebsco.de/retiolum/hosts.tar.gz} +URL=${URL:-http://euer.krebsco.de/retiolum/hosts.tar.gz} IRCCHANNEL=${IRCCHANNEL:-"#krebsco"} IRCSERVER=${IRCSERVER:-"irc.freenode.net"} @@ -49,7 +49,7 @@ Options: -t \$DIR Choose another Temporary directory, default is /tmp/tinc-install-fu -o \$HOST Choose another Hostname, default is your system hostname -n \$NET Choose another tincd netname,this also specifies the path to your tinc config, default is retiolum - -u \$URL specify another hostsfiles.tar.gz url, default is euer.krebsco.de/retiolum/hosts.tar.gz + -u \$URL specify another hostsfiles.tar.gz url, default is http://euer.krebsco.de/retiolum/hosts.tar.gz -l \$OS specify an OS, numeric parameter.0=Automatic 1=Linux 2=Android, disables automatic OS-finding, default is 0 -r \$ADDR give the node an reachable remote address, ipv4 or dns EOF @@ -266,7 +266,7 @@ fi #get tinc-hostfiles mkdir -p $TEMPDIR/hosts -$LOADER euer.krebsco.de/retiolum/hosts.tar.gz | tar zx -C $TEMPDIR/hosts/ +$LOADER $URL | tar zx -C $TEMPDIR/hosts/ #check for free ip #version 4 @@ -315,7 +315,7 @@ else mv $TEMPDIR/hosts ./ fi -rm -r $TEMPDIR +rm -r $TEMPDIR || echo "$TEMPDIR does not exist, skipping removal" echo "Subnet = $IP4" > hosts/$HOSTN echo "Subnet = $IP6" >> hosts/$HOSTN -- cgit v1.2.3 From 0080bb1059ad5402500c747d56c19a175604ddda Mon Sep 17 00:00:00 2001 From: Lassulus Date: Thu, 27 Dec 2012 23:08:20 +0100 Subject: fixed hostmask generation --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 41a1f73a..3f904871 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -58,7 +58,7 @@ EOF #convert hostmask to subnetmask only version 4 host2subnet() { - NEEDDOTSINSUB=$(expr 3 - $(echo $SUBNET4 | sed 's/[0-9]*//g')) + NEEDDOTSINSUB=$(expr 3 - $( echo $SUBNET4 | tr -C -d . | wc -c)) FULLSUBNET=$(echo $SUBNET4$(eval "printf '.0'%.0s {1..${#NEEDDOTSINSUB}}"s)) result=$(($(($((1 << $1)) - 1)) << $((32 - $1)))) byte="" -- cgit v1.2.3 From 5293a12d29879a295f12e28f70104dbd91bf1621 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Thu, 27 Dec 2012 23:14:10 +0100 Subject: added SURL parameter for supernodes.tar.gz url --- retiolum/scripts/tinc_setup/new_install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index b24a28a0..f4678c41 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -18,6 +18,7 @@ NETNAME=${NETNAME:-retiolum} MASK4=${MASK4:-16} MASK6=${MASK6:-16} URL=${URL:-http://euer.krebsco.de/retiolum/hosts.tar.gz} +SURL=${SURL:-http://euer.krebsco.de/retiolum/supernodes.tar.gz} IRCCHANNEL=${IRCCHANNEL:-"#krebsco"} IRCSERVER=${IRCSERVER:-"irc.freenode.net"} @@ -310,7 +311,7 @@ cd $TINCDIR/$NETNAME if [ $OS -eq 3 ]; then mkdir hosts - $LOADER http://euer.krebsco.de/retiolum/supernodes.tar.gz | tar xz -C hosts/ + $LOADER $SURL | tar xz -C hosts/ else mv $TEMPDIR/hosts ./ fi -- cgit v1.2.3 From 72be0c40f7bf594887364bf3dcb7774f99849b24 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Thu, 27 Dec 2012 23:26:50 +0100 Subject: fixed install bug --- retiolum/scripts/tinc_setup/new_install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index f4678c41..ad1a04ac 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -121,7 +121,7 @@ get_hostname() #os autodetection find_os() { - if grep -qe 'Linux' /etc/*release 2>/dev/null || grep -qe 'Linux' /etc/issue ; then + if grep -qe 'Linux' /etc/*release 2>/dev/null || grep -qe 'Linux' /etc/issue 2>/dev/null; then OS=1 elif type getprop >/dev/null; then OS=2 @@ -367,7 +367,7 @@ else echo '' >> tinc-up echo "addr4=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET4[.][^ ]*\\) *$|\\1|p\" \$host)" >> tinc-up echo 'ifconfig $INTERFACE $addr4' >> tinc-up - echo "route add -net $FULLSUBNET netmask $RETARDEDMASK dev $INTERFACE " >> tinc-up + echo "route add -net $FULLSUBNET netmask $RETARDEDMASK dev \$INTERFACE " >> tinc-up fi #fix permissions -- cgit v1.2.3 From c73b44e358627551dfb4835c5eb0620078e6e9fc Mon Sep 17 00:00:00 2001 From: EUcancER Date: Thu, 27 Dec 2012 23:46:27 +0100 Subject: tinc_installer: fix ip_finder, Random, others --- retiolum/scripts/tinc_setup/new_install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index b24a28a0..fadfa9f7 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -28,8 +28,8 @@ OS=${OS:-0} IP4=${IP4:-0} IP6=${IP6:-0} -RAND4=0 -RAND6=0 +RAND4=1 +RAND6=1 usage() { @@ -94,7 +94,7 @@ check_ip_valid6() #check if ip is taken function check_ip_taken() { - if grep -q -E "$1(#|/)" $TEMPDIR/hosts/* ;then + if grep -q -r -E "$1(#|/)" $TEMPDIR/hosts/ ;then return 1 else return 0 @@ -366,7 +366,7 @@ else echo '' >> tinc-up echo "addr4=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET4[.][^ ]*\\) *$|\\1|p\" \$host)" >> tinc-up echo 'ifconfig $INTERFACE $addr4' >> tinc-up - echo "route add -net $FULLSUBNET netmask $RETARDEDMASK dev $INTERFACE " >> tinc-up + echo "route add -net $FULLSUBNET netmask $RETARDEDMASK dev \$INTERFACE " >> tinc-up fi #fix permissions -- cgit v1.2.3 From d1c0f2ea597d4f043d9c4e7134c7a8f6bcbe9260 Mon Sep 17 00:00:00 2001 From: EUcancER Date: Fri, 28 Dec 2012 00:29:49 +0100 Subject: retiolum/install: enable shell-expansion until further notice, fallback for OS --- retiolum/scripts/tinc_setup/new_install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 0a49c983..90de1511 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -6,7 +6,7 @@ if test "${nosudo-false}" != true -a `id -u` != 0; then exec sudo -E "$0" "$@" exit 23 # go to hell fi -set -euf +set -eu # SUBNET4=${SUBNET4:-10.243} SUBNET6=${SUBNET6:-42} @@ -127,6 +127,9 @@ find_os() OS=2 elif grep -qe 'OpenWrt' /etc/*release 2>/dev/null; then OS=3 + else + echo "Cannot determine your operating system, falling back to Linux" + OS=1 fi } -- cgit v1.2.3 From 98f66c758c1a5eaaacd0cd8ad7ecb742d8adae2f Mon Sep 17 00:00:00 2001 From: Lassulus Date: Fri, 28 Dec 2012 01:27:41 +0100 Subject: fixed os detection, readded set -f --- retiolum/scripts/tinc_setup/new_install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 90de1511..579ebff9 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -6,7 +6,7 @@ if test "${nosudo-false}" != true -a `id -u` != 0; then exec sudo -E "$0" "$@" exit 23 # go to hell fi -set -eu +set -euf # SUBNET4=${SUBNET4:-10.243} SUBNET6=${SUBNET6:-42} @@ -125,7 +125,7 @@ find_os() OS=1 elif type getprop >/dev/null; then OS=2 - elif grep -qe 'OpenWrt' /etc/*release 2>/dev/null; then + elif test -e /etc/openwrt_release; then OS=3 else echo "Cannot determine your operating system, falling back to Linux" -- cgit v1.2.3 From 1aa5bf4c3c30c474c081bcb8d89a4f06fd3e6e86 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Fri, 28 Dec 2012 01:56:08 +0100 Subject: fixed netmask magic --- retiolum/scripts/tinc_setup/new_install.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 579ebff9..82878673 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -17,6 +17,7 @@ HOSTN=${HOSTN:-$SYSHOSTN} NETNAME=${NETNAME:-retiolum} MASK4=${MASK4:-16} MASK6=${MASK6:-16} +RMASK=${RMASK:-255.255.0.0} URL=${URL:-http://euer.krebsco.de/retiolum/hosts.tar.gz} SURL=${SURL:-http://euer.krebsco.de/retiolum/supernodes.tar.gz} @@ -60,14 +61,13 @@ EOF host2subnet() { NEEDDOTSINSUB=$(expr 3 - $( echo $SUBNET4 | tr -C -d . | wc -c)) - FULLSUBNET=$(echo $SUBNET4$(eval "printf '.0'%.0s {1..${#NEEDDOTSINSUB}}"s)) - result=$(($(($((1 << $1)) - 1)) << $((32 - $1)))) - byte="" - for i in {0..2}; do - byte=.$(($result % 256))$byte - result=$(($result / 256)) - done - RETARDEDMASK=$result$byte + case $NEEDDOTSINSUB in + 3) FULLSUBNET=$SUBNET4.0.0.0 ;; + 2) FULLSUBNET=$SUBNET4.0.0 ;; + 1) FULLSUBNET=$SUBNET4.0 ;; + 0) FULLSUBNET=$SUBNET4 ;; + *) echo "cannot read subnet" && exit 1;; + esac } #check if ip is valid ipv4 function @@ -370,7 +370,7 @@ else echo '' >> tinc-up echo "addr4=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET4[.][^ ]*\\) *$|\\1|p\" \$host)" >> tinc-up echo 'ifconfig $INTERFACE $addr4' >> tinc-up - echo "route add -net $FULLSUBNET netmask $RETARDEDMASK dev \$INTERFACE " >> tinc-up + echo "route add -net $FULLSUBNET netmask $RMASK dev \$INTERFACE " >> tinc-up fi #fix permissions -- cgit v1.2.3 From a80634362df520d6f3fa2e90e7ed3c9523367488 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Fri, 28 Dec 2012 05:26:21 +0100 Subject: fixed android bug --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 82878673..7433d7b1 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -168,7 +168,7 @@ else LOADER=curl fi -if ! $(ping -c 1 euer.krebsco.de -W 5 1>/dev/null) ;then +if ! $(ping -c 1 -W 5 euer.krebsco.de 1>/dev/null) ;then echo "Cant reach euer, check if your internet is working" exit 1 fi -- cgit v1.2.3 From 09f5a23e9c562e602714bbe235ea8ab62bb4cadb Mon Sep 17 00:00:00 2001 From: root Date: Sat, 5 Jan 2013 22:59:21 +0000 Subject: fix connectTo, replace euer with pigstarter --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 7433d7b1..167cccfc 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -334,7 +334,7 @@ AutoConnect = 3 #ConnectTos ConnectTo = supernode -ConnectTo = euer +ConnectTo = pigstarter ConnectTo = pico EOF -- cgit v1.2.3 From 99e9301be379f466948d1be30f7b97285027b062 Mon Sep 17 00:00:00 2001 From: makefu Date: Sat, 5 Jan 2013 23:26:46 +0000 Subject: boot/retiolum.sh: welcome to the escaping hell --- retiolum/scripts/tinc_setup/new_install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 167cccfc..1d16cfb9 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -346,17 +346,17 @@ if type ip >/dev/null; then echo '' >> tinc-up echo 'conf=$dirname/tinc.conf' >> tinc-up echo '' >> tinc-up - echo 'name=$(sed -n "s|^ *Name *= *\([^ ]*\) *$|\1|p " $conf)' >> tinc-up + echo 'name=$(sed -n "s|^ *Name *= *\([^ ]*\) *$|\\1|p" $conf)' >> tinc-up echo '' >> tinc-up echo 'host=$dirname/hosts/$name' >> tinc-up echo '' >> tinc-up echo 'ip link set $INTERFACE up' >> tinc-up echo '' >> tinc-up - echo "addr4=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET4[.][^ ]*\\) *$|\\1|p\" \$host)" >> tinc-up + echo "addr4=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET4[.][^ ]*\\) *\$|\\\\1|p\" \$host)" >> tinc-up echo 'ip -4 addr add $addr4 dev $INTERFACE' >> tinc-up echo "ip -4 route add $FULLSUBNET/$MASK4 dev \$INTERFACE" >> tinc-up echo '' >> tinc-up - echo "addr6=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET6[:][^ ]*\\) *$|\\1|p\" \$host)" >> tinc-up + echo "addr6=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET6[:][^ ]*\\) *\$|\\\\1|p\" \$host)" >> tinc-up echo 'ip -6 addr add $addr6 dev $INTERFACE' >> tinc-up echo "ip -6 route add $SUBNET6::/$MASK6 dev \$INTERFACE" >> tinc-up else @@ -364,11 +364,11 @@ else echo '' >> tinc-up echo 'conf=$dirname/tinc.conf' >> tinc-up echo '' >> tinc-up - echo 'name=$(sed -n "s|^ *Name *= *\([^ ]*\) *$|\1|p " $conf)' >> tinc-up + echo 'name=$(sed -n "s|^ *Name *= *\([^ ]*\) *$|\\1|p" $conf)' >> tinc-up echo '' >> tinc-up echo 'host=$dirname/hosts/$name' >> tinc-up echo '' >> tinc-up - echo "addr4=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET4[.][^ ]*\\) *$|\\1|p\" \$host)" >> tinc-up + echo "addr4=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET4[.][^ ]*\\) *$|\\\\1|p\" \$host)" >> tinc-up echo 'ifconfig $INTERFACE $addr4' >> tinc-up echo "route add -net $FULLSUBNET netmask $RMASK dev \$INTERFACE " >> tinc-up fi -- cgit v1.2.3 From 7f97a33b1a8c427f29eab3a015df6581bb6bab36 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 6 Jan 2013 03:04:47 +0000 Subject: fix new_install installer --- retiolum/scripts/tinc_setup/new_install.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'retiolum/scripts/tinc_setup') diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 1d16cfb9..410dce62 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -12,7 +12,14 @@ SUBNET4=${SUBNET4:-10.243} SUBNET6=${SUBNET6:-42} TEMPDIR=$