#!/bin/sh 

# This script is installed into /etc/NetworkManager/dispatcher.d
# on RHEL6 for starting/stopping of PowerIscsi.

export LC_ALL=C

if [ "$2" = "down" ]; then
   /sbin/ip route ls | grep -q ^default || {
       [ -f /var/lock/subsys/PowerIscsi ] && /etc/rc.d/init.d/PowerIscsi stop || :
   } && { :; }
fi

if [ "$2" = "up" ]; then
   /sbin/ip -o route show dev "$1" | grep -q '^default' && {
       /sbin/chkconfig PowerIscsi && /etc/rc.d/init.d/PowerIscsi start || :
   } || { :; }
fi

