diff options
-rwxr-xr-x | debian/progress-linux.postinst | 119 |
1 files changed, 63 insertions, 56 deletions
diff --git a/debian/progress-linux.postinst b/debian/progress-linux.postinst index 59e68c9..b284aac 100755 --- a/debian/progress-linux.postinst +++ b/debian/progress-linux.postinst @@ -2,48 +2,51 @@ set -e -Install_apt () -{ - # apt sources - echo "Installing /etc/apt/sources.list.d/progress-linux.list ..." +PROJECT="progress-linux" +DOMAIN="progress-linux.org" +PACKAGES="https://deb.progress-linux.org/packages" -cat > /etc/apt/sources.list.d/progress-linux.list << EOF -# /etc/apt/sources.list.d/progress-linux.list +Install_apt_sources () +{ +cat > "/etc/apt/sources.list.d/${PROJECT}.list" << EOF +# /etc/apt/sources.list.d/${PROJECT}.list EOF +} - # apt preferences - echo "Installing /etc/apt/preferences.d/progress-linux.pref ..." +Remove_apt_sources () +{ + rm -f "/etc/apt/sources.list.d/${PROJECT}.list" +} -cat > /etc/apt/preferences.d/progress-linux.pref << EOF -# /etc/apt/preferences.d/progress-linux.pref +Install_apt_preferences () +{ +cat > "/etc/apt/preferences.d/${PROJECT}.pref" << EOF +# /etc/apt/preferences.d/${PROJECT}.pref EOF +} - # apt key - echo "Installing /etc/apt/trusted.gpg.d/progress-linux.gpg ..." - rm -f /etc/apt/trusted.gpg.d/progress-linux.gpg - for KEY in /usr/share/progress-linux/pgp-keys/*archive-key.gpg - do - cat "${KEY}" >> /etc/apt/trusted.gpg.d/progress-linux.gpg - done +Remove_apt_preferences () +{ + rm -f "/etc/apt/preferences.d/${PROJECT}.pref" } -Remove_apt () +Install_apt_keys () { - # apt sources - echo "Removing /etc/apt/sources.list.d/progress-linux.list ..." - rm -f /etc/apt/sources.list.d/progress-linux.list + rm -f "/etc/apt/trusted.gpg.d/${PROJECT}.gpg" - # apt preferences - echo "Removing /etc/apt/sources.list.d/progress-linux.list ..." - rm -f /etc/apt/preferences.d/progress-linux.pref + for KEY in "/usr/share/${PROJECT}/pgp-keys"/*archive-key.gpg + do + cat "${KEY}" >> "/etc/apt/trusted.gpg.d/${PROJECT}.gpg" + done +} - # apt key - echo "Removing /etc/apt/trusted.gpg.d/progress-linux.gpg ..." - rm -f /etc/apt/trusted.gpg.d/progress-linux.gpg +Remove_apt_keys () +{ + rm -f "/etc/apt/trusted.gpg.d/${PROJECT}.gpg" } -Configure_apt () +Configure_apt_sources () { ARCHIVE="${1}" @@ -57,13 +60,16 @@ Configure_apt () ;; esac - # apt sources - cat >> /etc/apt/sources.list.d/progress-linux.list << EOF -deb https://deb.progress-linux.org/packages ${ARCHIVE} ${AREAS} +cat >> "/etc/apt/sources.list.d/${PROJECT}.list" << EOF +deb ${PACKAGES} ${ARCHIVE} ${AREAS} EOF +} + +Configure_apt_preferences () +{ + ARCHIVE="${1}" - # apt preferences - cat >> /etc/apt/preferences.d/progress-linux.pref << EOF +cat >> "/etc/apt/preferences.d/${PROJECT}.pref" << EOF Package: * Pin: release n=${ARCHIVE} @@ -71,28 +77,25 @@ Pin-Priority: 999 EOF } -Configure_ssh () +Configure_ssh_known_hosts () { - KEY="$(cat /usr/share/progress-linux/ssh-keys/ssh.progress-linux.org.pub)" - - echo "Installing /etc/ssh/ssh_known_hosts ..." + KEY="$(cat /usr/share/${PROJECT}/ssh-keys/ssh.${DOMAIN}.pub)" if [ ! -e "/etc/ssh/ssh_known_hosts" ] then - # ssh cert-authority mkdir -p /etc/ssh cat > "/etc/ssh/ssh_known_hosts" << EOF # /etc/ssh/ssh_known_hosts -@cert-authority *.progress-linux.org ${KEY} +@cert-authority *.${DOMAIN} ${KEY} EOF else - grep -v '^@cert-authority \*.progress-linux.org' /etc/ssh/ssh_known_hosts > /etc/ssh/ssh_known_hosts.tmp + 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 *.progress-linux.org ${KEY} +@cert-authority *.${DOMAIN} ${KEY} EOF mv -f /etc/ssh/ssh_known_hosts.tmp /etc/ssh/ssh_known_hosts @@ -103,30 +106,34 @@ case "${1}" in configure) . /usr/share/debconf/confmodule - db_get progress-linux/archives - ARCHIVES="${RET}" # multiselect w/ empty + db_get ${PROJECT}/archives + ARCHIVES="$(echo ${RET} | sed -e 's|, | |g')" # multiselect w/ empty - db_get progress-linux/archive-areas - ARCHIVE_AREAS="${RET:-main}" # string w/o empty + db_get ${PROJECT}/archive-areas + ARCHIVE_AREAS="$(echo ${RET:-main} | sed -e 's|, | |g')" # string w/o empty db_stop + # apt if [ -n "${ARCHIVES}" ] then - Install_apt + 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 + Remove_apt_sources + Remove_apt_preferences + Remove_apt_keys fi - ARCHIVES="$(echo ${ARCHIVES} | sed -e 's|, | |g')" - ARCHIVE_AREAS="$(echo ${ARCHIVE_AREAS} | sed -e 's|, | |g')" - - for ARCHIVE in ${ARCHIVES} - do - Configure_apt ${ARCHIVE} - done - - Configure_ssh + # openssh-server + Configure_ssh_known_hosts ;; abort-upgrade|abort-remove|abort-deconfigure) |