linux-image-manager/scripts/image/chroot.sh

48 lines
1.2 KiB
Bash
Raw Normal View History

2020-05-02 11:46:39 +02:00
#!/bin/bash
2020-05-15 10:41:44 +02:00
# shellcheck source=/dev/null # Deactivate SC1090
# shellcheck disable=SC2015 # Deactivating bool hint
2020-05-19 11:10:06 +02:00
# shellcheck disable=SC2154 # Deactivate not referenced link
2020-05-15 12:00:03 +02:00
source "$(dirname "$(readlink -f "${0}")")/base.sh" || (echo "Loading base.sh failed." && exit 1)
2020-05-15 10:41:44 +02:00
2020-05-15 12:23:07 +02:00
info "Starting chroot..."
set_device_path
2020-05-15 14:10:24 +02:00
make_working_folder
2020-05-15 10:41:44 +02:00
2020-05-15 14:10:24 +02:00
make_mount_folders
2020-05-15 12:23:07 +02:00
set_partition_paths
2020-05-15 12:00:03 +02:00
2020-05-15 14:10:24 +02:00
mount_partitions
2020-05-15 10:41:44 +02:00
2020-05-15 14:10:24 +02:00
mount_binds
2020-05-15 10:41:44 +02:00
info "ld.so.preload fix" &&
2020-05-15 18:11:30 +02:00
sed -i 's/^/#CHROOT /g' "$root_mount_path""etc/ld.so.preload" ||
warning "Failed."
2020-05-15 10:41:44 +02:00
2020-05-15 18:11:30 +02:00
info "Copy qemu binary..." &&
cp -v /usr/bin/qemu-arm-static "$root_mount_path""usr/bin/" ||
2020-05-15 11:18:19 +02:00
error
2020-05-15 10:41:44 +02:00
2020-05-15 18:11:30 +02:00
info "Copy resolve.conf..."
cp -v /etc/resolv.conf "$root_mount_path""etc/" &&
warning "Failed. Propably there is no internet connection available."
2020-05-15 10:41:44 +02:00
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" &&
2020-05-15 12:00:03 +02:00
chroot "$root_mount_path" /bin/bash ||
2020-05-15 11:18:19 +02:00
error
2020-05-15 10:41:44 +02:00
info "Clean up" &&
info "revert ld.so.preload fix" &&
2020-05-15 18:11:30 +02:00
sed -i 's/^#CHROOT //g' "$root_mount_path""etc/ld.so.preload" ||
warning "Failed."
2020-05-15 10:41:44 +02:00
info "unmount everything" &&
2020-05-15 12:00:03 +02:00
umount "$root_mount_path"/{dev/pts,dev,sys,proc,boot,} ||
2020-05-15 11:18:19 +02:00
error