#!/bin/sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin

# in case of `dpkg -r' leaving conffile.
if ! [ -x /usr/sbin/tmpreaper ]; then
    exit 0
fi

# Remove `/tmp/...' files not accessed in 4 days, protecting the .ICE
# and .X files, but removing symlinks. Note that the sockets are safe
# even without the `--protect', unless `--all' is given, and the
# `.X*-lock' files would be safe also, as long as they have no write
# permissions, so this particular protect is mainly illustrative, and
# redundant.  For best results, don't try to get fancy with the
# moustache expansions.  KISS.  Always --test your protect patterns.
#
# For users of Japanese software: also protect .iroha (cannaserver) and 
# .ki2 (kinput2) lock files.

# ! Important !  Please read the manual regarding the --protect option.
#                The pattern *MUST* be surrounded by single quotes.

nice -n10 tmpreaper --symlinks 7d  \
  --protect '/tmp/.X*-{lock,unix,unix/*}' \
  --protect '/tmp/.ICE-{unix,unix/*}' \
  --protect '/tmp/.iroha_{unix,unix/*}' \
  --protect '/tmp/.ki2-{unix,unix/*}' \
    /tmp
