+#!/bin/bash
+#
+# $Id$
+# Script to set the mode for MADWIFI. Should be called by ifup.
+# Copyright (C) 2007 The Trustees of Princeton University
+
+. /etc/sysconfig/network-scripts/network-functions
+CONFIG="$1"
+source_config
+
+WLANDEV=$(basename $(readlink -e /sys/class/net/$DEVICE/device/net:wifi* 2>/dev/null) 2>/dev/null)
+if [ -n "$MODE$WLANDEV" ]; then
+ wlanconfig "$DEVICE" destroy &> /dev/null
+ m=$( echo "$MODE" | tr '[A-Z]' '[a-z]' | tr -d - )
+ case "$m" in
+ managed)
+ m=sta
+ ;;
+ master)
+ m=ap
+ ;;
+ repeater)
+ m=wds
+ ;;
+ esac
+ wlanconfig "$DEVICE" create wlandev $WLANDEV wlanmode "$m"
+fi