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

Last change on this file since 1237 was 1237, checked in by jrpelegrina, 5 years ago

fix

File size: 2.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    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=$(type -fp a2dismod-lliurex)
47    DISMOD=$(type -fp a2dismod)
48    ${DISMOD_LLIUREX} php7.0
49    ${DISMOD} php5
50    if [ -f /etc/apache2-lliurex/mods-available/php7.0.conf ]; then
51        mv /etc/apache2-lliurex/mods-available/php7.0.conf /etc/apache2-lliurex/mods-available/php7.0.conf.disabled
52    fi
53    if [ -f /etc/apache2-lliurex/mods-available/php7.0.load ]; then
54        mv /etc/apache2-lliurex/mods-available/php7.0.load /etc/apache2-lliurex/mods-available/php7.0.load.disabled
55    fi
56    if [ -f /etc/apache2/mods-available/php5.conf ]; then
57        mv /etc/apache2/mods-available/php5.conf /etc/apache2-lliurex/mods-available/php5.conf.disabled
58    fi
59    if [ -f /etc/apache2/mods-available/php5.load ]; then
60        mv /etc/apache2/mods-available/php5.load /etc/apache2-lliurex/mods-available/php5.load.disabled
61    fi
62}
63
64case "$1" in
65    configure)
66        setup_apache
67        change_ports
68        fix_mods
69        systemctl enable apache2-lliurex
70        systemctl restart apache2-lliurex
71        systemctl restart apache2
72    ;;
73
74    abort-upgrade|abort-remove|abort-deconfigure)
75    ;;
76
77    *)
78        echo "postinst called with unknown argument \`$1'" >&2
79        exit 1
80    ;;
81esac
82
83# dh_installdeb will replace this with shell code automatically
84# generated by other debhelper scripts.
85
86#DEBHELPER#
87
88exit 0
Note: See TracBrowser for help on using the repository browser.