diff --git a/README.md b/README.md index dcafc95..7f2c79f 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,14 @@ bash installer.sh ``` ### Command line arguments -| 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 | -| -p \| --prefix | /usr | Binary prefix for hass.io installation | -| -s \| --sysconfdir | /etc | Configuration directory for hass.io installation | + +| 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 | +| -s \| --sysconfdir | /etc | Configuration directory for hass.io installation | you can set these parameters by appending ` -- ` like: diff --git a/installer.sh b/installer.sh index e019c0c..6496a60 100644 --- a/installer.sh +++ b/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}