postinst is in dtc-xen 0.5.17-1.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | #!/bin/sh
set -e
echoIfVerbose () {
if [ ""$VERBOSE_INSTALL = "yes" ] ; then
echo $1
fi
}
debian_get_config () {
. /usr/share/debconf/confmodule
db_version 2.0
db_get dtc-xen/conf_soap_login
conf_soap_login=$RET
db_get dtc-xen/conf_soap_pass
conf_soap_pass=$RET
db_get dtc-xen/conf_debian_repository
conf_debian_repository=$RET
db_get dtc-xen/conf_debian_release
conf_debian_release=$RET
db_get dtc-xen/conf_netmask
conf_netmask=$RET
db_get dtc-xen/conf_broadcast
conf_broadcast=$RET
db_get dtc-xen/conf_gateway
conf_gateway=$RET
db_get dtc-xen/conf_linux_kernel_name
conf_linux_kernel_name=$RET
db_get dtc-xen/conf_linux_domu_initrd
conf_linux_domu_initrd=$RET
db_get dtc-xen/conf_lvm_name
conf_lvm_name=$RET
db_get dtc-xen/conf_vps_mountpoint
conf_vps_mountpoint=$RET
db_get dtc-xen/conf_info_finish_setup
db_unregister dtc-xen/conf_soap_pass
db_stop
}
# Parameter:
# $1: field to search for
# $2: value to configure in it
replace_config_value () {
# If the varibale appears commented out (which is sometimes the default), uncomment
grep -Eq "^[ \t]*${1}=" ${DTCXEN_ETCPATH}/dtc-xen.conf || \
grep -Eq "^#[ \t]${1}=" ${DTCXEN_ETCPATH}/dtc-xen.conf && \
sed -i "s|^#[ \t]${1}=|${1}=|" ${DTCXEN_ETCPATH}/dtc-xen.conf
# If the variable isn't present after the above, happend it at the end of the file
grep -Eq "^[ \t]*${1}=" ${DTCXEN_ETCPATH}/dtc-xen.conf || \
echo "${1}=" >>${DTCXEN_ETCPATH}/dtc-xen.conf
# Finally, set the new value to the variable
sed -i "s|^[ \t]*${1}=.*|${1}=${2}|" ${DTCXEN_ETCPATH}/dtc-xen.conf
}
write_debian_config_files () {
replace_config_value provisioning_volgroup ${conf_lvm_name}
replace_config_value provisioning_mount_point ${conf_vps_mountpoint}
replace_config_value debian_repo ${conf_debian_repository}
replace_config_value debian_release ${conf_debian_release}
replace_config_value GATEWAY ${conf_gateway}
replace_config_value NETMASK ${conf_netmask}
replace_config_value BROADCAST ${conf_broadcast}
replace_config_value KERNEL_RELEASE ${conf_linux_kernel_name}
replace_config_value KMOD_PATH "/lib/modules/${conf_linux_kernel_name}"
replace_config_value KERNELPATH "/boot/vmlinuz-${conf_linux_kernel_name}"
if [ -f "/boot/initrd.img-${conf_linux_kernel_name}" ] ; then
replace_config_value INITRDPATH "/boot/initrd.img-${conf_linux_kernel_name}"
fi
replace_config_value cert_passphrase ${cert_passphrase}
}
create_ssl_cert () {
mkdir -p $DTCXEN_ETCPATH
CWD=`pwd`
cd $DTCXEN_ETCPATH
# Check if we have an old passphrase stored!
if [ -e ${DTCXEN_ETCPATH}/dtc-xen.conf ] ; then
. ${DTCXEN_ETCPATH}/dtc-xen.conf
fi
if [ -z "${cert_passphrase}" ] ; then
cert_passphrase=`dd if=/dev/random bs=64 count=1 2>|/dev/null | md5sum | cut -d' ' -f1`
fi
# If the config file exist, read the passphrase from the file
echoIfVerbose "---> Generating SSL certs for the SOAP python server"
rm -f $DTCXEN_ETCPATH/privkey.pem $DTCXEN_ETCPATH/dtc-xen.cert.csr $DTCXEN_ETCPATH/dtc-xen.cert.cert $DTCXEN_ETCPATH/dtc-xen.cert.key
CERTPASS_TMP_FILE=`${MKTEMP} certfilepass.XXXXXX` || exit 1
echo $cert_passphrase >$CERTPASS_TMP_FILE
OLD_UMASK=`umask`
umask 0077
( echo "US"; echo "the-state"; echo "My-ocation"; echo "GPLHost"; echo "No-unit"; echo $conf_soap_hostname;
echo "webmaster@"$conf_soap_hostname; echo "challenge pass";
echo $conf_cert_organization; ) | $OPENSSL req -passout file:$CERTPASS_TMP_FILE -new > $DTCXEN_ETCPATH/dtc-xen.cert.csr
$OPENSSL rsa -passin file:$CERTPASS_TMP_FILE -in $DTCXEN_ETCPATH/privkey.pem -out $DTCXEN_ETCPATH/dtc-xen.cert.key
$OPENSSL x509 -in $DTCXEN_ETCPATH/dtc-xen.cert.csr -out $DTCXEN_ETCPATH/dtc-xen.cert.cert -req -signkey $DTCXEN_ETCPATH/dtc-xen.cert.key -days 3650
umask $OLD_UMASK
rm $CERTPASS_TMP_FILE
cd $CWD
}
manage_htpasswd () {
if [ -e "/usr/bin/htpasswd" ] ;then
HTPASSWD="/usr/bin/htpasswd"
else
if [ -e "/usr/sbin/htpasswd2" ] ;then
HTPASSWD="/usr/sbin/htpasswd2"
else
echo "Didn't find any htpasswd binary: exiting !!!"
exit 1;
fi
fi
# Generate the htpasswd file (each time, it doesn't mater)
echoIfVerbose "---> Generating $DTCXEN_ETCPATH/htpasswd file for the SOAP python server"
# Just in case there's no password set (which is the case if running debconf in non-interactive), generate a random one
if [ -z ${conf_soap_pass} ] ; then
echoIfVerbose "WARNING: No password set durring debconf, will pickup a random one."
echoIfVerbose "Issue a dpkg-reconfigure dtc-xen to setup a real password."
conf_soap_pass=`dd if=/dev/random bs=64 count=1 2>|/dev/null | md5sum | cut -d' ' -f1 | awk '{print substr($0,0,16)}'`
fi
$HTPASSWD -cb $DTCXEN_ETCPATH/htpasswd ${conf_soap_login} ${conf_soap_pass}
}
# All this function should NOT exist.
# These are ISSUES in Debian that I'm really not happy off...
# Fellow maintainers, please fix your packages
debian_fixups () {
# Needs the /var/lib/rpm to setup CentOS, it's not there by default, so we add it
# This will be fixed in the next yum package we'll release, but I really think this
# should be fixed in the RPM package
mkdir -p /var/lib/rpm
# Xen packagers in Debian decided to omit the /etc/xen/auto folder, WHY???
mkdir -p /etc/xen/auto
# Delete an eventual cron job that was installed prior dtc-xen 0.4
if [ -e /etc/cron.d/dtc-xen ] ; then
rm -f /etc/cron.d/dtc-xen
fi
}
VERBOSE_INSTALL=yes
DTCXEN_ETCPATH=/etc/dtc-xen
XEN_USER_HOME=/var/lib/dtc-xen/ttyssh_home
MKTEMP="mktemp -t"
OPENSSL=/usr/bin/openssl
################################
### EXECUTION STARTS HERE!!! ###
################################
if ! [ -e ${DTCXEN_ETCPATH}/dtc-xen.conf ] ; then
cp /usr/share/dtc-xen/dtc-xen.conf ${DTCXEN_ETCPATH}
fi
debian_get_config
debian_fixups
create_ssl_cert
write_debian_config_files
manage_htpasswd
touch ${DTCXEN_ETCPATH}/authorized_keys2
# Make it safer...
chmod 600 ${DTCXEN_ETCPATH}/dtc-xen.conf
# Correct an eventual old version that was running with wrong rights
chmod 600 ${DTCXEN_ETCPATH}/privkey.pem
chmod 600 ${DTCXEN_ETCPATH}/dtc-xen.cert.cert ${DTCXEN_ETCPATH}/dtc-xen.cert.csr ${DTCXEN_ETCPATH}/dtc-xen.cert.key
# This is to be able to mount the VPS partitions in order to bootstrap.
mkdir -p ${conf_vps_mountpoint}
# Manage the dtc-xen users, so people can log through the physical console
# using ssh xenXX@node99999.example.com (where XX is the VPS number).
# We first add a group xenusers, then we add our 29 users.
mkdir -p ${XEN_USER_HOME}
if getent group xenusers >/dev/null ; then
echoIfVerbose "Group xenusers already exists in /etc/group"
else
echoIfVerbose "Add group xenusers"
groupadd xenusers
fi
mkdir -p $XEN_USER_HOME
if [ -e ${DTCXEN_ETCPATH}/sources.list ] ; then
cp /etc/apt/sources.list ${DTCXEN_ETCPATH}
fi
# Delete the old configuration files as we don't use them anymore,
# and we don't want to confuse our users.
if [ -e ${DTCXEN_ETCPATH}/dtc_create_vps.conf.sh ] ; then
rm -f ${DTCXEN_ETCPATH}/dtc_create_vps.conf.sh
fi
if [ -e ${DTCXEN_ETCPATH}/soap.conf ] ; then
rm -f ${DTCXEN_ETCPATH}/soap.conf
fi
# Automatically added by dh_installinit
if [ -x "/etc/init.d/dtc-xen" ]; then
update-rc.d dtc-xen defaults >/dev/null
invoke-rc.d dtc-xen start || exit $?
fi
# End automatically added section
# Automatically added by dh_python2:
if which pycompile >/dev/null 2>&1; then
pycompile -p dtc-xen /usr/share/dtc-xen
fi
# End automatically added section
# Automatically added by dh_python2:
if which pycompile >/dev/null 2>&1; then
pycompile -p dtc-xen /usr
fi
# End automatically added section
exit 0
|