postinst is in moodle 3.0.3+dfsg-0ubuntu1.
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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | #!/bin/sh
# postinst script for moodle
#
# see: dh_installdeb(1)
#
# 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>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
set -e
#set -x
if [ -f /etc/dbconfig-common/moodle.conf ] ; then
. /etc/dbconfig-common/moodle.conf
fi
# source debconf stuff
. /usr/share/debconf/confmodule
# source dbconfig-common stuff
. /usr/share/dbconfig-common/dpkg/postinst
check_php5mysql_notinstalled() {
dpkg -s php5-mysql | grep Status | grep -q installed >/dev/null 2>&1 && return 1
return 0
}
check_php5psql_notinstalled() {
dpkg -s php5-pgsql | grep Status | grep -q installed >/dev/null 2>&1 && return 1
return 0
}
moodle_config() {
local cfile=/etc/moodle/config.php
local tempfile=`tempfile`
local wwwroot
db_get moodle/www
wwwroot="$RET"
if [ -z "$dbc_dbserver" ]; then
dbc_dbserver="localhost";
fi
if [ "$dbc_dbtype" = "pgsql" ]; then
dbc_dbtype="postgres7"
fi
cat > $tempfile <<EOF
<?php
# This file has been generated by debconf
# You can find a commented config file in /usr/share/doc/moodle/
unset(\$CFG);
global \$CFG;
\$CFG = new stdClass();
\$CFG->dbtype = '${dbc_dbtype}';
\$CFG->dbhost = '${dbc_dbserver}';
\$CFG->dbname = '${dbc_dbname}';
\$CFG->dbuser = '${dbc_dbuser}';
\$CFG->dbpass = '${dbc_dbpass}';
\$CFG->prefix = 'mdl_';
\$CFG->wwwroot = '${wwwroot}';
\$CFG->dirroot = '/usr/share/moodle';
\$CFG->dataroot = '/var/lib/moodle';
\$CFG->directorypermissions = 0750;
\$CFG->admin = 'admin';
\$CFG->pathtodu = '/usr/bin/du';
\$CFG->unzip = '/usr/bin/unzip';
\$CFG->zip = '/usr/bin/zip';
\$CFG->respectsessionsettings = true;
\$CFG->disableupdatenotifications = true;
# For improved security, make sure html purifier is used.
\$CFG->enablehtmlpurifier = true;
if (file_exists("\$CFG->dirroot/lib/setup.php")) { // Do not edit
include_once("\$CFG->dirroot/lib/setup.php");
} else {
if (\$CFG->dirroot == dirname(__FILE__)) {
echo "<p>Could not find this file: \$CFG->dirroot/lib/setup.php</p>";
echo "<p>Are you sure all your files have been uploaded?</p>";
} else {
echo "<p>Error detected in config.php</p>";
echo "<p>Error in: \\\$CFG->dirroot = '\$CFG->dirroot';</p>";
echo "<p>Try this: \\\$CFG->dirroot = '".dirname(__FILE__)."';</p>";
}
die;
}
EOF
ucf --debconf-ok $tempfile $cfile
chmod 640 $cfile
chown root:www-data $cfile
}
apache_config() {
local wwwroot
local alias
local tmp
local tempfile=`tempfile`
local cfile="/etc/moodle/apache.conf"
local php_settings
php_settings="<IfModule mod_php5.c>
php_flag magic_quotes_gpc Off
php_flag magic_quotes_runtime Off
php_flag file_uploads On
php_flag session.auto_start Off
php_flag session.bug_compat_warn Off
php_value upload_max_filesize 2M
php_value post_max_size 2M
</IfModule>"
db_get moodle/www
wwwroot="$RET"
#check if it's possible to do the alias
tmp=`echo $wwwroot | sed 's#^https*://[^/]*/*##'`
if [ -n "$tmp" ]; then
tmp_alias="#Uncomment the line below if you want to use alias
#This will not work well with virtual hosts
Alias /${tmp} /usr/share/moodle/"
else
tmp_alias="#You can't use alias because your Moodle is not in a sub-directory
#Create appropriate virtual host insted."
fi
cat > $tempfile <<EOF
# This file has been generated by debconf
${tmp_alias}
<Directory /usr/share/moodle/>
Options +FollowSymLinks
AllowOverride None
order deny,allow
deny from all
allow from 127.0.0.0/8
allow from localhost
#comment out the line below to allow remote access
#allow from all
${php_settings}
<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>
</Directory>
EOF
ucf --debconf-ok $tempfile $cfile
chmod 640 $cfile
chown root:www-data $cfile
#Sample config for the virtual host
tempfile=`tempfile`
cfile="/etc/moodle/apache.vhost.conf"
server=`echo $wwwroot |cut -d'/' -f3`
cat > $tempfile <<EOF
<VirtualHost *:80>
ServerAdmin webmaster@${server}
ServerName ${server}
DocumentRoot /usr/share/moodle/
<Directory /usr/share/moodle/>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
${php_settings}
</Directory>
ErrorLog \${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog \${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EOF
ucf --debconf-ok $tempfile $cfile
chmod 640 $cfile
chown root:www-data $cfile
}
dbc_mysql_createdb_encoding="UTF8"
dbc_pgsql_createdb_encoding="UTF8"
dbc_first_version="1.9.8-1"
dbc_go moodle $@
case "$1" in
configure)
moodle_config
apache_config
cfile=/etc/moodle/config.php
moodledir=/usr/share/moodle
[ -f $moodledir/config.php ] && rm $moodledir/config.php
ln -s $cfile $moodledir/config.php
if [ "$dbc_dbtype" = "mysql" ] && check_php5mysql_notinstalled ; then
echo 'Error - You have specified that you wish to use a mysql' >&2
echo 'database, but php5-mysql is not installed. You must install' >&2
echo 'php5-mysql before you can complete your moodle installation.' >&2
fi
if [ "$dbc_dbtype" = "postgresql" ] && check_php5psql_notinstalled ; then
echo 'Error - You have specified that you wish to use a postgresql' >&2
echo 'database, but php5-pgsql is not installed. You must install' >&2
echo 'php5-pgsql before you can complete your moodle installation.' >&2
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0
|