2018-08-31 16:02:49 +00:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
2019-01-04 12:37:52 +00:00
|
|
|
|
# Copyright © 2018 – 2019 Red Hat, Inc.
|
2018-08-31 16:02:49 +00:00
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
source /etc/os-release
|
2018-10-15 17:24:12 +00:00
|
|
|
|
release=$VERSION_ID
|
2018-08-31 16:02:49 +00:00
|
|
|
|
|
2018-09-20 18:33:00 +00:00
|
|
|
|
prefix_sudo=""
|
2018-10-12 15:03:23 +00:00
|
|
|
|
registry="registry.fedoraproject.org"
|
|
|
|
|
registry_candidate="candidate-registry.fedoraproject.org"
|
2018-09-12 12:54:50 +00:00
|
|
|
|
toolbox_prompt="🔹[\u@\h \W]\\$ "
|
2018-08-31 16:02:49 +00:00
|
|
|
|
|
|
|
|
|
|
2018-11-07 16:17:02 +00:00
|
|
|
|
is_integer()
|
|
|
|
|
{
|
|
|
|
|
[ "$1" != "" ] && [ $1 -eq $1 2>&42 ]
|
|
|
|
|
return $?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-08-31 16:02:49 +00:00
|
|
|
|
create()
|
2018-09-14 17:27:50 +00:00
|
|
|
|
(
|
2018-11-09 12:27:40 +00:00
|
|
|
|
dbus_system_bus_address="unix:path=/var/run/dbus/system_bus_socket"
|
2018-11-07 11:56:10 +00:00
|
|
|
|
tmpfs_size=$((64 * 1024 * 1024)) # 64 MiB
|
2018-09-14 17:27:50 +00:00
|
|
|
|
working_container_name="fedora-toolbox-working-container-$(uuidgen --time)"
|
|
|
|
|
|
2018-12-03 11:49:13 +00:00
|
|
|
|
if [ "$DBUS_SYSTEM_BUS_ADDRESS" != "" ]; then
|
|
|
|
|
dbus_system_bus_address=$DBUS_SYSTEM_BUS_ADDRESS
|
|
|
|
|
fi
|
|
|
|
|
dbus_system_bus_path=$(echo $dbus_system_bus_address | cut --delimiter = --fields 2 2>&42)
|
|
|
|
|
dbus_system_bus_path=$(readlink --canonicalize $dbus_system_bus_path 2>&42)
|
|
|
|
|
|
2019-01-11 13:50:02 +00:00
|
|
|
|
echo "$0: checking if image $toolbox_image already exists" >&42
|
|
|
|
|
|
2018-09-26 15:14:08 +00:00
|
|
|
|
if ! $prefix_sudo buildah inspect --type image $toolbox_image >/dev/null 2>&42; then
|
2019-01-11 13:50:02 +00:00
|
|
|
|
echo "$0: trying to create working container $working_container_name" >&42
|
|
|
|
|
echo "$0: looking for image localhost/$base_toolbox_image" >&42
|
|
|
|
|
|
2018-10-12 15:03:23 +00:00
|
|
|
|
if ! $prefix_sudo buildah from \
|
|
|
|
|
--name $working_container_name \
|
|
|
|
|
localhost/$base_toolbox_image >/dev/null 2>&42; then
|
2019-01-11 13:50:02 +00:00
|
|
|
|
echo "$0: looking for image $registry/$fgc/$base_toolbox_image" >&42
|
|
|
|
|
|
2018-10-12 15:03:23 +00:00
|
|
|
|
if ! $prefix_sudo buildah from \
|
|
|
|
|
--name $working_container_name \
|
|
|
|
|
$registry/$fgc/$base_toolbox_image >/dev/null 2>&42; then
|
|
|
|
|
echo "$0: failed to create working container"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2018-08-31 16:02:49 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2019-01-11 13:50:02 +00:00
|
|
|
|
echo "$0: trying to configure working container $working_container_name" >&42
|
|
|
|
|
|
2018-09-20 18:33:00 +00:00
|
|
|
|
if ! $prefix_sudo buildah run $working_container_name -- useradd \
|
2018-08-31 16:02:49 +00:00
|
|
|
|
--no-create-home \
|
2018-10-25 15:07:36 +00:00
|
|
|
|
--shell $SHELL \
|
2018-08-31 16:02:49 +00:00
|
|
|
|
--uid $UID \
|
|
|
|
|
--groups wheel \
|
|
|
|
|
$USER \
|
2018-09-12 18:13:32 +00:00
|
|
|
|
>/dev/null 2>&42; then
|
2019-01-03 13:00:43 +00:00
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
2018-08-31 16:02:49 +00:00
|
|
|
|
echo "$0: failed to create user $USER with UID $UID"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2018-09-20 18:33:00 +00:00
|
|
|
|
if ! $prefix_sudo buildah run $working_container_name -- passwd -d $USER >/dev/null 2>&42; then
|
2019-01-03 13:00:43 +00:00
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
2018-08-31 16:02:49 +00:00
|
|
|
|
echo "$0: failed to remove password for user $USER"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2018-09-20 18:34:31 +00:00
|
|
|
|
if ! $prefix_sudo buildah run $working_container_name -- passwd -d root >/dev/null 2>&42; then
|
2019-01-03 13:00:43 +00:00
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
2018-09-20 18:34:31 +00:00
|
|
|
|
echo "$0: failed to remove password for user root"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2018-09-20 18:33:00 +00:00
|
|
|
|
if ! $prefix_sudo buildah config --volume $HOME $working_container_name >/dev/null 2>&42; then
|
2019-01-03 13:00:43 +00:00
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
2018-08-31 16:02:49 +00:00
|
|
|
|
echo "$0: failed to configure volume for $HOME"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2018-09-20 18:33:00 +00:00
|
|
|
|
if ! $prefix_sudo buildah config --volume $XDG_RUNTIME_DIR $working_container_name >/dev/null 2>&42; then
|
2019-01-03 13:00:43 +00:00
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
2018-11-09 10:58:18 +00:00
|
|
|
|
echo "$0: failed to configure volume for $XDG_RUNTIME_DIR"
|
2018-08-31 16:02:49 +00:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2018-11-09 12:27:40 +00:00
|
|
|
|
if ! $prefix_sudo buildah config \
|
|
|
|
|
--volume $dbus_system_bus_path \
|
|
|
|
|
$working_container_name >/dev/null 2>&42; then
|
2019-01-03 13:00:43 +00:00
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
2018-11-09 12:27:40 +00:00
|
|
|
|
echo "$0: failed to configure volume for $dbus_system_bus_path"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2018-10-16 17:50:31 +00:00
|
|
|
|
if ! $prefix_sudo buildah config --volume /dev/dri $working_container_name >/dev/null 2>&42; then
|
2019-01-03 13:00:43 +00:00
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
2018-10-16 17:50:31 +00:00
|
|
|
|
echo "$0: failed to configure volume for /dev/dri"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2019-01-11 15:01:29 +00:00
|
|
|
|
if ! $prefix_sudo buildah config --volume /dev/fuse $working_container_name >/dev/null 2>&42; then
|
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
|
|
|
|
echo "$0: failed to configure volume for /dev/fuse"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2018-09-20 18:33:00 +00:00
|
|
|
|
if ! $prefix_sudo buildah config --user $USER $working_container_name >/dev/null 2>&42; then
|
2019-01-03 13:00:43 +00:00
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
2018-08-31 16:02:49 +00:00
|
|
|
|
echo "$0: failed to configure the default user as $USER"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2018-09-20 18:33:00 +00:00
|
|
|
|
if ! $prefix_sudo buildah config --workingdir $HOME $working_container_name >/dev/null 2>&42; then
|
2019-01-03 13:00:43 +00:00
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
2018-08-31 16:02:49 +00:00
|
|
|
|
echo "$0: failed to configure the initial working directory to $HOME"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2019-01-11 13:50:02 +00:00
|
|
|
|
echo "$0: trying to create image $toolbox_image" >&42
|
|
|
|
|
|
2018-09-20 18:33:00 +00:00
|
|
|
|
if ! $prefix_sudo buildah commit --rm $working_container_name $toolbox_image >/dev/null 2>&42; then
|
2019-01-03 13:00:43 +00:00
|
|
|
|
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
|
2018-08-31 16:02:49 +00:00
|
|
|
|
echo "$0: failed to create image $toolbox_image"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2019-01-11 13:50:02 +00:00
|
|
|
|
|
|
|
|
|
echo "$0: created image $toolbox_image" >&42
|
2018-08-31 16:02:49 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2019-01-11 13:50:02 +00:00
|
|
|
|
echo "$0: checking if container $toolbox_container already exists" >&42
|
|
|
|
|
|
2018-09-21 10:26:33 +00:00
|
|
|
|
if $prefix_sudo podman inspect --type container $toolbox_container >/dev/null 2>&42; then
|
|
|
|
|
echo "$0: container $toolbox_container already exists"
|
2018-08-31 16:02:49 +00:00
|
|
|
|
exit 1
|
2018-09-26 14:59:38 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2018-11-07 11:56:10 +00:00
|
|
|
|
total_ram=$(awk '( $1 == "MemTotal:" ) { print $2 }' /proc/meminfo 2>&42) # kibibytes
|
2018-11-07 16:17:02 +00:00
|
|
|
|
if is_integer $total_ram; then
|
2018-11-07 11:56:10 +00:00
|
|
|
|
tmpfs_size=$((total_ram*1024/2)) # bytes
|
|
|
|
|
fi
|
|
|
|
|
|
2018-09-26 14:59:38 +00:00
|
|
|
|
max_uid_count=65536
|
|
|
|
|
max_minus_uid=$((max_uid_count-UID))
|
|
|
|
|
uid_plus_one=$((UID+1))
|
2018-11-07 11:56:10 +00:00
|
|
|
|
|
2019-01-11 13:50:02 +00:00
|
|
|
|
echo "$0: trying to create container $toolbox_container" >&42
|
|
|
|
|
|
2018-09-26 14:59:38 +00:00
|
|
|
|
if ! $prefix_sudo podman create \
|
|
|
|
|
--group-add wheel \
|
|
|
|
|
--hostname toolbox \
|
|
|
|
|
--interactive \
|
|
|
|
|
--name $toolbox_container \
|
|
|
|
|
--network host \
|
|
|
|
|
--privileged \
|
|
|
|
|
--security-opt label=disable \
|
2018-11-07 11:56:10 +00:00
|
|
|
|
--tmpfs /dev/shm:size=$tmpfs_size \
|
2018-09-26 14:59:38 +00:00
|
|
|
|
--tty \
|
|
|
|
|
--uidmap $UID:0:1 \
|
|
|
|
|
--uidmap 0:1:$UID \
|
|
|
|
|
--uidmap $uid_plus_one:$uid_plus_one:$max_minus_uid \
|
|
|
|
|
--volume $HOME:$HOME \
|
|
|
|
|
--volume $XDG_RUNTIME_DIR:$XDG_RUNTIME_DIR \
|
2018-11-09 12:27:40 +00:00
|
|
|
|
--volume $dbus_system_bus_path:$dbus_system_bus_path \
|
2018-10-16 17:50:31 +00:00
|
|
|
|
--volume /dev/dri:/dev/dri \
|
2019-01-11 15:01:29 +00:00
|
|
|
|
--volume /dev/fuse:/dev/fuse \
|
2018-09-26 14:59:38 +00:00
|
|
|
|
$toolbox_image \
|
|
|
|
|
/bin/sh >/dev/null 2>&42; then
|
|
|
|
|
echo "$0: failed to create container $toolbox_container"
|
|
|
|
|
exit 1
|
2018-08-31 16:02:49 +00:00
|
|
|
|
fi
|
2019-01-11 13:50:02 +00:00
|
|
|
|
|
|
|
|
|
echo "$0: created container $toolbox_container" >&42
|
2018-09-14 17:27:50 +00:00
|
|
|
|
)
|
2018-08-31 16:02:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enter()
|
2018-11-12 13:38:44 +00:00
|
|
|
|
(
|
|
|
|
|
shell_to_exec=/bin/bash
|
|
|
|
|
|
2019-01-11 13:50:02 +00:00
|
|
|
|
echo "$0: trying to start container $toolbox_container" >&42
|
|
|
|
|
|
2018-09-20 18:33:00 +00:00
|
|
|
|
if ! $prefix_sudo podman start $toolbox_container >/dev/null 2>&42; then
|
2018-08-31 16:02:49 +00:00
|
|
|
|
echo "$0: failed to start container $toolbox_container"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2018-11-09 12:27:40 +00:00
|
|
|
|
if [ "$DBUS_SYSTEM_BUS_ADDRESS" != "" ]; then
|
|
|
|
|
set_dbus_system_bus_address="--env DBUS_SYSTEM_BUS_ADDRESS=$DBUS_SYSTEM_BUS_ADDRESS"
|
|
|
|
|
fi
|
|
|
|
|
|
2019-01-11 13:50:02 +00:00
|
|
|
|
echo "$0: looking for $SHELL in container $toolbox_container" >&42
|
|
|
|
|
|
2018-11-12 13:38:44 +00:00
|
|
|
|
if $prefix_sudo podman exec $toolbox_container test -f $SHELL 2>&42; then
|
|
|
|
|
shell_to_exec=$SHELL
|
|
|
|
|
else
|
2019-01-11 14:01:43 +00:00
|
|
|
|
echo "$0: $SHELL not found in $toolbox_container; using $shell_to_exec instead" >&42
|
2018-10-25 15:11:32 +00:00
|
|
|
|
fi
|
2018-11-12 13:38:44 +00:00
|
|
|
|
|
2019-01-11 13:50:02 +00:00
|
|
|
|
echo "$0: trying to exec $shell_to_exec in container $toolbox_container" >&42
|
|
|
|
|
|
2018-11-12 13:38:44 +00:00
|
|
|
|
$prefix_sudo podman exec \
|
|
|
|
|
--env COLORTERM=$COLORTERM \
|
|
|
|
|
--env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
|
|
|
|
|
$set_dbus_system_bus_address \
|
|
|
|
|
--env DESKTOP_SESSION=$DESKTOP_SESSION \
|
|
|
|
|
--env DISPLAY=$DISPLAY \
|
|
|
|
|
--env LANG=$LANG \
|
|
|
|
|
--env SHELL=$SHELL \
|
|
|
|
|
--env SSH_AUTH_SOCK=$SSH_AUTH_SOCK \
|
|
|
|
|
--env TERM=$TERM \
|
|
|
|
|
--env VTE_VERSION=$VTE_VERSION \
|
|
|
|
|
--env XDG_CURRENT_DESKTOP=$XDG_CURRENT_DESKTOP \
|
|
|
|
|
--env XDG_DATA_DIRS=$XDG_DATA_DIRS \
|
|
|
|
|
--env XDG_MENU_PREFIX=$XDG_MENU_PREFIX \
|
|
|
|
|
--env XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
|
|
|
|
|
--env XDG_SEAT=$XDG_SEAT \
|
|
|
|
|
--env XDG_SESSION_DESKTOP=$XDG_SESSION_DESKTOP \
|
|
|
|
|
--env XDG_SESSION_ID=$XDG_SESSION_ID \
|
|
|
|
|
--env XDG_SESSION_TYPE=$XDG_SESSION_TYPE \
|
|
|
|
|
--env XDG_VTNR=$XDG_VTNR \
|
|
|
|
|
--interactive \
|
|
|
|
|
--tty \
|
|
|
|
|
$toolbox_container \
|
2019-01-07 21:00:33 +00:00
|
|
|
|
/bin/sh -c 'cd "$1"; export PS1="$2"; shift 2; exec "$@"' \
|
|
|
|
|
/bin/sh \
|
|
|
|
|
"$PWD" \
|
|
|
|
|
"$toolbox_prompt" \
|
|
|
|
|
$shell_to_exec -l 2>&42
|
2018-11-12 13:38:44 +00:00
|
|
|
|
)
|
2018-08-31 16:02:49 +00:00
|
|
|
|
|
|
|
|
|
|
2018-10-12 14:58:21 +00:00
|
|
|
|
exit_if_extra_operand()
|
|
|
|
|
{
|
|
|
|
|
if [ "$1" != "" ]; then
|
|
|
|
|
echo "$0: extra operand '$1'"
|
|
|
|
|
echo "Try '$0 --help' for more information."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-10-15 15:05:49 +00:00
|
|
|
|
exit_if_unrecognized_option()
|
|
|
|
|
{
|
|
|
|
|
echo "$0: unrecognized option '$1'"
|
|
|
|
|
echo "Try '$0 --help' for more information."
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-08-31 16:02:49 +00:00
|
|
|
|
usage()
|
|
|
|
|
{
|
2018-10-16 17:21:46 +00:00
|
|
|
|
echo "Usage: fedora-toolbox [--container <name>]"
|
|
|
|
|
echo " [--release <release>]"
|
|
|
|
|
echo " [-v | --verbose]"
|
|
|
|
|
echo " create [--candidate-registry]"
|
2018-10-16 17:35:34 +00:00
|
|
|
|
echo " [--image <name>]"
|
2018-10-16 17:21:46 +00:00
|
|
|
|
echo " or: fedora-toolbox [--container <name>]"
|
|
|
|
|
echo " [--release <release>]"
|
|
|
|
|
echo " [-v | --verbose]"
|
|
|
|
|
echo " enter"
|
|
|
|
|
echo " or: fedora-toolbox --help"
|
2018-08-31 16:02:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-09-12 18:13:32 +00:00
|
|
|
|
exec 42>/dev/null
|
|
|
|
|
|
2018-10-26 11:41:30 +00:00
|
|
|
|
while [[ "$1" = -* ]]; do
|
2018-09-12 18:00:30 +00:00
|
|
|
|
case $1 in
|
2018-10-16 17:07:41 +00:00
|
|
|
|
--container )
|
|
|
|
|
shift
|
2018-10-26 11:41:30 +00:00
|
|
|
|
if [ "$1" = "" ]; then
|
2018-10-16 17:07:41 +00:00
|
|
|
|
echo "$0: missing argument for '--container'"
|
|
|
|
|
echo "Try '$0 --help' for more information."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
toolbox_container=$1
|
|
|
|
|
;;
|
2018-09-12 18:00:30 +00:00
|
|
|
|
-h | --help )
|
|
|
|
|
usage
|
|
|
|
|
exit
|
|
|
|
|
;;
|
2018-10-15 17:24:12 +00:00
|
|
|
|
--release )
|
|
|
|
|
shift
|
2018-10-26 11:41:30 +00:00
|
|
|
|
if [ "$1" = "" ]; then
|
2018-10-15 17:24:12 +00:00
|
|
|
|
echo "$0: missing argument for '--release'"
|
|
|
|
|
echo "Try '$0 --help' for more information."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2018-11-09 12:30:15 +00:00
|
|
|
|
arg=$(echo $1 | sed 's/^F\|^f//' 2>&42)
|
2018-11-07 16:17:02 +00:00
|
|
|
|
if ! is_integer $arg; then
|
2018-10-15 17:24:12 +00:00
|
|
|
|
echo "$0: invalid argument for '--release'"
|
|
|
|
|
echo "Try '$0 --help' for more information."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2018-10-26 12:06:52 +00:00
|
|
|
|
if [ $arg -le 0 2>&42 ]; then
|
|
|
|
|
echo "$0: invalid argument for '--release'"
|
|
|
|
|
echo "Try '$0 --help' for more information."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
release=$arg
|
2018-10-15 17:24:12 +00:00
|
|
|
|
;;
|
2018-09-20 18:33:00 +00:00
|
|
|
|
--sudo )
|
|
|
|
|
prefix_sudo="sudo"
|
|
|
|
|
;;
|
2018-09-12 18:13:32 +00:00
|
|
|
|
-v | --verbose )
|
|
|
|
|
exec 42>&2
|
|
|
|
|
;;
|
2018-09-12 18:00:30 +00:00
|
|
|
|
* )
|
2018-10-15 15:05:49 +00:00
|
|
|
|
exit_if_unrecognized_option $1
|
2018-09-12 18:00:30 +00:00
|
|
|
|
esac
|
|
|
|
|
shift
|
|
|
|
|
done
|
|
|
|
|
|
2018-10-15 17:24:12 +00:00
|
|
|
|
fgc="f$release"
|
2018-10-26 11:41:30 +00:00
|
|
|
|
[ "$toolbox_container" = "" ] && toolbox_container="fedora-toolbox-$USER:$release"
|
2018-10-15 17:24:12 +00:00
|
|
|
|
base_toolbox_image="fedora-toolbox:$release"
|
|
|
|
|
toolbox_image="fedora-toolbox-$USER:$release"
|
|
|
|
|
|
2018-10-26 11:41:30 +00:00
|
|
|
|
if [ "$1" = "" ]; then
|
2018-09-12 18:00:30 +00:00
|
|
|
|
echo "$0: missing command"
|
2018-09-12 17:53:31 +00:00
|
|
|
|
echo "Try '$0 --help' for more information."
|
2018-08-31 16:02:49 +00:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
op=$1
|
2018-10-12 14:58:21 +00:00
|
|
|
|
shift
|
|
|
|
|
|
2018-08-31 16:02:49 +00:00
|
|
|
|
case $op in
|
|
|
|
|
create )
|
2018-10-26 11:41:30 +00:00
|
|
|
|
while [[ "$1" = -* ]]; do
|
2018-10-12 14:58:21 +00:00
|
|
|
|
case $1 in
|
2018-10-12 15:03:23 +00:00
|
|
|
|
--candidate-registry )
|
|
|
|
|
registry=$registry_candidate
|
|
|
|
|
;;
|
2018-10-16 17:35:34 +00:00
|
|
|
|
--image )
|
|
|
|
|
shift
|
2018-10-26 11:41:30 +00:00
|
|
|
|
if [ "$1" = "" ]; then
|
2018-10-16 17:35:34 +00:00
|
|
|
|
echo "$0: missing argument for '--image'"
|
|
|
|
|
echo "Try '$0 --help' for more information."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
toolbox_image=$1
|
|
|
|
|
;;
|
2018-10-12 14:58:21 +00:00
|
|
|
|
* )
|
2018-10-15 15:05:49 +00:00
|
|
|
|
exit_if_unrecognized_option $1
|
2018-10-12 14:58:21 +00:00
|
|
|
|
esac
|
|
|
|
|
shift
|
|
|
|
|
done
|
|
|
|
|
exit_if_extra_operand $1
|
2018-08-31 16:02:49 +00:00
|
|
|
|
create
|
|
|
|
|
exit
|
|
|
|
|
;;
|
|
|
|
|
enter )
|
2018-10-26 11:41:30 +00:00
|
|
|
|
while [[ "$1" = -* ]]; do
|
2018-10-12 14:58:21 +00:00
|
|
|
|
case $1 in
|
|
|
|
|
* )
|
2018-10-15 15:05:49 +00:00
|
|
|
|
exit_if_unrecognized_option $1
|
2018-10-12 14:58:21 +00:00
|
|
|
|
esac
|
|
|
|
|
shift
|
|
|
|
|
done
|
|
|
|
|
exit_if_extra_operand $1
|
2018-08-31 16:02:49 +00:00
|
|
|
|
enter
|
|
|
|
|
exit
|
|
|
|
|
;;
|
|
|
|
|
* )
|
2018-10-12 15:32:06 +00:00
|
|
|
|
echo "$0: unrecognized command '$op'"
|
2018-08-31 16:02:49 +00:00
|
|
|
|
echo "Try '$0 --help' for more information."
|
|
|
|
|
exit 1
|
|
|
|
|
esac
|