summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2014-09-23 11:10:06 (EDT)
committer P. J. McDermott <pj@pehjota.net>2014-09-23 11:10:06 (EDT)
commitabd26803bbf56a5c40e5e8f32fc08d63cccb6690 (patch)
tree3737b4963747383347520dce6f0aeb7c53f2fc6d
parent5419c7519a416670db8223206218c0693e8c1425 (diff)
cmd/shell: Mount working directory within root
This makes ProteanOS utilities like those of platconf-pkg-tools easily usable.
-rw-r--r--lib/cmd/shell.sh20
1 files changed, 18 insertions, 2 deletions
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/${$}"
}