init/functions: handle non-present /qubes-mac qubesdb and check if iface exists

This commit is contained in:
Frédéric Pierret (fepitre) 2019-06-20 16:06:25 +02:00
parent aa7ab25a78
commit 967060eb32
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2

View File

@ -131,7 +131,7 @@ umount_retry() {
get_mac_from_iface() {
local iface="$1"
local mac
if [ "x$iface" != "x" ]; then
if [ "x$iface" != "x" ] && [ -e "/sys/class/net/$iface" ]; then
mac="$(cat "/sys/class/net/$iface/address")"
fi
echo "$mac"
@ -149,7 +149,7 @@ get_iface_from_mac() {
get_qubes_managed_iface() {
local mac
local qubes_iface
mac="$(qubesdb-read /qubes-mac)"
mac="$(qubesdb-read /qubes-mac 2> /dev/null)"
qubes_iface="$(get_iface_from_mac "$mac")"
if [ "x$qubes_iface" != "x" ]; then
echo "$qubes_iface"