no hardcodear el nombre de la red

This commit is contained in:
fauno 2021-06-14 19:36:57 -03:00
parent b67c5be3c1
commit 2ec663a79f

View File

@ -62,14 +62,14 @@ fi
# Servicio de tinc@rap (si existe el principal)
if [ "${notincsv}" != true ]; then
tincrapsvstatus="$(systemctl status tinc@rap || :)"
tincrapsvstatus="$(systemctl status tinc@${NETWORK} || :)"
if [ -z "${tincrapsvstatus}" ]; then
msg_orange "No se encontró el servicio de tinc@rap"
msg_orange "No se encontró el servicio de tinc@${NETWORK}"
else
tincsv="$(systemctl show tinc@rap)"
tincsv="$(systemctl show tinc@${NETWORK})"
echo "${tincsv}" | grep -q UnitFileState=enabled && enabled=si || enabled=no
echo "${tincsv}" | grep -q ActiveState=active && active=si || active=no
msgtxt="Se encontró el servicio de tinc@rap: inicio en arranque=${enabled}, activo ahora=${active}"
msgtxt="Se encontró el servicio de tinc@${NETWORK}: inicio en arranque=${enabled}, activo ahora=${active}"
if [ "${active}" = si ]; then msg "${msgtxt}"
else msg_orange "${msgtxt}"; fi
fi
@ -78,25 +78,25 @@ fi
# Interface de red
iplink="$(ip link show "${NETWORK}" 2>/dev/null || :)"
if [ -z "${iplink}" ]; then
msg_orange "No se encontró la interface de red de la rap"
msg_orange "No se encontró la interface de red de la ${NETWORK}"
else
echo "${iplink}" | grep -q 'state UNKNOWN' && interface=true || interface=false
if [ "${interface}" != true ]; then
msg_orange "Interface de red de la rap encontrada, pero caída"
msg_orange "Interface de red de la ${NETWORK} encontrada, pero caída"
else
msg "Interface de red de la rap encontrada y andando"
msg "Interface de red de la ${NETWORK} encontrada y andando"
# IPv6 local
ipaddress="$(ip address show "${NETWORK}" | grep inet6 | tr -s ' ' | cut -d' ' -f3)"
if [ -z "${ipaddress}" ]; then
msg_orange "No se encontró ninguna IP de rap"
msg_orange "No se encontró ninguna IP de ${NETWORK}"
elif [ "$(echo "${ipaddress}" | wc -l)" -eq 1 ]; then
msg_orange "Se encontró una sola IP: ${ipaddress}"
else
iprap="$(echo "${ipaddress}" | grep "${ULA_PREFIX}" || :)"
if [ -z "${iprap}" ]; then
msg_orange "Se encontraron varias IPs de rap, pero ninguna válida"
msg_orange "Se encontraron varias IPs de ${NETWORK}, pero ninguna válida"
else
msg "Tu IP de rap es: ${iprap}"
msg "Tu IP de ${NETWORK} es: ${iprap}"
fi
fi
fi