This file is indexed.

preinst is in snort-common 2.9.2-3ubuntu1.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

 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
#!/bin/sh

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>

DBCONF="/etc/snort/database.conf"
GENCONF="/etc/snort/snort.conf"

case "$1" in
    install)
        # Do nothing
    ;;
    upgrade)
         # earlier versions modified /etc/snort/snort.conf directly for the
         # DB stuff, we splitt it off in a sepperate file, to ensure smooth
         # upgrades
         if dpkg --compare-versions "$2" eq "2.8.5.2-3" 
         then
         # Fix bug from previous release that resulted in an
         # incorrect database.conf being generated
            if [ -e "$DBCONF" -a -e "$GENCONF" ] && grep -q "http://www.snort.org" $DBCONF
            then    
                rm -f $DBCONF
                touch $DBCONF
            fi
        fi

         if dpkg --compare-versions "$2" le "2.8.5.2-3" && [ -e "$GENCONF" ] && grep -q "(#DBSTART#)" "$GENCONF" 
         then
             GENCONF_TEMPFILE=`mktemp`
             DBCONF_TEMPFILE=`mktemp`
             # Look into the generated configuration file to see if
             # there is a database definition, if there is, transparently
             # copy it over to its new location

             cat "$GENCONF" |  perl -ne ' $output=0 if /^\# \(\#DBEND\#\)/; print if $output; $output=1 if /^\# \(\#DBSTART\#\)/; ' >$DBCONF_TEMPFILE
             cat "$GENCONF" | perl -ne '$output=1 if /^\#/; $output=1 if /^\# \(\#DBEND\#\)/; print if $output; $output=0 if /^\# \(\#DBSTART\#\)/;' >$GENCONF_TEMPFILE

             # Be on the safe side, if we do not generate a non-empty
             # configuration abort:
             if [ -s "$GENCONF_TEMPFILE" ] ; then
                 mv $GENCONF_TEMPFILE $GENCONF
                 mv $DBCONF_TEMPFILE $DBCONF
             else
                 echo "ERROR: Preinstallation script was unable to extract a proper configuration file for migration. Please report this as a bug in the snort-common Debian package" >&2
                 exit 1
             fi
         fi
    ;;
    configure)
    ;;
    abort-upgrade)
    ;;
    *) 
        echo "preinst called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.



exit 0