This file is indexed.

postinst is in dotclear 2.8.0+dfsg-1ubuntu1.

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
#!/bin/sh
# postinst script for dotclear
#
# see: dh_installdeb(1)

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>
#        * <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

old_version=$2

_DEBUG="off"	# DEBUG enabled using 'on' value

DEBUG() {
	if [ "$_DEBUG" = "on" ] ; then
		$@
	fi
}

httpserver_init() {
    db_get dotclear/httpserver
    httpservers="$RET"
    for httpserver in $httpservers; do
	httpserver=${httpserver%,}

	if [ "$httpserver" = "lighttpd" ] ; then
	    _lighttpd_install
	else
	    _apache_install $1 $httpserver
	fi
    done
}

_lighttpd_install() {
    if [ ! -f /etc/lighttpd/conf-available/50-dotclear.conf ] ; then
	if which lighty-enable-mod >/dev/null 2>&1 ; then
	    ln -s ../../dotclear/lighttpd.conf /etc/lighttpd/conf-available/50-dotclear.conf
	    lighty-enable-mod dotclear
	    _reload_server lighttpd
	fi
    fi
}

_nginx_install() {
    if [ ! -f /etc/nginx/conf.d/50-dotclear.conf ] ; then
	ln -s ../../dotclear/nginx.conf /etc/nginx/conf.d/50-dotclear.conf
	_reload_server nginx
    fi
}

_apache_install() {
    server=$2
    CONF="dotclear"
    COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)

    if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
        . /usr/share/apache2/apache2-maintscript-helper
        apache2_invoke enconf $CONF || exit $?
    elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
	[ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$CONF.conf ] \
	    && ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
	_reload_server $server
    fi
}

_reload_server() {
    server=$1
    if [ -x invoke-rc.d ]; then
	invoke-rc.d $server reload 3>/dev/null || true
    else
	/etc/init.d/$server reload 3>/dev/null || true
    fi
}

_dc_hash_mac() {
    crypt_library="/usr/share/dotclear/web/inc/libs/clearbricks/common/lib.crypt.php";
    dc_pwd=$(php -r "include '$crypt_library';echo crypt::hmac('$DC_MASTER_KEY','$ADMIN_PASSWORD');");
}

dc_database_initialisation() {
    if [ "$dbc_dbtype" = pgsql ]; then
    	dbc_sqlexec_cmd='_dbc_pgsql_exec_command'
    	dbc_sqlfile_cmd='dbc_pgsql_exec_file'
    fi

    # sqlite doesn't have a md5() function
    blog_uid="`dd if=/dev/urandom count=1 | md5sum | sed -e 's/ *-$//'`"
    # sqlite doesn't have a now() function
    now="`date +'%F %T'`"
    tz=`cat /etc/timezone`

    dc_command="INSERT INTO dc_blog
    (blog_id, blog_uid, blog_creadt, blog_upddt, blog_url, blog_name, blog_status)
    VALUES
    ('default', '$blog_uid', '$now', '$now', 'http://localhost/dotclear/?', 'My first blog', 1);";
    $dbc_sqlexec_cmd $dc_command || true

    # user admin
    _dc_hash_mac
    dc_command="INSERT INTO dc_user
    (user_id, user_super, user_pwd, user_email, user_lang, user_tz, user_creadt, user_upddt)
    VALUES
    ('$ADMIN_LOGIN', 1, '$dc_pwd', '$ADMIN_MAIL', 'en', '$tz', '$now', '$now');";
    $dbc_sqlexec_cmd $dc_command || true

    # default settings
    dc_setting_command="INSERT INTO dc_setting
    (blog_id, setting_ns, setting_id, setting_value, setting_type, setting_label)
    VALUES";

    dc_command=${dc_setting_command}"
    (null, 'system', 'blog_timezone', '$tz', 'string', 'Blog timezone');";
    $dbc_sqlexec_cmd $dc_command || true

    dc_command=${dc_setting_command}"
    ('default', 'system', 'blog_timezone', '$tz', 'string', 'Blog timezone');";
    $dbc_sqlexec_cmd $dc_command || true

    $dbc_sqlfile_cmd /usr/share/dotclear/debian/config.sql || true
}

#
# fixperms 0644 /usr/share/dotclear
#
fixperms () {
    PERMS="$1"
    FILE="$2"
    DEBUG echo "Fixing perms on ${FILE} (${PERMS})"
    chmod ${PERMS} "${FILE}"
}

#
# fixownership user:group /var/cache/dotclear
#
fixownership ()
{
    OWNER="$1"
    FILE="$2"
    DEBUG echo "Fixing ownership on ${FILE} (${OWNER})"
    chown ${OWNER} "${FILE}"
}

dbc_first_version="2.3.1"
dbc_dbtypes="mysql, pgsql, sqlite3"

. /usr/share/debconf/confmodule

db_get dotclear/debconf_install
if [ "$RET" = false ]; then
    exit 0;
fi

. /usr/share/dbconfig-common/dpkg/postinst

dbc_dbfile_owner="www-data:www-data"
dbc_dbfile_perms="0640"

case "$1" in
    configure)

	if [ -z "$old_version" ]; then
	    db_get dotclear/debconf_install
	    db_get dotclear/database-type
	    if [ "$RET" = sqlite3 ];then
		include_template="config_sqlite.php.template"
	    else
		include_template="config.php.template"
	    fi

            TMP_FILE=`mktemp /tmp/dotclear.XXXXXX`
	    DC_MASTER_KEY="`dd if=/dev/urandom count=1 | shasum | sed -e 's/ *-$//'`"

	    cat /usr/share/dotclear/debian/$include_template | \
		sed -e "s/_DC_MASTER_KEY_/$DC_MASTER_KEY/g" > $TMP_FILE

	    dbc_generate_include_owner="root:www-data"
	    dbc_generate_include_perms="0640"
	    dbc_generate_include=template:/etc/dotclear/config.php
	    dbc_generate_include_args="-o template_infile=$TMP_FILE"

	    db_get dotclear/admin_login
	    ADMIN_LOGIN=${RET:-admin}
	    db_get dotclear/admin_password
	    ADMIN_PASSWORD=${RET:-admin}
	    db_get dotclear/admin_mail
	    ADMIN_MAIL=${RET:-admin@localhost}

	    dbc_go dotclear $@
 	    dc_database_initialisation

            if [ -f $TMP_FILE ] ; then
		rm -f $TMP_FILE;
            fi
	fi

	fixperms 0775 /var/cache/dotclear
	fixperms 0775 /var/lib/dotclear/web/locales
	fixperms 0775 /var/lib/dotclear/web/plugins
	fixperms 0775 /var/lib/dotclear/web/public
	fixperms 0775 /var/lib/dotclear/web/themes

	fixownership "root:www-data" /var/cache/dotclear
	fixownership "root:www-data" /var/lib/dotclear/web/locales
	fixownership "root:www-data" /var/lib/dotclear/web/plugins
	fixownership "root:www-data" /var/lib/dotclear/web/public
	fixownership "root:www-data" /var/lib/dotclear/web/themes

	# to prevent automatic update
	fixperms 0600 /usr/share/dotclear/web/inc/digests

	httpserver_init $1

	;;

    abort-upgrade|abort-remove|abort-deconfigure)
	;;

    *)
        exit 1
	;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.



exit 0