File: textpattern.postinst

package info (click to toggle)
textpattern 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,888 kB
  • ctags: 4,970
  • sloc: php: 27,609; sh: 175; makefile: 20
file content (91 lines) | stat: -rw-r--r-- 2,169 bytes parent folder | download
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
#!/bin/sh
# postinst script for textpattern
#
# see: dh_installdeb(1)

set -e

. /usr/share/debconf/confmodule
. /usr/share/dbconfig-common/dpkg/postinst 
dbc_generate_include=php:/etc/textpattern/debian-db.php
dbc_generate_include_owner="www-data:www-data"
dbc_generate_include_perms="660"
dbc_dbfile_owner="www-data:www-data"
dbc_dbfile_perms="0660"
dbc_dbuser=textpattern
dbc_dbname=textpattern

dbc_go textpattern $@

lighttpd_install() {
	if [ ! -f /etc/lighttpd/conf-available/50-textpattern.conf ] ; then
		if [ ! -x /usr/sbin/lighty-enable-mod ] ; then
			echo "Lighttpd not installed, skipping"
		else
			ln -s /etc/textpattern/lighttpd.conf /etc/lighttpd/conf-available/50-textpattern.conf
			lighty-enable-mod textpattern
		fi
	fi
}

apache_install() {
	webserver=$1
	if [ -d /etc/$webserver/conf.d ] && [ ! -e /etc/$webserver/conf.d/textpattern ]; then
               ln -s /etc/textpattern/apache.conf /etc/$webserver/conf.d/textpattern
	fi
}

case "$1" in
    configure)

	# Handle webserver reconfiguration/restart ; stolen from zabbix package
	db_get textpattern/reconfigure-webserver || true
	webservers="$RET"
	restart=""

	for webserver in $webservers; do
            webserver=${webserver%,}
	    if [ "$webserver" = "lighttpd" ] ; then
		lighttpd_install
	    else
		apache_install $webserver
	    fi
            test -x /usr/sbin/$webserver || continue
            restart="$restart $webserver"
        done

        db_get textpattern/restart-webserver || true
	res="$RET"
	db_stop || true
	if [ "$res" = "true" ]; then
            for webserver in $restart; do
		webserver=${webserver%,}
		if [ -x /usr/sbin/invoke-rc.d ]; then
                    invoke-rc.d $webserver restart
		else
                    /etc/init.d/$webserver restart
		fi
            done
	fi

	chown -R www-data:www-data /var/lib/textpattern/images
	chmod -R 750 /var/lib/textpattern/images
	chown -R www-data:www-data /var/lib/textpattern/files
	chmod -R 750 /var/lib/textpattern/files
    ;;

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

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac


#DEBHELPER#

exit 0