Merge branch 'debian' into suites/experimental
authorRalph Ronnquist <rrq@rrq.au>
Sun, 28 Jan 2024 22:40:06 +0000 (09:40 +1100)
committerRalph Ronnquist <rrq@rrq.au>
Sun, 28 Jan 2024 22:40:06 +0000 (09:40 +1100)
devnodes-init.sh [new file with mode: 0755]
functions
overlay-clean-root [new file with mode: 0755]
overlay-clean-root.8.adoc [new file with mode: 0644]
overlay-postmount

diff --git a/devnodes-init.sh b/devnodes-init.sh
new file mode 100755 (executable)
index 0000000..5e5402c
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh /lib/init/init-d-script
+### BEGIN INIT INFO
+# Provides:          devices
+# Required-Start:    
+# Required-Stop:     
+# Default-Start:     S
+# Default-Stop:      0 1 6
+# Short-Description: set up devnodes
+# Description:       Initialize /dev from /.devnodes.tgz
+### END INIT INFO
+
+DAEMON=none
+DESC="devnodes: restore and capture /dev on startup and shutdown."
+TGZ=/.devnodes.tgz
+
+do_start_override() {
+    [ -e $TGZ ] && tar -xzf $TGZ --skip-old-files -C /dev
+}
+
+do_stop_override() {
+    cd /dev && tar czf $TGZ *
+}
+
+do_status_override() {
+    find /dev -type d -exec ls -ld '{}' ';'
+    stat -c %Y $TGZ
+}
index fa1d527012262a85a85c8b718cf28fe71a9be71a..8f39d4014e9213a56c63f4dc03b228f94e73c5ce 100644 (file)
--- a/functions
+++ b/functions
@@ -103,6 +103,12 @@ setup_veth_cables() {
     for C in "$@" ; do
        IF=$NETNS$i
        MAC="${C#*=}"
+        if ip link show $IF > /dev/null 2>&1 ; then
+           : # The interface exists already (bad badness); let things fail
+        elif ifquery --state $IF >/dev/null 2>&1 ; then
+            # doesn't exist but has residue state; quiet cleanup
+            ifdown -f $IF > /dev/null 2>&1
+        fi
        if [ -z "$MAC" ] ; then
            # set up veth with "random" mac address
            ip link add $IF type veth peer name eth$i netns $NETNS
diff --git a/overlay-clean-root b/overlay-clean-root
new file mode 100755 (executable)
index 0000000..06c997d
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# This script "cleans" the UPPER directory tree for a subhost by
+# comparing it with the LOWER tree and remove all files that are equal
+# to content.
+
+PROGRAMDIR="$(dirname $(realpath $0))"
+. $PROGRAMDIR/functions
+
+subhost_name $1
+subhost_config
+
+
+
+: ${LOWER:-/}
+
+if [ ! -d "$UPPER" ] || [ ! -d "$LOWER" ] ; then
+    echo "*** needs a root path" >&2
+    exit 1
+fi
+
+if is_live $NAME ; then
+    echo "** Cannot clean running subhost **" >&2
+    exit 1
+fi
+
+UPPER="${UPPER%/}"
+LOWER="${LOWER%/}"
+
+if [ "$UPPER" = "$LOWER" ] ; then
+    echo "** UPER and LOWER are the same directory **" >&2
+    exit 1
+fi
+
+du -sh $UPPER
+exit 0
+DIFFS=/tmp/clean-$NAME.$$
+rm -f $DIFFS
+find $UPPER -type f -printf '%P\n'| while read X ; do
+    cmp "$UPPER/$X" "$LOWER/$X" >> $DIFFS 2>&1 && rm "$UPPER/$X"
+done 
+du -sh $UPPER
+echo "(See details in $DIFFS)"
diff --git a/overlay-clean-root.8.adoc b/overlay-clean-root.8.adoc
new file mode 100644 (file)
index 0000000..d501413
--- /dev/null
@@ -0,0 +1,26 @@
+overlay-boot(8)
+===============
+:doctype: manpage
+:revdate: {sys:date "+%Y-%m-%d %H:%M:%S"}
+:COLON: :
+:EQUALS: =
+
+NAME
+----
+overlay-clean-root - Clean UPPER relative LOWER by removing equal files.
+
+SYNOPSIS
+--------
+*overlay-clean-root* _conf_
+
+DESCRIPTION
+-----------
+
+*overlay-clean-root* reduces the UPPER directory tree for an off-line
+subhost by removing all files that equal to the files they shadow in
+the LOWER directory tree.
+
+SEE ALSO
+--------
+
+*overlay-boot*
index e8f32ac7e44010bbf5248ca6ac2c9a4c2d11afec..a8080549c6e1db16dd607af1fcf56465e22c00f2 100755 (executable)
@@ -37,5 +37,8 @@ if [ "$RAM_SIZE" != "none" ] ; then
     mount -t tmpfs -osize=$RAM_SIZE,mode=755 tmpfs $LIVE/run
 fi
 
-echo "Installing $OVERLAYDIR/reaper to $LIVE/.reaper"
+echo "bind-mount /etc/adjtime into subhost, if possible"
+mount --bind /etc/adjtime $LIVE/etc/adjtime || true
+
+echo "install $OVERLAYDIR/reaper to $LIVE/.reaper"
 cp -p $OVERLAYDIR/reaper $LIVE/.reaper