#!/bin/sh -e

# source the debconf library
. /usr/share/debconf/confmodule

case "$1" in

  configure)
    if [ -d /etc/nut/ ] ; then
    	chown root:nut /etc/nut/
    fi
    for file in ups.conf upsd.conf upsmon.conf upsd.users upssched.conf ; do
        if [ -f /etc/nut/$file ] ; then
            chown root:nut /etc/nut/$file
            chmod 640 /etc/nut/$file
        fi
    done
    chown root:nut /var/run/nut /var/lib/nut
    chmod 770 /var/run/nut /var/lib/nut

    # restart udev to apply the USB rules to the already plugged devices
    [ -x /etc/init.d/udev ] && /etc/init.d/udev restart
    ;;

  abort-upgrade)
    # do nothing
    ;;

  abort-remove)
    # do nothing
    ;;

  abort-deconfigure)
    # do nothing
    ;;

  *)
    echo "$0: incorrect arguments: $*" >&2
    exit 1
    ;;

esac

/etc/init.d/nut stop
#DEBHELPER#

# handle upsmon failing to close
# all inherited file descriptors
db_stop


syntax highlighted by Code2HTML, v. 0.9.1