summaryrefslogtreecommitdiff
path: root/dht/vnet/core-screen-shell.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dht/vnet/core-screen-shell.sh')
-rwxr-xr-xdht/vnet/core-screen-shell.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/dht/vnet/core-screen-shell.sh b/dht/vnet/core-screen-shell.sh
new file mode 100755
index 00000000..012c8540
--- /dev/null
+++ b/dht/vnet/core-screen-shell.sh
@@ -0,0 +1,58 @@
1#!/bin/bash
2digit=$1
3[ -z "$digit" ] && {
4 touch core-count
5 count=$(cat core-count)
6 count=${count:-(-1)}
7 count=$(( $count + 1 ))
8 echo $count > core-count
9 digit=$(printf '%X' $count)
10 user=$(cat core-user)
11 (
12 cd ve$digit
13 port=$(( 33400 + $count ))
14 echo nsenter --net=/var/run/netns/vep$digit chpst -u $user ../$0 $digit $port > cmd0
15 exec nsenter --net=/var/run/netns/vep$digit chpst -u $user ../$0 $digit $port
16 exit 1
17 )
18}
19port=$2
20
21addr=$(ip -o address show dev vep$digit | sed -n 's#.* inet \([^ /]*\).*#\1#p')
22echo $addr
23pwd
24whoami
25# Usage (connected) : ./DHT_bootstrap [--ipv4|--ipv6] IP PORT KEY
26# Usage (unconnected): ./DHT_bootstrap [--ipv4|--ipv6]
27
28if [ "$digit" = 0 ]
29then
30 echo $$ > pid
31 echo ../DHT_bootstrap > cmd.txt
32 echo $addr > addr.txt
33 {
34 sleep 0.5
35 echo IP: $addr >> PUBLIC_ID.txt
36 } &
37 exec ../DHT_bootstrap
38else
39 vars='{
40 if( boot_key == "" ) { boot_key=$0 ; print("boot_key=" boot_key) }
41 else if( $1 == "Port:" ) print("boot_port=" $2);
42 else if( $1 == "IP:" ) print("boot_ip=" $2);
43 }'
44 boot_ip=
45 boot_port=
46 boot_key=
47 awk "$vars" ../ve0/PUBLIC_ID.txt > vars.txt 2>&1
48 . vars.txt
49 echo ../DHT_bootstrap $boot_ip $boot_port $boot_key > cmd.txt
50 echo $$ > pid
51 echo $addr > addr.txt
52 {
53 sleep 0.5
54 echo IP: $addr >> PUBLIC_ID.txt
55 } &
56 exec ../DHT_bootstrap $boot_ip $boot_port $boot_key
57fi
58sleep 30