File: flavours.preinst

package info (click to toggle)
apache 1.3.34-4.1
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 4,800 kB
  • ctags: 90
  • sloc: sh: 1,273; makefile: 685; perl: 215
file content (68 lines) | stat: -rw-r--r-- 1,480 bytes parent folder | download | duplicates (3)
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
#! /bin/bash

set -e

case "$1" in
    install|upgrade)

    if [ "$1" = install -o "$1" = upgrade ] && [ "$2" != "" ]
    then
	if [ ! -d /etc/@FLAVOUR@ -a -d /etc/httpd ]
	then
	    echo Copying existing configuration from "\`/etc/httpd'" to "\`/etc/@FLAVOUR@'..."
	    mkdir -m 755 /etc/@FLAVOUR@ &&
		(cd /etc/httpd; tar cf - .) | (cd /etc/@FLAVOUR@; tar xpf -)
	fi

	# this should ensure a sane stop of apache upgrading from woody/testing
	# NOTE: woody prerm script is broken and does not stop apache!

	if [ -x "/etc/init.d/@FLAVOUR@" ]; then
	    if [ -x /usr/sbin/invoke-rc.d ]; then
		invoke-rc.d @FLAVOUR@ stop
	    else
		/etc/init.d/@FLAVOUR@ stop
	    fi
	fi
	# there might be some @FLAVOUR@ processes still running

	cnt=0
	while [ "`pidof @FLAVOUR@ | awk '{print $0}'`" ]; do
	    if [ $cnt -gt 30 ]; then
		PIDS=`pidof @FLAVOUR@ | awk '{print $0}'`
		for i in $PIDS; do
		    kill $i
		    # we killed apache, possibly because init scripts
		    # are disable. Track the status and restart it
		    # at the end of postinst.
		    touch /etc/@FLAVOUR@/.@FLAVOUR@mustberestarted
		done
	    fi
	    cnt=`expr $cnt + 1`
	    sleep 1
	done

	# ugly but this is a template
	if [ "@FLAVOUR@" = "apache-ssl" ]; then
	    PIDS=`pidof gcache | awk '{print $0}'`
	    for i in $PIDS; do
		kill $i
	    done
	fi
    fi

    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac

#DEBHELPER#

exit 0