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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
|
#! /bin/sh
# Horde postinst script using debconf
# Written by Ola Lundqvist <opal@debian.org>
# Adapted for Horde2 by Nils Rennebarth <nils@debian.org>
#
# All questions should have been asked via debconf
# now we just go get those, build a temp file which we read in and
# then build our config files and set everthing up
set -e
# 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>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see /usr/share/doc/packaging-manual/
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
create_file_from_template() {
infile=$1
outfile=$2
# Password may contain anything, so we need to descend to quoting
# hell.
safepass="$dbpass"
# quote normal quote and final backslash because we need to write
# a single quoted PHP string
safepass=$(echo "$safepass" | sed -e "s/'/\\\\'/g" -e 's/\\$/\\\\'/)
# Now double backslashes because we will use sed
safepass=$(echo "$safepass" | sed -e 's/\\/\\\\/g')
# Finally escape an eventual hash sign with a backslash because
# we use the hash sign as a delimiter
safepass=$(echo "$safepass" | sed -e 's/#/\\#/g')
sed -e " \
s#@dbclass@#$dbclass#; \
s#@dbtype@#$mydbtype#; \
s#@dbname@#$dbname#; \
s#@dbserver@#$dbserver#; \
s#@dbport@#$dbport#; \
s#@dbuser@#$dbuser#; \
s#@dbbasedn@#$dbbasedn#; \
s#@dbuid@#$dbuid#; \
s#@dbpass@#$safepass#; \
" <$infile >$outfile
}
case "$1" in
configure)
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
. /usr/share/debconf/confmodule
db_version 2.0
# Build localization
P=$(pwd)
cd /usr/share/horde2
make -C po > /dev/null 2>&1 || true
cd $P
extensions=
# Type of the databasemgr to use.
db_get "horde2/databasemgr_type"
dbtype="$RET"
if [ "$dbtype" != "none" ] ; then
# Where it is located.
db_get "horde2/databasemgr_server"
dbserver="$RET"
# Port number
db_get "horde2/databasemgr_port"
dbport="$RET"
# Name of the database
db_get "horde2/database_name"
dbname="$RET"
# Name of the user to have access.
db_get "horde2/database_user"
dbuser="$RET"
# Its password.
db_get "horde2/database_pass"
dbpass="$RET"
fi
# These shortnames allow us to make sed statements common
case $dbtype in
MySQL)
mydbtype="mysql"
dbclass="sql"
;;
PostgreSQL)
mydbtype="pgsql"
dbclass="sql"
;;
LDAP)
mydbtype="ldap"
dbclass="ldap"
;;
none)
mydbtype="none"
dbclass="session"
;;
*)
mydbtype="none"
dbclass="sql"
;;
esac
if [ "$mydbtype" != "none" ] ; then
extensions="$extensions $mydbtype"
fi
###############################################################################
################################ Php4 #########################################
###############################################################################
# tell wwwconfig-common we have php4
php_get="done"
phpver="php4"
phpini=/etc/php4/apache/php.ini
###############################################################################
############################### Configure database ############################
###############################################################################
case $dbtype in
PostgreSQL)
#######################################################################
########################## PostgreSQL #################################
#######################################################################
if [ "$dbserver" != "localhost" ] ; then
echo "You have to modify the postgres server manually to allow"
echo "network requests!"
else
. /usr/share/wwwconfig-common/pgsql-allowip.sh
if [ "$status" = "error" ] ; then
echo " **** WARNING **** "
echo "You stated your using PostgreSQL as a database and"
echo "that it is local yet the install program cannot seem"
echo "to set up the config files for it."
fi
fi
DIR=/usr/share/horde2/scripts
if [ -x $(which psql) ]; then
db_get "horde2/dbpgadmin"
dbadmin="$RET"
. /usr/share/wwwconfig-common/pgsql-createuser.sh
. /usr/share/wwwconfig-common/pgsql-createdb.sh
if [ "$status" = "create" ] ; then
for i in auth prefs category; do
# create sql commands from templates
create_file_from_template $DIR/$i.sql.in $DIR/$i.sql
sqlfile=$DIR/$i.sql
. /usr/share/wwwconfig-common/pgsql-exec.sh
rm $DIR/$i.sql
done
fi
else
echo "Not configuring PostgreSQL database because we cannot locate"
echo "the psql client executable (postgresql-client package missing)."
fi
;;
MySQL)
if [ -x $(which mysql) ]; then
if [ -e /usr/share/wwwconfig-common/mysql-localadmpass.get ] ; then
. /usr/share/wwwconfig-common/mysql-localadmpass.get
fi
if [ -z "$dbadmin" ] ; then
db_input "high" "horde2/dbmyadmin" || true
db_go
db_get "horde2/dbmyadmin"
dbadmin="$RET"
fi
if [ -z "$dbadmpass" ] ; then
# Just for safety.
db_input "critical" "horde2/dbadmpass" || true
db_go
db_get "horde2/dbadmpass"
dbadmpass="$RET"
db_reset "horde2/dbadmpass"
fi
. /usr/share/wwwconfig-common/mysql-createdb.sh
if [ "$status" = "create" ] ; then
sqlfile=/usr/share/horde2/scripts/mysql_tables.sql
create_file_from_template $sqlfile.in $sqlfile
. /usr/share/wwwconfig-common/mysql-exec.sh
rm $sqlfile
fi
. /usr/share/wwwconfig-common/mysql-createuser.sh
else
echo "Not configuring MySQL database because we cannot locate"
echo "the mysql client executable (mysql-client package missing)."
fi
;;
none)
echo "Not configuring a database, at your request."
;;
esac
###############################################################################
########################## Configure Horde ####################################
###############################################################################
webgroup=www-data
if [ -e /etc/horde2/horde-debian.php ] ; then
if [ ! -e /var/lib/horde2/horde-debian.php ] ; then
mv /etc/horde2/horde-debian.php /var/lib/horde2/horde-debian.php
fi
fi
(
umask 0027 # File may contain passwords
if [ "$dbclass" = "ldap" ] ; then
create_file_from_template /usr/share/horde2/horde-debian.php.ldap.in /var/lib/horde2/horde-debian.php
else
create_file_from_template /usr/share/horde2/horde-debian.php.sql.in /var/lib/horde2/horde-debian.php
fi
chgrp $webgroup /var/lib/horde2/horde-debian.php
)
# Migrate out of the non-FHS /var/state
if dpkg --compare-versions "$2" le-nl 2.1-3 && [ -d /var/state/horde2 ]
then
mv -b /var/state/horde2/* /var/lib/horde2/ 2>/dev/null || true
rmdir /var/state/horde2/
# It's not FHS, and it's probably our fault this is here,
# so delete it if we can.
rmdir /var/state/ 2> /dev/null || true
fi
###############################################################################
############################# Servers restart #################################
###############################################################################
servers="exim apache-ssl apache"
. /usr/share/wwwconfig-common/restart.sh
# New feature, allowing patches to be applied automatically.
patchdir=/etc/horde2/patches
. /usr/share/wwwconfig-common/autopatch_all.sh
db_stop
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 0
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
|