#!/bin/sh

set -eu

if [ "$(puavo-conf puavo.hosttype)" != 'bootserver' ]; then
  rm -f /etc/incron.d/handle_cups_printers_changes \
        /etc/incron.d/handle_images_changes
  exit 0
fi

cat <<'EOF' > /etc/incron.d/handle_cups_changes.tmp
/etc/cups IN_ATTRIB,IN_CLOSE_WRITE,IN_CREATE,IN_DELETE,IN_DELETE_SELF,IN_MODIFY,IN_MOVE_SELF,IN_MOVE,recursive=false /usr/local/lib/puavo-handle-cups-changes $#
EOF
mv /etc/incron.d/handle_cups_changes.tmp \
   /etc/incron.d/handle_cups_changes

cat <<'EOF' > /etc/incron.d/handle_images_changes.tmp
/images IN_ATTRIB,IN_CLOSE_WRITE,IN_CREATE,IN_DELETE,IN_DELETE_SELF,IN_MOVE_SELF,IN_MOVE,recursive=false /usr/local/lib/puavo-handle-image-changes $#
EOF
mv /etc/incron.d/handle_images_changes.tmp \
   /etc/incron.d/handle_images_changes
