===============================
Private WAN router space hooks
===============================

Private WAN router space hooks are run with the "start" argument after
a space is started and with the "stop" argument before the space is removed.

After a space hook has been added, you must restart the space from the
management server to execute the hook for the first time.

Unlike other hook types, the Private WAN router space hooks are only run on a
private WAN router. To configure the hooks, log into a private WAN router via
SSH and configure the hooks according to the following patterns.

Hook locations:

-  ``/etc/bonding/privatewan-router-space.d/all``: hooks to be run for all spaces
-  ``/etc/bonding/privatewan-router-space.d/<space key>``: hooks for individual spaces
-  ``/etc/bonding/privatewan-router-space.d/default``: hooks for spaces with no individual
   hook folder

An example space hook is available at
``/usr/share/doc/bonding/examples/privatewanrouter-space-hook``.

.. warning::
    If the space's key is updated in the management server, the hook directory for this space
    must be renamed to reflect the new key.

Environment variables
----------------------

Space hooks are run with the following environment variables:

-  SPACE_ID: the space ID
-  SPACE_KEY: the space key
-  SPACE_TABLE: the space routing table
-  NODE_ID: the ID of the private WAN router
