.. -*- coding: utf-8; indent-tabs-mode: nil; -*-


local-bsdtools-periodic
=======================

Synopsis
--------

**daily/720.local-triggered-action**

**daily/750.local-trim-zfs**

**daily/800.local-ipv6-refresh**


Description
-----------

The package contains a set of periodic scripts.

All scripts are disabled by default.

As all :manpage:`periodic(8)` scripts given scripts can be configured
in :manpage:`periodic.conf(5)`.


Daily Scripts
~~~~~~~~~~~~~

**720.local-triggered-action**

  Take actions triggered by the existence of given files.

  **daily_local_triggered_action_enable** (bool)
     Set it to ``YES`` to enable this script.

  **daily_local_triggered_action_files** (str)
     The readability of any of the given files triggers the action.

  **daily_local_triggered_action_condition** (str)
     A condition to check before executing the action.

     May be a Shell expression.

     The list of existing trigger files -- which is a subset of
     `daily_local_triggered_action_files` -- is available in the Shell
     variable `TRIGGER_FILES`.

  **daily_local_triggered_action_action** (str)
     The action to execute to.

     May be a Shell expression.

     The list of existing trigger files -- which is a subset of
     `daily_local_triggered_action_files` -- is available in the Shell
     variable `TRIGGER_FILES`.

  **daily_local_triggered_action_files_remove** (bool)
     By default all existing trigger files given in
     `daily_local_triggered_action_files` are deleted when the action
     has been executed successfully.

     Set to ``NO`` to disable this behaviour.

  **daily_local_triggered_action_profiles** (str)
     If a non-empty value is given the script executes in profile-mode.

     If profiles are defined this script is re-executed once for for
     every profile with the profile as parameter.

     No other global option as `daily_local_triggered_action_enable`
     is used.

     Instead profile level configurations which are named after the
     profile are used. The configuration variables have the form
     `daily_local_triggered_action_${profile}_{files,condition,action,files_remove}`.

     For the sake of variable evaluation some special characters in a given
     profile are mapped to the underscore ``_``.

**750.local-trim-zfs**

  If enabled it automatically trims ZFS pools at regular invervals by
  calling :command:`zpool trim`.

  **daily_local_trim_zfs_enable** (bool)
     Set to ``YES`` to enable this script.

  **daily_local_trim_zfs_pool** (str)
     The list of ZFS pool to trim to.

     If empty then all known pool are trimmed.

  **daliy_local_trim_zfs_default_threshold** (int)
     The number of days between trims.

     Default: 35

**800.local-ipv6-refresh**

  On some networks there are issuses of loosing IPv6 connectivity
  after some uptime with BSD kernels.

  This scripts helps to keep connectivity. It updates the IPv6
  neighbour cache to ensure proper IPv6 connectivity by calling
  :command:`traceroute6` at regular intervals.

  **daily_local_ipv6_refresh_enable** (bool)
     Set to `YES` to enable this script.

  **daily_local_ipv6_refresh_flags** (str)
     A list of flags given to :manpage:`traceroute(8)`.

     Default: -n -w2 -q2 -m1 -I

  **daily_local_ipv6_refresh_target** (str)
     The target of :manpage:`traceroute6(8)`.

     If empty then `ipv6_defaultrouter` as given by :manpage:`sysrc(8)`
     is used -- if available.


Examples
--------

Conditions and actions can be complex Shell expressions. They are evauluated
with `eval` in the Shell::

    daily_local_triggered_action_condition="service nginx onestatus || service apache2 onestatus"

    daily_local_triggered_action_action="{ service nginx onereload && service apache2 onereload ; } || true"

Profiles::

    daily_local_triggered_action_enable=YES

    daily_local_triggered_action_profiles="p1 p2-1"

    # If the file exists this is executed daily because it is not removed
    daily_local_triggered_action_p1_files="trigger-for-p1.txt"
    daily_local_triggered_action_p1_condition="true"
    daily_local_triggered_action_p1_action="cat \${TRIGGER_FILES} | mail -s ALERT root"
    daily_local_triggered_action_p1_remove_files="NO"

    daily_local_triggered_action_p2_1_files="trigger-for-p2.txt"
    daily_local_triggered_action_p2_1_condition="true"
    daily_local_triggered_action_p2_1_action="echo 'something happened' | mail -s ALERT root"

Note that the use of `TRIGGER_FILES` must be quoted in condition and
action definitions because they are executed indirectly in the context
of the Shell's `eval`.


See Also
--------

:manpage:`local-bsdtools(8)`, :manpage:`periodic(8)`,
:manpage:`periodic.conf(5)`, :manpage:`rc.conf(5)`, :manpage:`sysrc(8)`,
:manpage:`zpool-trim(8)`, :manpage:`traceroute(8)`


Bugs
----

For a given profile "p1" there is no evaluation of something like
"daily_local_triggered_action_p1_enable".
