This file is indexed.

postinst is in phamm 0.5.18-3.1.

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
#!/bin/sh

set -e

CONFFILE="/etc/phamm/config.php"
PLUGINS="/etc/phamm/plugins"

#chown -R root:www-data $PLUGINS
#chmod -R 0640 $PLUGINS

. /usr/share/debconf/confmodule
db_version 2.0 || [ $? -lt 30 ]

if [ "$1" = "configure" ]; then
    
    if [ ! -f /var/log/phamm.log ]; then
	touch /var/log/phamm.log
	chown www-data:adm /var/log/phamm.log
	chmod 640 /var/log/phamm.log
    fi

	if [ ! -f $CONFFILE ]; then
		cp /usr/share/phamm/config.inc.example.php $CONFFILE
		chown -R root:www-data $CONFFILE
		chmod 0640 $CONFFILE
		if [ ! -e /usr/share/phamm/config.inc.php ]; then
		    ln -s $CONFFILE /usr/share/phamm/config.inc.php
		fi
	else
		# Solve a non-link file in 0.5.9-*
		if [ ! -e /usr/share/phamm/config.inc.php ]; then
		    ln -s $CONFFILE /usr/share/phamm/config.inc.php
		fi
		exit 0
	fi

	db_get phamm/ldap-server || true
	ldapserver="$RET"
    perl -i -p -e "s/\('LDAP_HOST_NAME','127.0.0.1'\)/\('LDAP_HOST_NAME','$ldapserver'\)/" $CONFFILE 2> /dev/null


	db_get phamm/ldap-tls || true
	tls="$RET"
	if [ "$tls" = "true" ]; then
	    perl -i -p -e "s/\('LDAP_HOST_NAME','/\('LDAP_HOST_NAME','ldaps:\/\//" $CONFFILE 2> /dev/null
	    perl -i -p -e "s/\('LDAP_PORT','389'\)/\('LDAP_PORT','636'\)/" $CONFFILE 2> /dev/null

	fi

	db_get phamm/ldap-basedn || true
	basedn="$RET"
    perl -i -p -e "s/\('SUFFIX','dc=example,dc=tld'\)/\('SUFFIX','$basedn'\)/" $CONFFILE 2> /dev/null

	db_get phamm/ldap-binddn || true
	binddn="$RET"
	perl -i -p -e "s/\('BINDDN','cn=admin,dc=example,dc=tld'\)/\('BINDDN','$binddn'\)/" $CONFFILE 2> /dev/null
	
	perl -i -p -e "s/\('LDAP_BASE','o=hosting,dc=example,dc=tld'\)/\('LDAP_BASE','o=hosting,$basedn'\)/" $CONFFILE 2> /dev/null
	
	perl -i -p -e "s/\('PHAMM_LOG',0\)/\('PHAMM_LOG',1\)/" $CONFFILE 2> /dev/null

    # Autoconfiguration for apache*
    db_get phamm/reconfigure-webserver || true
    webservers="$RET"
    restart=""
    
    for webserver in $webservers; do
        webserver=${webserver%,}
        test -x /usr/sbin/$webserver || continue
	
        case "$webserver" in
            apache|apache-perl|apache-ssl)
                if [ -x /usr/sbin/modules-config ]; then
                    if [ -f /usr/lib/apache/1.3/libphp5.so ]; then
                        if ! grep "^LoadModule php5_module " /etc/$webserver/modules.conf > /dev/null 2>&1; then
                            modules-config $webserver enable mod_php5
                        fi
                    elif [ -f /usr/lib/apache/1.3/libphp4.so ]; then
                        if ! grep "^LoadModule php4_module " /etc/$webserver/modules.conf > /dev/null 2>&1; then
                            modules-config $webserver enable mod_php4
                        fi
                    else
                        if [ -f /usr/lib/apache/1.3/mod_actions.so ]; then
                            if ! grep "^LoadModule action_module " /etc/$webserver/modules.conf > /dev/null 2>&1; then
                                modules-config $webserver enable mod_actions
                            fi
                        fi
                        if [ -f /usr/lib/apache/1.3/mod_cgi.so ]; then
                            if ! grep "^LoadModule cgi_module " /etc/$webserver/modules.conf > /dev/null 2>&1; then
                                modules-config $webserver enable mod_cgi
                            fi
                        fi
                    fi
                fi
                if grep "^Include /etc/phamm/apache.conf" /etc/$webserver/httpd.conf > /dev/null 2>&1; then
                    mv -f /etc/$webserver/httpd.conf /etc/$webserver/httpd.conf.old.phamm
                    grep -v "^Include /etc/phamm/apache.conf" /etc/$webserver/httpd.conf.old.phamm \
                        > /etc/$webserver/httpd.conf
                fi
                if ! grep "^Include /etc/$webserver/conf.d" /etc/$webserver/httpd.conf > /dev/null 2>&1; then
                    cp -f /etc/$webserver/httpd.conf /etc/$webserver/httpd.conf.old.phamm
                    echo "Include /etc/$webserver/conf.d" >> /etc/$webserver/httpd.conf
                fi
                if [ -f /etc/$webserver/httpd.conf.old.phamm ] && [ ! -f /etc/$webserver/httpd.conf.old ]; then
                    mv -f /etc/$webserver/httpd.conf.old.phamm /etc/$webserver/httpd.conf.old
                fi
                mkdir -p /etc/$webserver/conf.d
                ;;
            apache2)
                if [ -d /etc/$webserver/mods-enabled ]; then
                    if [ ! -f /etc/$webserver/mods-enabled/actions.load ] && [ ! -h /etc/$webserver/mods-enabled/actions.load ]; then
                        ln -s /etc/$webserver/mods-available/actions.load /etc/$webserver/mods-enabled/actions.load
                    fi
                    if [ -f /etc/apache2/mods-available/php5.load ]; then
                        if [ ! -f /etc/$webserver/mods-enabled/php5.load ] && [ ! -h /etc/$webserver/mods-enabled/php5.load ]; then
                            ln -s /etc/$webserver/mods-available/php5.load /etc/$webserver/mods-enabled/php5.load
                        fi
                    elif [ -f /etc/apache2/mods-available/php4.load ]; then
                        if [ ! -f /etc/$webserver/mods-enabled/php4.load ] && [ ! -h /etc/$webserver/mods-enabled/php4.load ]; then
                            ln -s /etc/$webserver/mods-available/php4.load /etc/$webserver/mods-enabled/php4.load
                        fi
                    else
                        if [ ! -f /etc/$webserver/mods-enabled/cgi.load ] && [ ! -h /etc/$webserver/mods-enabled/cgi.load ]; then
                            ln -s /etc/$webserver/mods-available/cgi.load /etc/$webserver/mods-enabled/cgi.load
                        fi
                    fi
                fi
                ;;
        esac

        if [ ! -f /etc/$webserver/conf.d/phamm ] && [ ! -h /etc/$webserver/conf.d/phamm ]; then
            ln -s /etc/phamm/apache.conf /etc/$webserver/conf.d/phamm
	    restart="$restart $webserver"
        fi
    done

    db_get phamm/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
    
fi



exit 0