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

BAC: Factor creating new hosts into xnewhost

parent 91d7694b
......@@ -2,6 +2,23 @@
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() {
ref=$1
......
......@@ -25,10 +25,10 @@
cycle=n
[ "$1" = "-cycle" ] && cycle=y
# lo on everything
xunshare A -- ip link set lo up
xunshare B -- ip link set lo up
xunshare C -- ip link set lo up
# set up hosts
xnewhost A 2
xnewhost B
xnewhost C
# links
xlink B A # B-A
......@@ -58,16 +58,3 @@ if [ $cycle = y ]; then
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
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