From: Ralph Ronnquist Date: Sun, 28 Jan 2024 22:40:06 +0000 (+1100) Subject: Merge branch 'debian' into suites/experimental X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=abdb6485d7bbc902c21b169d5ebffa21e54887e4;hp=e6d6b7101cf2a439fb1409fd3e880f5040f26e58;p=rrq%2Foverlay-boot.git Merge branch 'debian' into suites/experimental --- diff --git a/devnodes-init.sh b/devnodes-init.sh new file mode 100755 index 0000000..5e5402c --- /dev/null +++ b/devnodes-init.sh @@ -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 +} diff --git a/functions b/functions index fa1d527..8f39d40 100644 --- 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 index 0000000..06c997d --- /dev/null +++ b/overlay-clean-root @@ -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 index 0000000..d501413 --- /dev/null +++ b/overlay-clean-root.8.adoc @@ -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* diff --git a/overlay-postmount b/overlay-postmount index e8f32ac..a808054 100755 --- a/overlay-postmount +++ b/overlay-postmount @@ -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