summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2019-05-01 13:24:07 +0200
committerKarel Kočí <cynerd@email.cz>2019-05-01 13:24:07 +0200
commit6689047a779b248e3444821344a71a7498f405a1 (patch)
treede7c1237344f9cd0909d217d16dd1e1dadf70713 /scripts
parent03b93d2eb0afb92b9bdd20f58234e1281e07887f (diff)
downloadlaminar-cnf-6689047a779b248e3444821344a71a7498f405a1.tar.gz
laminar-cnf-6689047a779b248e3444821344a71a7498f405a1.tar.bz2
laminar-cnf-6689047a779b248e3444821344a71a7498f405a1.zip
uchroot: fix for qemu hosted systems
It seems that because in case of qemu run ash it does not detect that it should a loggin shell. This changes uchroot so it forces ash to be always logging shell. This also makes user argument optional
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/uchroot33
1 files changed, 15 insertions, 18 deletions
diff --git a/scripts/uchroot b/scripts/uchroot
index ad6b9c3..5a876c2 100755
--- a/scripts/uchroot
+++ b/scripts/uchroot
@@ -1,14 +1,10 @@
#!/bin/sh
+# Usage: uchroot [USER [SCRIPT [ARG]..]]
+# Configuration has to be passed trough envrionment.
+# ROOT: path to directory to chroot in
+# ARCH: optional target architecture (if qemu should be used)
+# MOUNT: pairs of two paths separated by colon (LOCAL:INROOT)
set -e
-[ $# -ge 1 ] || {
- echo "Usage: uchroot USER [CMD] [ARG].." >&2
- echo "Configuration has to be passed trough envrionment."
- echo " ROOT: path to directory to chroot in"
- echo " ARCH: optional target architecture (if qemu should be used)"
- echo " MOUNT: pairs of two paths separated by colon (LOCAL:INROOT)"
- exit 1
-}
-
if [ "$(id -u)" != "0" ]; then
exec uroot --binfmt "$0" "$@"
fi
@@ -19,13 +15,6 @@ fi
exit 1
}
-USR="${1:-root}"
-shift
-[ $# -lt 1 ] && CMD="" || {
- CMD="-c \"$1\""
- shift
-}
-
[ -d "$ROOT" ] || {
echo "There is no such directory: $ROOT" >&2
exit 1
@@ -52,5 +41,13 @@ if [ "$ARCH" != "$(arch)" ]; then
cp -f "$qemu_exec" "$ROOT$qemu_exec"
fi
-exec chroot "$ROOT" /bin/sh -c \
- ". /etc/profile && exec su -l $USR $CMD \"\$@\"" -- "$@"
+USR="${1:-root}"
+shift 2>/dev/null || true
+
+if [ $# -gt 0 ]; then
+ SCRIPT="$1"
+ shift
+ exec chroot "$ROOT" /bin/su -l "$USR" -- -l -c "$SCRIPT" -- "$@"
+else
+ exec chroot "$ROOT" /bin/su -l "$USR" -- -l
+fi