summaryrefslogtreecommitdiffstats
path: root/retiolum
diff options
context:
space:
mode:
Diffstat (limited to 'retiolum')
-rw-r--r--retiolum/Makefile2
-rw-r--r--retiolum/hosts/alphalabs1
-rw-r--r--retiolum/hosts/steve10
-rwxr-xr-xretiolum/scripts/adv_graphgen/find_legacy_hosts.py59
-rwxr-xr-xretiolum/scripts/tinc_setup/install.sh16
5 files changed, 82 insertions, 6 deletions
diff --git a/retiolum/Makefile b/retiolum/Makefile
index effdbfb8..a7fa500a 100644
--- a/retiolum/Makefile
+++ b/retiolum/Makefile
@@ -11,7 +11,7 @@ hosts:
bin/update-retiolum-hosts || true
install: update
- punani -Eih tinc /usr/bin/python /usr/bin/python2
+ ../punani/bin/punani -Eih tinc /usr/bin/python /usr/bin/python2
@# will not run automatically
scripts/tinc_setup/install.sh
scripts/autostart/create-startup.sh
diff --git a/retiolum/hosts/alphalabs b/retiolum/hosts/alphalabs
index ca99549c..4019dd19 100644
--- a/retiolum/hosts/alphalabs
+++ b/retiolum/hosts/alphalabs
@@ -1,3 +1,4 @@
+Address = 10.9.0.10
Subnet = 10.7.7.10
Subnet = 42:0:0:0:0:0:0:a1fa/128
-----BEGIN RSA PUBLIC KEY-----
diff --git a/retiolum/hosts/steve b/retiolum/hosts/steve
new file mode 100644
index 00000000..59e26e21
--- /dev/null
+++ b/retiolum/hosts/steve
@@ -0,0 +1,10 @@
+Subnet = 10.7.7.101
+Subnet = 42:58a0:e7b1:506e:b09e:1b68:5149:c6e8/128
+-----BEGIN RSA PUBLIC KEY-----
+MIIBCgKCAQEA2mt6xByDU2eVsQhjG33vT18Byfxqq4TPOvbV8RAyx0RWeolXGWnx
+p+wKHVITCyL5JCYs7fUYQoDC900bQa/waWgcN8dHfiUmUPtiUjcc35UWaNTLkVGs
+XEe47JMpnnB3D8ynXXKHsG8JXFjpxQpan/fnSuUG7nsB6anxjNHstkmsGGp60P1V
+6Xt5GcN+Mw1peH5LhIOcXaMNEHj/DlIjQSubCf3yelcxoSgnZibP5GfiI6JwKXDu
+A3Sv+wfAGTYdTOE6RBsvBI0lTNUSw02WxaMG4Hfe6+19XEnC1bSwg8+7VsqFmeWi
+uoaQeerhP1QD3GIX81Xe8ENvvFGzCdfARwIDAQAB
+-----END RSA PUBLIC KEY-----
diff --git a/retiolum/scripts/adv_graphgen/find_legacy_hosts.py b/retiolum/scripts/adv_graphgen/find_legacy_hosts.py
new file mode 100755
index 00000000..52388b6d
--- /dev/null
+++ b/retiolum/scripts/adv_graphgen/find_legacy_hosts.py
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+# -*- coding: utf8 -*-
+
+import sys,json
+""" TODO: Refactoring needed to pull the edges out of the node structures again,
+it should be easier to handle both structures"""
+DUMP_FILE = "/krebs/db/availability"
+
+def get_all_nodes():
+ import os
+ return os.listdir("/etc/tinc/retiolum/hosts")
+def generate_stats():
+ """ Generates some statistics of the network and nodes
+ """
+ import json
+ jlines = []
+ try:
+ f = open(DUMP_FILE,'r')
+ for line in f:
+ jlines.append(json.loads(line))
+ f.close()
+ except Exception,e:
+ pass
+ all_nodes = {}
+ for k in get_all_nodes():
+ all_nodes[k] = get_node_availability(k,jlines)
+ print ( json.dumps(all_nodes))
+
+def get_node_availability(name,jlines):
+ """ calculates the node availability by reading the generated dump file
+ adding together the uptime of the node and returning the time
+ parms:
+ name - node name
+ jlines - list of already parsed dictionaries node archive
+ """
+ begin = last = current = 0
+ uptime = 0
+ #sys.stderr.write ( "Getting Node availability of %s\n" % name)
+ for stat in jlines:
+ if not stat['nodes']:
+ continue
+ ts = stat['timestamp']
+ if not begin:
+ begin = last = ts
+ current = ts
+ if stat['nodes'].get(name,{}).get('to',[]):
+ uptime += current - last
+ else:
+ pass
+ #sys.stderr.write("%s offline at timestamp %f\n" %(name,current))
+ last = ts
+ all_the_time = last - begin
+ try:
+ return uptime/ all_the_time
+ except:
+ return 1
+
+
+generate_stats()
diff --git a/retiolum/scripts/tinc_setup/install.sh b/retiolum/scripts/tinc_setup/install.sh
index a550a068..2198589b 100755
--- a/retiolum/scripts/tinc_setup/install.sh
+++ b/retiolum/scripts/tinc_setup/install.sh
@@ -22,11 +22,15 @@ echo "added known hosts:"
ls -1 hosts | LC_ALL=C sort
echo "delete the nodes you do not trust!"
+hostname="${HOSTNAME-`cat /etc/hostname`}"
myname="${1:-}"
if [ ! "$myname" ]
then
- echo "select username: "
+ printf "select node name [$hostname]: "
read myname
+ if test -z "$myname"; then
+ myname="$hostname"
+ fi
fi
if [ ! -e "hosts/$myname" ]
then
@@ -35,11 +39,13 @@ then
if [ ! "$myipv4" ]
then
- echo "select v4 subnet ip (1-255) :"
+ printf 'select v4 subnet ip (1-255): '
read v4num
- if ! $MYBIN/check-free-retiolum-v4 $v4num;then
- exit 1
- fi
+ until $MYBIN/check-free-retiolum-v4 $v4num; do
+ echo "your're an idiot!"
+ printf 'select unused v4 subnet ip (1-255): '
+ read v4num
+ done
myipv4="10.7.7.$v4num"
fi
echo "Subnet = $myipv4" > hosts/$myname