summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts/tinc_setup/new_install.sh
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2013-01-29 19:01:43 +0100
committermakefu <github@syntax-fehler.de>2013-01-29 19:01:43 +0100
commit14b5fb8d60919516950e9ac1e3ff895968ed3a3c (patch)
tree282921b51f5c780cdbe2e3f88b0f825aba901d1c /retiolum/scripts/tinc_setup/new_install.sh
parent715b2e23b0cb347dbf6b6516e5811e45406324ac (diff)
parentd96cf23ac2c57d9791343c03d01fa54fe5295d2c (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'retiolum/scripts/tinc_setup/new_install.sh')
-rwxr-xr-xretiolum/scripts/tinc_setup/new_install.sh67
1 files changed, 45 insertions, 22 deletions
diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh
index 4dc973d9..1ff42e54 100755
--- a/retiolum/scripts/tinc_setup/new_install.sh
+++ b/retiolum/scripts/tinc_setup/new_install.sh
@@ -12,9 +12,10 @@ SUBNET4=${SUBNET4:-10.243}
SUBNET6=${SUBNET6:-42}
TEMPDIR=${TEMPDIR:-auto}
TINCDIR=${TINCDIR:-auto}
+exists() { type "$1" >/dev/null 2>/dev/null; }
-if type hostname >/dev/null ;then SYSHOSTN=${HOSTNAME:-$(hostname)}
-elif type uci >/dev/null ;then SYSHOSTN=$(uci get system.@system[0].hostname)
+if exists hostname ;then SYSHOSTN=${HOSTNAME:-$(hostname)}
+elif exists uci ;then SYSHOSTN=$(uci get system.@system[0].hostname)
elif [ -e /etc/hostname ] ;then SYSHOSTN=$(cat /etc/hostname)
else SYSHOSTN="unknown"
fi
@@ -28,7 +29,7 @@ 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}
-IRCCHANNEL=${IRCCHANNEL:-"#krebsco"}
+IRCCHANNEL=${IRCCHANNEL:-"#krebs"}
IRCSERVER=${IRCSERVER:-"irc.freenode.net"}
IRCPORT=${IRCPORT:-6667}
@@ -105,14 +106,16 @@ get_hostname()
find_os()
{
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
+ OS='linux'
+ elif exists getprop ; then
+ OS='android'
elif test -e /etc/openwrt_release; then
- OS=3
+ OS='openwrt'
+ elif uname -s | grep -qi 'darwin'; then
+ OS='osx'
else
echo "Cannot determine your operating system, falling back to Linux"
- OS=1
+ OS='linux'
fi
}
@@ -135,13 +138,13 @@ if [ $OS -eq 0 ]; then
fi
#check if everything is installed
-if ! type awk >/dev/null; then
+if ! exists awk ; then
echo "Please install awk"
exit 1
fi
-if ! type curl >/dev/null; then
- if ! type wget >/dev/null; then
+if ! exists curl ; then
+ if ! exists wget ; then
echo "Please install curl or wget"
exit 1
else
@@ -157,23 +160,37 @@ if ! $(ping -c 1 -W 5 euer.krebsco.de 1>/dev/null) ;then
fi
#check if everything is installed
-if [ $OS -eq 2 ]; then
+if [ $OS = 'android' ]; 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 [ $TINCDIR = 'auto' ]; then TINCDIR=/usr/local/etc/tinc ;fi
- if [ $TEMPDIR = 'auto' ]; then TEMPDIR=/data/secure/data ;fi
+ DEV="/dev/tun"
+ if [ $TINCDIR = 'auto' ]; then TINCDIR="/usr/local/etc/tinc" ;fi
+ if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/storage/sdcard0/tinc-fu" ;fi
+ mount -o remount,rw /
+ mount -o remount,rw /system
+ fi
+elif [ $OS = 'osx' ]; then
+ if ! exists tincd >/dev/null; then
+ echo "Please install tinc"
+ exit 1
+ else
+ TINCBIN=tincd
+ DEV="/dev/net/tun"
+ if [ $TINCDIR = 'auto' ]; then TINCDIR="/usr/local/etc/tinc" ;fi
+ if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/tmp/tinc-install-fu" ;fi
fi
else
- if ! type tincd >/dev/null; then
+ if ! exists 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
+ DEV="/dev/net/tun"
+ if [ $TINCDIR = 'auto' ]; then TINCDIR="/etc/tinc" ;fi
+ if [ $TEMPDIR = 'auto' ]; then TEMPDIR="/tmp/tinc-install-fu" ;fi
fi
fi
@@ -229,7 +246,7 @@ get_hostname $HOSTN
mkdir -p $TINCDIR/$NETNAME
cd $TINCDIR/$NETNAME
-if [ $OS -eq 3 ]; then
+if [ $OS = 'openwrt' ]; then
mkdir hosts
$LOADER $SURL | tar xz -C hosts/
else
@@ -243,7 +260,7 @@ echo "Subnet = $IP6" >> hosts/$HOSTN
cat>tinc.conf<<EOF
Name = $HOSTN
-Device = /dev/net/tun
+Device = $DEV
#newer tinc features
LocalDiscovery = yes
@@ -258,7 +275,7 @@ EOF
host2subnet $MASK4
#check if ip is installed
-if type ip >/dev/null; then
+if exists ip >/dev/null; then
echo 'dirname="`dirname "$0"`"' > tinc-up
echo '' >> tinc-up
echo 'conf=$dirname/tinc.conf' >> tinc-up
@@ -292,16 +309,22 @@ fi
#fix permissions
chmod +x tinc-up
-chown -R root:root .
+chown -R 0:0 .
#generate keys with tinc
-if type tincctl >/dev/null; then
+if exists tincctl ; then
yes | tincctl -n $NETNAME generate-keys
cat rsa_key.pub >> hosts/$HOSTN
else
yes | $TINCBIN -n $NETNAME -K
fi
+if [ $OS = 'android' ]; then
+ mkdir /etc/tinc
+ cd /
+ mv $TINCDIR/$NETNAME /etc/tinc/
+ cd /etc/tinc/$NETNAME
+fi
#write to irc-channel
NICK="${HOSTN}_$(head /dev/urandom | tr -dc "0123456789" | head -c3)"