1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
#!/bin/bash
# Copyright (C) 2024 Pädagogisches Landesinstitut Rheinland-Pfalz
# Copyright (C) 2024 Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
# postinst script for debian-edu-router-fai
#
# see: dh_installdeb(1)
set -e
# DEBCONF IS NOT AVAILABLE, PLEASE AMEND TO Pre-Depends BEFORE ENABLING.
#. /usr/share/debconf/confmodule || exit 255
if [ -e /etc/debian-edu/router.conf ]; then
source /etc/debian-edu/router.conf
fi
PRODUCTNAME="${PRODUCTNAME:-"Debian Edu Router"}"
PRODUCTNAME_FAI="${PRODUCTNAME_FAI:-"${PRODUCTNAME} FAI"}"
PRODUCTVERSION=$(dpkg-query --show --showformat='${Version}' "${DPKG_MAINTSCRIPT_PACKAGE}" 2>/dev/null || echo "UNKNOWN")
# db_title "${PRODUCTNAME_FAI}"
common_file="/usr/share/debian-edu-router/debian-edu-router.common"
# Load common functions, variables and stuff.
if [ -s "$common_file" ]; then
source "$common_file"
else
echo "Could not load common file at "$common_file"."
exit 0;
fi
# db_version 2.0
# db_capb backup escape
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package
# Load dialog answers
# db_get debian-edu-router-fai... || true
# question="${RET}"
function center() {
local total_width="$1"
local str="$2"
local str_length=${#str}
local padding=$(( (total_width - str_length) / 2 ))
local left_padding=$padding
local right_padding=$(( total_width - str_length - left_padding ))
printf "%${left_padding}s%s%${right_padding}s" "" "$str" ""
}
function create_files_from_templates() {
product_name_and_version="${PRODUCTNAME_FAI} ${PRODUCTVERSION}"
# Pad $product_name_and_version, with spaces left and right, to make it center aligned.
product_name_and_version="$(center 54 "$product_name_and_version")"
fai_templates_dir="/usr/share/debian-edu-router/templates/debian-edu-router-fai.TEMPLATE/"
# NOTE: .temp, not .in! .in files are also used by FAI.
for conf_tpl in $(ls ${fai_templates_dir}/*.temp); do
conf="/etc/debian-edu/fai/debian-edu-router-fai.TEMPLATE/$(basename ${conf_tpl/.temp/})"
cp "${conf_tpl}" "${conf}"
sed -i "${conf}" -e "s|@PRODUCT_NAME_AND_VERSION@|${product_name_and_version}|" \
${NULL}
done
}
function main() {
create_files_from_templates
debug_log "Configuration of '$PRODUCTNAME' FAI finished."
}
case "$1" in
configure)
main
;;
abort-upgrade)
notice_log "Upgrade of debian-edu-router-fai package was aborted."
;;
*)
error_log "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
|