Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
hostapd init script fixes
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
nivw
Apprentice
Apprentice


Joined: 09 Nov 2005
Posts: 261

PostPosted: Sat May 07, 2011 2:17 pm    Post subject: hostapd init script fixes Reply with quote

here are my fixes to /etc/init.d/hostapd
Quote:
--- /etc/init.d/hostapd 2011-05-07 12:29:59.000000000 +0300
+++ /etc/init.d/hostapd.orig 2011-05-07 16:51:40.000000000 +0300
@@ -6,13 +6,12 @@
opts="start stop reload"

depend() {
-# local myneeds=
-# for iface in ${INTERFACES}; do
-# myneeds="${myneeds} net.${iface}"
-# done
-#
-# [ -n "${myneeds}" ] && need ${myneeds}
-# need net.br0
+ local myneeds=
+ for iface in ${INTERFACES}; do
+ myneeds="${myneeds} net.${iface}"
+ done
+
+ [ -n "${myneeds}" ] && need ${myneeds}
use logger
}

@@ -31,52 +30,21 @@
checkconfig || return 1

ebegin "Starting ${SVCNAME}"
- start-stop-daemon --start \
- --pidfile /var/run/${SVCNAME}.pid \
- --exec /usr/sbin/hostapd \
- -- -P /var/run/${SVCNAME}.pid -B ${OPTIONS} ${CONFIGS}
- # if used with brdiging option make sure that it is added to bridge
- #CONFIGS=/etc/hostapd/hostapd.conf
- local bridge_name=$(grep "^bridge=.*" "${CONFIGS}" 2>/dev/null | sed s/bridge=//)
- if [ -n "${bridge_name}" ] ; then
- local wireless_device=$(grep "^interface=.*" "${CONFIGS}" 2>/dev/null | sed s/interface=//)
- sleep 5
- #if wireless device is NOT already apart of the bridge,
- local device_in_bridge=$(ls -l /sys/class/*net*/${wireless_device}/brport/bridge 2>/dev/null |sed 's|.*/||')
- if [ -z "${device_in_bridge}" ] ; then
- ewarn "/sbin/brctl addif ${bridge_name} ${wireless_device}"
- /sbin/brctl addif ${bridge_name} ${wireless_device}
- fi
- fi
+ start-stop-daemon --start --exec /usr/sbin/hostapd \
+ -- -B ${OPTIONS} ${CONFIGS}
eend $?
}

stop() {
ebegin "Stopping ${SVCNAME}"
- local wireless_device=$(grep "^interface=.*" "${CONFIGS}" 2>/dev/null | sed s/^interface=//)
- local device_in_bridge=$(ls -l /sys/class/*net*/${wireless_device}/brport/bridge 2>/dev/null |sed 's|.*/||')
-
- if [ -n "${device_in_bridge}" ] ; then
- einfo "Removing ${device_in_bridge} from bridge"
- sleep 1
- ewarn "/sbin/brctl delif ${device_in_bridge} ${wireless_device}"
- /sbin/brctl delif ${device_in_bridge} ${wireless_device}
- fi
- if [ -f /var/run/${SVCNAME}.pid ] ; then
- #start-stop-daemon --stop --pidfile /var/run/${SVCNAME}.pid
- /bin/kill -9 `cat /var/run/${SVCNAME}.pid` 2> /dev/null
- rm /var/run/${SVCNAME}.pid
- else
- einfo ${SVCNAME}
- pgrep -f '/usr/sbin/hostapd' 2> /dev/null&&pkill -f '/usr/sbin/hostapd'
- fi
- eend 0
+ start-stop-daemon --stop --exec /usr/sbin/hostapd
+ eend $?
}

reload() {
checkconfig || return 1

ebegin "Reloading ${SVCNAME} configuration"
- kill -9 $(cat /var/run/${SVCNAME}.pid) > /dev/null 2>&1
+ kill -HUP $(pidof /usr/sbin/hostapd) > /dev/null 2>&1
eend $?
}


this address two issues:
1. in case the wireless network device is a part of a bridge , make sure it is added to that bridge
2. kill the hostapd binary, in any weird case.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum