diff options
author | tv <tv@also> | 2011-05-29 14:28:06 +0200 |
---|---|---|
committer | tv <tv@also> | 2011-05-29 14:28:06 +0200 |
commit | 6ab10542e484d12e1635a016860e27e8167e5185 (patch) | |
tree | ba5acc68d05538ee1396f09e9724b05eaf389725 /modules/retiolum/scripts | |
parent | 9ea4cbe1e006f703d1367f5aa3229849775b7128 (diff) | |
parent | b7e9b977884f8d4d6149b06e3567f288b920daa6 (diff) |
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'modules/retiolum/scripts')
-rwxr-xr-x | modules/retiolum/scripts/adv_graphgen/parse.py | 20 | ||||
-rwxr-xr-x | modules/retiolum/scripts/adv_graphgen/sanitize.sh | 2 | ||||
-rw-r--r-- | modules/retiolum/scripts/autostart/Makefile | 12 | ||||
-rw-r--r-- | modules/retiolum/scripts/tinc_setup/autoupdate_cron.sh | 7 | ||||
-rwxr-xr-x | modules/retiolum/scripts/tinc_setup/install.sh | 12 |
5 files changed, 38 insertions, 15 deletions
diff --git a/modules/retiolum/scripts/adv_graphgen/parse.py b/modules/retiolum/scripts/adv_graphgen/parse.py index 04b42c33..639c5316 100755 --- a/modules/retiolum/scripts/adv_graphgen/parse.py +++ b/modules/retiolum/scripts/adv_graphgen/parse.py @@ -12,6 +12,7 @@ def write_digraph(nodes): print ('digraph retiolum {') print (' node[shape=box,style=filled,fillcolor=grey]') generate_stats(nodes) + nodes = delete_unused_nodes(nodes) merge_edges(nodes) for k,v in nodes.iteritems(): write_node(k,v) @@ -21,7 +22,12 @@ def generate_stats(nodes): """ for k,v in nodes.iteritems(): v['num_conns'] = len(v.get('to',[])) - +def delete_unused_nodes(nodes): + new_nodes = {} + for k,v in nodes.iteritems(): + if v.get('to',[]): + new_nodes[k] = v + return new_nodes def merge_edges(nodes): """ merge back and forth edges into one DESTRUCTS the current structure by deleting "connections" in the nodes @@ -45,12 +51,14 @@ def write_node(k,v): node += "external:"+v['external-ip']+":"+v['external-port']+"\\l" if v.has_key('num_conns'): node += "Num Connects:"+str(v['num_conns'])+"\\l" - - node += "internal:"+v.get('internal-ip','¯\\\\(°_o)/¯')+"\\l\"" + for addr in v.get('internal-ip',['¯\\\\(°_o)/¯']): + node += "internal:"+addr+"\\l" + node +="\"" if v['external-ip'] == "MYSELF": node += ",fillcolor=steelblue1" node += "]" - print (node) + print node + for con in v.get('to',[]): edge = " "+k+ " -> " +con['name'] + "[weight="+str(float(con['weight'])) if con.get('bidirectional',False): @@ -74,7 +82,9 @@ def parse_input(): if line == 'End of subnet list.\n': break l = line.replace('\n','').split() - nodes[l[2]]['internal-ip'] = l[0].split('#')[0] + if not nodes[l[2]].get('internal-ip',False): + nodes[l[2]]['internal-ip'] = [] + nodes[l[2]]['internal-ip'].append(l[0].split('#')[0]) if line == 'Edges:': edges = {} for line in sys.stdin: diff --git a/modules/retiolum/scripts/adv_graphgen/sanitize.sh b/modules/retiolum/scripts/adv_graphgen/sanitize.sh index 88591b67..0e12d207 100755 --- a/modules/retiolum/scripts/adv_graphgen/sanitize.sh +++ b/modules/retiolum/scripts/adv_graphgen/sanitize.sh @@ -10,4 +10,4 @@ sudo sed -n '/tinc.retiolum/{s/.*tinc.retiolum\[[0-9]*\]: //gp}' $LOG_FILE |\ $GRAPH_SETTER1 -Tpng -o $1retiolum_1.png retiolum.dot $GRAPH_SETTER2 -Tpng -o $1retiolum_2.png retiolum.dot $OPENER retiolum_1.png &>/dev/null -rm retiolum.dot +#rm retiolum.dot diff --git a/modules/retiolum/scripts/autostart/Makefile b/modules/retiolum/scripts/autostart/Makefile index 7ca589e1..aba6bd33 100644 --- a/modules/retiolum/scripts/autostart/Makefile +++ b/modules/retiolum/scripts/autostart/Makefile @@ -1,8 +1,14 @@ INIT_FOLDER=/etc/init.d .phony: all -all: +debian: #TODO change the tinc file before writing - cp tinc $(INIT_FOLDER)/tinc - chmod +x $(INIT_FOLDER)/tinc + cp tinc /etc/init.d/tinc + chmod +x /etc/init.d echo "retiolum" > /etc/tinc/nets.boot update-rc.d tinc defaults +arch: + @cp tinc /etc/rc.d + @chmod +x /etc/rc.d/tinc + @echo "add tinc to DAEMONS in /etc/rc.conf" + + diff --git a/modules/retiolum/scripts/tinc_setup/autoupdate_cron.sh b/modules/retiolum/scripts/tinc_setup/autoupdate_cron.sh new file mode 100644 index 00000000..d5d41aaf --- /dev/null +++ b/modules/retiolum/scripts/tinc_setup/autoupdate_cron.sh @@ -0,0 +1,7 @@ +cat <<EOF +# Add these lines to your crontab: + +12 23 * * * /home/node/usr/sbin/tincd -n retiolum &>/dev/null +12 23 * * * cd /home/node/etc/tinc/retiolum/hosts/ && /opt/local/bin/git pull && pkill -HUP tincd +EOF + diff --git a/modules/retiolum/scripts/tinc_setup/install.sh b/modules/retiolum/scripts/tinc_setup/install.sh index de7d2225..9df38df7 100755 --- a/modules/retiolum/scripts/tinc_setup/install.sh +++ b/modules/retiolum/scripts/tinc_setup/install.sh @@ -1,10 +1,10 @@ #! /bin/sh # USE WITH GREAT CAUTION -make -C ../../ update +#make -C ../../ update set -e - -CURR=`dirname "$0"` +DIRNAME=`dirname $0` +CURR=`readlink -f ${DIRNAME}` MYBIN=../../bin netname=retiolum # create configuration directory for $netname @@ -30,6 +30,7 @@ then then echo "select v4 subnet ip (1-255) :" read v4num + myipv4=10.7.7.$v4num if [ "$v4num" -gt 0 -a "$v4num" -lt "256" ]; then echo "check" @@ -37,7 +38,6 @@ then echo "you are made of stupid. bailing out" exit 1 fi - myipv4=10.7.7.$v4num fi echo "Subnet = $myipv4" > hosts/$myname @@ -47,7 +47,7 @@ else echo "own host file already exists! will not write again!" fi -cp $CURR/tinc-up . +cp $CURR/tinc-up /etc/tinc/$netname/ cat>tinc.conf<<EOF Name = $myname @@ -61,7 +61,7 @@ if [ ! -e rsa_key.priv ] then echo "creating new keys" tincd -n $netname -K - python ${CURR}/write_channel.py || \ + python ${CURR}/write_channel.py $myname || \ echo "cannot write public key to IRC, you are on your own. Good Luck" else echo "key files already exist, skipping" |