postinst is in dokuwiki 0.0.20160626.a-2.
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 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 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499  | #!/bin/sh
# Postinst script for Dokuwiki.
set -e
# Create an apache configuration file for dokuwiki
write_apache2_conf()
{
    apacheconf=`tempfile`
    
    # Get config options
    db_get dokuwiki/system/documentroot
    docroot=$RET;
    cat >> $apacheconf <<-EOF
	AliasMatch ^$docroot/sites/[^/]+$      /usr/share/dokuwiki/
	AliasMatch ^$docroot/sites/[^/]+/(.*)$ /usr/share/dokuwiki/\$1
	Alias      $docroot                    /usr/share/dokuwiki/
	EOF
    # Print directory options for /usr/share/dokuwiki
    cat >> $apacheconf <<-EOF
	<Directory /usr/share/dokuwiki/>
		Options +FollowSymLinks
		AllowOverride All
		order allow,deny
	EOF
    db_get dokuwiki/system/accessible
    if [ "$RET" = "global" ]; then  # Globally accessible
        echo "	Allow from all" >> $apacheconf
    elif [ "$RET" = "localhost only" ]; then  # Access only from localhost
	echo "	Allow from localhost 127.0.0.1 ::1" >> $apacheconf
    else  # Access from localnet
	db_get dokuwiki/system/localnet
	echo "	Allow from localhost 127.0.0.1 ::1" >> $apacheconf
	echo "	Allow from $RET" >> $apacheconf
    fi
    
    cat >> $apacheconf <<-EOF
	        <IfModule mod_rewrite.c>
	                # Uncomment to implement server-side URL rewriting
	                # (cf. <http://www.dokuwiki.org/config:userewrite>).
                        # Do *not* mix that with multisite!
	                #RewriteEngine on
	                #RewriteBase /dokuwiki
	                #RewriteRule ^lib                      - [L]
	                #RewriteRule ^doku.php                 - [L]
	                #RewriteRule ^feed.php                 - [L]
	                #RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=\$1  [QSA,L]
	                #RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=\$1 [QSA,L]
	                #RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_\$1&id=\$2 [QSA,L]
	                #RewriteRule ^$                        doku.php  [L]
	                #RewriteRule (.*)                      doku.php?id=\$1  [QSA,L]
	        </IfModule>
	</Directory>
	<Directory /usr/share/dokuwiki/bin>
	        Require all denied
	</Directory>
	<Directory /var/lib/dokuwiki/data>
	        Require all denied
	</Directory>
	EOF
    
    ucf --debconf-ok $apacheconf /etc/dokuwiki/apache.conf
    ucfr dokuwiki /etc/dokuwiki/apache.conf
    # Remove temporary file
    rm $apacheconf;
    if [ -e /etc/dokuwiki/apache.conf ]; then
        chmod 0644 /etc/dokuwiki/apache.conf
    fi
}
# Create a lighttpd configuration file for dokuwiki
write_lighttpd_conf()
{
    lighttpdconf=$(tempfile)
    # Get document root
    db_get dokuwiki/system/documentroot
    docroot=$RET;
    # Configure lighttpd to server dokuwiki on the docroot
    echo "alias.url += (\"$docroot\" => \"/usr/share/dokuwiki\")" >> $lighttpdconf
    cat >> $lighttpdconf << EOF
\$HTTP["url"] =~ "^$docroot" {
  server.follow-symlink = "enable"
}
\$HTTP["url"] =~ "/(\.|_)ht" {
  url.access-deny = ( "" )
}
\$HTTP["url"] =~ "^$docroot/(bin|data|inc|conf)" {
  url.access-deny = ( "" )
}
EOF
    # TODO: access restriction
    # Write the configuration file to its final location
    ucf --debconf-ok $lighttpdconf /etc/dokuwiki/lighttpd.conf
    ucfr dokuwiki /etc/dokuwiki/lighttpd.conf
    # Remove temporary file
    rm $lighttpdconf;
    if [ -e /etc/dokuwiki/lighttpd.conf ]; then
        chmod 0644 /etc/dokuwiki/lighttpd.conf
    fi
}
# Create a local dokuwiki configuration file
write_dokuwiki_conf()
{
    dokuwikiconf=$(tempfile)
    cat >> $dokuwikiconf << EOF
<?php
/**
 * Dokuwiki's Main Configuration File - Local Settings
 * Auto-generated by Debian postinst script
 */
EOF
    db_get dokuwiki/wiki/title
    title="$(printf "%s" "$RET" | sed -e 's/\\/\\\\/g;'"s/'/\\\\'/g")"
    echo "\$conf['title'] = '$title';" >> $dokuwikiconf
    db_get dokuwiki/wiki/license
    echo "\$conf['license'] = '$RET';" >> $dokuwikiconf
    echo "#\$conf['lang'] = 'en';" >> $dokuwikiconf
    db_get dokuwiki/wiki/acl
    if [ "$RET" = "true" ]; then
        echo "\$conf['useacl'] = 1;" >> $dokuwikiconf
        echo "\$conf['superuser'] = '@admin';" >> $dokuwikiconf
    fi
    ucf --debconf-ok $dokuwikiconf /etc/dokuwiki/local.php
    ucfr dokuwiki /etc/dokuwiki/local.php
    # Remove temporary file
    rm $dokuwikiconf
    if [ -e /etc/dokuwiki/local.php ]; then
        chmod 0644 /etc/dokuwiki/local.php
    fi
    # Set permissions according to the user's wishes
    db_get dokuwiki/system/writeconf
    if [ "$RET" = "true" ]; then
        if [ -e /etc/dokuwiki/local.php ]; then
            chown root:www-data /etc/dokuwiki/local.php
            chmod 0664 /etc/dokuwiki/local.php
            if ! dpkg-statoverride --list /etc/dokuwiki >/dev/null 2>&1; then
                dpkg-statoverride --update --add root www-data 0775 /etc/dokuwiki
            fi
        fi
    fi
    db_get dokuwiki/system/writeplugins
    if [ "$RET" = "true" ]; then
        if ! dpkg-statoverride --list /var/lib/dokuwiki/lib/plugins >/dev/null 2>&1; then
            dpkg-statoverride --update --add root www-data 0775 /var/lib/dokuwiki/lib/plugins
        fi
    fi
}
# Set up an initial access control system
setup_acl()
{
    # Do not touch ACLs of existing installationq
    if [ ! -e /var/lib/dokuwiki/acl/acl.auth.php ]; then
        aclauth=`tempfile`
        cat >> $aclauth << EOF
# acl.auth.php
# <?php exit()?>
# Don't modify the lines above
#
# Access Control Lists
#
# Auto-generated by Debian postinst script
EOF
        db_get dokuwiki/wiki/policy
        if [ "$RET" = "closed" ]; then
                echo "*               @ALL          0" >> $aclauth
                echo "*               @user         8" >> $aclauth
        elif [ "$RET" = "public" ]; then
                echo "*               @ALL          1" >> $aclauth
                echo "*               @user         8" >> $aclauth
        else
                echo "*               @ALL          8" >> $aclauth
        fi
    	ucf --debconf-ok $aclauth /var/lib/dokuwiki/acl/acl.auth.php
        ucfr dokuwiki /var/lib/dokuwiki/acl/acl.auth.php
        # Remove temporary file
        rm $aclauth;
    
        if [ -e /var/lib/dokuwiki/acl/acl.auth.php ]; then
            chown www-data:root /var/lib/dokuwiki/acl/acl.auth.php
        fi
    fi
}
# Set up an initial administrator account
setup_superuser()
{
    # Do not touch user lists of existing installations
    if [ ! -e /var/lib/dokuwiki/acl/users.auth.php ]; then
        usersauth=`tempfile`
        db_get dokuwiki/wiki/superuser
        superuser="$RET"
        db_get dokuwiki/wiki/fullname
        fullname="$RET"
        db_get dokuwiki/wiki/email
        email="$RET"
        db_get dokuwiki/wiki/password
        password=$(echo -n "$RET" | md5sum -b | cut -d' ' -f1)
        db_set dokuwiki/wiki/password ""
        db_set dokuwiki/wiki/confirm ""
        echo "$superuser:$password:$fullname:$email:admin,user" >> $usersauth
    	ucf --debconf-ok $usersauth /var/lib/dokuwiki/acl/users.auth.php
        ucfr dokuwiki /var/lib/dokuwiki/acl/users.auth.php
        # Remove temporary file
        rm $usersauth;
        if [ -e /var/lib/dokuwiki/acl/users.auth.php ]; then
            chown www-data:root /var/lib/dokuwiki/acl/users.auth.php
        fi
    fi
}
# Create a .htaccess sample file for dokuwiki
write_htaccess()
{
    # Restore the backup of the .htaccess that used to be part of the
    # package and would have been lost. See preinst.
    if [ -f /usr/share/dokuwiki/.htaccess.upgrade ]
    then
        mv /usr/share/dokuwiki/.htaccess.upgrade /etc/dokuwiki/htaccess
    fi
    # A previous versions of this script, 0.0.20091225c-4, used to restore the
    # backup *after* ucf. As this erased the following official modification
    # after ucf, let us make it back before ucf.
    if [ -e /etc/dokuwiki/local.php -a -f /etc/dokuwiki/htaccess ]; then
        sed -i -e '/^php_value auto_prepend_file "\/usr\/share\/dokuwiki\/prepend.php"$/,+1d' /etc/dokuwiki/htaccess
    fi
    ucfr dokuwiki /etc/dokuwiki/htaccess
    ucf --debconf-ok /usr/share/dokuwiki/.htaccess.dist /etc/dokuwiki/htaccess
}
# Configure Apache web servers (possibly version 1.3 or 2.x?)
configure_apache2()
{
    # Remove old configuration symlink for apache 2.2
    if [ -e /etc/apache2/conf.d/dokuwiki.conf ]
    then
        rm /etc/apache2/conf.d/dokuwiki.conf
    fi
    # Remove possible user compatibility symlink for apache 2.4
    if [ -h /etc/apache2/conf-available/dokuwiki.conf ]
    then
        rm /etc/apache2/conf-available/dokuwiki.conf
    fi
    if [ -d /etc/apache2/conf-available -a ! -e /etc/apache2/conf-available/dokuwiki.conf ]
    then
        ln -s /etc/dokuwiki/apache.conf /etc/apache2/conf-available/dokuwiki.conf
        if [ -e /usr/share/apache2/apache2-maintscript-helper ]
        then
            . /usr/share/apache2/apache2-maintscript-helper
            apache2_invoke enconf dokuwiki
        fi
    fi
}
# Reload apache2
reload_apache2()
{
    # Nothing, since `apache2_invoke enconf` already did what had to be done
    :
}
# Configure lighttpd web server
configure_lighttpd()
{
    dir="/etc/lighttpd/conf-available"
    file="$dir/50-dokuwiki.conf"
    if [ -d "$dir" ] && [ ! -e "$file" ]; then
        if ! command -v bash > /dev/null ; then
            echo "Lighttpd not installed, skipping"
        else
            echo "Installing into... [$dir]" >/dev/stderr
            ln -sf /etc/dokuwiki/lighttpd.conf "$file"
            lighty-enable-mod dokuwiki
        fi
    fi
}
# Reload lighttpd
reload_lighttpd()
{
    # That may fail if lighttpd is not running: this is not a real problem,
    # ignore it.
    invoke-rc.d lighttpd reload || true
}
# Configure requested web server
configure_webservers()
{
    db_get dokuwiki/system/configure-webserver
    webservers="$RET"
    db_get dokuwiki/system/restart-webserver
    restart="$RET"
    write_apache2_conf
    write_lighttpd_conf
    for webserver in $webservers; do
        webserver=${webserver%,}
        # Note: configure_apache2 uses functions from
        # /usr/share/apache2/apache2-maintscript-helper, which require an
        # unmodified environment, including maintainer script arguments "$@"
        configure_$webserver "$@"
        if [ "$restart" = "true" ]
        then
            reload_$webserver "$@"
        fi
    done
}
if [ $1 = "configure" ]; then
    . /usr/share/debconf/confmodule
    write_htaccess
    write_dokuwiki_conf
    db_get dokuwiki/wiki/acl
    if [ "$RET" = "true" ]; then
        setup_acl
        db_get dokuwiki/wiki/superuser
        if [ ! -z "$RET" ]; then
            setup_superuser
        fi
    fi
    # Note: configure_webservers uses functions from
    # /usr/share/apache2/apache2-maintscript-helper, which require an
    # unmodified environment, including maintainer script arguments "$@"
    configure_webservers "$@"
    db_stop
    # A double transition...
    # Templates and plugins used to be under /usr/share/dokuwiki/lib.
    # They were moved to /var/lib/dokuwiki to allow additions within the FHS.
    # But some plugins need to find DokuWiki's root directory at ../../../,
    # so they are now installed under /var/lib/dokuwiki/lib to reproduce the
    # original hierarchy at /var/lib/dokuwiki.
    # Possible cases for /usr/share/dokuwiki/lib/tpl:
    # * inexistant, regular file, special file: *abnormal* cases, not handled;
    # * symlink: no transition needed;
    # * directory: transition to the new location needed.
    if [ ! -L /usr/share/dokuwiki/lib/tpl ]; then
        echo -n "Moving template directory from /usr/share/dokuwiki to /var/lib/dokuwiki/lib... " >/dev/stderr
        mv /usr/share/dokuwiki/lib/tpl/* /var/lib/dokuwiki/lib/tpl/ 2> /dev/null || true
        if ! rmdir /usr/share/dokuwiki/lib/tpl; then
            # Files left on /usr/share/dokuwiki/lib/tpl.
            # Typical case: the user added files deeply in
            # /usr/share/dokuwiki/lib/tpl/default. Requires user
            # intervention.
            echo >/dev/stderr
            echo "Some files were left on /usr/share/dokuwiki/lib/tpl:" >/dev/stderr
            echo "they are backed up on /usr/share/dokuwiki/lib/tpl.old," >/dev/stderr
            echo "please check them and consider removing them." >/dev/stderr
            mv /usr/share/dokuwiki/lib/tpl /usr/share/dokuwiki/lib/tpl.old
        fi
        ln -s /var/lib/dokuwiki/lib/tpl /usr/share/dokuwiki/lib/
        echo "[done]" >/dev/stderr
    fi
    # Possible clases for /var/lib/dokuwiki/tpl:
    # * inexistant: no transition needed;
    # * regular file, special file, symlink:  *abnormal* cases, not handled;
    # * directory: transition to the new location needed.
    if [ -d /var/lib/dokuwiki/tpl ]; then
        echo -n "Moving template directory from /var/lib/dokuwiki to /var/lib/dokuwiki/lib... " >/dev/stderr
        # A previous version of this script, 0.0.20090214b-3.1, used to
        # brutally move templates from /usr/share/dokuwiki/lib to
        # /var/lib/dokuwiki, resulting in files not belonging to the package.
        # On upgrade, they are left, but can be removed safely as they are now
        # simply provided by the package.
        rm -f /var/lib/dokuwiki/tpl/default/images/bullet.gif \
              /var/lib/dokuwiki/tpl/default/images/button-cc.gif \
              /var/lib/dokuwiki/tpl/default/images/button-css.png \
              /var/lib/dokuwiki/tpl/default/images/button-debian.png \
              /var/lib/dokuwiki/tpl/default/images/button-debian.png.uue \
              /var/lib/dokuwiki/tpl/default/images/button-donate.gif \
              /var/lib/dokuwiki/tpl/default/images/button-dw.png \
              /var/lib/dokuwiki/tpl/default/images/button-php.gif \
              /var/lib/dokuwiki/tpl/default/images/button-rss.png \
              /var/lib/dokuwiki/tpl/default/images/buttonshadow.png \
              /var/lib/dokuwiki/tpl/default/images/button-xhtml.png \
              /var/lib/dokuwiki/tpl/default/images/closed.gif \
              /var/lib/dokuwiki/tpl/default/images/favicon.ico \
              /var/lib/dokuwiki/tpl/default/images/inputshadow.png \
              /var/lib/dokuwiki/tpl/default/images/link_icon.gif \
              /var/lib/dokuwiki/tpl/default/images/mail_icon.gif \
              /var/lib/dokuwiki/tpl/default/images/open.gif \
              /var/lib/dokuwiki/tpl/default/images/tocdot2.gif \
              /var/lib/dokuwiki/tpl/default/images/UWEB.png \
              /var/lib/dokuwiki/tpl/default/images/UWEBshadow.png \
              /var/lib/dokuwiki/tpl/default/images/windows.gif
        rmdir /var/lib/dokuwiki/tpl/default/images/ 2> /dev/null || true
        rm -f /var/lib/dokuwiki/tpl/default/design.css \
              /var/lib/dokuwiki/tpl/default/detail.php \
              /var/lib/dokuwiki/tpl/default/footer.html \
              /var/lib/dokuwiki/tpl/default/layout.css \
              /var/lib/dokuwiki/tpl/default/main.php \
              /var/lib/dokuwiki/tpl/default/media.css \
              /var/lib/dokuwiki/tpl/default/mediamanager.php \
              /var/lib/dokuwiki/tpl/default/print.css \
              /var/lib/dokuwiki/tpl/default/rtl.css \
              /var/lib/dokuwiki/tpl/default/style.ini
        rmdir /var/lib/dokuwiki/tpl/default/ 2> /dev/null || true
        rm -f /var/lib/dokuwiki/tpl/index.php
        mv /var/lib/dokuwiki/tpl/* /var/lib/dokuwiki/lib/tpl/ 2> /dev/null || true
        if ! rmdir /var/lib/dokuwiki/tpl; then
            # Files left on /var/lib/dokuwiki/tpl.
            # Typical case: the user added files deeply in
            # /var/lib/dokuwiki/tpl/default. Requires user
            # intervention.
            echo >/dev/stderr
            echo "Some files were left on /var/lib/dokuwiki/tpl:" >/dev/stderr
            echo "they are backed up on /var/lib/dokuwiki/tpl.old," >/dev/stderr
            echo "please check them and consider removing them." >/dev/stderr
            mv /var/lib/dokuwiki/tpl /var/lib/dokuwiki/tpl.old
        fi
        echo "[done]" >/dev/stderr
    fi
    # Possible cases for /usr/share/dokuwiki/lib/plugins:
    # * inexistant, regular file, special file: *abnormal* cases, not handled;
    # * symlink: no transition needed;
    # * directory: transition to the new location needed.
    if [ ! -L /usr/share/dokuwiki/lib/plugins ]; then
        echo -n "Moving plugins directory from /usr/share/dokuwiki to /var/lib/dokuwiki/lib... " >/dev/stderr
        mv /usr/share/dokuwiki/lib/plugins/* /var/lib/dokuwiki/lib/plugins/ 2> /dev/null || true
        if ! rmdir /usr/share/dokuwiki/lib/plugins; then
            # Files left on /usr/share/dokuwiki/lib/plugins.
            # Typical case: the user added files deeply in
            # /usr/share/dokuwiki/lib/plugins/something_provided_by_the_package.
            # Requires user intervention.
            echo >/dev/stderr
            echo "Some files were left on /usr/share/dokuwiki/lib/plugins:" >/dev/stderr
            echo "they are backed up on /usr/share/dokuwiki/lib/plugins.old," >/dev/stderr
            echo "please check them and consider removing them." >/dev/stderr
            mv /usr/share/dokuwiki/lib/plugins /usr/share/dokuwiki/lib/plugins.old
        fi
        ln -s /var/lib/dokuwiki/lib/plugins /usr/share/dokuwiki/lib/
        echo "[done]" >/dev/stderr
    fi
    # Possible cases for /var/lib/dokuwiki/plugins:
    # * inexistant: no transition needed;
    # * regular file, special file, symlink:  *abnormal* cases, not handled;
    # * directory: transition to the new location needed.
    if [ -d /var/lib/dokuwiki/plugins ]; then
        echo -n "Moving plugins directory from /var/lib/dokuwiki to /var/lib/dokuwiki/lib... " >/dev/stderr
        mv /var/lib/dokuwiki/plugins/* /var/lib/dokuwiki/lib/plugins/ 2> /dev/null || true
        if ! rmdir /var/lib/dokuwiki/plugins; then
            # Files left on /var/lib/dokuwiki/plugins.
            # Typical case: the user added files deeply in
            # /var/lib/dokuwiki/plugins/something_provided_by_the_package.
            # Requires user intervention.
            echo >/dev/stderr
            echo "Some files were left on /var/lib/dokuwiki/plugins:" >/dev/stderr
            echo "they are backed up on /var/lib/dokuwiki/plugins.old," >/dev/stderr
            echo "please check them and consider removing them." >/dev/stderr
            mv /var/lib/dokuwiki/plugins /var/lib/dokuwiki/plugins.old
        fi
        echo "[done]" >/dev/stderr
    fi
fi
 |