#!/bin/bash
# Example shaping hook.
# 
# Shaping hooks are run with the "start" argument when the tunnel is started,
# "stop" when the tunnel is stopped, and "update-rates" when the available
# sending rate changes. This occurs, for example, when a leg goes down and its
# bandwidth is no longer available to the bond. Hooks are called at most once
# every five seconds.
#
# Shaping hooks are only called if the bond's QoS profile setting is not blank.
# If a bond has an individual shaping hook folder (see below), the bond's
# selected QoS profile will not take effect unless the default QoS hook has
# been linked into the bond's individual hook folder. For example, to keep the
# behaviour of a bond's selected QoS profile while also using a shaping hook
# for the bond, run the following command on the bonder or aggregator:
# ln -s /etc/bonding/shaping.d/default/20_qos /etc/bonding/shaping.d/<bond ID>/20_qos
# 
# Environment variables:
#   ID: bond ID
#   INTERFACE: tunnel interface name (i.e. tun1)
#   SPEED: available sending speed in kilobits per second

start () {
    remove 2> /dev/null
    true
}
stop () {
    remove
}
remove () {
    true
}

# Avoid changing anything below here.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    *)
        echo "Usage: $0 {start|stop|update-rates}"
        exit 1
        ;;
esac
