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

Last change on this file since 1240 was 1240, checked in by jrpelegrina, 4 years ago

fix

File size: 3.0 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    echo "Setting up apache multi-instance"
22    if [ ! -f /usr/share/doc/apache2/examples/setup-instance ]; then
23        echo "ERROR: setup-instance from apache2 not found !!!"
24        exit 1
25    fi
26    if [ -d /etc/apache2-lliurex ]; then
27        mv /etc/apache2-lliurex /etc/apache2-lliurex-${NOW}
28    fi
29    bash /usr/share/doc/apache2/examples/setup-instance lliurex
30}
31change_ports(){
32    echo "Changing default ports from 80 -> 800 & 443 -> 4430 in apache-lliurex"
33    if [ ! -d /etc/apache2-lliurex ]; then
34        echo "ERROR: /etc/apache2-lliurex not found !!!"
35        exit 1
36    fi
37    sed -i -r 's/80/800/g' /etc/apache2-lliurex/ports.conf
38    sed -i -r 's/443/4430/g' /etc/apache2-lliurex/ports.conf
39    for site in /etc/apache2-lliurex/sites-available/*.conf; do
40        sed -i -r 's/\*:80/\*:800/g' ${site}
41        sed -i -r 's/\*:443/\*:4430/g' ${site}
42    done;
43}
44fix_mods(){
45    echo "Fixing php modules in apache & apache-lliurex"
46    DISMOD_LLIUREX=$(/usr/bin/which a2dismod-lliurex)
47    DISMOD=$(/usr/bin/which a2dismod)
48    echo "Using: ${DISMOD_LLIUREX} & ${DISMOD}"
49    if [ -L /etc/apache2-lliurex/mods-enabled/php7.0.load ]; then
50        ${DISMOD_LLIUREX} php7.0
51    fi
52    if [ -L /etc/apache2/mods-enabled/php5.load ]; then
53        ${DISMOD} php5
54    fi
55    if [ -f /etc/apache2-lliurex/mods-available/php7.0.conf ]; then
56        mv /etc/apache2-lliurex/mods-available/php7.0.conf /etc/apache2-lliurex/mods-available/php7.0.conf.disabled
57    fi
58    if [ -f /etc/apache2-lliurex/mods-available/php7.0.load ]; then
59        mv /etc/apache2-lliurex/mods-available/php7.0.load /etc/apache2-lliurex/mods-available/php7.0.load.disabled
60    fi
61    if [ -f /etc/apache2/mods-available/php5.conf ]; then
62        mv /etc/apache2/mods-available/php5.conf /etc/apache2-lliurex/mods-available/php5.conf.disabled
63    fi
64    if [ -f /etc/apache2/mods-available/php5.load ]; then
65        mv /etc/apache2/mods-available/php5.load /etc/apache2-lliurex/mods-available/php5.load.disabled
66    fi
67}
68
69case "$1" in
70    configure)
71        setup_apache
72        change_ports
73        fix_mods
74        systemctl enable apache2-lliurex
75        systemctl restart apache2-lliurex
76        systemctl restart apache2
77    ;;
78
79    abort-upgrade|abort-remove|abort-deconfigure)
80    ;;
81
82    *)
83        echo "postinst called with unknown argument \`$1'" >&2
84        exit 1
85    ;;
86esac
87
88# dh_installdeb will replace this with shell code automatically
89# generated by other debhelper scripts.
90
91#DEBHELPER#
92
93exit 0
Note: See TracBrowser for help on using the repository browser.