~mythbuntu/mythbuntu/mythbuntu

« back to all changes in this revision

Viewing changes to weekly_build/work/debian-mythplugins/mythweb.postinst

  • Committer: Mario Limonciello
  • Date: 2007-07-30 00:05:59 UTC
  • Revision ID: supermario@portablemario-20070730000559-6jm2h0ns9m9zi1te
remerge with mythtv/mythplugins gutsy

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
set -e
4
4
 
 
5
. /usr/share/debconf/confmodule
 
6
#DEBHELPER#
 
7
 
 
8
# this small function prepares mythweb.conf for authentication setup
 
9
 
 
10
enableauth() 
 
11
{
 
12
    cat $1 | sed -e \
 
13
    "s/\#    AuthType/AuthType/" \
 
14
    -e "s/^\#    AuthName/AuthName/" \
 
15
    -e "s/^\#    AuthUserFile/AuthUserFile/" \
 
16
    -e "s/^\#    Require/Require/" \
 
17
    -e "s/^\#    BrowserMatch/BrowserMatch/" \
 
18
    -e "s/^\#    Order/Order/" \
 
19
    -e "s/^\#    Satisfy/Satisfy/" \
 
20
    -e "s,/var/www/htdigest,${2}," > ${1}.new
 
21
    mv ${1}.new $1
 
22
}
 
23
 
 
24
disableauth() 
 
25
{
 
26
    cat $1 | sed -e \
 
27
    "s/^AuthType/\#    AuthType/" \
 
28
    -e "s/^AuthName/\#    AuthName/" \
 
29
    -e "s/^AuthUserFile/\#    AuthUserFile/" \
 
30
    -e "s/^Require/\#    Require/" \
 
31
    -e "s/^BrowserMatch/\#    BrowserMatch/" \
 
32
    -e "s/^Order/\#    Order/" \
 
33
    -e "s/^Satisfy/\#    Satisfy/" > ${1}.new
 
34
    mv ${1}.new $1
 
35
}
 
36
 
 
37
 
5
38
reload_apache()
6
39
{
7
40
    if apache2ctl configtest 2>/dev/null; then
14
47
case "$1" in
15
48
    configure)
16
49
 
17
 
        # like mythtv-common.postinst
18
 
        . /usr/share/debconf/confmodule
19
 
 
20
50
        db_get mythtv/mysql_host
21
51
        hostname="$RET"
22
52
        db_get mythtv/mysql_mythtv_dbname
26
56
        db_get mythtv/mysql_mythtv_password
27
57
        mythtv_password="$RET"
28
58
 
29
 
        db_stop
30
 
 
31
59
        HTACCESS=/etc/mythtv/mythweb-htaccess
 
60
        if test -f $HTACCESS; then
 
61
            cp $HTACCESS ${HTACCESS}.dpkg-old
 
62
        fi
32
63
        NEW=${HTACCESS}.new
33
 
        touch $NEW
34
64
 
35
65
        if [ -s $HTACCESS ]; then
36
66
            INPUT=$HTACCESS
37
 
            chown --reference=$INPUT $NEW
38
 
            chmod --reference=$INPUT $NEW
39
67
        else
40
68
            INPUT=/usr/share/mythtv/mythweb/.htaccess.dist
41
 
            chown mythtv:www-data $NEW
42
 
            chmod 640 $NEW
43
69
        fi
44
70
 
45
71
        cat $INPUT | sed -e "
48
74
s/\(^[ \t]*setenv[ \t]\+db_login[ \t]\+\"\)[^\"]*\"/\1$mythtv_username\"/g;
49
75
s/\(^[ \t]*setenv[ \t]\+db_password[ \t]\+\"\)[^\"]*\"/\1$mythtv_password\"/g;
50
76
            " > $NEW
51
 
        mv $NEW $HTACCESS
 
77
        mv -f $NEW $HTACCESS
52
78
 
53
 
        ACCESS=/etc/mythtv/mythweb-htaccess.conf
54
 
        if test -f $ACCESS; then
55
 
            mv $ACCESS ${ACCESS}.dpkg-old
56
 
        fi
 
79
    MYTHWEBDIR=/etc/apache2/sites-enabled/mythwebdir
 
80
    if test -f $MYTHWEBDIR; then
 
81
        a2dissite mythwebdir > /dev/null || true
 
82
    fi
57
83
 
58
84
        CONFIG=/etc/mythtv/mythweb-settings.php
59
85
        if test -f $CONFIG; then
89
115
            a2ensite mythwebdir >/dev/null || true
90
116
            reload_apache
91
117
        fi
 
118
 
 
119
    # handle password protection/ authentication setup
 
120
    # get our values from the DB
 
121
    DIGESTFILE=/etc/mythtv/mythweb-digest
 
122
    db_get mythweb/enable || true
 
123
    AUTH_ENABLE="$RET"
 
124
    if [ "$AUTH_ENABLE" = true ]; then
 
125
        db_get mythweb/username || true
 
126
        USERNAME="$RET";
 
127
        db_get mythweb/password || true
 
128
        PASSWORD="$RET";
 
129
        a2enmod auth_digest > /dev/null || true
 
130
        
 
131
        # create htdigest file create password hash thanks to 
 
132
        # http://trac.lighttpd.net/trac/wiki/Docs:ModAuth :)
 
133
        HASH=`echo -n ${USERNAME}:MythTV:${PASSWORD} | md5sum | cut -b -32` || true
 
134
        echo ${USERNAME}:MythTV:${HASH} > $DIGESTFILE
 
135
        enableauth "${HTACCESS}" "${DIGESTFILE}" || true    
 
136
        chown mythtv:www-data ${DIGESTFILE}
 
137
        chmod 640 ${DIGESTFILE}
 
138
    else
 
139
        disableauth "${HTACCESS}" || true
 
140
    fi
 
141
 
 
142
        chown mythtv:www-data ${HTACCESS}
 
143
        chmod 640 ${HTACCESS}
 
144
 
92
145
    ;;
93
146
 
94
147
    abort-upgrade|abort-remove|abort-deconfigure)
101
154
    ;;
102
155
esac
103
156
 
104
 
#DEBHELPER#
105
 
 
106
157
exit 0