From d70d0ddad8c7eb15e8039d2f6118f5c6c6c4e460 Mon Sep 17 00:00:00 2001 From: timoxa0 Date: Sun, 27 Oct 2024 18:34:46 +0500 Subject: [PATCH] build_fn: Backup resolv.conf symlink and fix mount and trim --- common.d/build_functions.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/common.d/build_functions.sh b/common.d/build_functions.sh index 13d9a04..dbd910b 100644 --- a/common.d/build_functions.sh +++ b/common.d/build_functions.sh @@ -12,7 +12,9 @@ setup_inet() log "Rootdir [$rootdir] does not exists" ierror return 2 } - + [ -L "$rootdir/etc/resolv.conf" ] && { + mv "$rootdir/etc/resolv.conf" "$rootdir/etc/resolv.conf.1" + } echo "nameserver 1.1.1.1" > "$rootdir/etc/resolv.conf" echo "xiaomi-nabu" > "$rootdir/etc/hostname" echo "127.0.0.1 localhost @@ -42,7 +44,7 @@ create_image() trim_image() { { - name="$(get_image_path "$1")" + name="$1" e2fsck -f "$name" resize2fs -M "$name" } || { @@ -54,15 +56,10 @@ trim_image() # shellcheck disable=SC2155 mount_image() { - local rootdir="$1" - [ ! -d "$rootdir" ] && { - log "Rootdir [$rootdir] does not exists" ierror - return 2 - } local mountdir="$(mktemp --tmpdir=./tmp/ -d)" local mountdir="$(realpath "$mountdir")" - mount -o loop "$(get_image_path "$1")" "$mountdir" || { + mount -o loop "$1" "$mountdir" || { log "Failed to mount image" ierror return 1 }