From abd26803bbf56a5c40e5e8f32fc08d63cccb6690 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 23 Sep 2014 11:10:06 -0400 Subject: cmd/shell: Mount working directory within root This makes ProteanOS utilities like those of platconf-pkg-tools easily usable. --- diff --git a/lib/cmd/shell.sh b/lib/cmd/shell.sh index 2745f4b..5c85d7e 100644 --- a/lib/cmd/shell.sh +++ b/lib/cmd/shell.sh @@ -24,6 +24,7 @@ use chroot cmd_shell_main() { local root= + local uname_s= if [ ${#} -lt 1 ]; then print_cmd_usage 'shell' >&2 @@ -36,13 +37,28 @@ cmd_shell_main() . "${root}/etc/os-release" profile_set "${ID}" + uname_s="$( (uname -s) 2>/dev/null)" || uname_s='unknown' + mkdir -p "${root}/prokit/wd/${$}" + case "${uname_s}" in + 'Linux') + mount -o bind . "${root}/prokit/wd/${$}" + ;; + esac + chroot_mount "${root}" if [ ${#} -eq 0 ]; then - chroot "${root}" /bin/sh + chroot "${root}" /bin/sh -c "cd '/prokit/wd/${$}'; /bin/sh" printf '\n' info "$(get_msg 'cmd_shell_exiting')" else - chroot "${root}" /bin/sh -c "${*}" + chroot "${root}" /bin/sh -c "cd '/prokit/wd/${$}'; ${*}" fi chroot_umount "${root}" + + case "${uname_s}" in + 'Linux') + umount "${root}/prokit/wd/${$}" + ;; + esac + rmdir "${root}/prokit/wd/${$}" } -- cgit v0.9.1