build_fn: Backup resolv.conf symlink and fix mount and trim
This commit is contained in:
parent
b87edce4a4
commit
d70d0ddad8
|
@ -12,7 +12,9 @@ setup_inet()
|
||||||
log "Rootdir [$rootdir] does not exists" ierror
|
log "Rootdir [$rootdir] does not exists" ierror
|
||||||
return 2
|
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 "nameserver 1.1.1.1" > "$rootdir/etc/resolv.conf"
|
||||||
echo "xiaomi-nabu" > "$rootdir/etc/hostname"
|
echo "xiaomi-nabu" > "$rootdir/etc/hostname"
|
||||||
echo "127.0.0.1 localhost
|
echo "127.0.0.1 localhost
|
||||||
|
@ -42,7 +44,7 @@ create_image()
|
||||||
trim_image()
|
trim_image()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
name="$(get_image_path "$1")"
|
name="$1"
|
||||||
e2fsck -f "$name"
|
e2fsck -f "$name"
|
||||||
resize2fs -M "$name"
|
resize2fs -M "$name"
|
||||||
} || {
|
} || {
|
||||||
|
@ -54,15 +56,10 @@ trim_image()
|
||||||
# shellcheck disable=SC2155
|
# shellcheck disable=SC2155
|
||||||
mount_image()
|
mount_image()
|
||||||
{
|
{
|
||||||
local rootdir="$1"
|
|
||||||
[ ! -d "$rootdir" ] && {
|
|
||||||
log "Rootdir [$rootdir] does not exists" ierror
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
local mountdir="$(mktemp --tmpdir=./tmp/ -d)"
|
local mountdir="$(mktemp --tmpdir=./tmp/ -d)"
|
||||||
local mountdir="$(realpath "$mountdir")"
|
local mountdir="$(realpath "$mountdir")"
|
||||||
|
|
||||||
mount -o loop "$(get_image_path "$1")" "$mountdir" || {
|
mount -o loop "$1" "$mountdir" || {
|
||||||
log "Failed to mount image" ierror
|
log "Failed to mount image" ierror
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue