Skip to content

Commit

Permalink
feat(just): add support for all distrobox args and do some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
HikariKnight committed Jan 14, 2024
1 parent 5f1a41f commit 57d68b4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions build/ublue-os-just/libfunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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
}

0 comments on commit 57d68b4

Please sign in to comment.