summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-02-26 16:25:59 +0100
committerHelmut Grohne <helmut@subdivi.de>2024-02-26 16:25:59 +0100
commitae025c7aba7e4cbbe794cb48de4464d0e136dfee (patch)
treee3ee9ca5fd3bd7b9631ed8e6c221060b5a76f35d
parentf0979fae03bcc4767ac4df1cb8fad9277e952637 (diff)
downloaddebvm-ae025c7aba7e4cbbe794cb48de4464d0e136dfee.tar.gz
debvm-create: allow running without unshare again
In a CI-environment such as salsa-ci, we tend to run as root and want --mode=root rather than --mode=unshare.
-rwxr-xr-xbin/debvm-create19
1 files changed, 15 insertions, 4 deletions
diff --git a/bin/debvm-create b/bin/debvm-create
index b93fa23..a8d5727 100755
--- a/bin/debvm-create
+++ b/bin/debvm-create
@@ -303,12 +303,17 @@ fi
# construct mmdebstrap options as $@:
set -- \
--verbose \
- --mode=unshare \
--variant=apt \
"--format=$MMFORMAT" \
'--customize-hook=echo "LABEL=debvm / ext4 defaults 0 0" >"$1/etc/fstab"' \
"$@"
+if test "$(id -u)" = 0; then
+ set -- --mode=root "$@"
+else
+ set -- --mode=unshare "$@"
+fi
+
if test -n "$ARCHITECTURE"; then
set -- "--architecture=$ARCHITECTURE" "$@"
fi
@@ -394,9 +399,15 @@ if ! check_skip autologin; then
set -- "--customize-hook=$SHARE_DIR/customize-autologin.sh" "$@"
fi
-run_inside_userns() {
- unshare --user --map-auto --map-user=65536 --map-group=65536 --keep-caps -- "$@"
-}
+if test "$(id -u)" = 0; then
+ run_inside_userns() {
+ "$@"
+ }
+else
+ run_inside_userns() {
+ unshare --user --map-auto --map-user=65536 --map-group=65536 --keep-caps -- "$@"
+ }
+fi
TEMPROOT=
cleanup() {