source: php5-lliurex-compat/fuentes/debian/postinst @ 1500

Last change on this file since 1500 was 1500, checked in by mabarracus, 5 years ago

add flag to debug dpkg installing

File size: 3.8 KB
Line 
1#!/bin/sh
2# postinst script for php5-lliurex-compat
3#
4# see: dh_installdeb(1)
5
6set -e
7
8# summary of how this script can be called:
9#        * <postinst> `configure' <most-recently-configured-version>
10#        * <old-postinst> `abort-upgrade' <new version>
11#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12#          <new-version>
13#        * <postinst> `abort-remove'
14#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15#          <failed-install-package> <version> `removing'
16#          <conflicting-package> <version>
17# for details, see https://www.debian.org/doc/debian-policy/ or
18# the debian-policy package
19NOW=$(date +'%Y%m%d%h%m')
20setup_apache(){
21    INST="/etc/apache2-lliurex"
22    FILES="ports.conf apache2.conf envvars"
23    IS_DONE=0
24    for file in $FILES; do
25        if [ -f ${INST}/${file} ]; then
26            IS_DONE=1
27        fi
28    done
29    if [ ${IS_DONE} -eq 1 ]; then 
30            echo "Apache2 multi-instance seems already configured, skipping multi-instance configuration"
31            return
32    fi
33   
34    echo "Setting up apache multi-instance"
35    if [ ! -f /usr/share/doc/apache2/examples/setup-instance ]; then
36        echo "ERROR: setup-instance from apache2 not found !!!"
37        exit 1
38    fi
39    if [ -d /etc/apache2-lliurex ]; then
40        mv /etc/apache2-lliurex /etc/apache2-lliurex-${NOW}
41    fi
42    bash /usr/share/doc/apache2/examples/setup-instance lliurex
43}
44change_ports(){
45    echo "Changing default ports from 80 -> 800 & 443 -> 4430 in apache-lliurex"
46    if [ ! -d /etc/apache2-lliurex ]; then
47        echo "ERROR: /etc/apache2-lliurex not found !!!"
48        exit 1
49    fi
50    sed -i -r 's/80/800/g' /etc/apache2-lliurex/ports.conf
51    sed -i -r 's/443/4430/g' /etc/apache2-lliurex/ports.conf
52    for site in /etc/apache2-lliurex/sites-available/*.conf; do
53        tst80=$(egrep ':80' ${site}|wc -l)
54        tst443=$(egrep ':443' ${site}|wc -l)
55        if [ ${tst80} -ne 0 ]; then
56            echo "Fixing port 80 in site: " ${site}
57            sed -i -r 's/\*:80/\*:800/g' ${site}
58        fi
59        if [ ${tst443} -ne 0 ]; then
60            echo "Fixing port 443 in site: " ${site}
61            sed -i -r 's/\*:443/\*:4430/g' ${site}
62        fi
63    done;
64}
65fix_mods(){
66    echo "Fixing php modules in apache & apache-lliurex"
67    DISMOD_LLIUREX=$(/usr/bin/which a2dismod-lliurex)
68    DISMOD=$(/usr/bin/which a2dismod)
69    echo "Using: ${DISMOD_LLIUREX} & ${DISMOD}"
70    if [ -L /etc/apache2-lliurex/mods-enabled/php7.0.load ]; then
71        echo "Disabling php7 into apache2-lliurex instance"
72        ${DISMOD_LLIUREX} php7.0
73    fi
74    if [ -L /etc/apache2/mods-enabled/php5.load ]; then
75        echo "Disabling php5 into apache2 instance"
76        ${DISMOD} php5
77    fi
78    if [ -f /etc/apache2-lliurex/mods-available/php7.0.conf ]; then
79        mv /etc/apache2-lliurex/mods-available/php7.0.conf /etc/apache2-lliurex/mods-available/php7.0.conf.disabled
80    fi
81    if [ -f /etc/apache2-lliurex/mods-available/php7.0.load ]; then
82        mv /etc/apache2-lliurex/mods-available/php7.0.load /etc/apache2-lliurex/mods-available/php7.0.load.disabled
83    fi
84    if [ -f /etc/apache2/mods-available/php5.conf ]; then
85        mv /etc/apache2/mods-available/php5.conf /etc/apache2/mods-available/php5.conf.disabled
86    fi
87    if [ -f /etc/apache2/mods-available/php5.load ]; then
88        mv /etc/apache2/mods-available/php5.load /etc/apache2/mods-available/php5.load.disabled
89    fi
90}
91
92case "$1" in
93    configure)
94        if [ -f /tmp/debug_compat ]; then
95            set -x
96        fi
97        setup_apache
98        change_ports
99        fix_mods
100        echo "Enabling multi-site services"
101        systemctl enable apache2-lliurex
102        systemctl daemon-reload
103        systemctl restart apache2-lliurex
104        systemctl restart apache2
105        if [ -f /tmp/debug_compat ]; then
106            set +x
107        fi
108    ;;
109
110    abort-upgrade|abort-remove|abort-deconfigure)
111    ;;
112
113    *)
114        echo "postinst called with unknown argument \`$1'" >&2
115        exit 1
116    ;;
117esac
118
119# dh_installdeb will replace this with shell code automatically
120# generated by other debhelper scripts.
121
122#DEBHELPER#
123
124exit 0
Note: See TracBrowser for help on using the repository browser.