summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Wunderlich2015-06-01 09:35:14 +0000
committerSimon Wunderlich2015-06-01 09:35:14 +0000
commitde8c0f19e072313b5d5adf5c00ddc9efaaa16bb6 (patch)
treeac28d745be1087ad2b34dd077efe9e0048851d72
parentef881054724b7336fc36c0d945d640b947984427 (diff)
parenta251e8fb2a89b1d893c2797a8d2571308d340740 (diff)
downloadrouting-de8c0f19e072313b5d5adf5c00ddc9efaaa16bb6.tar.gz
Merge pull request #102 from mwarning/master
alfred: do not handle 'none' as an existing interface
-rwxr-xr-xalfred/files/alfred.init49
1 files changed, 29 insertions, 20 deletions
diff --git a/alfred/files/alfred.init b/alfred/files/alfred.init
index b777b53..5ce06c0 100755
--- a/alfred/files/alfred.init
+++ b/alfred/files/alfred.init
@@ -16,10 +16,27 @@ pid_file_alfred="/var/run/alfred.pid"
pid_file_vis="/var/run/batadv-vis.pid"
enable=0
vis_enable=0
-batmanif=""
SERVICE_DAEMONIZE=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()
{
local args=""
@@ -41,14 +58,20 @@ alfred_start()
config_get batmanif "$section" 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"
enable=1
- config_get_bool start_vis "$section" start_vis 0
- if [ "$start_vis" = 1 ] && [ -x /usr/sbin/batadv-vis ]; then
- vis_enable=1
- append vis_args "-i $batmanif -s"
- fi
+ config_get_bool start_vis "$section" start_vis 0
+ if [ "$start_vis" = 1 ] && [ -x /usr/sbin/batadv-vis ]; then
+ vis_enable=1
+ append vis_args "-i $batmanif -s"
+ fi
config_get_bool run_facters "$section" run_facters 0
@@ -64,20 +87,6 @@ start()
exit 0
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"
SERVICE_PID_FILE="$pid_file_alfred"
service_start /usr/sbin/alfred ${alfred_args}