test for existing prior to restarting NetworkManager; include sleep after restart for devices which reset WiFi connection on restart

This commit is contained in:
dcmartin 2020-12-28 16:42:12 -08:00
parent e2a66e35d3
commit 845b533ed5

24
installer.sh Normal file → Executable file
View file

@ -95,25 +95,41 @@ if [[ "$(sysctl --values kernel.dmesg_restrict)" != "0" ]]; then
fi fi
# Create config for NetworkManager # Create config for NetworkManager
tmp=$(mktemp)
curl -sL "${URL_NM_CONF}" -o ${tmp}
if [ $(diff ${tmp} ${FILE_NM_CONF} | wc -c) -gt 0 ]; then
info "Creating NetworkManager configuration" info "Creating NetworkManager configuration"
curl -sL "${URL_NM_CONF}" > "${FILE_NM_CONF}" mv -f ${tmp} "${FILE_NM_CONF}"
if [ ! -f "$FILE_NM_CONNECTION" ]; then if [ ! -f "$FILE_NM_CONNECTION" ]; then
curl -sL "${URL_NM_CONNECTION}" > "${FILE_NM_CONNECTION}" curl -sL "${URL_NM_CONNECTION}" > "${FILE_NM_CONNECTION}"
fi fi
nmrestart='true'
fi
rm -f ${tmp}
tmp=$(mktemp)
curl -sL "${URL_INTERFACES}" -o ${tmp}
if [ $(diff ${tmp} ${FILE_INTERFACES} | wc -c) -gt 0 ]; then
warn "Changes are needed to the /etc/network/interfaces file" warn "Changes are needed to the /etc/network/interfaces file"
info "If you have modified the network on the host manualy, those can now be overwritten" info "If you have modified the network on the host manualy, those can now be overwritten"
info "If you do not overwrite this now you need to manually adjust it later" info "If you do not overwrite this now you need to manually adjust it later"
info "Do you want to proceed with overwriting the /etc/network/interfaces file? [N/y] " info "Do you want to proceed with that? [N/y] "
read answer < /dev/tty read answer < /dev/tty
if [[ "$answer" =~ "y" ]] || [[ "$answer" =~ "Y" ]]; then if [[ "$answer" =~ "y" ]] || [[ "$answer" =~ "Y" ]]; then
info "Replacing /etc/network/interfaces" info "Replacing /etc/network/interfaces"
curl -sL "${URL_INTERFACES}" > "${FILE_INTERFACES}"; mv -f ${tmp} "${FILE_INTERFACES}"
nmrestart='true'
fi fi
fi
rm -f ${tmp}
if [ "${nmrestart:-false}" = 'true' ]; then
info "Restarting NetworkManager" info "Restarting NetworkManager"
systemctl restart "${SERVICE_NM}" systemctl restart "${SERVICE_NM}"
info "Sleeping for five (5) seconds"
sleep 5
fi
# Parse command line parameters # Parse command line parameters
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
@ -193,7 +209,7 @@ if [ ! -d "$DATA_SHARE" ]; then
fi fi
# Read infos from web # Read infos from web
HASSIO_VERSION=$(curl -s $URL_VERSION | jq -e -r '.supervisor') HASSIO_VERSION=$(curl -sL $URL_VERSION | jq -e -r '.supervisor')
## ##
# Write configuration # Write configuration