Merge pull request #102 from mwarning/master

alfred: do not handle 'none' as an existing interface
This commit is contained in:
Simon Wunderlich 2015-06-01 11:35:14 +02:00
commit de8c0f19e0

View file

@ -16,10 +16,27 @@ pid_file_alfred="/var/run/alfred.pid"
pid_file_vis="/var/run/batadv-vis.pid" pid_file_vis="/var/run/batadv-vis.pid"
enable=0 enable=0
vis_enable=0 vis_enable=0
batmanif=""
SERVICE_DAEMONIZE=1 SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1 SERVICE_WRITE_PID=1
wait_for_dir()
{
local ifce="$1" dir="$2"
if ! [ -d "$dir" ] ; then
timeout=30
echo "${initscript}: waiting $timeout secs for $ifce interface..."
for i in $(seq $timeout); do
sleep 1
[ -d "$dir" ] && break
if [ $i == $timeout ] ; then
echo "${initscript}: $ifce not detected, alfred not starting."
exit 1
fi
done
fi
}
alfred_start() alfred_start()
{ {
local args="" local args=""
@ -41,6 +58,12 @@ alfred_start()
config_get batmanif "$section" batmanif config_get batmanif "$section" batmanif
append args "-b $batmanif" append args "-b $batmanif"
if [ "$batmanif" != "none" ]; then
wait_for_dir "$batmanif" "/sys/class/net/$batmanif/mesh"
fi
wait_for_dir "$interface" "/sys/class/net/$interface/"
append alfred_args "$args" append alfred_args "$args"
enable=1 enable=1
@ -64,20 +87,6 @@ start()
exit 0 exit 0
fi fi
mesh_dir="/sys/class/net/$batmanif/mesh/"
if ! [ -d "$mesh_dir" ] ; then
timeout=30
echo "${initscript}: waiting $timeout secs for $batmanif interface..."
for i in $(seq $timeout); do
sleep 1
[ -d "$mesh_dir" ] && break
if [ $i == $timeout ] ; then
echo "${initscript}: $batmanif not detected, alfred not starting."
exit 1
fi
done
fi
echo "${initscript}: starting alfred" echo "${initscript}: starting alfred"
SERVICE_PID_FILE="$pid_file_alfred" SERVICE_PID_FILE="$pid_file_alfred"
service_start /usr/sbin/alfred ${alfred_args} service_start /usr/sbin/alfred ${alfred_args}