From 845b533ed52fe81b726dfddd3a87944156e10f6f Mon Sep 17 00:00:00 2001 From: dcmartin Date: Mon, 28 Dec 2020 16:42:12 -0800 Subject: [PATCH] test for existing prior to restarting NetworkManager; include sleep after restart for devices which reset WiFi connection on restart --- installer.sh | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) mode change 100644 => 100755 installer.sh diff --git a/installer.sh b/installer.sh old mode 100644 new mode 100755 index e019c0c..f672180 --- a/installer.sh +++ b/installer.sh @@ -95,25 +95,41 @@ if [[ "$(sysctl --values kernel.dmesg_restrict)" != "0" ]]; then fi # Create config for NetworkManager -info "Creating NetworkManager configuration" -curl -sL "${URL_NM_CONF}" > "${FILE_NM_CONF}" -if [ ! -f "$FILE_NM_CONNECTION" ]; then +tmp=$(mktemp) +curl -sL "${URL_NM_CONF}" -o ${tmp} +if [ $(diff ${tmp} ${FILE_NM_CONF} | wc -c) -gt 0 ]; then + info "Creating NetworkManager configuration" + mv -f ${tmp} "${FILE_NM_CONF}" + if [ ! -f "$FILE_NM_CONNECTION" ]; then curl -sL "${URL_NM_CONNECTION}" > "${FILE_NM_CONNECTION}" + fi + nmrestart='true' fi +rm -f ${tmp} -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 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] " -read answer < /dev/tty +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" + 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 "Do you want to proceed with that? [N/y] " + read answer < /dev/tty -if [[ "$answer" =~ "y" ]] || [[ "$answer" =~ "Y" ]]; then + if [[ "$answer" =~ "y" ]] || [[ "$answer" =~ "Y" ]]; then info "Replacing /etc/network/interfaces" - curl -sL "${URL_INTERFACES}" > "${FILE_INTERFACES}"; + mv -f ${tmp} "${FILE_INTERFACES}" + nmrestart='true' + fi fi +rm -f ${tmp} -info "Restarting NetworkManager" -systemctl restart "${SERVICE_NM}" +if [ "${nmrestart:-false}" = 'true' ]; then + info "Restarting NetworkManager" + systemctl restart "${SERVICE_NM}" + info "Sleeping for five (5) seconds" + sleep 5 +fi # Parse command line parameters while [[ $# -gt 0 ]]; do @@ -193,7 +209,7 @@ if [ ! -d "$DATA_SHARE" ]; then fi # 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