Add option to run the installer unattended
Added an option so the installer script doesn't ask for input. Required for automated installations
This commit is contained in:
parent
e2a66e35d3
commit
1910ccbb86
2 changed files with 58 additions and 47 deletions
|
@ -20,8 +20,10 @@ bash installer.sh
|
|||
```
|
||||
|
||||
### Command line arguments
|
||||
|
||||
| argument | default | description |
|
||||
|--------------------|----------------------|--------------------------------------------------------|
|
||||
| ------------------ | -------------------- | -------------------------------------------------------------------------- |
|
||||
| -a \| --auto | | Don't ask for input, assume yes to all questions. For automated installers |
|
||||
| -m \| --machine | | On a special platform they need set a machine type use |
|
||||
| -d \| --data-share | $PREFIX/share/hassio | data folder for hass.io installation |
|
||||
| -p \| --prefix | /usr | Binary prefix for hass.io installation |
|
||||
|
|
91
installer.sh
91
installer.sh
|
@ -7,15 +7,48 @@ function info { echo -e "\e[32m[info] $*\e[39m"; }
|
|||
function warn { echo -e "\e[33m[warn] $*\e[39m"; }
|
||||
function error { echo -e "\e[31m[error] $*\e[39m"; exit 1; }
|
||||
|
||||
warn ""
|
||||
warn "If you want more control over your own system, run"
|
||||
warn "Home Assistant as a VM or run Home Assistant Core"
|
||||
warn "via a Docker container."
|
||||
warn ""
|
||||
warn "If you want to abort, hit ctrl+c within 10 seconds..."
|
||||
warn ""
|
||||
# Parse command line parameters
|
||||
while [[ $# -gt 0 ]]; do
|
||||
arg="$1"
|
||||
|
||||
sleep 10
|
||||
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
|
||||
;;
|
||||
-a|--auto)
|
||||
AUTO=1
|
||||
;;
|
||||
*)
|
||||
error "Unrecognized option $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$AUTO" ]; then
|
||||
warn ""
|
||||
warn "If you want more control over your own system, run"
|
||||
warn "Home Assistant as a VM or run Home Assistant Core"
|
||||
warn "via a Docker container."
|
||||
warn ""
|
||||
warn "If you want to abort, hit ctrl+c within 10 seconds..."
|
||||
warn ""
|
||||
|
||||
sleep 10
|
||||
fi
|
||||
|
||||
ARCH=$(uname -m)
|
||||
|
||||
|
@ -101,11 +134,15 @@ if [ ! -f "$FILE_NM_CONNECTION" ]; then
|
|||
curl -sL "${URL_NM_CONNECTION}" > "${FILE_NM_CONNECTION}"
|
||||
fi
|
||||
|
||||
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
|
||||
if [ -z "$AUTO" ]; 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 overwriting the /etc/network/interfaces file? [N/y] "
|
||||
read answer < /dev/tty
|
||||
else
|
||||
answer="y"
|
||||
fi
|
||||
|
||||
if [[ "$answer" =~ "y" ]] || [[ "$answer" =~ "Y" ]]; then
|
||||
info "Replacing /etc/network/interfaces"
|
||||
|
@ -115,34 +152,6 @@ fi
|
|||
info "Restarting NetworkManager"
|
||||
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}
|
||||
|
|
Loading…
Reference in a new issue