#!/bin/sh

# This script should be used with pm-utils, to enjoy your bridge just copy this
# as /etc/pm/sleep.d/bridge

BridgeSuspend() {
    for i in `/sbin/brctl show|sed -n "s/^[^ ]*\t\([^\t]*\)/\1/p"`
    do
      ip link set dev $i down
    done
    return 0
}

BridgeResume() {
    for i in `/sbin/brctl show|sed -n "s/^[^ ]*\t\([^\t]*\)/\1/p"`
    do
      ip link set dev $i up
    done
    return 0
}

case "$1" in
	hibernate|suspend)
		BridgeSuspend
		;;
	thaw|resume)
		BridgeResume
		;;
	*) exit 1
		;;
esac
