File: micro-httpd.postinst

package info (click to toggle)
micro-httpd 20051212-9
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 96 kB
  • ctags: 23
  • sloc: sh: 299; ansic: 231; makefile: 67
file content (87 lines) | stat: -rw-r--r-- 1,528 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
#!/bin/sh

set -e

PACKAGE=$(basename $0 | sed 's/\..*//')

WWWDIR=/var/www
conf=/etc/inetd.conf
pkgdir=/usr/share/$PACKAGE
port="www"
entry="$port\tstream\ttcp\tnowait root\t/usr/sbin/tcpd /usr/sbin/$PACKAGE $WWWDIR"

Debhelper ()
{
    :
    #DEBHELPER#
}

Warn ()
{
    echo "$*" >&2
}

IsInInetd ()
{
    #  Debian may have inetd.conf entry already
    grep -q "^[[:space:]]*$port.*$PACKAGE" $conf
}

IsConflictInetd ()
{
    grep -q "^[[:space:]#]*$port" $conf
}

HttpdWarning ()
{
    # There isn't much point inetd if apache already installed and
    # occupies port 80

    if ls /etc/init.d/apache* > /dev/null 2> /dev/null; then
        Warn "$PACKAGE: [WARN] Apache found. $conf uses port 'www'" \
             "which may be same (you may need to change port)"
    fi
}

InetdName ()
{
    name=inetd

    if [ -f /etc/init.d/openbsd-inetd ]; then
        name="openbsd-inetd"
    elif [ -f /etc/init.d/rlinetd ]; then
        name="rlinetd"
    fi

    echo $name
}

InstallInetd ()
{
    Warn "$0: adding new $conf entry"
    update-inetd --group STANDARD --add "$entry"

    #  This directory must be there

    [ ! -d $WWWDIR ] && mkdir -p $WWWDIR

    invoke-rc.d $(InetdName) reload
}

Main ()
{
    if [ "$1" = "install" ] || [ "$1" = "configure" ]; then
        if IsConflictInetd ; then
            Warn "$PACKAGE: [WARNING] Not installing to $conf due to existing 'www' entry"
        else
	    IsInInetd || InstallInetd
            HttpdWarning
        fi
    fi

    Debhelper
}

Main "$@"

# End of file