File virt-manager-manage.sh of Package virt-manager-container

#!/bin/bash
# aginies@suse.com
# quick script to manage the container

if [ -f /etc/virt-manager-functions ] ; then
    . /etc/virt-manager-functions
elif [ -f `pwd`/virt-manager-functions ]; then
    echo "Found local version of virt-manager-functions"
    export CONF="`pwd`/virt-manager-container.conf"
    . "`pwd`/virt-manager-functions"
else
    echo "! need /etc/virt-manager-functions; Exiting";
    exit 1
fi
check_load_config_file

run_container() {
podman container runlabel run ${IMAGE}
}

info() {
cat <<EOF 
Configuration file: ${CONF}
#####################################################
CONTAINER_NAME: '${CONTAINER_NAME}'
IMAGE: '${IMAGE}'
#####################################################
EOF
}

if [ -z "$1" ]; then
info
echo "

First ARG is mandatory:
$0 [run|rm|rmcache|logs]


DEPLOYMENT:
run
    start virt-manager

rm
    delete the container '${CONTAINER_NAME}'

rmcache
    remove the container image in cache ${IMAGE}

DEBUG:
logs
    see log of container '${CONTAINER_NAME}'

 "
 exit 1
fi

###########
# MAIN
###########
set -uxo pipefail

case $1 in
    rm)
    set +e
    podman stop ${CONTAINER_NAME}
    podman rm ${CONTAINER_NAME}
    ;;
    run)
    run_container
    ;;
    rmcache)
    podman rmi ${IMAGE}
    ;;
    logs)
    podman logs ${CONTAINER_NAME}
    ;;
    info)
    info
    ;;
esac
openSUSE Build Service is sponsored by