File: utils

package info (click to toggle)
frr 10.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 77,024 kB
  • sloc: ansic: 687,126; python: 226,152; perl: 6,379; sh: 2,685; cpp: 1,883; makefile: 670; yacc: 397; lex: 363; lisp: 66; xml: 35; javascript: 8
file content (61 lines) | stat: -rw-r--r-- 867 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
61
#!/bin/sh

Wait_for_service ()
{
	LOOP="0"
	LIMIT="10"

	echo -n "Waiting for service to be up and running "

	while ! vtysh -c "show version" 2>/dev/null | grep -Eq "^FRRouting"
	do
		echo -n "."

		LOOP="$((${LOOP} + 1))"

		if [ "${LOOP}" -ge "${LIMIT}" ]
		then
			echo "Failed to start service after ${LIMIT}s, giving up."
			return 1
		fi

		sleep 1s
	done

	echo " done."
}

cleanup ()
{
	result=$?

	set +e

	if [ "$result" -ne 0 ]
	then
		echo "### Something failed, showing logs"
		echo
		echo "### Last 100 lines of syslog:"
		tail -n 100 /var/log/syslog
		echo

		for f in /var/log/frr/*.log
		do
			if [ -f "$f" ]
			then
				echo "### Last 100 lines of $f:"
				tail -n 100 "$f"
				echo
			fi
		done

		echo "### ps output:"
		ps fauxwZ
		echo

		echo "### Last 100 dmesg lines:"
		dmesg -T | tail -n 100 || :
	else
		echo "### ALL TESTS PASSED"
	fi
}