From c7c7a897d9668a71af38d2a63753bf20e629767f Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Mon, 23 Nov 2020 03:59:34 +0000 Subject: [PATCH] Resolve "Bugfix: handling empty DIFACE" --- scripts/env/setup.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/env/setup.sh b/scripts/env/setup.sh index b7c9643..ce3e9bc 100755 --- a/scripts/env/setup.sh +++ b/scripts/env/setup.sh @@ -22,13 +22,25 @@ fi echo "MISTBORN_TAG=$MISTBORN_TAG" | sudo tee -a ${VAR_FILE} -#### install and base services -iface=$(ip -o -4 route show to default | egrep -o 'dev [^ ]*' | awk 'NR==1{print $2}') - -# default interface +# copy current service files to systemd (overwriting as needed) sudo cp /opt/mistborn/scripts/services/Mistborn* /etc/systemd/system/ + +# set script user and owner sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/User=root/User=$USER/" #sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/ root:root / $USER:$USER /" + +# reload in case the iface is not immediately set +sudo systemctl daemon-reload + +#### install and base services +iface=$(ip -o -4 route show to default | egrep -o 'dev [^ ]*' | awk 'NR==1{print $2}' | tr -d '[:space:]') +## cannot be empty +while [[ -z "$iface" ]]; do + sleep 2 + iface=$(ip -o -4 route show to default | egrep -o 'dev [^ ]*' | awk 'NR==1{print $2}' | tr -d '[:space:]') +done + +# default interface sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/DIFACE/$iface/" -sudo systemctl daemon-reload \ No newline at end of file +sudo systemctl daemon-reload