Skip to content

Commit

Permalink
feat: Simplify and document upgrade process (#44)
Browse files Browse the repository at this point in the history
* fix: Explicitly pull latest image before container creation

* refactor(setup.sh): Simplify container removal

* style(setup.sh): Do single-line for if-then

* feat(setup.sh): Add upgrade option

* refactor: Move relevant echo to `remove_davincibox_container` function

* docs: Add Upgrading section
  • Loading branch information
zelikos authored Dec 18, 2023
1 parent cd50ba4 commit 420cc5b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 22 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,40 @@ The suffix at the end is for the `add-davinci-launcher` script. If omitted, setu

You can still run `add-davinci-launcher` separately, as either `add-davinci-launcher distrobox` or `add-davinci-launcher toolbox`, depending on what you're using.

## Upgrading

Upgrading requires re-creating the davincibox container with the newest version of the image.

If a new version of davincibox is available and you want to upgrade, you can do so manually or with `setup.sh`.

### `setup.sh`

Run `setup.sh upgrade`, then follow the installation steps above.

### Manual

See the Uninstallation section below, then go through manual setup again.

## Uninstallation

Run `./setup.sh remove`, or

Distrobox:

```
# If you are upgrading, you can avoid this line
distrobox enter davincibox -- add-davinci-launcher remove
distrobox stop davincibox
distrobox rm davincibox
```

Toolbox:

```
# If you are upgrading, you can avoid this line
toolbox run --container davincibox add-davinci-launcher remove
podman container stop davincibox
toolbox rm davincibox
```
Expand Down
52 changes: 30 additions & 22 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

container_type=""

remove_davincibox_container () {
podman container stop davincibox
podman container rm davincibox

echo "davincibox removed."
}

# Check if distrobox is installed
if ! command -v distrobox &> /dev/null
then
if ! command -v distrobox &> /dev/null; then
# If no distrobox, check for toolbox
echo "Distrobox not found. Checking for toolbox..."
if ! command -v toolbox &> /dev/null
then
if ! command -v toolbox &> /dev/null; then
echo "Toolbox not found."
# If neither are installed, inform the user, then exit
echo "Please install either distrobox or toolbox to use this script."
Expand All @@ -23,27 +28,32 @@ else
fi


if [[ $1 == "remove" ]]
then
echo "Removing DaVinci Resolve and davincibox..."
if [[ $container_type == "distrobox" ]]
then
if [[ $1 == "remove" ]]; then
if [[ $container_type == "distrobox" ]]; then
distrobox enter davincibox -- add-davinci-launcher remove
distrobox stop davincibox
distrobox rm davincibox
elif [[ $container_type == "toolbox" ]]
then
elif [[ $container_type == "toolbox" ]]; then
toolbox run --container davincibox add-davinci-launcher remove
podman container stop davincibox
toolbox rm davincibox
fi
echo "davincibox removed."

echo "Removing DaVinci Resolve and davincibox..."
remove_davincibox_container
elif [[ $1 == "upgrade" ]]; then
echo "Removing davincibox container..."
remove_davincibox_container

echo "To complete the upgrade, re-run this setup script"
echo "as you would for a fresh installation."
echo "e.g. ./setup.sh DaVinci_Resolve_18.5.1_Linux.run"
else
# Create davincibox on user's system
echo "Setting up davincibox..."

if [[ $container_type == "distrobox" ]]
then
# Do this separately here to ensure the latest image is present
# before the container is created.
# See https://github.com/zelikos/davincibox/issues/26#issuecomment-1850642631
podman image pull ghcr.io/zelikos/davincibox:latest

if [[ $container_type == "distrobox" ]]; then
distrobox create -i ghcr.io/zelikos/davincibox:latest -n davincibox
# Start up the container now after creation,
# rather than during the later steps
Expand All @@ -55,11 +65,9 @@ else

# Check for installer file validity here instead of above,
# because container can still be set up whether the file is valid or not.
if [[ -f $(readlink -e $1) ]]
then
if [[ -f $(readlink -e $1) ]]; then
# Run setup-davinci
if [[ $container_type == "distrobox" ]]
then
if [[ $container_type == "distrobox" ]]; then
distrobox enter davincibox -- setup-davinci $1 $container_type
else
toolbox run --container davincibox setup-davinci $1 $container_type
Expand Down

0 comments on commit 420cc5b

Please sign in to comment.