Added matter-iso script and fixed few issues in matter-chroot
This commit is contained in:
@ -32,37 +32,51 @@ error() {
|
||||
## util functions ##
|
||||
####################
|
||||
chrt() {
|
||||
mount --bind /dev $TARGET/dev
|
||||
mount --bind /dev/pts $TARGET/dev/pts
|
||||
mount -t proc proc $TARGET/proc
|
||||
mount -t sysfs sysfs $TARGET/sys
|
||||
mount -t tmpfs tmpfs $TARGET/run
|
||||
mount -t proc proc "$TARGET/proc"
|
||||
mount -t sysfs sysfs "$TARGET/sys"
|
||||
if [[ -d "$TARGET/sys/firmware/efi/efivars" ]]; then
|
||||
mount -t efivarfs efivarfs "$TARGET/sys/firmware/efi/efivars"
|
||||
fi
|
||||
|
||||
mount -o bind /dev "$TARGET/dev"
|
||||
mount -t devpts none "$TARGET/dev/pts"
|
||||
mount -t tmpfs tmpfs "$TARGET/run"
|
||||
|
||||
if [ -h $TARGET/dev/shm ]; then
|
||||
mkdir -p $TARGET/$(readlink $TARGET/dev/shm)
|
||||
else
|
||||
mount -t tmpfs -o nosuid,nodev tmpfs $TARGET/dev/shm
|
||||
mount -t tmpfs -o nosuid,nodev tmpfs "$TARGET/dev/shm"
|
||||
fi
|
||||
|
||||
|
||||
local prompt='\['$BOLD'\['$RED'(chroot)\['$RESET'\['$BOLD' \u@\h:\w#\['$RESET' '
|
||||
chroot $TARGET /usr/bin/env -i \
|
||||
chroot "$TARGET" /usr/bin/env -i \
|
||||
HOME=/root \
|
||||
TERM="$TERM" \
|
||||
PS1="$prompt" \
|
||||
PATH=/usr/bin:/usr/sbin \
|
||||
$@
|
||||
"$@"
|
||||
|
||||
umount $TARGET/dev/pts
|
||||
mountpoint -q $TARGET/dev/shm && umount $TARGET/dev/shm
|
||||
umount $TARGET/dev
|
||||
umount $TARGET/run
|
||||
umount $TARGET/proc
|
||||
umount $TARGET/sys
|
||||
# kill procs that may prevent umount
|
||||
killall -9 dirmngr 2> /dev/null
|
||||
killall -9 gpg-agent 2> /dev/null
|
||||
|
||||
umount "$TARGET/proc"
|
||||
mountpoint -q "$TARGET/sys/firmware/efi/efivars" && umount "$TARGET/sys/firmware/efi/efivars"
|
||||
umount "$TARGET/sys"
|
||||
|
||||
umount "$TARGET/dev/pts"
|
||||
mountpoint -q "$TARGET/dev/shm" && umount "$TARGET/dev/shm"
|
||||
umount "$TARGET/dev"
|
||||
umount "$TARGET/run"
|
||||
}
|
||||
|
||||
#################
|
||||
## main script ##
|
||||
#################
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
error "Cannot chroot without root"
|
||||
fi
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
error "Please specify a directory"
|
||||
fi
|
||||
@ -81,4 +95,4 @@ if [ $# -gt 1 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
chrt bash --login
|
||||
chrt bash --login
|
||||
|
Reference in New Issue
Block a user