vpn-select: Fix case of missing .pid file

Bug: If /tmp/run/fastd.${project}.pid is missing, the directory
/proc/ is checked instead of /proc/{something}.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Reviewed-by: Tim Niemeyer <tim@tn-x.org>
This commit is contained in:
Adrian Schmutzler 2017-08-31 20:46:05 +02:00 committed by Tim Niemeyer
parent 4dbf136a31
commit 2567b53334
1 changed files with 3 additions and 2 deletions

View File

@ -79,10 +79,11 @@ if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
/etc/init.d/fastd reload
# fastd start/stop for various situations
pidfile="/tmp/run/fastd.${project}.pid"
if [ "$(ls /etc/fastd/${project}/peers/* 2>/dev/null)" ]; then
[ -d /proc/$(cat /tmp/run/fastd.${project}.pid) ] || /etc/init.d/fastd start
([ -s "$pidfile" ] && [ -d "/proc/$(cat "$pidfile")" ]) || /etc/init.d/fastd start
else
[ -d /proc/$(cat /tmp/run/fastd.${project}.pid) ] && /etc/init.d/fastd stop
([ -s "$pidfile" ] && [ -d "/proc/$(cat "$pidfile")" ]) && /etc/init.d/fastd stop
fi
fi