summaryrefslogtreecommitdiff
path: root/multitech/recipes/ocg-scripts/ocg-scripts-1.0
diff options
context:
space:
mode:
authorJesse Gilles <jgilles@multitech.com>2013-12-19 17:01:20 -0600
committerJesse Gilles <jgilles@multitech.com>2013-12-19 17:01:20 -0600
commitd1d558fe1b6da8eee511c90a05c022edc90e5e1d (patch)
treeea68ef8779b0c0165d4af72b9bfff06afb25e614 /multitech/recipes/ocg-scripts/ocg-scripts-1.0
parentac8e3fe96e5c449bc53000fe94b7e9155941188c (diff)
ocg-scripts: add bridge support to ocg-wifi-ap
Diffstat (limited to 'multitech/recipes/ocg-scripts/ocg-scripts-1.0')
-rwxr-xr-xmultitech/recipes/ocg-scripts/ocg-scripts-1.0/ocg-wifi-ap49
1 files changed, 32 insertions, 17 deletions
diff --git a/multitech/recipes/ocg-scripts/ocg-scripts-1.0/ocg-wifi-ap b/multitech/recipes/ocg-scripts/ocg-scripts-1.0/ocg-wifi-ap
index 19f6cc1..d96d597 100755
--- a/multitech/recipes/ocg-scripts/ocg-scripts-1.0/ocg-wifi-ap
+++ b/multitech/recipes/ocg-scripts/ocg-scripts-1.0/ocg-wifi-ap
@@ -1,13 +1,26 @@
#!/bin/bash
dhcpd_file=/etc/udhcpd.conf
+hostapd_file=/etc/hostapd.conf
interface=wlan0
do_start() {
+ if [ "$1" = "bridge" ]; then
+ interface=br0
+ if ! grep -E -q "^bridge=$interface\s*$" $hostapd_file; then
+ echo "Enabling bridge=br0 in $hostapd_file"
+ sed -r -i "s/^#?bridge=.*$/bridge=$interface/" $hostapd_file
+ fi
+ fi
+
echo "starting hostap daemon"
/etc/init.d/hostapd start
- echo "setting IP address of access point"
- ifconfig $interface $1
+
+ if [ "$1" != "bridge" ]; then
+ echo "setting IP address of access point"
+ ifconfig $interface $1
+ fi
+
if ! grep -E -q "^interface\s+$interface" $dhcpd_file; then
echo "Changing dhcpd interface to $interface"
sed -r -i "s/^interface\s+.*$/interface $interface/" $dhcpd_file
@@ -24,24 +37,26 @@ do_stop() {
# main
if [[ $# -lt 1 ]]
then
- echo "usage: $0 start|stop|restart [access point IP address]"
+ echo "usage: $0 start|stop|restart [access point IP address|\"bridge\"]"
exit 1
elif [[ $# -eq 2 ]]
then
- ret=1
- if [[ $2 =~ ^([0-9]{1,3}\.){3,3}[0-9]{1,3}$ ]]
- then
- OIFS=$IFS
- IFS='.'
- ip=($2)
- IFS=$OFIS
- [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
- ret=$?
- fi
- if [[ ret -ne 0 ]]
- then
- echo "invalid IP address"
- exit 1
+ if [ "$2" != "bridge" ]; then
+ ret=1
+ if [[ $2 =~ ^([0-9]{1,3}\.){3,3}[0-9]{1,3}$ ]]
+ then
+ OIFS=$IFS
+ IFS='.'
+ ip=($2)
+ IFS=$OFIS
+ [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
+ ret=$?
+ fi
+ if [[ ret -ne 0 ]]
+ then
+ echo "invalid IP address"
+ exit 1
+ fi
fi
ip=$2
else