summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-09-02 22:55:51 +0200
committerKarel Kočí <cynerd@email.cz>2018-09-02 23:18:50 +0200
commite753a4d1af740a3cfeb4a4c994395f3a0a5a3c73 (patch)
tree43f8f15d1309d8b101e6feba431a10fc6aa5d4ae /scripts
parent0f6273a567c504ed4dc631ba18252ea0e16146b0 (diff)
downloadlaminar-cnf-e753a4d1af740a3cfeb4a4c994395f3a0a5a3c73.tar.gz
laminar-cnf-e753a4d1af740a3cfeb4a4c994395f3a0a5a3c73.tar.bz2
laminar-cnf-e753a4d1af740a3cfeb4a4c994395f3a0a5a3c73.zip
alpine-amd64: try to change how we do chroot
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/uchroot15
1 files changed, 7 insertions, 8 deletions
diff --git a/scripts/uchroot b/scripts/uchroot
index 6aa76b2..b11981a 100755
--- a/scripts/uchroot
+++ b/scripts/uchroot
@@ -1,7 +1,7 @@
#!/bin/sh
set -e
-[ $# -ge 2 ] || {
- echo "Usage: uchroot ROOT USER[:GROUP] [CMD] [ARG].." >&2
+[ $# -ge 1 ] || {
+ echo "Usage: uchroot ROOT [USER] [CMD]" >&2
exit 1
}
@@ -11,8 +11,10 @@ fi
###############################################################
ROOT="$1"
-USERSPEC="$2"
+USR="${2:-root}"
shift 2
+[ $# -lt 1 ] && CMD="" || CMD="-c '$@'"
+
[ -d "$ROOT" ] || {
echo "There is no such directory: $ROOT" >&2
exit 1
@@ -22,14 +24,11 @@ shift 2
exit 1
}
-
+mount --rbind "$ROOT" "$ROOT"
mount -t proc none "$ROOT/proc"
mount --rbind /dev "$ROOT/dev"
mount --rbind /sys "$ROOT/sys"
cp -f /etc/resolv.conf "$ROOT/etc/resolv.conf"
cp -f /etc/hosts "$ROOT/etc/hosts"
-if [ $# -lt 1 ]; then
- set "/bin/sh"
-fi
-exec chroot --userspec="$USERSPEC" "$ROOT" "$@"
+exec chroot "$ROOT" /bin/sh -c ". /etc/profile && exec su $CMD -l $USR" "$0"