File label-install of Package grafana-container

#!/bin/sh -eu

# This is the install script for grafana when run in a privileged
# container.

cd /
PATH="/usr/bin:/usr/sbin"
CONTAINER=grafana
BINSCRIPT=${CONTAINER}-container-manage.sh
MAINFON=${CONTAINER}-functions
MAINCONF=${CONTAINER}-container.conf

echo "LABEL INSTALL"
# ensure all scripts will be present on the host 
if [ ! -e /host/usr/local/bin/${BINSCRIPT} ]; then
	echo "copy /container/${BINSCRIPT} in /host/usr/local/bin/"
	cp -av /container/${BINSCRIPT} /host/usr/local/bin/
else
	echo "/host/usr/local/bin/${BINSCRIPT} already exist"
fi

# For podman, cp a systemd unit for starting on boot
if [ ! -e /host/etc/systemd/system/${CONTAINER}.service ]; then
	mkdir -p /host/etc/systemd/system/
	cp -pv /container/${CONTAINER}.service /host/etc/systemd/system/
else
	echo "/host/etc/systemd/system/${CONTAINER}.service already exist"
fi

# ensure CONTAINER-container.conf is present on the host 
if [ ! -e /host/etc/${MAINCONF} ]; then
	echo "copy /container/${MAINCONF} in /host/etc/"
	cp -av /container/${MAINCONF} /host/etc/
else
	echo "/host/etc/${MAINCONF} already exist"
fi

# ensure CONTAINER-functions is present on the host 
if [ ! -e /host/etc/${MAINFON} ]; then
	echo "copy /container/${MAINFON} in /host/etc/"
	cp -av /container/${MAINFON} /host/etc/
else
	echo "/host/etc/${MAINFON} already exist"
fi
openSUSE Build Service is sponsored by