mirror of
https://github.com/kevinveenbirkenbach/linux-image-manager.git
synced 2024-12-22 20:15:03 +01:00
Refactored code
This commit is contained in:
parent
473de735de
commit
e8f23beb33
@ -35,35 +35,46 @@
|
||||
# https://gist.github.com/htruong/0271d84ae81ee1d301293d126a5ad716
|
||||
# so it's better just to let the pi resize the partitions
|
||||
|
||||
mkdir -p /mnt/raspbian
|
||||
# shellcheck source=/dev/null # Deactivate SC1090
|
||||
# shellcheck disable=SC2015 # Deactivating bool hint
|
||||
source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1)
|
||||
|
||||
# mount partition
|
||||
mount -o rw "$1""2" /mnt/raspbian
|
||||
mount -o rw "$1""1" /mnt/raspbian/boot
|
||||
info "Making mount dir..." &&
|
||||
mkdir -p /mnt/raspbian ||
|
||||
error "Failed."
|
||||
|
||||
# mount binds
|
||||
mount --bind /dev /mnt/raspbian/dev/
|
||||
mount --bind /sys /mnt/raspbian/sys/
|
||||
mount --bind /proc /mnt/raspbian/proc/
|
||||
mount --bind /dev/pts /mnt/raspbian/dev/pts
|
||||
info "Mount partitions..."
|
||||
mount -o rw "$1""2" /mnt/raspbian &&
|
||||
mount -o rw "$1""1" /mnt/raspbian/boot ||
|
||||
error "Failed."
|
||||
|
||||
# ld.so.preload fix
|
||||
sed -i 's/^/#CHROOT /g' /mnt/raspbian/etc/ld.so.preload
|
||||
info "Mount binds..." &&
|
||||
mount --bind /dev /mnt/raspbian/dev/ &&
|
||||
mount --bind /sys /mnt/raspbian/sys/ &&
|
||||
mount --bind /proc /mnt/raspbian/proc/ &&
|
||||
mount --bind /dev/pts /mnt/raspbian/dev/pts &&
|
||||
error "Failed."
|
||||
|
||||
# copy qemu binary
|
||||
cp /usr/bin/qemu-arm-static /mnt/raspbian/usr/bin/
|
||||
info "ld.so.preload fix" &&
|
||||
sed -i 's/^/#CHROOT /g' /mnt/raspbian/etc/ld.so.preload ||
|
||||
error "Failed."
|
||||
|
||||
echo "You will be transferred to the bash shell now."
|
||||
echo "Issue 'exit' when you are done."
|
||||
echo "Issue 'su pi' if you need to work as the user pi."
|
||||
info "copy qemu binary" &&
|
||||
cp -v /usr/bin/qemu-arm-static /mnt/raspbian/usr/bin/ ||
|
||||
error "Failed."
|
||||
|
||||
# chroot to raspbian
|
||||
chroot /mnt/raspbian /bin/bash
|
||||
info "You will be transferred to the bash shell now." &&
|
||||
info "Issue 'exit' when you are done." &&
|
||||
info "Issue 'su pi' if you need to work as the user pi." &&
|
||||
info "chroot to raspbian" &&
|
||||
chroot /mnt/raspbian /bin/bash ||
|
||||
error "Failed."
|
||||
|
||||
# ----------------------------
|
||||
# Clean up
|
||||
# revert ld.so.preload fix
|
||||
sed -i 's/^#CHROOT //g' /mnt/raspbian/etc/ld.so.preload
|
||||
info "Clean up" &&
|
||||
info "revert ld.so.preload fix" &&
|
||||
sed -i 's/^#CHROOT //g' /mnt/raspbian/etc/ld.so.preload ||
|
||||
error "Failed."
|
||||
|
||||
# unmount everything
|
||||
umount /mnt/raspbian/{dev/pts,dev,sys,proc,boot,}
|
||||
info "unmount everything" &&
|
||||
umount /mnt/raspbian/{dev/pts,dev,sys,proc,boot,} ||
|
||||
error "Failed."
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC2010 # ls | grep allowed
|
||||
# shellcheck source=/dev/null # Deactivate SC1090
|
||||
source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1)
|
||||
|
||||
info "Setupscript for images started..."
|
||||
|
Loading…
Reference in New Issue
Block a user