File firefox-wrapper.sh of Package firefox-image

#!/bin/bash

set -e

FIREFOX_VERSION="__FIREFOX_VERSION__"
RELEASE="__RELEASE__"
DIGEST="$FIREFOX_VERSION-$RELEASE"
CONTAINERNAME="firefox-image"
APPNAME="firefox"
REGISTRY="registry.opensuse.org/home/msirringhaus/firefox-container/opensuse_factory_containerfile/opensuse/bci/firefox"
IMAGE="$REGISTRY:$DIGEST"
EXPORT_DEST="$HOME/.local/suse/bin/"

function get_container_image() {
  podman container list -a --format "{{.Image}}" --filter "name=$CONTAINERNAME"
}

function container_exists() {
  image=$(get_container_image)
  return $(test "$image" == "$IMAGE")
}

function main() {
  if ! container_exists; then
    echo "Throwing away container"
    distrobox rm -f "$CONTAINERNAME"
    echo "(Re)creating container"
    distrobox create -n "$CONTAINERNAME" -i "$IMAGE" --no-entry --pull
    echo "Creating binary export"
    distrobox enter "$CONTAINERNAME" -- distrobox-export --bin "/usr/bin/$APPNAME" --export-path "$EXPORT_DEST"
  fi
  echo "Found container. Starting app."
  "$EXPORT_DEST/$APPNAME"
}

main "$@"
openSUSE Build Service is sponsored by