File: postinst

package info (click to toggle)
movabletype-opensource 4.2.3-1%2Blenny3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 21,268 kB
  • ctags: 15,862
  • sloc: perl: 178,892; php: 26,178; sh: 161; makefile: 82
file content (103 lines) | stat: -rw-r--r-- 3,522 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
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# postinst maintainer script for movabletype-opensource

#set -x

# source debconf stuff
. /usr/share/debconf/confmodule
# source dbconfig-common stuff
dbc_dbfile_owner="www-data:www-data"
. /usr/share/dbconfig-common/dpkg/postinst 
dbc_go movabletype-opensource $@

if [ "$1" == "configure" ]; then
    # Generate mt-config.cgi

    NEWCONF=/etc/movabletype-opensource/.mt-config.cgi.new

    if [ -f /etc/dbconfig-common/movabletype-opensource.conf ]; then
        . /etc/dbconfig-common/movabletype-opensource.conf
        if [ -n "$dbc_install" -a "$dbc_install" == "true" ]; then
            # We can proceed
            cat > $NEWCONF <<EOF
CGIPath /cgi-bin/movabletype/
StaticWebPath /mt-static/
StaticFilePath /usr/share/movabletype/static/
MailTransfer sendmail
SendMailPath /usr/sbin/sendmail
HTMLUmask 0022
DBUmask 0022
UploadUmask 0022
DirUmask 0022
CaptchaSourceImageBase /usr/share/movabletype/static/images/captcha-source/

EOF
            chmod 600 $NEWCONF
            if [ "$dbc_dbtype" == "sqlite" ]; then
                echo "ObjectDriver DBI::sqlite" >> $NEWCONF
                echo "Database $dbc_basepath/$dbc_dbname" >> $NEWCONF
            elif [ "$dbc_dbtype" == "mysql" ]; then
                echo "ObjectDriver DBI::mysql" >> $NEWCONF
                echo "Database $dbc_dbname" >> $NEWCONF
                echo "DBUser $dbc_dbuser" >> $NEWCONF
                if [ -n "$dbc_dbpass" ]; then
                    echo "DBPassword $dbc_dbpass" >> $NEWCONF
                fi
                if [ -n "$dbc_dbhost" ]; then
                    echo "DBHost $dbc_dbhost" >> $NEWCONF
                fi
                if [ -n "$dbc_dbport" ]; then
                    echo "DBPort $dbc_dbport" >> $NEWCONF
                fi
            elif [ "$dbc_dbtype" == "pgsql" ]; then
                echo "ObjectDriver DBI::pgsql" >> $NEWCONF
                echo "Database $dbc_dbname" >> $NEWCONF
                echo "DBUser $dbc_dbuser" >> $NEWCONF
                if [ -n "$dbc_dbpassword" ]; then
                    echo "DBPassword $dbc_dbpassword" >> $NEWCONF
                fi
                if [ -n "$dbc_dbhost" ]; then
                    echo "DBHost $dbc_dbhost" >> $NEWCONF
                fi
                if [ -n "$dbc_dbport" ]; then
                    echo "DBPort $dbc_dbport" >> $NEWCONF
                fi
            fi

            REALCONF=/etc/movabletype-opensource/mt-config.cgi
            if [ -f $REALCONF ]; then
                ISNEW=no
            else
                ISNEW=yes
            fi
            ucf $NEWCONF $REALCONF
            if [ $ISNEW = "yes" ]; then
                chown root:www-data $REALCONF
                chmod 640 $REALCONF
            fi
            rm -f $NEWCONF

        fi
    fi

    if [ -x /usr/sbin/apache2ctl ]; then
        if [ -z "$2" ] || dpkg --compare-versions "$2" lt 4.2.3-1+lenny1~test.2; then
            db_get movabletype-opensource/reload_apache || true
            RELOAD="$RET"
            if [ "$RELOAD" = "true" ]; then
                if apache2ctl configtest 2>/dev/null; then
                    invoke-rc.d apache2 reload || true
                else
                    echo "apache2 configuration broken, not reloading!"
                fi
            else
                echo "Please manually reload Apache to apply the configuration update"
            fi
        fi
    fi

    # Reset this for the next upgrade
    db_fset movabletype-opensource/schema_upgrade seen false
fi

#DEBHELPER#