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
14
README.md
14
README.md
|
@ -20,12 +20,14 @@ bash installer.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
### Command line arguments
|
### Command line arguments
|
||||||
| argument | default | description |
|
|
||||||
|--------------------|----------------------|--------------------------------------------------------|
|
| argument | default | description |
|
||||||
| -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 |
|
| -a \| --auto | | Don't ask for input, assume yes to all questions. For automated installers |
|
||||||
| -p \| --prefix | /usr | Binary prefix for hass.io installation |
|
| -m \| --machine | | On a special platform they need set a machine type use |
|
||||||
| -s \| --sysconfdir | /etc | Configuration directory for hass.io installation |
|
| -d \| --data-share | $PREFIX/share/hassio | data folder for hass.io installation |
|
||||||
|
| -p \| --prefix | /usr | Binary prefix for hass.io installation |
|
||||||
|
| -s \| --sysconfdir | /etc | Configuration directory for hass.io installation |
|
||||||
|
|
||||||
you can set these parameters by appending ` --<parameter> <value>` like:
|
you can set these parameters by appending ` --<parameter> <value>` like:
|
||||||
|
|
||||||
|
|
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 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; }
|
||||||
|
|
||||||
warn ""
|
# Parse command line parameters
|
||||||
warn "If you want more control over your own system, run"
|
while [[ $# -gt 0 ]]; do
|
||||||
warn "Home Assistant as a VM or run Home Assistant Core"
|
arg="$1"
|
||||||
warn "via a Docker container."
|
|
||||||
warn ""
|
|
||||||
warn "If you want to abort, hit ctrl+c within 10 seconds..."
|
|
||||||
warn ""
|
|
||||||
|
|
||||||
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)
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
@ -101,11 +134,15 @@ if [ ! -f "$FILE_NM_CONNECTION" ]; then
|
||||||
curl -sL "${URL_NM_CONNECTION}" > "${FILE_NM_CONNECTION}"
|
curl -sL "${URL_NM_CONNECTION}" > "${FILE_NM_CONNECTION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
warn "Changes are needed to the /etc/network/interfaces file"
|
if [ -z "$AUTO" ]; then
|
||||||
info "If you have modified the network on the host manualy, those can now be overwritten"
|
warn "Changes are needed to the /etc/network/interfaces file"
|
||||||
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
|
||||||
|
else
|
||||||
|
answer="y"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$answer" =~ "y" ]] || [[ "$answer" =~ "Y" ]]; then
|
if [[ "$answer" =~ "y" ]] || [[ "$answer" =~ "Y" ]]; then
|
||||||
info "Replacing /etc/network/interfaces"
|
info "Replacing /etc/network/interfaces"
|
||||||
|
@ -115,34 +152,6 @@ 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}
|
PREFIX=${PREFIX:-/usr}
|
||||||
SYSCONFDIR=${SYSCONFDIR:-/etc}
|
SYSCONFDIR=${SYSCONFDIR:-/etc}
|
||||||
DATA_SHARE=${DATA_SHARE:-$PREFIX/share/hassio}
|
DATA_SHARE=${DATA_SHARE:-$PREFIX/share/hassio}
|
||||||
|
|
Loading…
Reference in a new issue