Skip to content

Commit

Permalink
improve help outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
89luca89 committed Dec 10, 2021
1 parent da70f3b commit 3a561e5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 16 deletions.
19 changes: 11 additions & 8 deletions distrobox-create
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ show_help() {
cat <<EOF
distrobox version: ${version}
distrobox-create takes care of creating the container with input name and image.
Created container will be tightly integrated with the host, allowing to share
the HOME folder of the user, external storage, external usb devices and
graphical apps (X11/Wayland) and audio.
Usage:
distrobox-create --image registry.fedoraproject.org/fedora-toolbox:35 --name fedora-toolbox-35
Expand All @@ -42,7 +47,6 @@ Options:
--help/-h: show this message
--verbose/-v: show more verbosity
--version/-V: show version
"
EOF
}

Expand Down Expand Up @@ -101,6 +105,7 @@ generate_command() {
# Set the container hostname the same as the container name.
# use the host's namespace for ipc, network, pid, ulimit
result_command="podman create"
# add podman verbose if -v is specified
if [ "${verbose}" -ne 0 ]; then
result_command="${result_command} --log-level debug"
fi
Expand Down Expand Up @@ -141,9 +146,10 @@ generate_command() {
result_command="${result_command} --volume ${host_directory}:/run/host${host_directory}:rslave"
fi
done

# those are dynamic configs needed by the container to function properly
# and integrate with the host
host_links="/etc/host.conf /etc/hosts /etc/resolv.conf /etc/localtime /etc/timezone"
host_links="/etc/host.conf /etc/hosts /etc/resolv.conf /etc/localtime"
for host_link in ${host_links}; do
# Check if the file exists first
if [ -f "${host_link}" ]; then
Expand All @@ -152,10 +158,6 @@ generate_command() {
fi
done

if [ -d /run/media ]; then
result_command="${result_command} --volume /run/media:/run/media:rslave"
fi

# mount also the XDG_RUNTIME_DIR to ensure functionality of the apps
if [ -d /run/user/"${container_user_uid}" ]; then
result_command="${result_command} --volume /run/user/${container_user_uid}:/run/user/${container_user_uid}"
Expand Down Expand Up @@ -211,5 +213,6 @@ if ! podman image exists "${container_image}"; then
fi

# Generate the command and execute
# shellcheck disable=SC2046
eval $(generate_command)
cmd="$(generate_command)"
# shellcheck disable=SC2086
eval ${cmd}
11 changes: 8 additions & 3 deletions distrobox-enter
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ show_help() {
cat <<EOF
distrobox version: ${version}
distrobox-enter takes care of entering the container with the name specified.
Default command executed is your SHELL, buf you can specify different shells or
entire commands to execute.
Usage:
distrobox-enter --name fedora-toolbox-35 -- bash -l
Expand All @@ -37,7 +41,6 @@ Options:
--help/-h: show this message
--verbose/-v: show more verbosity
--version/-V: show version
"
EOF
}

Expand Down Expand Up @@ -117,6 +120,7 @@ podman logs -f ${container_name}"

# entering container using our user and workdir
result_command="podman exec"
# add podman verbose if -v is specified
if [ "${verbose}" -ne 0 ]; then
result_command="${result_command} --log-level debug"
fi
Expand All @@ -134,5 +138,6 @@ podman logs -f ${container_name}"
}

# Generate the command and execute
# shellcheck disable=SC2046
eval $(generate_command)
cmd="$(generate_command)"
# shellcheck disable=SC2086
eval ${cmd}
22 changes: 20 additions & 2 deletions distrobox-export
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,30 @@ show_help() {
cat <<EOF
distrobox version: ${version}
distrobox-export takes care of exporting an app or a service from the container
to the host.
Exported app will be easily available in your normal launcher and it will
automatically be launched from the container it is exported from.
Exported servicess will be available in the host's user's systemd session, so
systemctl --user status exported_service_name
will show the status of the service exported.
You can specifi additional flags to add to the command, for example if you want
to export an electron app, you could add the "--foreground" flag to the command:
distrobox-export --app atom --extra-flags "--foreground"
This works for both services and apps.
Note you can use --app OR --service but not together.
Usage:
distrobox-export --app mpv
distrobox-export --service syncthing
Note you can use --app OR --service but not together.
Options:
--app/-a: name of the application to export
Expand All @@ -47,7 +66,6 @@ Options:
--extra-flags/-ef: extra flags to add to the command
--verbose/-v: show more verbosity
--version/-V: show version
"
EOF
}

Expand Down
11 changes: 9 additions & 2 deletions distrobox-init
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ show_help() {
cat <<EOF
distrobox version: ${version}
distrobox-init is the entrypoint of a created distrobox.
Note that this HAS to run from inside a distrobox, will not work if you run it
from your host.
distrobox-init will take care of installing missing dependencies (eg. sudo), set
up the user and groups, mount folders from the host to ensure the tight
integration.
Usage:
distrobox-init --name ${USER} --user $(id -ru) --group $(id -rg) --home ${HOME}
Expand All @@ -32,7 +40,6 @@ Options:
--help/-h: show this message
--verbose/-v: show more verbosity
--version/-V: show version
"
EOF
}

Expand Down Expand Up @@ -208,7 +215,7 @@ done

# We'll also bind mount READ-WRITE useful mountpoints to pass external drives and libvirt from
# the host to the container
HOST_MOUNTS="/media /mnt /run/systemd/journal /run/libvirt /var/mnt /var/lib/libvirt"
HOST_MOUNTS="/media /run/media /mnt /run/systemd/journal /run/libvirt /var/mnt /var/lib/libvirt"
for host_mount in ${HOST_MOUNTS}; do
mount_bind /run/host"${host_mount}" "${host_mount}" rw
done
Expand Down
1 change: 0 additions & 1 deletion install
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Options:
--path/-p: path where to deploy the files (default /usr/local/bin)
--help/-h: show this message
-v: show more verbosity
"
EOF
}

Expand Down

0 comments on commit 3a561e5

Please sign in to comment.