Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Illyse
Flash Openwrt Mikrotik Rb952ui 5ac2nD
Commits
9b154f78
Commit
9b154f78
authored
Sep 03, 2021
by
Félix Sipma
Browse files
teste l'interface réseau avant de lancer le reste du script
parent
dbadc453
Changes
1
Hide whitespace changes
Inline
Side-by-side
flash_openwrt_mikrotik_rb952ui-5ac2nD.py
View file @
9b154f78
...
...
@@ -3,6 +3,7 @@ import os
import
shutil
import
subprocess
import
sys
from
pathlib
import
Path
# variables à changer:
IFNAME
=
"enp0s25"
...
...
@@ -59,6 +60,14 @@ if not os.path.isfile(OPENWRT_INITRAMFS_IMAGE): sys.exit(RED + "Le fichier \""
if
not
os
.
path
.
isfile
(
OPENWRT_SYSUPGRADE_IMAGE
):
sys
.
exit
(
RED
+
"Le fichier
\"
"
+
OPENWRT_SYSUPGRADE_IMAGE
+
"
\"
est introuvable."
+
NC
)
print
(
BLUE
+
"Teste si l'interface réseau "
+
IFNAME
+
" est configurée correctement."
+
NC
)
if
not
os
.
path
.
isfile
(
"/sys/class/net/"
+
IFNAME
+
"/operstate"
):
sys
.
exit
(
RED
+
"L'interface "
+
IFNAME
+
" n'existe pas."
)
contents
=
Path
(
"/sys/class/net/"
+
IFNAME
+
"/operstate"
).
read_text
()
contents
=
contents
.
replace
(
"
\n
"
,
""
)
if
not
contents
==
"up"
:
sys
.
exit
(
RED
+
"L'interface "
+
IFNAME
+
"n'est pas configurée correctement."
)
print
(
BLUE
+
"Teste si le routeur est accessible sur l'ip "
+
IP_ROUTEROS
+
NC
)
try
:
subprocess
.
check_output
(
"ping -c 1 "
+
IP_ROUTEROS
,
shell
=
True
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment