File: wait4ifup

package info (click to toggle)
shorewall-core 4.6.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 372 kB
  • ctags: 22
  • sloc: sh: 607; perl: 126; makefile: 15
file content (60 lines) | stat: -rwxr-xr-x 1,578 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#
#     Shorewall interface helper utility - V4.2
#
#     (c) 2007,2014 - Tom Eastep (teastep@shorewall.net)
#
#	This file is installed in /usr/share/shorewall/wait4ifup
#
#	Shorewall documentation is available at http://www.shorewall.net
#
#       This program is part of Shorewall.
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by the
#       Free Software Foundation, either version 2 of the license or, at your
#       option, any later version.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#	GNU General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#	If an error occurs while starting or restarting the firewall, the
#	firewall is automatically stopped.
#
#	The firewall uses configuration files in /etc/shorewall/ - skeleton
#	files is included with the firewall.
#
#	wait4ifup <interface> [ <seconds to wait> ]
#

interface_is_up() {
    [ -n "$(/sbin/ip link list dev $1 2> /dev/null | /bin/grep -e '[<,]UP[,>]')" ]
}

case $# in
    1)
	timeout=60
	;;
    2)
	timeout=$2
	;;
    *)
	echo "usage: $(basename $0) <interface> [ <timeout> ]"
	exit 2
	;;
esac

while [ $timeout -gt 0 ]; do
    interface_is_up $1 && exit 0
    /bin/sleep 1
    timeout=$(( $timeout - 1 ))
done

exit 1