#!/bin/sh set -e PROJECT="progress-linux" DOMAIN="progress-linux.org" PACKAGES="https://cdn.deb.progress-linux.org/packages" Install_apt_sources () { cat > "/etc/apt/sources.list.d/${PROJECT}.list" << EOF # /etc/apt/sources.list.d/${PROJECT}.list EOF } Remove_apt_sources () { rm -f "/etc/apt/sources.list.d/${PROJECT}.list" } Install_apt_preferences () { cat > "/etc/apt/preferences.d/${PROJECT}.pref" << EOF # /etc/apt/preferences.d/${PROJECT}.pref EOF } Remove_apt_preferences () { rm -f "/etc/apt/preferences.d/${PROJECT}.pref" } Install_apt_keys () { cp -f "/usr/share/${PROJECT}/pgp-keys/apt.${DOMAIN}.gpg" "/etc/apt/trusted.gpg.d/${PROJECT}.gpg" } Remove_apt_keys () { rm -f "/etc/apt/trusted.gpg.d/${PROJECT}.gpg" } Configure_apt_sources () { ARCHIVE="${1}" case "${ARCHIVE}" in *-extras) AREAS="${ARCHIVE_AREAS}" ;; *) AREAS="$(echo ${ARCHIVE_AREAS} | sed -e 's| restricted||')" ;; esac cat >> "/etc/apt/sources.list.d/${PROJECT}.list" << EOF deb ${PACKAGES} ${ARCHIVE} ${AREAS} EOF } Configure_apt_preferences () { ARCHIVE="${1}" cat >> "/etc/apt/preferences.d/${PROJECT}.pref" << EOF Package: * Pin: release n=${ARCHIVE} Pin-Priority: 999 EOF } Configure_ssh_known_hosts () { KEY="$(cat /usr/share/${PROJECT}/ssh-keys/ssh.${DOMAIN}.pub)" if [ ! -e "/etc/ssh/ssh_known_hosts" ] then mkdir -p /etc/ssh cat > "/etc/ssh/ssh_known_hosts" << EOF # /etc/ssh/ssh_known_hosts @cert-authority *.${DOMAIN} ${KEY} EOF else grep -v "^@cert-authority \*.${DOMAIN}" /etc/ssh/ssh_known_hosts > /etc/ssh/ssh_known_hosts.tmp cat >> "/etc/ssh/ssh_known_hosts.tmp" << EOF @cert-authority *.${DOMAIN} ${KEY} EOF mv -f /etc/ssh/ssh_known_hosts.tmp /etc/ssh/ssh_known_hosts fi } Remove_ssh_known_hosts () { if [ ! -e /etc/ssh/ssh_known_hosts ] then return fi # ssh cert-authority grep -v "^@cert-authority \*.${DOMAIN}" /etc/ssh/ssh_known_hosts > /etc/ssh/ssh_known_hosts.tmp if [ "$(md5sum /etc/ssh/ssh_known_hosts.tmp | cut -d' ' -f1)" = "2a2b4fdd70705b2029b35a24217138e6" ] then rm -f /etc/ssh/ssh_known_hosts.tmp rm -f /etc/ssh/ssh_known_hosts rmdir /etc/ssh > /dev/null 2>&1 || true else mv -f /etc/ssh/ssh_known_hosts.tmp /etc/ssh/ssh_known_hosts fi } case "${1}" in configure) . /usr/share/debconf/confmodule db_get ${PROJECT}/archives ARCHIVES="$(echo ${RET} | sed -e 's|, | |g')" # multiselect w/ empty db_get ${PROJECT}/archive-areas ARCHIVE_AREAS="$(echo ${RET:-main} | sed -e 's|, | |g')" # string w/o empty db_stop DEBIAN_VERSION="$(cat /etc/debian_version)" case "${DEBIAN_VERSION}" in 10.*|buster/sid) ;; 11.*|bullseye/sid) ;; *) echo "W: unsupported debian release" Remove_apt_sources Remove_apt_preferences Remove_apt_keys Remove_ssh_known_hosts exit 0 ;; esac # apt if [ -n "${ARCHIVES}" ] then Install_apt_sources Install_apt_preferences Install_apt_keys for ARCHIVE in ${ARCHIVES} do Configure_apt_sources ${ARCHIVE} Configure_apt_preferences ${ARCHIVE} done else Remove_apt_sources Remove_apt_preferences Remove_apt_keys fi # openssh-server Configure_ssh_known_hosts ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`${1}'" >&2 exit 1 ;; esac #DEBHELPER# exit 0