-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver-pkgctl-r8152-restart-reload.sh
526 lines (456 loc) · 25 KB
/
driver-pkgctl-r8152-restart-reload.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
#!/bin/bash
# Sources of ideas I used :
# - https://stackoverflow.com/a/932187/17694638
# - https://stackoverflow.com/a/48229061/17694638
# ╔════════════════════════════════════════════════════════════════════════════════════════╗
# ║ ║
# ║ Script for reload or restart the pkgctl-r8152 driver for USB-ETH 2,5 GBps adaptator ║
# ║ for Synology NAS ║
# ║ ---------------- ║
# ╚════════════════════════════════════════════════════════════════════════════════════════╝
#
# Version 1.5
#
# /!\ Need to be launched in root mode in SSH CLI, or in the task planner in DSM
#
# chmod 760 ./driver-pkgctl-r8152-restart-reload.sh
#
# In order to use the script, I suggest to create 2 tasks in DSM tasks manager :
# 1. One launched at every boot/reboot of the NAS
# 2. Another launched every 5 or 10 minutes, in order to ensure the driver is working fine
# ~~~~~ Arguments passed to the script ~~~~ #
nb_param=$#
arg1=$1
arg2=$2
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# ====================================================================================== #
# ============================= Variables needed to be set ============================= #
# ====================================================================================== #
# Set to no for no ipv6, or yes to let ipv6 activated (global parameter: it's for all interfaces)
ipv6="no"
# Set to the interface in 2,5G/5G you want to check : eth0 or eth1, or eth2 ...
# In Synology NAS, the physical interfaces are :
# - eth0 = LAN1
# - eth1 = LAN2
# - eth2 = LAN3
# - eth3 = LAN4
# Be aware that is it to be the physical interface without ovs (Open vSwitch) installed, not the ovs_ one. The ovs is to be dealt after.
interface="eth2"
# Add embedded physical interfaces you want to disable when $interface is up and running correctly
# and enable when $interface isn't working correctly.
# Choose wisely!
# And do not set ovs_ethX, it will be handled differently.
embedded_interface_to_deactivate=("eth0" "eth1")
# Set the gateway to test (could be whatever IP address you want to ping)
# or let the script determine the default gateway set by setting the value to "".
gateway=""
# gateway="192.168.2.203"
## Variables Gotify
# Set gotify_notif to false to disable gotify notification
# true to enable gotify notification
gotify_notif=true
gotify_url=https://gotify.ndd.tld
gotify_token=xxxx-token-xxx
# ====================================================================================== #
# ~~~~~~~~~~ Check if root access ~~~~~~~~~ #
if [[ "$EUID" = 0 ]]; then
echo "(1) already root"
else
echo "You're not root... sudoing now..."
sudo -k # make sure to ask for password on next sudo
if sudo true; then
echo "(2) correct password"
else
echo "(3) wrong password"
exit 1
fi
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# Check if OVS is activated :
if [[ -n "$(ifconfig | grep "ovs_")" ]]; then
echo "Open vSwitch est activé !"
ovs="true"
else
echo "Open vSwitch n'est pas activé !"
ovs="false"
fi
# Set this to true of Open vSwitch is activated, or false if not. This will be used to manage the ovs_ethX in the script.
# ovs="false"
# ====================================================================================== #
# ====================== Some variables needed, but not to touch ! ===================== #
# ====================================================================================== #
driver_ok_ko=""
iteration_status=0
iteration_ping=0
## Variables Gotify
gotify_priority_success=2
gotify_priority_error=4
gotify_priority_fail=8
#Default values
gotify_priority=${gotify_priority_error}
message=""
title="Script : $(basename "$0")"
mode=""
gotify_always=""
# ====================================================================================== #
# ====================================================================================== #
# ======================= Check parameters and command line help ======================= #
# ====================================================================================== #
display_help() {
echo "Usage: $(basename "$0") {boot|task|manual} [--notify]" >&2
echo
echo " {boot|task|manual} : Launch mode, mandatory"
echo " boot set script to a launch after boot"
echo " task set script to a task manager schedule launch"
echo " manual set script to a manual launch (from CLI)"
echo
echo " -n, --notify [Optionnal, always send gotify notification]"
echo " -r, --reactivate_all_down_ethX [Optional, and do only reactivation of all ethX interfaces it find with ip link"]
echo
# echo some stuff here for the -a or --add-options
exit 1
}
if [[ nb_param -gt 2 || nb_param -eq 0 ]]; then
display_help
else
case $arg1 in
-h | --help)
display_help
;;
boot)
mode="boot"
;;
task)
mode="task"
;;
manual)
mode="manual"
;;
# ... (same format for other required arguments)
*)
echo "Unknown 1st parameter passed: $1"
display_help
;;
esac
fi
if [[ -z "${arg2}" ]]; then
gotify_always="non"
elif [[ "${arg2}" == "--notify" ]] || [[ "${arg2}" == "-n" ]]; then
gotify_always="oui"
elif [[ "${arg2}" == "--reactivate_all_down_ethX" ]] || [[ "${arg2}" == "-r" ]]; then
# This will exit after this function (exit is inside the function).
reactivation_all="true"
else
printf "Unknown 2nd parameter passed: %s" "$1"
display_help
fi
if [[ "${mode}" == "boot" ]] || [[ "${mode}" == "manual" ]]; then
gotify_always="oui"
elif [[ "${mode}" == "task" ]]; then
gotify_always="non"
fi
# DEBUG
# echo "Parameter n°1 = $arg1"
# echo "Parameter n°2 = $arg2"
# echo "mode = $mode"
# echo "gotify_always = $gotify_always"
# ====================================================================================== #
# ====================================================================================== #
# ========================= Functions needed by the main script ======================== #
# ====================================================================================== #
function send_gotify_notification() {
# On va envoyer une notification toutes les 2 heures si tout va bien pour le pilote
# Sinon la notification partira quoiqu'il arrive.
# Vérification de l'heure : heure paire notification, heure impaire pas de notification
#
if [ "$gotify_notif" = true ]; then
heure=10#$(date +"%H")
minutes=10#$(date +"%M")
heure_paire=""
minutes_zero=""
((heure % 2 == 0)) && heure_paire="oui" || heure_paire="non"
((minutes == 0)) && minutes_zero="oui" || minutes_zero="non"
# Si heure paire et gotify_priority_success, ou bien si gotify_priority_error ou gotify_priority_fail, on envoi une notification
if [[ "${gotify_always}" == "oui" ]] || [ ${gotify_priority} -eq ${gotify_priority_error} ] || [ ${gotify_priority} -eq ${gotify_priority_fail} ] || { [ ${gotify_priority} -eq ${gotify_priority_success} ] && ((heure % 2 == 0 && minutes == 0)); }; then
# if [[ "${gotify_always}" == "oui" ]] || [ ${gotify_priority} -eq ${gotify_priority_error} ] || [ ${gotify_priority} -eq ${gotify_priority_fail} ] || { [ ${gotify_priority} -eq ${gotify_priority_success} ] && [[ "${heure_paire}" == "oui" ]] && [[ "${minutes_zero}" == "oui" ]]; }; then
URL="${gotify_url}/message?token=${gotify_token}"
printf "\n\tSending Gotify Notification...\n"
# /usr/bin/curl -s -S --data '{"message": "'"${message}"'", "title": "'"${title}"'", "priority":'"${gotify_priority}"', "extras": {"client::display": {"contentType": "text/markdown"}}}' -X POST -H Content-Type:application/json "${URL}" &>/dev/null
# In order to accept the escape characters, the post command must be in text/plain
/usr/bin/curl -s -S -X POST "${URL}" -H "accept: application/json" -H "Content-Type: application/json" --data "{ \"message\": \"${message}\", \"title\": \"${title}\", \"priority\": ${gotify_priority}, \"extras\": {\"client::display\": {\"contentType\": \"text/plain\"}}}" &>/dev/null
# /usr/bin/curl -s -S -X POST "${URL}" -H "accept: application/json" -H "Content-Type: application/json" --data "{ \"message\": \"${message}\", \"title\": \"${title}\", \"priority\": ${gotify_priority}, \"extras\": {\"client::display\": {\"contentType\": \"text/markdown\"}}}" &>/dev/null
printf "\n"
fi
fi
}
function driver_restart_reload() {
# Restart or reload the driver
sudo synosystemctl reload-or-restart pkgctl-r8152
# In some case, the interface works fine, but the driver reports 'disabled' with 'synosystemctl get-enable-status pkgctl-r8152' command...
# Let's try to enable it again
if [[ "$(sudo synosystemctl get-enable-status pkgctl-r8152)" != "enabled" ]]; then
sudo synosystemctl enable pkgctl-r8152
fi
echo ""
# For the record, here some synosystemctl commands:
# start [--no-block] NAME... Start (activate) one or more units
# stop [--no-block] NAME... Stop (deactivate) one or more units
# restart [--no-block] NAME... Start or restart one or more units
# try-restart [--no-block] NAME... Restart one or more units if active
# reload [--no-block] NAME... Reload one or more units
# reload-or-restart [--no-block] NAME... Reload or restart one or more units
# get-enable-status NAME Get the enable status of given unit
# get-active-status NAME Get the active status of given unit
# get-load-status NAME Get the load status of given unit
}
function disable_ipv6() {
# Disable ipv6
_interface="$1"
if [[ "${ovs}" == "true" ]]; then
# VMM and Open vSwitch are installed
# So the physical ethX haven't any IP adresses, they're on the ovs_ethX !
_interface="ovs_${_interface}"
fi
if [[ "${ipv6}" == "no" ]]; then
if [[ $(cat /proc/net/if_inet6 | grep "${_interface}") != "" ]]; then
printf "\tDeactivation of ipv6 on interface %s in 5s...\n" "${_interface}"
message="${message}\tDeactivation of ipv6 on interface ${_interface} in 5s...\n"
sleep 5s
sudo ip -6 addr flush "${_interface}"
else
printf "\tIpv6 on interface %s is already deactivated.\n" "${_interface}"
message="${message}\tIpv6 on interface ${_interface} is already deactivated.\n"
fi
fi
}
function get_status() { # Get status from the pkgctl-r8152 driver
iteration_status=$((iteration_status + 1))
active_status=$(sudo synosystemctl get-active-status pkgctl-r8152)
load_status=$(sudo synosystemctl get-load-status pkgctl-r8152)
enable_status=$(sudo synosystemctl get-enable-status pkgctl-r8152)
package_version=$(sudo synopkg version r8152)
package_onoff=$(sudo synopkg is_onoff r8152)
# Test if the status above are normal :
# - active_status must be "active"
# - load_status must be "loaded"
# - enable_status must be "enabled"
printf "\t"
printf %s "$package_onoff"
printf " , version is %s\n" "$package_version"
printf "\n\tpkgctl-r8152 active_status = %s\n" "$active_status"
printf "\tpkgctl-r8152 load_status = %s\n" "$load_status"
printf "\tpkgctl-r8152 enable_status = %s\n\n" "$enable_status"
message="${message}\t\n\tpkgctl-r8152 active_status = $active_status\n"
message="${message}\tpkgctl-r8152 load_status = $load_status\n"
message="${message}\tpkgctl-r8152 enable_status = $enable_status\n\n"
if [[ "${active_status}" != "active" ]] || [[ "${load_status}" != "loaded" ]] || [[ "${enable_status}" != "enabled" ]]; then
# The driver need to be restarted or reloaded
printf "\tThe driver status AREN'T OK !\n\tThe driver need to be restarted or reloaded !\n"
message="${message}\tThe driver status AREN'T OK !\n\tThe driver need to be restarted or reloaded !\n"
driver_ok_ko="KO"
elif [[ "${active_status}" = "active" ]] && [[ "${load_status}" = "loaded" ]] && [[ "${enable_status}" = "enabled" ]]; then
# The driver is well started and loaded
printf "\tThe driver status is OK ! No need to do something more.\n"
message="${message}\tThe driver status is OK ! No need to do something more.\n"
# No need to do something more here
else
printf "\tUnknown error with get_status() ! code = %d\n" "$RESULT"
message="${message}\tUnknown error with get_status() ! code = $RESULT\n"
send_gotify_notification
exit 1
fi
}
function ping_gateway() { # Check gateway availability to ping
_interface="$1"
if [[ "${ovs}" == "true" ]]; then
# VMM and Open vSwitch are installed
# So the physical ethX haven't any IP adresses, they're on the ovs_ethX !
_interface="ovs_${_interface}"
fi
iteration_ping=$((iteration_ping + 1))
# Checking if the gateway is set to a value or not.
# If not, this will determine the default gateway
if [[ -z "${gateway}" ]]; then
gateway=$(sudo ip r | grep default | cut -d ' ' -f 3)
fi
if [ -z "$gateway" ]; then
printf "\n\tError ! No gateway found with the 'ip r' command...\n"
message="${message}\n\tError ! No gateway found with the 'ip r' command...\n"
send_gotify_notification
exit 99
else
printf "\tgateway is = %s\n" $gateway
message="${message}\tgateway is = $gateway\n"
sudo ping -I $_interface -q -t 2 -c 1 $gateway >/dev/null && PING="OK" || PING="not-OK"
fi
}
function reactivate_all_down_ethX() {
printf "Reactivation of all Ethernet interfaces."
all_eth_interfaces=$(ip link | grep " eth" | awk -F ": " '{print $2}')
for all_eth_interfaces_i in ${all_eth_interfaces[*]}; do
printf "\nInterface being processed : %s" "${all_eth_interfaces_i}"
printf "\n\tReactivation of %s." "${all_eth_interfaces_i}"
sudo ifconfig "${all_eth_interfaces_i}" up
printf " Done.\n"
disable_ipv6 "${all_eth_interfaces_i}"
if [[ "${ovs}" == "true" ]]; then
# VMM and Open vSwitch are installed
sudo ifconfig "ovs_${all_eth_interfaces_i}" up
# No more use for this here.
# disable_ipv6 "ovs_${all_eth_interfaces_i}"
ethx_IP=$(ip addr show "ovs_${all_eth_interfaces_i}" | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) # Thanks to : https://askubuntu.com/a/560466
printf "\t-> %s should be up now. You can connect the NAS on %s in order to sort things out...\n" "ovs_${all_eth_interfaces_i}" "${ethx_IP}"
message="${message}\n\t-> ovs_${all_eth_interfaces_i} should be up now. You can connect the NAS on ${ethx_IP} in order to sort things out...\n"
elif [[ "${ovs}" == "false" ]]; then
ethx_IP=$(ip addr show "${all_eth_interfaces_i}" | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) # Thanks to : https://askubuntu.com/a/560466
printf "\t-> %s should be up now. You can connect the NAS on %s in order to sort things out...\n" "${all_eth_interfaces_i}" "${ethx_IP}"
message="${message}\n\t-> ${all_eth_interfaces_i} should be up now. You can connect the NAS on ${ethx_IP} in order to sort things out...\n"
fi
done
printf " => Exiting script now.\n"
message="${message} => Exiting script now.\n"
gotify_priority=${gotify_priority_success}
send_gotify_notification
printf "\n"
exit 0
}
function reactivate_eth0_ethX() {
for embedded_interface_i in "${embedded_interface_to_deactivate[@]}"; do
printf "\n\tReactivation of %s." "${embedded_interface_i}"
sudo ifconfig "${embedded_interface_i}" up
printf " Done.\n"
disable_ipv6 "${embedded_interface_i}"
if [[ "${ovs}" == "true" ]]; then
# VMM and Open vSwitch are installed
printf "\n\tReactivation of ${embedded_interface_i} because of Open vSwitch installed with VMM.\n"
sudo ifconfig "ovs_${embedded_interface_i}" up
# No more use for this here.
# disable_ipv6 "ovs_${embedded_interface_i}"
ethx_IP=$(ip addr show "ovs_${embedded_interface_i}" | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) # Thanks to : https://askubuntu.com/a/560466
printf "\t-> %s should be up now. You can connect the NAS on %s in order to sort things out...\n" "ovs_${all_eth_interfaces_i}" "${ethx_IP}"
message="${message}\n\t-> ovs_${embedded_interface_i} should be up now. You can connect the NAS on ${ethx_IP} in order to sort things out...\n"
elif [[ "${ovs}" == "false" ]]; then
ethx_IP=$(ip addr show "${embedded_interface_i}" | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) # Thanks to : https://askubuntu.com/a/560466
printf "\t-> %s should be up now. You can connect the NAS on %s in order to sort things out...\n" "${embedded_interface_i}" "${ethx_IP}"
message="${message}\n\t-> ${embedded_interface_i} should be up now. You can connect the NAS on ${ethx_IP} in order to sort things out...\n"
fi
done
printf " => Exiting script now.\n"
message="${message} => Exiting script now.\n"
gotify_priority=${gotify_priority_fail}
send_gotify_notification
exit 1
}
function deactivate_eth0_ethX_if_up() {
# Test if eth0...ethX is/are already down or still up
for embedded_interface_i in "${embedded_interface_to_deactivate[@]}"; do
# See : https://unix.stackexchange.com/a/293319
if [[ "${ovs}" == "true" ]]; then
if [[ -n "$(ip a show ovs_${embedded_interface_i} up)" ]]; then
printf "\tovs_%s is still up and running. Shutting down now.\n" "${embedded_interface_i}"
message="${message}\tovs_${embedded_interface_i} is still up and running. Shutting down now.\n"
sudo ifconfig "ovs_${embedded_interface_i}" down
else
printf "\tovs_%s is already down.\n" "${embedded_interface_i}"
message="${message}\tovs_${embedded_interface_i} is already down.\n"
fi
fi
if [[ -n "$(ip a show ${embedded_interface_i} up)" ]]; then
printf "\t%s is still up and running. Shutting down now.\n" "${embedded_interface_i}"
message="${message}\t${embedded_interface_i} is still up and running. Shutting down now.\n"
sudo ifconfig "${embedded_interface_i}" down
else
printf "\t%s is already down.\n" "${embedded_interface_i}"
message="${message}\t${embedded_interface_i} is already down.\n"
fi
done
}
# ====================================================================================== #
# ===================================== Main script ==================================== #
# ====================================================================================== #
# ╔══════════════════════════════════════════════════════════════════════════╗
# ║ Check if the interfaces to disable aren't including the one we need to ║
# ║ be up and running ║
# ╚══════════════════════════════════════════════════════════════════════════╝
message=""
if [[ "${reactivation_all}" == "true" ]]; then
reactivate_all_down_ethX
fi
for embedded_interface_i in "${embedded_interface_to_deactivate[@]}"; do
if [[ "${embedded_interface_i}" == "${interface}" ]]; then
message="The interface '${embedded_interface_i}' you want disabled is the 2,5G / 5G interface you want to keep up and running.\nReview your settings... Exiting now.\n"
# printf "%s" "$message"
printf "The interface '%s' you want disabled is the 2,5G / 5G interface you want to keep up and running.\nReview your settings... Exiting now.\n" "${embedded_interface_i}"
send_gotify_notification
exit 1
fi
done
if [[ "${ovs}" == "true" ]]; then
message=" => As VMM is installed and Open vSwitch is activated, all physical interfaces will be managed with the virtual one (ovs_ethX).\n => So when we'll see ethX, ovs_ethX will be managed as well.\n"
printf " => As VMM is installed and Open vSwitch is activated, all physical interfaces will be managed with the virtual one (ovs_ethX).\n => So when we'll see ethX, ovs_ethX will be managed as well.\n"
fi
string_value=$(printf "%s" "${embedded_interface_to_deactivate[*]}")
# printf -v message "%s : will be deactivated if '%s' is up and running.\n" "${string_value[*]// /, }" "${interface}"
message="${message} => ${string_value[*]// /, } : will be deactivated if '${interface}' is up and running.\n"
printf " => %s : will be deactivated if '%s' is up and running.\n" "${string_value[*]// /, }" "${interface}"
# ╚══════════════════════════════════════════════════════════════════════════╝
# I assume that just after the boot, the driver may be not loaded for various reasons...
# Or after some time, the driver may fail, and the connectivity won't work anymore.
# This will check the connectivity to the gateway/ip provided, and the decide what to do
PING=""
# We will try 2 times to restart the driver if it has failed.
for ((i = 1; i < 3; i++)); do
printf "Try n°%i\n" ${i}
get_status
if [[ "${driver_ok_ko}" == "KO" ]]; then
# The driver status AREN'T OK !
# The driver need to be restarted or reloaded !
if ((i == 2)); then
# We are on the 2nd try, and the driver is still not OK !
printf "\n\tThe driver is still not OK on the 2nd try !\nThat's not good...\nIt means the %s isn't working... So let's reactivate the eth0 interface." $interface
message="${message}\n\tThe driver is still not OK on the 2nd try !\nThat's not good...\nIt means the ${interface} isn't working... So let's reactivate the eth0 interface."
reactivate_eth0_ethX
fi
driver_restart_reload
else
# The driver status is OK !
# Let's try the ping function
ping_gateway $interface
if [[ "${PING}" == "not-OK" ]]; then
# Ping isn't OK...
if ((i == 1)); then
# This is the first run
printf "\tGateway %s IS NOT accessible !\n\tThe driver need to be restarted or reloaded !\n" "$gateway"
message="${message}\tgateway ${gateway} IS NOT accessible !\n\tThe driver need to be restarted or reloaded !\n"
driver_ok_ko="KO"
driver_restart_reload
else
# This is the 2nd run
printf "\tThis is the second try, and the ping on this try isn't OK... \nIt means the %s isn't working... So let's reactivate the eth0 interface." $interface
message="${message}\tThis is the second try, and the ping on this try isn't OK... \nIt means the ${interface} isn't working... So let's reactivate the eth0 interface."
reactivate_eth0_ethX
fi
else
# Ping is OK
if ((i == 1)); then
# This is the first run
printf "\tgateway %s is accessible ! No need to do something more.\n" "$gateway"
message="${message}\tgateway ${gateway} is accessible !\t\nNo need to do something more.\n"
disable_ipv6 ${interface}
deactivate_eth0_ethX_if_up
gotify_priority=${gotify_priority_success}
send_gotify_notification
exit 0
else
# This is the 2nd run
printf "\tgateway %s is now accessible (on the 2nd run) !\nNote : the status wasn't OK before...\n" "$gateway"
message="${message}\tgateway $gateway is accessible !\t\nNo need to do something more.\n"
disable_ipv6 $interface
deactivate_eth0_ethX_if_up
gotify_priority=${gotify_priority_error}
send_gotify_notification
exit 1
fi
fi
fi
done