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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
#!/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
DISTRIBUTION="$(cat /etc/debian_version)"
case "${DISTRIBUTION}" in
10.*|buster/sid)
;;
*)
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
|