File: jserv.postinst

package info (click to toggle)
jserv 1.1.2-2
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 4,584 kB
  • ctags: 3,019
  • sloc: sh: 7,715; java: 6,635; ansic: 5,013; makefile: 814; perl: 39; xml: 32
file content (97 lines) | stat: -rw-r--r-- 3,843 bytes parent folder | download
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
#!/bin/sh -e

updateJServConf() {
    file=/etc/jserv/jserv.conf

    # The following entries were added for jserv-1.0.99b2-2
    # * In case we copied the old JServ 1.0 files:
    #   - Update to new JServ protocol ajpv12
    #   - Change jserv.properties location
    #   - Comment ApJServLogFile (which is now in /etc/apache/httpd.conf)
    #   - Uncomment ApJServManual entry
    # The following entries were added for jserv-1.0.99b3-2
    # * Update location of jserv.secret.key
    perl -p -i -e 's:ajpv11:ajpv12:; s:/etc/apache/jserv.properties:/etc/jserv/jserv.properties:; s:^(ApJServLogFile.*):#\1:; s:^#(ApJServManual.*):\1:; s:/etc/apache/jserv.secret.key:/etc/jserv/jserv.secret.key:;' $file
}

updateJServProp() {
    file=/etc/jserv/jserv.properties

    # The following entries were added for jserv-1.0.99b2-2
    # * In case we copied the old JServ 1.0 files:
    #   - Update to new JServ protocol ajpv12
    #   - Change servlet zone locations
    # * jsdk.jar changed to servlet-2.0.jar in jserv 1.0.99b2-2
    # The following entries were added for jserv-1.0.99b3-2
    # * Update location of jserv.secret.key
    perl -p -i -e 's:ajpv11:ajpv12:; s:/etc/apache/servletzones/:/etc/jserv/zones/:; s:/usr/share/java/jsdk.jar:/usr/share/java/servlet-2.0.jar:; s:/etc/apache/jserv.secret.key:/etc/jserv/jserv.secret.key:;' $file
}

case "$1" in
    configure)

        # Generate debug log file
        if [ ! -f /var/log/jserv.log ]; then
            touch /var/log/jserv.log
            chown www-data:www-data /var/log/jserv.log
            chmod 664 /var/log/jserv.log
        fi

        # Create secret key from random numbers
        if [ ! -f /etc/jserv/jserv.secret.key ]; then
            dd 2>/dev/null if=/dev/urandom of=/etc/jserv/jserv.secret.key bs=128 count=1
            chown www-data:root /etc/jserv/jserv.secret.key
            chmod 600 /etc/jserv/jserv.secret.key
        fi

        # Copy the configuration files from the old libapache-mod-jserv
        # package to their new location
        if [ ! -f /etc/jserv/jserv.conf -a -f /etc/apache/jserv.conf ]; then
            cp -p /etc/apache/jserv.* /etc/jserv/
            if [ -d /etc/apache/servletzones ]; then
                cp -a /etc/apache/servletzones/* /etc/jserv/zones
            fi
            /usr/sbin/update-jserv remove-apache || true
            updateJServConf
            updateJServProp
        fi

        # Copy the example configuration files to /etc/jserv if they are not
        # already present - otherwise update them
        if [ ! -f /etc/jserv/jserv.conf ]; then
           zcat /usr/share/doc/jserv/examples/jserv.conf.gz > /etc/jserv/jserv.conf
        fi
        if [ ! -f /etc/jserv/jserv.properties ]; then
           zcat /usr/share/doc/jserv/examples/jserv.properties.gz > /etc/jserv/jserv.properties
        else
           updateJServProp
           # jsdk.jar changed to servlet-2.0.jar in jserv 1.0.99b2-2
           perl -p -i -e 's:/usr/share/java/jsdk.jar:/usr/share/java/servlet-2.0.jar:' /etc/jserv/jserv.properties
        fi
        if [ ! -f /etc/jserv/zones/root.properties ]; then
           zcat /usr/share/doc/jserv/examples/root.properties.gz > /etc/jserv/zones/root.properties
        fi

        # Only configure the rest if this is the first installation
        if [ -z "$2" ]; then

	   # Jserv's init script moved from sequence code 20 to 30, so remove
	   # the old rc.d files first
	   update-rc.d -f jserv remove &>/dev/null

           # Add an include directive for jserv.conf to Apache's configuration
           # file and reload the Apache configuration
	   /usr/sbin/update-jserv add-apache
        fi

        #DEBHELPER#
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

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