Commit 493b5da1 authored by Kirill Smelkov's avatar Kirill Smelkov

BAC: Factor creating new hosts into xnewhost

parent 91d7694b
...@@ -2,6 +2,23 @@ ...@@ -2,6 +2,23 @@
PID=$$ PID=$$
# `xnewhost <name>` creates new virtual host.
xnewhost() {
local X=$1
# lo
xunshare $X -- ip link set lo up
# private /var/run so that e.g. smcrouted can be started
xnsenter $X -- mount -t tmpfs none /var/run
# open terminal inside the host for play
local nterm=${2:-1}
for i in `seq $nterm`; do
xnsenter $X -- xfce4-terminal --title=$X$i &
done
}
# `xunshare <dir> ...` -- unshare net/mount/... namespaces to be referenced by dir # `xunshare <dir> ...` -- unshare net/mount/... namespaces to be referenced by dir
xunshare() { xunshare() {
ref=$1 ref=$1
......
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
cycle=n cycle=n
[ "$1" = "-cycle" ] && cycle=y [ "$1" = "-cycle" ] && cycle=y
# lo on everything # set up hosts
xunshare A -- ip link set lo up xnewhost A 2
xunshare B -- ip link set lo up xnewhost B
xunshare C -- ip link set lo up xnewhost C
# links # links
xlink B A # B-A xlink B A # B-A
...@@ -58,16 +58,3 @@ if [ $cycle = y ]; then ...@@ -58,16 +58,3 @@ if [ $cycle = y ]; then
xnsenter B -- ip route append 224.0.0.0/4 dev b-c xnsenter B -- ip route append 224.0.0.0/4 dev b-c
xnsenter C -- ip route append 224.0.0.0/4 dev c-b xnsenter C -- ip route append 224.0.0.0/4 dev c-b
fi fi
# mount private /var/run so that smcrouted can be started
xnsenter A -- mount -t tmpfs none /var/run
xnsenter B -- mount -t tmpfs none /var/run
xnsenter C -- mount -t tmpfs none /var/run
# open terminals in A B C for play
xnsenter B -- xfce4-terminal --title=B &
xnsenter C -- xfce4-terminal --title=C &
xnsenter A -- xfce4-terminal --title=A &
xnsenter A -- xfce4-terminal --title=A2 &
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment