File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
set -e
7
7
8
+ LOG_FILE=" /var/log/hhnet.log"
9
+ sudo touch " $LOG_FILE "
10
+ sudo chmod 666 " $LOG_FILE "
11
+ exec >> " $LOG_FILE " 2>&1
12
+
8
13
function cleanup() {
9
14
for i in {0..3}; do
10
15
sudo ip l d " bond$i " 2> /dev/null || true
@@ -22,6 +27,7 @@ function cleanup() {
22
27
23
28
function setup_bond() {
24
29
local bond_name=$1
30
+ local start_time=$( date +%s)
25
31
26
32
sudo ip l a " $bond_name " type bond miimon 100 mode 802.3ad
27
33
@@ -32,15 +38,21 @@ function setup_bond() {
32
38
done
33
39
34
40
sudo ip l s " $bond_name " up
41
+ local end_time=$( date +%s)
42
+ echo " setup_bond completed in $(( end_time - start_time)) seconds" >> " $LOG_FILE "
35
43
}
36
44
37
45
function setup_vlan() {
38
46
local iface_name=$1
39
47
local vlan_id=$2
48
+ local start_time=$( date +%s)
40
49
41
50
sudo ip l s " $iface_name " up
42
51
sudo ip l a link " $iface_name " name " $iface_name .$vlan_id " type vlan id " $vlan_id "
43
52
sudo ip l s " $iface_name .$vlan_id " up
53
+
54
+ local end_time=$( date +%s)
55
+ echo " setup_vlan completed in $(( end_time - start_time)) seconds" >> " $LOG_FILE "
44
56
}
45
57
46
58
function get_ip() {
@@ -55,10 +67,18 @@ function get_ip() {
55
67
[ " $attempt " -ge " $max_attempts " ] && break
56
68
sleep 1
57
69
done
70
+
71
+ if [ -z " $ip " ]; then
72
+ sudo dhclient " $iface_name " || true
73
+ sleep 3
74
+ ip=$( ip a s " $iface_name " | awk ' /inet / {print $2}' )
75
+ fi
76
+
58
77
if [ -z " $ip " ]; then
59
78
echo " Failed to get IP address for $iface_name " >&2
60
79
exit 1
61
80
fi
81
+
62
82
echo " $ip "
63
83
}
64
84
Original file line number Diff line number Diff line change @@ -107,6 +107,9 @@ OUTPUT_FILE="/tmp/show-tech.log"
107
107
# Logs & Kernel Information
108
108
# ---------------------------
109
109
{
110
+ echo -e " \n=== hhnet logs ==="
111
+ cat /var/log/hhnet.log
112
+
110
113
echo -e " \n=== systemd-networkd logs ==="
111
114
journalctl -u systemd-networkd 2> /dev/null
112
115
You can’t perform that action at this time.
0 commit comments