adding batch mode
This commit is contained in:
parent
52e6529bf0
commit
4626d09e05
1 changed files with 56 additions and 42 deletions
96
installer.sh
96
installer.sh
|
@ -7,15 +7,57 @@ function info { echo -e "\e[32m[info] $*\e[39m"; }
|
||||||
function warn { echo -e "\e[33m[warn] $*\e[39m"; }
|
function warn { echo -e "\e[33m[warn] $*\e[39m"; }
|
||||||
function error { echo -e "\e[31m[error] $*\e[39m"; exit 1; }
|
function error { echo -e "\e[31m[error] $*\e[39m"; exit 1; }
|
||||||
|
|
||||||
|
BATCH_MODE=0
|
||||||
|
# Parse command line parameters
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
arg="$1"
|
||||||
|
|
||||||
|
case $arg in
|
||||||
|
-m|--machine)
|
||||||
|
MACHINE=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-d|--data-share)
|
||||||
|
DATA_SHARE=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-p|--prefix)
|
||||||
|
PREFIX=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-s|--sysconfdir)
|
||||||
|
SYSCONFDIR=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-b|--batch)
|
||||||
|
BATCH_MODE=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "Unrecognized option $1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
PREFIX=${PREFIX:-/usr}
|
||||||
|
SYSCONFDIR=${SYSCONFDIR:-/etc}
|
||||||
|
DATA_SHARE=${DATA_SHARE:-$PREFIX/share/hassio}
|
||||||
|
CONFIG=$SYSCONFDIR/hassio.json
|
||||||
|
|
||||||
|
|
||||||
warn ""
|
warn ""
|
||||||
warn "If you want more control over your own system, run"
|
warn "If you want more control over your own system, run"
|
||||||
warn "Home Assistant as a VM or run Home Assistant Core"
|
warn "Home Assistant as a VM or run Home Assistant Core"
|
||||||
warn "via a Docker container."
|
warn "via a Docker container."
|
||||||
warn ""
|
warn ""
|
||||||
warn "If you want to abort, hit ctrl+c within 10 seconds..."
|
if [ $BATCH_MODE -eq 0 ]; then
|
||||||
warn ""
|
warn "If you want to abort, hit ctrl+c within 10 seconds..."
|
||||||
|
warn ""
|
||||||
|
|
||||||
sleep 10
|
sleep 10
|
||||||
|
else
|
||||||
|
warn "Batch mode enabled, continuing..."
|
||||||
|
fi
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
@ -102,52 +144,24 @@ if [ ! -f "$FILE_NM_CONNECTION" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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"
|
if [ $BATCH_MODE -eq 0 ]; then
|
||||||
info "If you do not overwrite this now you need to manually adjust it later"
|
info "If you have modified the network on the host manualy, those can now be overwritten"
|
||||||
info "Do you want to proceed with overwriting the /etc/network/interfaces file? [N/y] "
|
info "If you do not overwrite this now you need to manually adjust it later"
|
||||||
read answer < /dev/tty
|
info "Do you want to proceed with overwriting the /etc/network/interfaces file? [N/y] "
|
||||||
|
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}";
|
curl -sL "${URL_INTERFACES}" > "${FILE_INTERFACES}";
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
info "Batch mode enabled, replacing /etc/network/interfaces"
|
||||||
|
curl -sL "${URL_INTERFACES}" > "${FILE_INTERFACES}";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Restarting NetworkManager"
|
info "Restarting NetworkManager"
|
||||||
systemctl restart "${SERVICE_NM}"
|
systemctl restart "${SERVICE_NM}"
|
||||||
|
|
||||||
# Parse command line parameters
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
arg="$1"
|
|
||||||
|
|
||||||
case $arg in
|
|
||||||
-m|--machine)
|
|
||||||
MACHINE=$2
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-d|--data-share)
|
|
||||||
DATA_SHARE=$2
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-p|--prefix)
|
|
||||||
PREFIX=$2
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-s|--sysconfdir)
|
|
||||||
SYSCONFDIR=$2
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
error "Unrecognized option $1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
PREFIX=${PREFIX:-/usr}
|
|
||||||
SYSCONFDIR=${SYSCONFDIR:-/etc}
|
|
||||||
DATA_SHARE=${DATA_SHARE:-$PREFIX/share/hassio}
|
|
||||||
CONFIG=$SYSCONFDIR/hassio.json
|
|
||||||
|
|
||||||
# Generate hardware options
|
# Generate hardware options
|
||||||
case $ARCH in
|
case $ARCH in
|
||||||
"i386" | "i686")
|
"i386" | "i686")
|
||||||
|
|
Loading…
Reference in a new issue