#!/bin/sh set -e CONFFILE="/etc/compute-tools/container.conf" Install () { DEFAULT="${1}" TARGET="${2}" mkdir -p "${DEFAULT}" > /dev/null 2>&1 || true mkdir -p "${TARGET}" > /dev/null 2>&1 || true if [ "${TARGET}" != "${DEFAULT}" ] then if [ -h "${DEFAULT}" ] then rm -f "${DEFAULT}" ln -s "${TARGET}" "${DEFAULT}" else if [ -e "${DEFAULT}" ] && [ -z "$(ls -A ${DEFAULT})" ] then rmdir "${DEFAULT}" ln -s "${TARGET}" "${DEFAULT}" fi fi fi if ! dpkg-statoverride --list "${DEFAULT}" > /dev/null 2>&1 && ! dpkg-statoverride --list "${TARGET}" > /dev/null 2>&1 then chmod ${DIRECTORY_PERMISSIONS} "${TARGET}" chown root:root "${TARGET}" chmod ${DIRECTORY_PERMISSIONS} "${DEFAULT}" chown root:root "${DEFAULT}" fi } case "${1}" in configure) . /usr/share/debconf/confmodule db_get open-infrastructure-compute-tools/machines-directory MACHINES_DIRECTORY="${RET:-/var/lib/machines}" # string (w/o empty) db_get open-infrastructure-compute-tools/config-directory CONFIG_DIRECTORY="${RET:-/etc/compute-tools/config}" # string (w/o empty) db_get open-infrastructure-compute-tools/debconf-directory DEBCONF_DIRECTORY="${RET:-/etc/compute-tools/debconf}" # string (w/o empty) db_get open-infrastructure-compute-tools/hooks-directory HOOKS_DIRECTORY="${RET:-/etc/compute-tools/hooks}" # string (w/o empty) db_get open-infrastructure-compute-tools/keys-directory KEYS_DIRECTORY="${RET:-/etc/compute-tools/keys}" # string (w/o empty) db_get open-infrastructure-compute-tools/cache-directory CACHE_DIRECTORY="${RET:-/var/cache/container}" # string (w/o empty) db_get open-infrastructure-compute-tools/directory-permissions DIRECTORY_PERMISSIONS="${RET}" # select (w/o empty) db_get open-infrastructure-compute-tools/build-script SCRIPT="${RET:-debian}" # string (w/o empty) db_get open-infrastructure-compute-tools/irc IRK_TARGETS="${RET}" # string (w/ empty) db_stop Install "/var/lib/machines" "${MACHINES_DIRECTORY}" Install "/etc/compute-tools/config" "${CONFIG_DIRECTORY}" Install "/etc/compute-tools/debconf" "${DEBCONF_DIRECTORY}" Install "/etc/compute-tools/hooks" "${HOOKS_DIRECTORY}" Install "/etc/compute-tools/keys" "${KEYS_DIRECTORY}" Install "/var/cache/container" "${CACHE_DIRECTORY}" if [ ! -e "${CONFFILE}" ] then cat > "${CONFFILE}" << EOF # ${CONFFILE} IRK_TARGETS="${IRK_TARGETS}" EOF fi cp -a -f "${CONFFILE}" "${CONFFILE}.tmp" # If the admin deleted or commented some variables but then set # them via debconf, (re-)add them to the config file. test -z "${IRK_TARGETS}" || \ grep -Eq '^ *IRK_TARGETS=' "${CONFFILE}" || \ echo "IRK_TARGETS=" >> "${CONFFILE}" sed -e "s|^ *IRK_TARGETS=.*|IRK_TARGETS=\"${IRK_TARGETS}\"|" \ < "${CONFFILE}" > "${CONFFILE}.tmp" mv -f "${CONFFILE}.tmp" "${CONFFILE}" if command -v sysctl > /dev/null 2>&1 then sysctl -q -p /etc/sysctl.d/zz-container.conf fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`${1}'" >&2 exit 1 ;; esac #DEBHELPER# case "${1}" in configure) # run after debhelper update-alternative scripts update-alternatives --quiet --set container_build-script "/usr/share/compute-tools/build-scripts/${SCRIPT}" ;; esac exit 0