From 4c562f7be65e878d987355ed69e2c9cc0b031929 Mon Sep 17 00:00:00 2001 From: r00t Date: Sat, 21 Mar 2015 04:55:07 -0400 Subject: [PATCH] forcing networking in case it fails --- overlay/etc/systemd/scripts/livecd.fix.sh | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/overlay/etc/systemd/scripts/livecd.fix.sh b/overlay/etc/systemd/scripts/livecd.fix.sh index 6778424..cd2b081 100755 --- a/overlay/etc/systemd/scripts/livecd.fix.sh +++ b/overlay/etc/systemd/scripts/livecd.fix.sh @@ -7,3 +7,44 @@ chmod 700 /var/db/sudo/lectured chgrp bdisk /var/db/sudo/lectured/bdisk chmod 600 /var/db/sudo/lectured/bdisk chmod 4755 /usr/bin/sudo + +function fuck_you_gimme_net() { +IFACE=$(ifconfig -a -s | egrep -E '^((en|wl)p?|em)' | awk '{print $1}' | tr '\n' ' ' | sed -e 's/\ $//g') +for i in ${IFACE}; +do + + LINK_STATE=$(ethtool ${i} | egrep '^[[:space:]]*Link' | sed -re 's/^[[:space:]]*Link detected:(.*)/\1/g') + DEV=$(echo ${i} | sed -re 's/^([A-Za-z]{1}).*/\1/g' | tr '[[:upper:]]' '[[:lower:]]' ) + if [ "${DEV}" == "e" ]; + then + if [ "${LINK_STATE}" != "no" ]; + then + DEV='ethernet-dhcp' + else + # skip disconnected ethernet + continue + fi + else + DEV='wireless-open' + fi + + ifconfig ${i} down + cp -a /etc/netctl/examples/${DEV} /etc/netctl/${i} + sed -i -re "s/^([[:space:]]*Interface[[:space:]]*=).*/\1${i}/g" /etc/netctl/${i} + if [ "${DEV}" == "wireless-open" ]; + then + ifconfig ${i} up && \ + ESSID=$(iwlist ${i} scanning | egrep -A5 -B5 '^[[:space:]]*Encryption key:off' | egrep '^[[:space:]]*ESSID:' | sed -re 's/^[[:space:]]*ESSID:(.*)/\1/g') + sed -i -re "s/^([[:space:]]*ESSID[[:space:]]*=).*/\1${ESSID}/g" /etc/netctl/${i} + ifconfig ${i} down + fi + netctl start ${i} > /dev/null 2>&1 +done +} + +ping -c1 google.com | grep -q '1 received' +if [[ "${?}" != "0" ]]; +then + fuck_you_gimme_net + systemctl restart openvpn@* +fi