summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/cmd/shell.sh12
-rw-r--r--man/prokit-shell.8in7
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/cmd/shell.sh b/lib/cmd/shell.sh
index dfff07f..b5b6d69 100644
--- a/lib/cmd/shell.sh
+++ b/lib/cmd/shell.sh
@@ -18,12 +18,14 @@
# along with the ProteanOS Development Kit. If not, see
# <http://www.gnu.org/licenses/>.
+use block
use profile
use session
cmd_shell_main()
{
local root=
+ local dev=
if [ ${#} -lt 1 ]; then
print_cmd_usage 'shell' >&2
@@ -33,6 +35,12 @@ cmd_shell_main()
root="${1}"
shift 1
+ dev=''
+ if is_block "${root}"; then
+ dev="${root}"
+ root="$(block_mount "${dev}")"
+ fi
+
. "${root}/etc/os-release"
profile_set "${ID}"
@@ -45,4 +53,8 @@ cmd_shell_main()
session_exec "${@}"
fi
session_end
+
+ if [ "x${dev}" != 'x' ]; then
+ block_umount "${root}"
+ fi
}
diff --git a/man/prokit-shell.8in b/man/prokit-shell.8in
index f42b15a..bb98ae1 100644
--- a/man/prokit-shell.8in
+++ b/man/prokit-shell.8in
@@ -5,12 +5,15 @@
prokit-shell \- Run a shell in an isolated environment
.SH SYNOPSIS
-\fBprokit shell\fP \fIroot-dir\fP [\fIcommand\fP [\fIargument\fP ...]]
+\fBprokit shell\fP \fIroot\fP [\fIcommand\fP [\fIargument\fP ...]]
.SH DESCRIPTION
\fBprokit shell\fP starts a shell in an isolated file system environment (using
\fBchroot\fP(8)) with basic file systems mounted.
.P
+If \fIroot\fP is a block device node, the block device is mounted and a shell is
+started in its file system.
+.P
If a \fIcommand\fP is given (with optional \fIargument\fPs), it is executed in a
non-interactive shell.
@@ -20,6 +23,8 @@ non-interactive shell.
# prokit shell $root echo Hello world
.IP \[bu]
# prokit shell $root 'opkg install build-essential-$(cat /etc/proteanos_arch)'
+.IP \[bu]
+# prokit shell /dev/sdb1
.SH COPYRIGHT
Copyright (C) 2014 Patrick "P. J." McDermott