This file is indexed.

postinst is in gnats 4.1.0-3.

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
 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
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/bin/sh
#
# Gnats installation script -- written by Brian White <bcwhite@pobox.com>
# (This was my very first attempt at learning perl... please forgive me!)
#
# Forgiving -- rewritten to bash :-) by Milan Zamazal <pdm@debian.org>.
# ...and streamlined with SED by Chad Walstrom <chewie@debian.org>

set -e

###############################################################################
#
# Utility functions
#

# Call arguments and never return error
protect () { "$@" || true; }

###############################################################################
#
# Common initialization for install scripts
#

. /usr/share/debconf/confmodule

protect db_get gnats/site
SITE=${RET:-default}
GNATSSITE="/var/lib/gnats/gnats-db/$SITE"
GNATSDBDIR="/var/lib/gnats/gnats-db"
PASSWDFILE="/etc/passwd"

###############################################################################
#
# Check the 'gnats' userid in the password file
#

if [ "$1" = configure ]; then

  if [ $(protect grep -c "^gnats:" /etc/group) -eq 0 ]; then
    adduser --group --gid 41 gnats
  fi
  
  PWFOUND=$(protect grep -c "^gnats:" /etc/passwd)

  if [ $PWFOUND -gt 1 ]; then
    db_subst gnats/user_multiple PASSWDFILE "/etc/passwd"
    db_input high gnats/user_multiple || true
    db_go
  fi

  if [ $PWFOUND -gt 0 ]; then
    if [ $(protect grep -c "^gnats:.*:/usr/lib/gnats/gnats-db:" /etc/passwd) -gt 0 ]
    then
      if [ -e /usr/lib/gnats/gnats-db/.profile ]; then
  mv /usr/lib/gnats/gnats-db/.profile /var/lib/gnats/
      fi
      usermod -d /var/lib/gnats gnats
    fi
    if [ $(protect grep -c "^gnats:[^:]*:41:41:" \
           /etc/passwd) \
   -eq 0 ]
    then
      usermod -u 41 -G 41 gnats
    fi
  else
    adduser --quiet --system --home /var/lib/gnats --no-create-home \
            --gid 41 --shell /bin/sh --disabled-login \
      --gecos 'GNU GNATS Bug-Reporting System' gnats
  fi

fi

###############################################################################
#
# Add the 'gnats' system into the mail aliases
#

if [ "$1" = configure ]; then
  
  #
  # Special mailers
  #

  EXIM=$(dpkg -l exim | protect grep -c '^.i')
  for F in /etc/exim/exim.conf /etc/exim.conf; do
    if [ -f $F ]; then
      EXIMCONF=$F
      break
    fi
  done

  if [ $EXIM -gt 0 ] && [ -n "$EXIMCONF" ]; then
    if [ $(grep -c '^[ \t]*user[ \t]*=' $EXIMCONF) -eq 0 ]; then
      LINES="$(grep '^[ \t]*#[ \t]*user[ \t]*=' $EXIMCONF)"
      if [ -n "$LINES" ]; then
        db_subst gnats/exim_user_uncomment LINES "$LINES"
  db_subst gnats/exim_user_uncomment EXIMCONF "$EXIMCONF"
  db_input high gnats/exim_user_uncomment || true
  db_go
      else
  db_subst gnats/exim_user_uncomment EXIMCONF "$EXIMCONF"
  db_input high gnats/exim_user_add || true
  db_go 
      fi
    fi
  fi

  QMAIL=$(dpkg -l qmail | protect grep -c '^.i')

  if [ $QMAIL -gt 0 ]; then

    # Generate dot files
#    echo "qmail found, installing qmail dot files..."
    for I in "qmail root" \
             "qmail-bugs | /usr/lib/gnats/queue-pr -q" \
             "qmail-query | /usr/lib/gnats/mail-query"; do
      KEY=${I%% *}
      FILE="/var/lib/gnats/.$KEY"
      if [ ! -f $FILE ]; then
  TEMPFILE=$(tempfile)
  echo "${I#$KEY }" >$TEMPFILE
  chmod 0644 $TEMPFILE
  chown gnats:gnats $TEMPFILE
  mv $TEMPFILE $FILE
      fi      
    done
