tag:
priority: 381
type: txt
help: Virtual Tunnel interface
val_help: <vtiN>; Virtual Tunnel interface name
syntax:expression: pattern $VAR(@) "^vti[0-9]+$" \
		   ; "vti must be (vti0-vti999..)"

begin:
if [ "${COMMIT_ACTION}" == DELETE ]; then
      # check if there is still a reference
      `${vyatta_sbindir}/vyatta-vti-config.pl --checkref --intf=$VAR(@)`
      if [ $? -gt 0 ] ; then
            echo "Interface $VAR(@) is referenced in vpn configuration."
            exit -1
      fi
fi
if [ "${COMMIT_ACTION}" == SET ]; then
        `${vyatta_sbindir}/vyatta-vti-config.pl --checkref --intf=$VAR(@)`
        if [ $? -eq 0 ]; then
                echo "Warning: Interface $VAR(@) is not referenced in vpn configuration."
        fi
fi

delete: 
  if [ -d /sys/class/net/$VAR(@) ] ; then
      ip link set $VAR(@) down
      ip tunnel del $VAR(@) mode ipip
  fi

end: 
if [ "${COMMIT_ACTION}" == DELETE ]; then
  /opt/vyatta/sbin/vyatta-tunnel-cleanup $VAR(@)
fi

