#! /bin/sh # postinst script for #PACKAGE# # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package # # quoting from the policy: # Any necessary prompting should almost always be confined to the # post-installation script, and should be protected with a conditional # so that unnecessary prompting doesn't happen if a package's # installation fails and the `postinst' is called with `abort-upgrade', # `abort-remove' or `abort-deconfigure'. #loading debconf module . /usr/share/debconf/confmodule #COMMON-FUNCTIONS# case "$1" in configure) CLAMAVMILTERCONF=/etc/clamav/clamav-milter.conf DEBROTATEFILE=/var/lib/clamav/clamav-milter.rotate.debconf CLAMAVROTATEFILE=/etc/logrotate.d/clamav-milter DEBCONFFILE=/var/lib/clamav/clamav-milter.conf db_get clamav-milter/debconf || true if [ "$RET" = "true" ]; then # Read the configuration file slurp_config "$CLAMAVMILTERCONF" db_get clamav-milter/MilterSocket || true MilterSocket="$RET" db_get clamav-milter/FixStaleSocket || true Fixstalesocket="$RET" db_get clamav-milter/MilterSocketGroup || true MilterSocketGroup="$RET" db_get clamav-milter/MilterSocketMode || true MilterSocketMode="$RET" db_get clamav-milter/User || true User="$RET" db_get clamav-milter/AddGroups || true Addgroups="$RET" db_get clamav-milter/ReadTimeout || true ReadTimeout="$RET" db_get clamav-milter/Foreground || true Foreground="$RET" db_get clamav-milter/Chroot || true Chroot="$RET" db_get clamav-milter/PidFile || true PidFile="$RET" db_get clamav-milter/TemporaryDirectory || true TemporaryDirectory="$RET" db_get clamav-milter/ClamdSocket || true ClamdSocket="$RET" db_get clamav-milter/LocalNet || true LocalNet="$RET" db_get clamav-milter/Whitelist || true Whitelist="$RET" db_get clamav-milter/OnInfected || true OnInfected="$RET" db_get clamav-milter/OnFail || true OnFail="$RET" db_get clamav-milter/RejectMsg || true RejectMsg="$RET" db_get clamav-milter/AddHeader || true AddHeader="$RET" db_get clamav-milter/LogFile || true LogFile="$RET" db_get clamav-milter/LogFileUnlock || true LogFileUnlock="$RET" db_get clamav-milter/LogFileMaxSize || true LogFileMaxSize="$RET" db_get clamav-milter/LogTime || true LogTime="$RET" db_get clamav-milter/LogSyslog || true LogSyslog="$RET" db_get clamav-milter/LogFacility || true LogFacility="$RET" db_get clamav-milter/LogVerbose || true LogVerbose="$RET" db_get clamav-milter/LogInfected || true LogInfected="$RET" db_get clamav-milter/LogClean || true LogClean="$RET" db_get clamav-milter/MaxFileSize || true maxfilesize="`echo $RET | sed -e s/M//g`" MaxFileSize="${maxfilesize}M" db_get clamav-milter/LogRotate || true LogRotate="$RET" db_get clamav-milter/SupportMultipleRecipients || true SupportMultipleRecipients="$RET" if [ -z "$LogFile" ] || [ "$LogFile" = 'none' ]; then LogSyslog=true fi if is_false $AddHeader; then AddHeader=no elif is_true $AddHeader; then AddHeader=Replace fi echo "#Automatically Generated by clamav-milter postinst" > $DEBCONFFILE echo "#To reconfigure clamav-milter run #dpkg-reconfigure clamav-milter" >> $DEBCONFFILE echo "#Please read /usr/share/doc/clamav-base/README.Debian.gz for details" >> $DEBCONFFILE [ -z "$MilterSocket" ] || [ "$MilterSocket" = 'true' ] && MilterSocket="/var/run/clamav/clamav-milter.ctl" [ -z "$User" ] && User=clamav [ -z "$OnClean" ] || [ "$OnClean" = 'true' ] && OnClean="Accept" [ -z "$MaxFileSize" ] && MaxFileSize="25M" cat >> $DEBCONFFILE << EOF MilterSocket $MilterSocket FixStaleSocket $Fixstalesocket User $User ReadTimeout $ReadTimeout Foreground $Foreground PidFile $PidFile ClamdSocket $ClamdSocket OnClean $OnClean OnInfected $OnInfected OnFail $OnFail AddHeader $AddHeader LogSyslog $LogSyslog LogFacility $LogFacility LogVerbose $LogVerbose LogInfected $LogInfected LogClean $LogClean LogRotate $LogRotate MaxFileSize $MaxFileSize SupportMultipleRecipients $SupportMultipleRecipients EOF if [ -n "$SkipAuthenticated" ]; then cat >> $DEBCONFFILE << EOF SkipAuthenticated $SkipAuthenticated EOF fi if [ -n "$Chroot" ]; then cat >> $DEBCONFFILE << EOF Chroot $Chroot EOF fi if [ -n "$LocalNet" ]; then cat >> $DEBCONFFILE << EOF LocalNet $LocalNet EOF fi if [ -n "$Whitelist" ]; then cat >> $DEBCONFFILE << EOF Whitelist $Whitelist EOF fi if [ -n "$RejectMsg" ]; then cat >> $DEBCONFFILE << EOF RejectMsg $RejectMsg EOF fi if [ -n "$TemporaryDirectory" ]; then cat >> $DEBCONFFILE << EOF TemporaryDirectory $TemporaryDirectory EOF else cat >> $DEBCONFFILE << EOF # TemporaryDirectory is not set to its default /tmp here to make overriding # the default with environment variables TMPDIR/TMP/TEMP possible EOF fi if [ -n "$LogFile" ] && [ "$LogFile" != 'none' ]; then echo "LogFile $LogFile" >> $DEBCONFFILE echo "LogTime $LogTime" >> $DEBCONFFILE echo "LogFileUnlock $LogFileUnlock" >> $DEBCONFFILE echo "LogFileMaxSize $LogFileMaxSize" >> $DEBCONFFILE fi [ -n "$MilterSocketGroup" ] && echo "MilterSocketGroup $MilterSocketGroup" >> $DEBCONFFILE [ -n "$MilterSocketMode" ] && echo "MilterSocketMode $MilterSocketMode" >> $DEBCONFFILE [ -n "$ReportHostname" ] && echo "ReportHostname $ReportHostname" >> $DEBCONFFILE [ -n "$VirusAction" ] && echo "VirusAction $VirusAction" >> $DEBCONFFILE [ -n "$AllowList" ] && echo "AllowList $AllowList" >> $DEBCONFFILE ucf_cleanup "$CLAMAVMILTERCONF" ucf_upgrade_check "$CLAMAVMILTERCONF" "$DEBCONFFILE" /var/lib/ucf/cache/:etc:clamav:clamav-milter.conf rm -f "$DEBCONFFILE" if [ -n "$AddGroups" ]; then for group in $AddGroups; do id "$User" | grep -q "$group" || adduser "$User" "$group" done fi else ucf_cleanup "$CLAMAVMILTERCONF" ucf -p "$CLAMAVMILTERCONF" fi if [ -f "$CLAMAVMILTERCONF" ] && [ ! -L "$CLAMAVMILTERCONF" ]; then chmod 644 $CLAMAVMILTERCONF || true chown root:root $CLAMAVMILTERCONF || true fi if [ -n "$LogFile" ] && [ "$LogFile" != 'none' ]; then if echo "$LogFile" | grep -q '^/dev/'; then make_logrotate=false else if [ "$LogRotate" = "true" ]; then make_logrotate=true else make_logrotate=false fi fi if [ "$make_logrotate" = 'true' ]; then echo "$LogFile {" > $DEBROTATEFILE echo " rotate 12" >> $DEBROTATEFILE echo " weekly" >> $DEBROTATEFILE echo " compress" >> $DEBROTATEFILE echo " delaycompress" >> $DEBROTATEFILE echo " create 640 $User adm" >> $DEBROTATEFILE echo " postrotate" >> $DEBROTATEFILE echo " invoke-rc.d clamav-milter restart > /dev/null || true" >> $DEBROTATEFILE echo " endscript" >> $DEBROTATEFILE echo " }" >> $DEBROTATEFILE touch "$LogFile" if [ -f "$LogFile" ] && [ ! -L "$LogFile" ]; then chown "$User":adm "$LogFile" chmod 0640 "$LogFile" fi ucf_cleanup "$CLAMAVROTATEFILE" ucf_upgrade_check "$CLAMAVROTATEFILE" "$DEBROTATEFILE" /var/lib/ucf/cache/:etc:logrotate.d:clamav-milter rm -f $DEBROTATEFILE else if [ -e "$CLAMAVROTATEFILE" ]; then echo "Disabling old logrotate script for clamav-milter" mv "$CLAMAVROTATEFILE" "$CLAMAVROTATEFILE".dpkg-old ucf -p "$CLAMAVROTATEFILE" fi fi else if [ -e "$CLAMAVROTATEFILE" ]; then echo "Disabling old logrotate script for clamav-milter" mv "$CLAMAVROTATEFILE" "$CLAMAVROTATEFILE".dpkg-old ucf -p "$CLAMAVROTATEFILE" fi fi db_stop || true ;; 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. #DEBHELPER# exit 0