#    echo "Done."

    # Generate aliases
    ASSIGN='/var/qmail/users/assign'
    if [ ! -f $ASSIGN ] || \
       [ $(protect grep -c '^.gnats-admin' $ASSIGN) -eq 0 ]; then
      db_subst gnats/qmail SITE "${SITE}"
      db_input high gnats/qmail || true
      db_go
    fi

  elif [ ! -f /etc/aliases ]; then

    db_subst gnats/unknown_mailer SITE "${SITE}"
    db_input high gnats/unknown_mailer || true
    db_go

  else
  
    #
    # Common mailers
    #

    if [ $(protect \
           egrep -c "^[ \t]*(gnats-admin|bugs|query-pr|$SITE-gnats)\>" \
     /etc/aliases) -lt 4 ]; then

      TEMPFILE=$(tempfile)
      sed "s/^#\([ \t]*\(gnats-admin\|bugs\|query-pr\|$SITE-gnats\)\>.*$\)/\1/" \
        /etc/aliases >$TEMPFILE
      
      if [ $(protect \
             egrep -c "^[ \t]*(gnats-admin|bugs|query-pr|$SITE-gnats)\>" \
       $TEMPFILE) -lt 4 ]; then
        egrep -v "^[ \t]*(gnats-admin|bugs|query-pr|$SITE-gnats)\>" \
          /etc/aliases >$TEMPFILE
        cat - >>$TEMPFILE <<EOF

# begin gnats aliases
gnats:          root
gnats-admin:    gnats
bugs:           "| /usr/lib/gnats/queue-pr -q"
query-pr:       "| /usr/lib/gnats/mail-query"
$SITE-gnats:    bugs
# end gnats aliases
EOF
      fi

      cp /etc/aliases /etc/aliases.dpkg-old
      chmod 644 $TEMPFILE
      mv $TEMPFILE /etc/aliases
      
      NEWALIASES=$(which newaliases)
      if [ -n "$NEWALIASES" ]; then
        "$NEWALIASES"
      fi      
    fi
    
  fi

fi

###############################################################################
#
# Initialize GNATS configuration files
#

if [ "$1" = configure ]; then
  #
  # Add symlink to the standard database
  #
  if [ ! -e /etc/gnats/db-config/default ]; then
    ln -sf /var/lib/gnats/gnats-db/gnats-adm /etc/gnats/db-config/default
  fi

  #
  # Add symlink for gnatsd.user_access
  #
  if [ ! -e /etc/gnats/gnatsd.user_access ]; then
    ln -sf /var/lib/gnats/gnats-db/gnats-adm/gnatsd.user_access /etc/gnats/gnatsd.user_access
  fi

  #
  # Create new database if necessary
  #
  if [ $(grep -c '^default:' /etc/gnats/databases) -gt 0 ]; then
    if [ -d "/var/lib/gnats/gnats-db/gnats-adm" ]; then
      # gnats-queue was present directly in older versions of the package, so
      # it can be deleted during the upgrade
      QUEUEDIR="/var/lib/gnats/gnats-db/gnats-queue"
      if [ ! -d "$QUEUEDIR" ]; then
        mkdir "$QUEUEDIR"
        chown gnats:gnats "$QUEUEDIR"
      fi
    else
      if [ -d "/var/lib/gnats/gnats-db" ]; then
        mv /var/lib/gnats/gnats-db /var/lib/gnats/gnats-db.old
      fi
      /usr/lib/gnats/mkdb default
      chown -R gnats:gnats /var/lib/gnats/gnats-db
    fi
  fi
fi

###############################################################################
#
# Add an inetd entry for client/server operations
#

if [ "$1" = configure ] ; then
  # If upgrading from 3.x, replace gnats entry with support
  if [ -n "$2" ] && dpkg --compare-versions "$2" lt 3.111-1; then
    update-inetd --remove "^#?gnats.*/gnatsd"
  fi

  # Add support entry
  update-inetd --add "#support    stream  tcp nowait  gnats /usr/sbin/tcpd  /usr/lib/gnats/gnatsd"
fi

###############################################################################
#
# Automatically added debhelper stuff
#