From 57d68b45fc391353db9c80d381740f0c324985c4 Mon Sep 17 00:00:00 2001 From: HikariKnight <2557889+HikariKnight@users.noreply.github.com> Date: Sun, 14 Jan 2024 10:20:45 +0100 Subject: [PATCH] feat(just): add support for all distrobox args and do some cleanup --- build/ublue-os-just/libfunctions.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/build/ublue-os-just/libfunctions.sh b/build/ublue-os-just/libfunctions.sh index 2c06e14b..ba8b15be 100644 --- a/build/ublue-os-just/libfunctions.sh +++ b/build/ublue-os-just/libfunctions.sh @@ -11,7 +11,9 @@ function Choose (){ echo "$CHOICE" } +######## ## Function to generate a confirm dialog and return the selected choice +######## # CHOICE=$(Confirm "Are you sure you want to do this?") # *user selects "No"* # echo "$CHOICE" will return "1" @@ -22,9 +24,16 @@ function Confirm (){ echo $? } -### Function to create a distrobox with standardized args +######## +## Function to create a distrobox with standardized args +######## +## Create a distrobox using default fedora:latest, name the box "my-fedora-box" and give it a custom homedir # Distrobox "fedora:latest" "my-fedora-box" "$HOME/.var/containers/fedora-box" +## Create a debian toolbox distrobox named debian-unstable # Distrobox "quay.io/toolbx-images/debian-toolbox:unstable" "debian-unstable" +## Create an ubuntu distrobox named someubuntubox with no custom homedir and unshare network namespace +## ($3 is required if supplying extra args, using "" makes the function skip it) +# Distrobox "ubuntu:latest" "someubuntubox" "" --unshare-ns function Distrobox (){ IMAGE="$1" NAME="$2" @@ -34,14 +43,15 @@ function Distrobox (){ HOMEDIR="$3" fi + # If a custom home directory is not specified if [ -z "$HOMEDIR" ]; then - distrobox-create --nvidia --image "$IMAGE" -n "$NAME" -Y + distrobox-create --nvidia --image "$IMAGE" -n "$NAME" "${@:2}" -Y else # Make the custom homedir path if it does not exist if [ ! -d "$HOMEDIR" ]; then mkdir -p "$HOMEDIR" fi # Create distrobox with custom home path - distrobox-create --nvidia --image "$IMAGE" -n "$NAME" -H "$HOMEDIR" -Y + distrobox-create --nvidia --image "$IMAGE" -n "$NAME" -H "$HOMEDIR" "${@:3}" -Y fi }