androot/mount.sh
JeremyStarTM 3f0f0e0113 Update code
CHANGES
- [androot.sh] Improve code quality
- [androot.sh] Modify DOWNLOADSERVER* variables
- [patch.sh] Implement rootfs patching
- [prepare.sh] Squashed bugs
- [rootfsbuilder/archlinux-x86_64.sh] Remove "copy pacman config" flag causing some issues
- [systeminstall.sh] Implement rootfs configuration and update script

BUGS
- [systeminstall.sh|patch.sh] Scripts only work on the same architecture as the host
2023-11-10 15:08:35 +01:00

68 lines
1.9 KiB
Bash
Executable file

#!/bin/bash
# disable errors regarding androot.source as
# it is created and loaded at runtime
# shellcheck disable=SC1091
source "${TMPDIR}/androot.source"
source "${TMPDIR}/androot.env"
log_diag "mount is now executing, with arguments \"${*}\""
# to avoid repetition
function mountf() {
# $@ is used intentionally here, so ignore error
# shellcheck disable=SC2068
if ! log_execute mount ${@}; then
indicate_fail
exit 1
fi
}
# to avoid repetition
function umountf() {
# $@ is used intentionally here, so ignore error
# shellcheck disable=SC2068
if ! log_execute umount ${@}; then
indicate_fail
exit 1
fi
}
case "${1}" in
"--mount")
log_diag "Using mount mode"
mkdir -p "${LOCATION}/mountdir"
# remount /data on android to enable
# suid and exec flags
if [ "${IS_ANDROID}" == "true" ]; then
indicate_exec "Remounting /data"
mount_fail "/data (remount)" "/data" -o remount,suid,exec
indicate_ok
fi
indicate_exec "Mounting rootfs"
mountf --bind "${LOCATION}/rootfs" "${LOCATION}/mountdir" -o rw,suid,dev,exec,auto,nouser,async
indicate_ok
indicate_exec "Binding directories"
# mount /dev BEFORE /dev/pts
mountf --bind "/dev" "${LOCATION}/mountdir/dev"
mountf --bind "/dev/pts" "${LOCATION}/mountdir/dev/pts"
mountf --bind "/sys" "${LOCATION}/mountdir/sys"
mountf --bind "/proc" "${LOCATION}/mountdir/proc"
indicate_ok
;;
"--unmount")
log_diag "Using unmount mode"
indicate_exec "Unmounting binds"
# unmount /dev AFTER /dev/pts
umountf "${LOCATION}/mountdir/dev/pts"
umountf "${LOCATION}/mountdir/dev"
umountf "${LOCATION}/mountdir/sys"
umountf "${LOCATION}/mountdir/proc"
indicate_ok
indicate_exec "Unmounting rootfs"
umountf "${LOCATION}/mountdir"
indicate_ok
;;
*)
log_error "--mount or --unmount required"
exit 1
;;
esac