This file is indexed.

postinst is in fex 20160104-1.

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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#!/bin/sh
# postinst script for fex
#
# see: dh_installdeb(1)

set -e

. /usr/share/debconf/confmodule

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

case "$1" in
    configure)
    # lets give them a fex user/group in all cases.
    getent group fex >/dev/null 2>&1 || addgroup --system fex
    getent passwd fex >/dev/null 2>&1 || adduser --system --home /usr/share/fex --no-create-home \
        --disabled-password --shell /bin/sh --ingroup fex fex

    FEX_USER_SHELL=$(getent passwd fex|awk -F: '{print $7}')
    if [ "$FEX_USER_SHELL" = "/bin/false" ];then
        echo "Updating user fex to have a valid shell (/bin/sh)"
        chsh -s /bin/sh fex
    fi

    # ensure fac and fex_cleanup are run as user fex
    for file in fex_cleanup logwatch fexwall;do
        dpkg-statoverride --list /usr/share/fex/bin/$file >/dev/null || dpkg-statoverride --add fex fex 4750 /usr/share/fex/bin/$file
        chown fex:fex /usr/share/fex/bin/$file
        chmod 4750 /usr/share/fex/bin/$file
    done
    dpkg-statoverride --list /usr/bin/fac >/dev/null || dpkg-statoverride --add fex fex 4750 /usr/bin/fac
    chown fex:fex /usr/bin/fac
    chmod 4750 /usr/bin/fac

    if [ ! -d /var/lib/fex/htdocs ]; then
        echo "Installing initial copy of htdocs into /var/lib/fex/htdocs ..."
        mkdir -p /var/lib/fex/htdocs/FAQ/
        cd /usr/share/fex/htdocs/
        find . -type f -exec cp {} /var/lib/fex/htdocs/{} \;
        ln -sf /usr/share/javascript/jquery/jquery.js /var/lib/fex/htdocs/FAQ/jquery.js
        ln -s /usr/share/fex/htdocs/download /var/lib/fex/htdocs/
    else
        echo "Upgrading version file in /var/lib/fex/htdocs"
        cp /usr/share/fex/htdocs/version /var/lib/fex/htdocs/version
        echo "/var/lib/fex/htdocs exists already, checking for default install"
        [ -d /var/lib/fex/htdocs/FAQ/ ]||mkdir /var/lib/fex/htdocs/FAQ/
        tmp=$(mktemp)
        vers=$(mktemp -d)
        (cd ${vers};tar xfz /usr/share/fex/.md5/htdocs.tgz)
        if [ -f /usr/share/fex/.lastver ];then
            lastinst=$(cat /usr/share/fex/.lastver)
            db_set fex/lastver "$lastinst"
            rm -f /usr/share/fex/.lastver
        else
            db_get fex/lastver
            lastinst=$RET
        fi
        lastinstnoepoch=$(echo $lastinst | cut -d':' -f 2)
        if [ -f ${vers}/${lastinst} ];then
            if (cd /var/lib/fex;md5sum -c --quiet "${vers}/${lastinst}" >/dev/null 2>&1);then
                # htdocs is identical
                echo "Updating $lastinst default htdocs to new default htdocs"
                cd /usr/share/fex/htdocs/
                find . -type f -exec cp {} /var/lib/fex/htdocs/{} \;
                rm -f "$tmp"
            fi
            if [ -L /var/lib/fex/htdocs/download ];then
                if [ "$(readlink /var/lib/fex/htdocs/download)" = "/usr/share/fex/htdocs/download" ];then
                    #echo "Download directory is up to date."
                    true
                else
                    echo "Download directory is pointing to non-default location."
                    echo "Please update client scripts yourself"
                fi
            else
                for file in /usr/share/fex/htdocs/download/*;do
                    ln -sf "$file" /var/lib/fex/htdocs/download
                done
            fi
            if [ -L /var/lib/fex/htdocs/FAQ/jquery.js ];then
                if [ "$(readlink /var/lib/fex/htdocs/FAQ/jquery.js)" = "/usr/share/javascript/jquery/jquery.js" ];then
                    #echo "jquery.js link is up to date."
                    true
                else
                    echo "jquery.js in htdocs/FAQ is pointing to non-default location."
                    echo "Please update jquery.js symlink yourself unless intended to not be system default"
                fi
            elif [ ! -f "/var/lib/fex/htdocs/FAQ/jquery.js" ];then
                ln -s /usr/share/javascript/jquery/jquery.js /var/lib/fex/htdocs/FAQ/jquery.js
            fi
        fi
        # tmp is created by mktemp and not cleaned up 
        # if we don't have ${vers}/${lastinst} - 
        # thus custom builds are always custom
        if [ -f "$tmp" ];then
            echo "Customizations in htdocs found. Not touching any files."
            echo "The new default pages are at /usr/share/fex/htdocs/."
            echo "Please check the diff yourself and update your htdocs dir if required."
            rm "$tmp"
        fi
        if [ -e /var/lib/fex/htdocs/FIX.jar ];then
            echo "F*IX is no longer supported. You should remove /var/lib/fex/htdocs/FIX.jar."
        elif [ -L /var/lib/fex/htdocs/FIX.jar -a ! -e /var/lib/fex/htdocs/FIX.jar ];then
            echo "Removing dangling symlink to FIX.jar"
            rm -f /var/lib/fex/htdocs/FIX.jar
        fi
        rm -rf ${vers} 
    fi

    # make sure we don't have MYHOSTNAME.MYDOMAIN as $hostname in /etc/fex/fex.ph
    myhostname=$(hostname -f) # in case our piuparts chroot doesn't know about hostname
    if [ ! -f /etc/fex/fex.ph ];then
        if [ -z "$myhostname" ];then
            echo 'Initializing /etc/fex/fex.ph WITHOUT hostname (Please correct before using F*EX)'
            cat /usr/share/fex/templates/fex.ph >/var/lib/fex/fex.ph
        else
            echo 'Initializing /etc/fex/fex.ph with correcting hostname (using: '${myhostname}')'
            cat /usr/share/fex/templates/fex.ph|sed -e 's/^\$hostname.*/\$hostname = '"'${myhostname}'"';/' >/var/lib/fex/fex.ph
        fi
        # make sure we reset ucf here..
        ucfr --purge fex /etc/fex/fex.ph
        mv /var/lib/fex/fex.ph /etc/fex/fex.ph
        ucfr fex /etc/fex/fex.ph

        # XXX: fex adminpw and ~fex/.fex/id will be autocreated by fex_cleanup further down
    else
        if egrep -q '^\$hostname.*=.*'"'MYHOSTNAME.MYDOMAIN'" /etc/fex/fex.ph 2>/dev/null;then
            echo 'Unconfigured hostname found in /etc/fex/fex.ph! Please correct before using F*EX'
        else
            PW=$(perl -e 'require "/etc/fex/fex.ph";print $admin_pw;')
            ADMIN=$(perl -e 'require "/etc/fex/fex.ph";print $admin;')
            if [ ! -f /usr/share/fex/.fex/id -a -n "$PW" ];then
                echo "Creating fex admin login. Moving admin_pw from fex.ph"
                [ -d /usr/share/fex/.fex/ ]||install -d -m 0700 -o fex -g fex /usr/share/fex/.fex/
                touch /usr/share/fex/.fex/id
                chmod 0600 /usr/share/fex/.fex/id
                chown fex:fex /usr/share/fex/.fex/id
                perl -e 'require "/etc/fex/fex.ph";$opt_p ||= "8888";print "$hostname:$opt_p\n$admin\n$admin_pw\n";' > /usr/share/fex/.fex/id
            fi
            if [ ! -f "/usr/share/fex/spool/${ADMIN}/@" ];then
                mkdir -p "/usr/share/fex/spool/${ADMIN}"
                chmod 0700 "/usr/share/fex/spool/${ADMIN}"
                touch "/usr/share/fex/spool/${ADMIN}/@"
                chmod 0600 "/usr/share/fex/spool/${ADMIN}/@"
                chown fex:fex "/usr/share/fex/spool/${ADMIN}"
                echo "$PW" > "/usr/share/fex/spool/${ADMIN}/@"
            fi
            if grep -q '^$admin_pw' /etc/fex/fex.ph 2>/dev/null;then
                echo '$admin_pw is set in /etc/fex/fex.ph ...'
                echo 'Removing line and replacing by comment.'
                echo 'From now on the fexmaster account also works in the web fac UI.'
                sed -i -e  '/^$admin_pw/s,^$admin_pw.*$,### $admin_pw is no longer used - fexmaster account may now also login via web-fac,' /etc/fex/fex.ph
                PW=$(perl -e 'require "/etc/fex/fex.ph";print $admin_pw;')
                if [ -n "$PW" ];then
                    echo
                    echo ' *** WARNING ***'
                    echo 'Some sort of include happening inside fex.ph. Please remove $admin_pw in include manually!'
                    echo ' *** WARNING ***'
                    echo
                fi
            fi
        fi
        NOTIFY=$(perl -e 'require "/etc/fex/fex.ph";print $notify_newrelease;')
        if [ "$NOTIFY" != "" ];then
            echo "You have notify_newrelease defined in /etc/fex/fex.ph!"
            echo 'This should be set to'
            echo '# ************************************************************'
            echo '$notify_newrelease='"'';"
            echo '# ************************************************************'
            echo 'to ensure you do not get nagged for new upstream releases.'
            echo "Updates for Debian fex come through apt/aptitude and don't need this obviously."
        fi
    fi
    if [ -f /etc/aliases -o -L /etc/aliases ]; then
        if ! grep -qi "^\s*fex\s*:" /etc/aliases; then
            if [ -z "$2" ];then
                echo "Adding system alias for fex to root"
                echo "fex: root" >> /etc/aliases
                # run newaliases for e.g. postfix
                newal=`which newaliases || true`
                if [ -n "$newal" ] && [ -x "$newal" ]; then
                    $newal || true
                fi
            else
                echo "You have no alias set for user fex in /etc/aliases!"
                echo "Consider adding one or you will not receive bounced emails from"
                echo "fex daemon email notifications"
            fi
        fi
    fi
    if [ -f /etc/exim/exim.conf -o -f /var/lib/exim4/config.autogenerated ]; then
        # exim4 found...
        [ ! -f /var/lib/exim4/config.autogenerated ]||ISTRUSTED=$(egrep '^\s*(MAIN_TRUSTED_USERS|trusted_users)\s*=.*fex' /var/lib/exim4/config.autogenerated||true)
        [ ! -f /etc/exim/exim.conf ]||ISTRUSTED=$(egrep '^\s*(MAIN_TRUSTED_USERS|trusted_users)\s*=.*fex' /etc/exim/exim.conf||true)
        [ -z "$ISTRUSTED" ]||echo "You're running exim4 and fex isn't in the trusted_users list. Consider adding or email notifications may not work!"
    fi
    
    # make sure we have correct permissions
    dpkg-statoverride --list /etc/fex/fex.ph >/dev/null || dpkg-statoverride --add fex fex 0640 /etc/fex/fex.ph
    dpkg-statoverride --list /etc/fex/fup.pl >/dev/null || dpkg-statoverride --add fex fex 0640 /etc/fex/fup.pl
    chown fex:fex /etc/fex/fex.ph /etc/fex/fup.pl
    chmod 0640 /etc/fex/fex.ph /etc/fex/fup.pl

    logdir=`sed -n '/\$logdir/s/^\$logdir\s*=\s*['"'"'"]\(.*\)['"'"'"].*/\1/p' /etc/fex/fex.ph|tail -n 1||true`
    if [ "$logdir" = "/var/log/fex" ];then
        for log in cleanup.log dop.log error.log fexsrv.log fop.log fup.log;do
            if [ -r /var/spool/fex/${log} ];then
                echo -n "Moving old log file ${log} to /var/log/fex"
                if [ ! -r /var/log/fex/${log} ];then
                    mv /var/spool/fex/${log} /var/log/fex/
                    chmod 0640 /var/log/fex/${log}
                    echo '.'
                elif [ ! -r /var/log/fex/${log}.1 ];then 
                    # we already have a new logfile in /var/log/fex
                    mv /var/spool/fex/${log} /var/log/fex/${log}.1
                    chmod 0640 /var/log/fex/${log}*
                    echo '.'
                else
                    echo ': failed!'
                    echo "New logdir already populated."
                    echo "Please move /var/spool/fex/${log} yourself if required."
                fi
            else
                # Create new logfile with correct permissions
                touch /var/log/fex/${log}
                chmod 0640 /var/log/fex/${log}
            fi 
        done
    elif [ -z "$logdir" -o "${logdir}" = '$spooldir' ];then
        echo 'Logdir still pointing to $spooldir. Please update to /var/log/fex'
        echo 'in order to take full advantage of logrotate settings.'
        echo 'Once you have updated your configfiles just run:'
        echo '           dpkg-reconfigure fex'
        echo 'To have the logfiles moved into their new location'
        else
        echo "Custom logdir configured. Not moving logfile to /var/log/fex."
    fi

    echo -n "Adding default spool keys dirs with secure permissions: "
    for dir in .dkeys .ukeys .akeys .skeys .gkeys .xkeys .locks;do
      mkdir -p "/var/spool/fex/$dir"
      chmod 0700 "/var/spool/fex/$dir"
    done
    echo "done."

    chown -R fex:fex /usr/share/fex/ /var/lib/fex/ /var/log/fex/ /var/spool/fex/
    chmod 0750 /usr/share/fex/ /var/lib/fex/ /var/log/fex/ /var/spool/fex/
    if [ -d /etc/xinetd.d ];then
        ucf --debconf-ok /usr/share/fex/templates/xinetd_fex /etc/xinetd.d/fex
        remainingsrv=`grep -r /usr/share/fex/bin/fexsrv /etc/xinetd.d|grep -v '^/etc/xinetd.d/fex:'|sed -e 's#^/etc/xinetd.d/\([^:]\+\):.*#\1#'|grep -v 'fex.*-*'||true`
        if [ ! -z "$remainingsrv" ];then
            echo "User-defined services in xinetd not updated: ${remainingsrv}. Please update yourself!"
        fi
        if [ -x /etc/init.d/xinetd ]; then
            if [ -x /usr/sbin/invoke-rc.d ]; then
                invoke-rc.d xinetd reload || true
            else
                /etc/init.d/xinetd reload || true
            fi
        fi
    elif [ -r /etc/inetd.conf ];then
        # We're running openbsd-inetd or something similar
        fexsrv=`egrep '\s/usr/share/fex/bin/fexsrv' /etc/inetd.conf 2>/dev/null||true`
        if [ -x /usr/sbin/update-inetd -a -z "$fexsrv" ];then
            # as --multi is ugly we'll only support v4 through inetd.conf
            # whoever wants IPv6 needs to go xinetd or hack his own version
            # i.e. replace tcp with tcp6
            update-inetd --add '8888\tstream\ttcp\tnowait\tfex:fex\t/usr/sbin/tcpd\t/usr/share/fex/bin/fexsrv'
        elif [ -z "$fexsrv" ];then
            echo 'Unable to automatically update inetd.conf'
            echo 'Please update yourself and restart inetd'
        fi
    fi
    echo 'Running fex_cleanup to verify config integrity ...'
    su -s /bin/bash -c /usr/share/fex/bin/fex_cleanup fex

    ;;

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

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

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



exit 0

# vi: set smartindent ts=4 sw=4 expandtab autoindent sts=4: