projects
/
rrq
/
subhost.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
45b11ec
)
Minor correction, with explicit chroot (as required in beowulf)
author
Ralph Ronnquist
<ralph.ronnquist@gmail.com>
Sat, 26 Feb 2022 23:08:14 +0000
(10:08 +1100)
committer
Ralph Ronnquist
<ralph.ronnquist@gmail.com>
Sat, 26 Feb 2022 23:08:14 +0000
(10:08 +1100)
control
patch
|
blob
|
history
diff --git
a/control
b/control
index b63bc74011edb82a44f6d9a8905b741664ef869c..f5831a267f8842a3d1090dece847d4d2501648c4 100755
(executable)
--- a/
control
+++ b/
control
@@
-29,7
+29,7
@@
usage() {
: ${WORK=$TOP/work}
: ${MOUNT=$TOP/mnt}
: ${NSNAME=$NAME}
: ${WORK=$TOP/work}
: ${MOUNT=$TOP/mnt}
: ${NSNAME=$NAME}
-: ${BRIDGES=
homenet
}
+: ${BRIDGES=
lan_br
}
: ${CONFIG=$TOP/config}
[ -e "$CONFIG" ] && . "$CONFIG"
: ${CONFIG=$TOP/config}
[ -e "$CONFIG" ] && . "$CONFIG"
@@
-39,7
+39,7
@@
cd "$SUBHOST" || exit 1
# Create a simple overlay subhost without its own image file
create_subhost() {
mkdir -p $TARGET $MOUNT $UPPER $WORK
# Create a simple overlay subhost without its own image file
create_subhost() {
mkdir -p $TARGET $MOUNT $UPPER $WORK
- [ -d "$OSROOT" ] || OSROOT=$SUBHOST/
daedalus/root
+ [ -d "$OSROOT" ] || OSROOT=$SUBHOST/
chimaera/base
[ -e $CONFIG ] || cat <<EOF > "$CONFIG"
# Subhost $NAME is an autogenerated overlay subhost with shared filesystem
OSROOT="$OSROOT"
[ -e $CONFIG ] || cat <<EOF > "$CONFIG"
# Subhost $NAME is an autogenerated overlay subhost with shared filesystem
OSROOT="$OSROOT"
@@
-47,10
+47,18
@@
BRIDGES="$BRIDGES"
EOF
}
EOF
}
-# generate a mac for given $1 (interface) using the last 5 characters
+# map a string into a hexadecimal number with 10-digits by folding the given string into 9-digit ascii-code numbers and adding them
+hexfoldsum() {
+ local V
+ V="$(b2sum -l 40 <<< "$1" | sed 's/\(..\)/\1:/g')"
+ echo "02:${V:0:14}"
+}
+
+# Generate a mac address for given interface by passing hostname,
+# subhost name and interface through 40-bit b2sum and with 02: prefix.
macaddr() {
macaddr() {
- local
M="$(xxd -p <<< "${1:$(( ${#1} - 5)):5}")66666666
"
- echo "0
a:${M:0:2}:${M:2:2}:${M:4:2}:${M:6:2}:${M:8:2
}"
+ local
V="$(b2sum -l 40 <<< "$(hostname)$NAME$1" | sed 's/\(..\)/\1:/g')
"
+ echo "0
2:${V:0:14
}"
}
# setup the subhost network namespace and link up the host side
}
# setup the subhost network namespace and link up the host side
@@
-78,8
+86,9
@@
setup_rootfs() {
if is_mounted $TARGET ; then
mount -oremount $TARGET
else
if is_mounted $TARGET ; then
mount -oremount $TARGET
else
- if [ -f "$IMAGE" ] ; then
- # The subhost has an image file with /root and /work in it
+ if [ -e "$IMAGE" ] ; then
+ # $IMAGE is either an image file or a link to a partition,
+ # with /root and /work in it.
is_mounted $MOUNT || mount $IMAGE $MOUNT || exit 1
UPPER=$MOUNT/root
WORK=$MOUNT/work
is_mounted $MOUNT || mount $IMAGE $MOUNT || exit 1
UPPER=$MOUNT/root
WORK=$MOUNT/work
@@
-106,7
+115,7
@@
case "$CMD" in
exec ip netns exec $NSNAME unshare \
--fork --pid --mount-proc --kill-child \
--uts --ipc --mount --cgroup \
exec ip netns exec $NSNAME unshare \
--fork --pid --mount-proc --kill-child \
--uts --ipc --mount --cgroup \
-
"--root=$TARGET"
$START
+
chroot $TARGET
$START
;;
stop)
umount $TARGET
;;
stop)
umount $TARGET