From 0e6aa260ad59312ced486a5c76185765405deb70 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Sat, 23 Apr 2022 16:43:22 +0000 Subject: [PATCH] Default to ns mode (not fakeroot) for bin wrappers and add sudoj command This is related to #292 --- README.md | 19 ++++++++++++++----- bin/sudoj | 8 ++++++++ lib/checks/check_all.sh | 1 + lib/core/wrappers.sh | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) create mode 100755 bin/sudoj diff --git a/README.md b/README.md index 458c1ac..da7248e 100644 --- a/README.md +++ b/README.md @@ -110,25 +110,34 @@ used, see the [Usage](#usage) section below. Run JuNest installed programs directly from host OS --------------------------------------- -Installed programs can be accessible directly from host without -entering directly into a JuNest session (no need to call `junest` command). +Program installed within JuNest can be accessible directly from host machine +without entering directly into a JuNest session +(no need to call `junest` command first). For instance, supposing the host OS is an Ubuntu distro you can directly run `pacman` by simply updating the `PATH` variable: ```sh export PATH="$PATH:~/.junest/usr/bin_wrappers" -pacman -S htop +sudoj pacman -S htop htop ``` -By default the wrappers use `"ns --fakeroot"` but you can change it via `JUNEST_ARGS` environment variable. +By default the wrappers use `ns` mode. To use the `ns --fakeroot` you can use the convenient command helper `sudoj`. +For more control on backend mode you can use the `JUNEST_ARGS` environment variable. For instance, if you want to run `iftop` with real root privileges: ``` -pacman -S iftop +sudoj pacman -S iftop sudo JUNEST_ARGS="groot" iftop ``` +Bin wrappers can be always recreated (e.g. in case for some reasons they get +corrupted) with: + +``` +junest create-bin-wrappers -f +``` + Install packages from AUR ------------------------- diff --git a/bin/sudoj b/bin/sudoj new file mode 100755 index 0000000..aa43e15 --- /dev/null +++ b/bin/sudoj @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# This file is part of JuNest (https://github.com/fsquillace/junest). +# + +export PATH="${PATH}:${JUNEST_HOME}/usr/bin_wrappers" + +JUNEST_ARGS="ns --fakeroot" "$@" diff --git a/lib/checks/check_all.sh b/lib/checks/check_all.sh index 394309c..2b39f9a 100755 --- a/lib/checks/check_all.sh +++ b/lib/checks/check_all.sh @@ -24,3 +24,4 @@ sudo -E "$JUNEST_SCRIPT" groot -- "$CHECK_SCRIPT" --run-root-tests --skip-aur-te # Test the wrappers work "$JUNEST_SCRIPT" create-bin-wrappers --force "$JUNEST_HOME"/usr/bin_wrappers/pacman --help +"${JUNEST_BASE}/bin/sudoj" pacman -Syu diff --git a/lib/core/wrappers.sh b/lib/core/wrappers.sh index da5517f..13b206a 100644 --- a/lib/core/wrappers.sh +++ b/lib/core/wrappers.sh @@ -36,7 +36,7 @@ function create_wrappers() { cat < "${JUNEST_HOME}/usr/bin_wrappers/${file}" #!/usr/bin/env bash -JUNEST_ARGS=\${JUNEST_ARGS:-ns --fakeroot} +JUNEST_ARGS=\${JUNEST_ARGS:-ns} eval junest "\${JUNEST_ARGS}" -- ${file} "\$(printf "%q" "\$@")" EOF