armbian_build/lib/functions/general/chroot-helpers.sh
Ash 408bc67619
Add shebangs for shellcheck (#4493)
* Add shebangs for shellcheck

See #AR-1406

* Add shebangs for shellcheck

Also for `extensions` scripts
2022-11-27 21:44:50 +01:00

34 lines
782 B
Bash

#!/usr/bin/env bash
# mount_chroot <target>
#
# helper to reduce code duplication
#
mount_chroot() {
local target=$1
mount -t tmpfs tmpfs "${target}/tmp"
mount -t proc chproc "${target}"/proc
mount -t sysfs chsys "${target}"/sys
mount -t devtmpfs chdev "${target}"/dev || mount --bind /dev "${target}"/dev
mount -t devpts chpts "${target}"/dev/pts
}
# umount_chroot <target>
#
# helper to reduce code duplication
#
umount_chroot() {
local target=$1
display_alert "Unmounting" "$target" "info"
while grep -Eq "${target}/*(dev|proc|sys|tmp)" /proc/mounts; do
umount -l --recursive "${target}"/dev > /dev/null 2>&1
umount -l "${target}"/proc > /dev/null 2>&1
umount -l "${target}"/sys > /dev/null 2>&1
umount -l "${target}"/tmp > /dev/null 2>&1
sleep 5
done
}