File label-install of Package bind-container

#!/bin/bash

copy_to_usr_local_sbin() {
    SCRIPT=$1
    BASEDIR=`dirname $SCRIPT`
    mkdir -p $BASEDIR
    if [ ! -e /host/usr/local/sbin/${SCRIPT} ]; then
        echo "Copying /container/${SCRIPT} to /host/usr/local/sbin/"
        cp -rp /container/${SCRIPT} /host/usr/local/sbin/${SCRIPT}
    else
        echo "/host/usr/local/sbin/${SCRIPT} already exists, will not update it"
    fi
}

copy_service_file() {
SERVICE=$1
if [ ! -e /host/etc/systemd/system/${SERVICE} ]; then
        echo "Copying /container/${SERVICE} to /host/etc/systemd/system/"
        cp -rp /container/${SERVICE} /host/etc/systemd/system/${SERVICE}
else
        echo "/host/etc/systemd/system/${SERVICE} already exists, will not update it"
fi
}

echo "LABEL INSTALL"

copy_service_file named.service

copy_to_usr_local_sbin rndc

if [ -d /host/var/lib/named ]; then
    echo "/host/var/lib/named already exists, will not update it"
else
    cp -rvp /var/lib/named /host/var/lib/named
fi
if [ -d /host/etc/named.d ]; then
    echo "/host/etc/named.d already exists, will not update it"
else
    cp -rvp /etc/named.d /host/etc/named.d
fi
if [ -f /host/etc/named.conf ]; then
    echo "/host/etc/named.conf already exists, will not update it"
else
    cp -rvp /etc/named.conf /host/etc/named.conf
fi
if [ -L /host/etc/rndc.key ]; then
    echo "/host/etc/rndc.key already exists, will not update it"
else
    # Replace logger since it isn't present in the install container
    sed -i 's/logger/echo/g' /usr/libexec/bind/named.prep
    /usr/libexec/bind/named.prep
    cp -vp /var/lib/named/rndc.key /host/var/lib/named
    ln -vs /var/lib/named/rndc.key /host/etc/rndc.key
fi
openSUSE Build Service is sponsored by