diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 133eb2fb..027183fd 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -92,8 +92,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi @@ -119,8 +117,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi @@ -142,8 +138,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi @@ -163,17 +157,12 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi return 0 ``` -This line should only be printed it the validation fails. -`"If you have issues with this script, please say something in the #devs_hassbian channel on Discord."` - ## Testing your code Testing the code can be done in the folowing steps: 1. Make sure you have the newest version from the upstream dev. branch. `sudo hassbian-config upgrade hassbian-script-dev` diff --git a/docs/hassbian_config.md b/docs/hassbian_config.md index bd086a29..4e1c8dbe 100644 --- a/docs/hassbian_config.md +++ b/docs/hassbian_config.md @@ -14,8 +14,8 @@ where command is one of: - `share-log` This will generate an hastebin link of the last hassbian-config operation. Optional flags: -- `-y | --accept` This will accept defaults on scripts that allow this. -- `-f | --force` This will force run an script. This is useful if you need to reinstall a package. +- `-Y | --accept` This will accept defaults on scripts that allow this. +- `-F | --force` This will force run an script. This is useful if you need to reinstall a package. - `-D | --debug` This will output every comand to the console. Other available commands: diff --git a/package/opt/hassbian/suites/appdaemon.sh b/package/opt/hassbian/suites/appdaemon.sh index c11402f6..bf278375 100644 --- a/package/opt/hassbian/suites/appdaemon.sh +++ b/package/opt/hassbian/suites/appdaemon.sh @@ -12,9 +12,6 @@ function appdaemon-show-copyright-info { } function appdaemon-install-package { -appdaemon-show-short-info -appdaemon-show-copyright-info - if [ "$ACCEPT" != "true" ]; then if [ -f "/usr/sbin/samba" ]; then echo -n "Do you want to add Samba share for AppDaemon configuration? [N/y] : " @@ -89,8 +86,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi @@ -98,9 +93,6 @@ return 0 } function appdaemon-upgrade-package { -appdaemon-show-short-info -appdaemon-show-copyright-info - echo "Stopping AppDaemon service..." systemctl stop appdaemon@homeassistant.service @@ -133,8 +125,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mUpgrade failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/duckdns.sh b/package/opt/hassbian/suites/duckdns.sh index ee0ca278..f6648957 100644 --- a/package/opt/hassbian/suites/duckdns.sh +++ b/package/opt/hassbian/suites/duckdns.sh @@ -13,10 +13,6 @@ function duckdns-show-copyright-info { } function duckdns-install-package { -duckdns-show-long-info -duckdns-show-copyright-info - -echo echo "Please take a moment to setup autorenewal of duckdns." echo "If no choice is made the installation will exit." echo @@ -108,8 +104,6 @@ if [ ! -z "${certvalidation}" ] && [ ! -z "${dnsvalidation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/hassbian-script-dev.sh b/package/opt/hassbian/suites/hassbian-script-dev.sh index e925f9b5..5d9c39c2 100644 --- a/package/opt/hassbian/suites/hassbian-script-dev.sh +++ b/package/opt/hassbian/suites/hassbian-script-dev.sh @@ -14,9 +14,6 @@ function hassbian-script-dev-show-copyright-info { } function hassbian-script-dev-upgrade-package { -hassbian-script-dev-show-short-info -hassbian-script-dev-show-copyright-info - echo "Creation and changing in to temporary folder." cd || exit sudo mkdir /tmp/hassbian_config_update diff --git a/package/opt/hassbian/suites/hassbian-script.sh b/package/opt/hassbian/suites/hassbian-script.sh index 56d4d042..5db4c7ff 100644 --- a/package/opt/hassbian/suites/hassbian-script.sh +++ b/package/opt/hassbian/suites/hassbian-script.sh @@ -12,9 +12,6 @@ function hassbian-script-show-copyright-info { } function hassbian-script-upgrade-package { -hassbian-script-show-short-info -hassbian-script-show-copyright-info - echo "Changing to temporary folder" cd /tmp || exit diff --git a/package/opt/hassbian/suites/hassbian.sh b/package/opt/hassbian/suites/hassbian.sh index 7fb131bd..b09f6c0f 100644 --- a/package/opt/hassbian/suites/hassbian.sh +++ b/package/opt/hassbian/suites/hassbian.sh @@ -13,9 +13,6 @@ function hassbian-show-copyright-info { } function hassbian-upgrade-package { -hassbian-show-short-info -hassbian-show-copyright-info - echo "Updating package list" sudo apt update diff --git a/package/opt/hassbian/suites/homeassistant-dev.sh b/package/opt/hassbian/suites/homeassistant-dev.sh index 95bba5d5..7a4619d6 100644 --- a/package/opt/hassbian/suites/homeassistant-dev.sh +++ b/package/opt/hassbian/suites/homeassistant-dev.sh @@ -12,9 +12,6 @@ function homeassistant-dev-show-copyright-info { } function homeassistant-dev-install-package { -homeassistant-dev-show-short-info -homeassistant-dev-show-copyright-info - echo "Stopping Home Assistant" systemctl stop home-assistant@homeassistant.service sync @@ -54,8 +51,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/homeassistant.sh b/package/opt/hassbian/suites/homeassistant.sh index 9867febf..7a62d139 100644 --- a/package/opt/hassbian/suites/homeassistant.sh +++ b/package/opt/hassbian/suites/homeassistant.sh @@ -12,9 +12,6 @@ function homeassistant-show-copyright-info { } function homeassistant-install-package { -homeassistant-show-short-info -homeassistant-show-copyright-info - echo "Changing to the homeassistant user" sudo -u homeassistant -H /bin/bash << EOF @@ -57,8 +54,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi @@ -66,9 +61,6 @@ return 0 } function homeassistant-upgrade-package { -homeassistant-show-short-info -homeassistant-show-copyright-info - echo "Checking current version" pypiversion=$(curl -s https://pypi.python.org/pypi/homeassistant/json | grep '"version":' | awk -F'"' '{print $4}') @@ -112,8 +104,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mUpgrade failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/homebridge.sh b/package/opt/hassbian/suites/homebridge.sh index ffb76445..4d6b3fa5 100644 --- a/package/opt/hassbian/suites/homebridge.sh +++ b/package/opt/hassbian/suites/homebridge.sh @@ -14,9 +14,6 @@ function homebridge-show-copyright-info { } function homebridge-install-package { -homebridge-show-long-info -homebridge-show-copyright-info - if [ "$ACCEPT" == "true" ]; then HOMEASSISTANT_URL="http://127.0.0.1:8123" HOMEASSISTANT_PASSWORD="" @@ -141,8 +138,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/hue.sh b/package/opt/hassbian/suites/hue.sh index 41d3b525..7842009c 100644 --- a/package/opt/hassbian/suites/hue.sh +++ b/package/opt/hassbian/suites/hue.sh @@ -14,9 +14,6 @@ function hue-show-copyright-info { } function hue-install-package { -hue-show-short-info -hue-show-copyright-info - echo "Setting permissions for Python." PYTHONVER=$(echo /usr/lib/*python* | awk -F/ '{print $NF}') sudo setcap 'cap_net_bind_service=+ep' /usr/bin/"$PYTHONVER" @@ -32,8 +29,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/libcec.sh b/package/opt/hassbian/suites/libcec.sh index d1a81737..4038eadf 100644 --- a/package/opt/hassbian/suites/libcec.sh +++ b/package/opt/hassbian/suites/libcec.sh @@ -13,9 +13,6 @@ function libcec-show-copyright-info { } function libcec-install-package { -libcec-show-short-info -libcec-show-copyright-info - echo "Running apt-get preparation" apt-get update apt-get install -y cmake libudev-dev libxrandr-dev swig @@ -82,8 +79,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/mariadb.sh b/package/opt/hassbian/suites/mariadb.sh index 499851b8..561fa71c 100644 --- a/package/opt/hassbian/suites/mariadb.sh +++ b/package/opt/hassbian/suites/mariadb.sh @@ -13,9 +13,6 @@ function mariadb-show-copyright-info { } function mariadb-install-package { -mariadb-show-short-info -mariadb-show-copyright-info - echo "Running apt-get preparation" apt-get update apt-get install -y mariadb-server libmariadbclient-dev @@ -47,8 +44,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/mosquitto.sh b/package/opt/hassbian/suites/mosquitto.sh index 3ed950ad..20bb728f 100644 --- a/package/opt/hassbian/suites/mosquitto.sh +++ b/package/opt/hassbian/suites/mosquitto.sh @@ -14,9 +14,6 @@ function mosquitto-show-copyright-info { } function mosquitto-install-package { -mosquitto-show-short-info -mosquitto-show-copyright-info - if [ "$ACCEPT" == "true" ]; then mqtt_username=pi mqtt_password=raspberry @@ -102,8 +99,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/mssql.sh b/package/opt/hassbian/suites/mssql.sh index e6c49144..af02ef4a 100644 --- a/package/opt/hassbian/suites/mssql.sh +++ b/package/opt/hassbian/suites/mssql.sh @@ -13,9 +13,6 @@ function mssql-show-copyright-info { } function mssql-install-package { -mssql-show-short-info -mssql-show-copyright-info - echo "Running apt-get preparation" apt-get update apt-get install -y freetds-dev @@ -52,8 +49,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/mysql.sh b/package/opt/hassbian/suites/mysql.sh index ecdd4eec..844aa51f 100644 --- a/package/opt/hassbian/suites/mysql.sh +++ b/package/opt/hassbian/suites/mysql.sh @@ -13,9 +13,6 @@ function mysql-show-copyright-info { } function mysql-install-package { -mysql-show-short-info -mysql-show-copyright-info - echo "Running apt-get preparation" apt-get update apt-get install -y default-libmysqlclient-dev libssl-dev @@ -50,8 +47,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/postgresql.sh b/package/opt/hassbian/suites/postgresql.sh index 36d6267e..5ad5d1ba 100644 --- a/package/opt/hassbian/suites/postgresql.sh +++ b/package/opt/hassbian/suites/postgresql.sh @@ -13,9 +13,6 @@ function postgresql-show-copyright-info { } function postgresql-install-package { -postgresql-show-short-info -postgresql-show-copyright-info - echo "Running apt-get preparation" apt-get update apt-get install -y postgresql-server-dev-9.6 postgresql-9.6 @@ -47,8 +44,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/python.sh b/package/opt/hassbian/suites/python.sh index 31f3708c..2fb7c267 100644 --- a/package/opt/hassbian/suites/python.sh +++ b/package/opt/hassbian/suites/python.sh @@ -12,9 +12,6 @@ function python-show-copyright-info { } function python-upgrade-package { -python-show-short-info -python-show-copyright-info - if [ "$FORCE" == "" ]; then printf "\\n\\n" echo "This script will change a lot on your pi." @@ -112,7 +109,6 @@ else rm -R /srv/homeassistant mv /srv/homeassistant_"$currentpython" /srv/homeassistant systemctl start home-assistant@homeassistant.service - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/razberry.sh b/package/opt/hassbian/suites/razberry.sh index b9b977a6..aaf29e6e 100644 --- a/package/opt/hassbian/suites/razberry.sh +++ b/package/opt/hassbian/suites/razberry.sh @@ -16,9 +16,6 @@ function razberry-show-copyright-info { } function razberry-install-package { -razberry-show-short-info -razberry-show-copyright-info - echo "Checking for version of Raspberry Pi" RPI_BOARD_REVISION=$(grep Revision /proc/cpuinfo | cut -d: -f2 | tr -d " ") if [[ $RPI_BOARD_REVISION == "a02082" || $RPI_BOARD_REVISION == "a22082" ]] diff --git a/package/opt/hassbian/suites/samba.sh b/package/opt/hassbian/suites/samba.sh index da5f4970..00e59777 100644 --- a/package/opt/hassbian/suites/samba.sh +++ b/package/opt/hassbian/suites/samba.sh @@ -14,9 +14,6 @@ function samba-show-copyright-info { } function samba-install-package { -samba-show-short-info -samba-show-copyright-info - echo "Running apt-get preparation" apt-get update apt-get install -y samba @@ -60,8 +57,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/tradfri.sh b/package/opt/hassbian/suites/tradfri.sh index a63a48a2..78dfcb59 100644 --- a/package/opt/hassbian/suites/tradfri.sh +++ b/package/opt/hassbian/suites/tradfri.sh @@ -13,9 +13,6 @@ function tradfri-show-copyright-info { } function tradfri-install-package { -tradfri-show-short-info -tradfri-show-copyright-info - echo "Running apt-get preparation" apt-get update apt-get install -y dh-autoreconf @@ -50,8 +47,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/opt/hassbian/suites/webterminal.sh b/package/opt/hassbian/suites/webterminal.sh index 7de0411c..95d51aa9 100644 --- a/package/opt/hassbian/suites/webterminal.sh +++ b/package/opt/hassbian/suites/webterminal.sh @@ -36,8 +36,6 @@ if [ ! -z "${validation}" ]; then else echo echo -e "\\e[31mInstallation failed..." - echo -e "\\e[31mAborting..." - echo -e "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord." echo return 1 fi diff --git a/package/usr/local/bin/hassbian-config b/package/usr/local/bin/hassbian-config index 723a1633..0827688d 100755 --- a/package/usr/local/bin/hassbian-config +++ b/package/usr/local/bin/hassbian-config @@ -22,8 +22,8 @@ function help { printf "%-8s\\t%s\\n" " share-log" "Generates an hastebin link of the last operation" printf "\\n" printf "available optional [options]:\\n" - printf "%-10s\\t%s\\n" " -y | --accept" "Accept defaults on scripts that allow this" - printf "%-10s\\t%s\\n" " -f | --force" "Force run an script, this is useful if you need to reinstall a package" + printf "%-10s\\t%s\\n" " -Y | --accept" "Accept defaults on scripts that allow this" + printf "%-10s\\t%s\\n" " -F | --force" "Force run an script, this is useful if you need to reinstall a package" printf "%-10s\\t%s\\n" " -D | --debug" "This will output every comand to the console." printf "\\n" printf "other [command] available:\\n" @@ -45,7 +45,6 @@ function get-all-suite-installers { return 0 } - function show-suites { printf "This is a list over all suites in hassbian-config\\n" printf "If a \\e[1msuite\\e[0m has \\e[32mgreen color\\e[0m in the name, you have already installed it.\\n" @@ -114,7 +113,6 @@ function share-log { return 0 fi else - echo "This will put the output from your last operation on hastebin." echo "This could include sensitive information." echo "If you are unsure about what it contains, you can run 'hassbian-config log' to check." @@ -135,65 +133,47 @@ function share-log { return 0 } -function install-suite { - if [ "$(id -u)" != "0" ]; then - echo "This script must be run with sudo. Use 'sudo hassbian-config install $1'" 1>&2 - return 1 - fi - if [ "$DEBUG" == "true" ]; then - set -x - fi - if [ ! -f $SUITE_CONTROL_DIR/"$1" ]; then - touch $SUITE_CONTROL_DIR/"$1" - echo "SCRIPTSTATE=uninstalled" > $SUITE_CONTROL_DIR/"$1" - fi - SUITESTATE=$(grep "SCRIPTSTATE" $SUITE_CONTROL_DIR/"$1" | awk -F'=' '{print $2}') - source $SUITE_INSTALL_DIR/"$1".sh - if [ "$FORCE" == "true" ]; then - "$1"-install-package | tee $LOGFILE - sed -i -- 's/SCRIPTSTATE='"$SUITESTATE"'/SCRIPTSTATE=installed/g' $SUITE_CONTROL_DIR/"$1" - elif [ "$SUITESTATE" == "installed" ]; then - echo "$1 is already installed, trying upgrade script..." - UPGRADE=$(grep "$1"-upgrade-package $SUITE_INSTALL_DIR/"$1".sh) - if [ "$UPGRADE" == "" ]; then - echo "Upgrade script is not available..." - echo "You can force run the install script like this:" - echo "sudo hassbian-config -f install $1" - return 0 - fi - "$1"-upgrade-package | tee $LOGFILE - sed -i -- 's/SCRIPTSTATE='"$SUITESTATE"'/SCRIPTSTATE=installed/g' $SUITE_CONTROL_DIR/"$1" +function run-suite { #This is the function the actually run install/upgrade. + source "$SUITE_INSTALL_DIR/$2".sh #Sourcing the script file. + "$2"-show-short-info && "$2"-show-copyright-info && printf "\\n" #Prints suite-show-short-info & suite-show-copyright-info to console. + if [ "$DEBUG" == "true" ]; then set -x; fi #Activating debug if --debug is used. + "$2"-"$1"-package #Running the script function install/upgrade SUITE. + RETURN=("$?") # Return value after script execution. + if [ "$DEBUG" == "true" ]; then set +x; fi #Deactivating debug if --debug is used. + if [ "$RETURN" == "0" ]; then STATE="installed"; else printf "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord.\\n" && STATE="failed"; fi #Set suite state to installed if 0 is returned, failed otherwise. + echo "SCRIPTSTATE=$STATE" > "$SUITE_CONTROL_DIR/$2" #Setting status in control file. + return 0 +} + +function install-suite { #This function do checks if we can/want to install. + check-permission + INSTALL=$(grep "$1"-install-package "$SUITE_INSTALL_DIR/$1".sh) #Checking if suite has install function. + SUITESTATE=$(if [ -f "$SUITE_CONTROL_DIR/$1" ]; then grep "SCRIPTSTATE" "$SUITE_CONTROL_DIR/$1" | awk -F'=' '{print $2}'; else echo ""; fi) #Checking current suite state. + if [ "$FORCE" == "true" ]; then #Go straight to run-suite if --force is used. + run-suite install "$1" | tee "$LOGFILE" #Run if -F/-f/--force is used. + elif [ "$SUITESTATE" == "installed" ] || [ "$INSTALL" == "" ]; then #Try redirect to upgrade script if already installed. + printf "%s is already installed or install script is not available...\\n" "$1" + UPGRADE=$(grep "$1"-upgrade-package "$SUITE_INSTALL_DIR/$1".sh) + if [ "$UPGRADE" == "" ]; then + printf "Upgrade script is not available...\\n\\nYou can force run the install script like this:\\nsudo hassbian-config install %s --force\\n" "$1" + return 0 + fi + printf "upgrade script for %s found, running that...\\n\\n" "$1" + run-suite upgrade "$1" | tee "$LOGFILE" #Redirects to upgrade script. else - source $SUITE_INSTALL_DIR/"$1".sh - "$1"-install-package | tee $LOGFILE - sed -i -- 's/SCRIPTSTATE='"$SUITESTATE"'/SCRIPTSTATE=installed/g' $SUITE_CONTROL_DIR/"$1" - fi - if [ "$DEBUG" == "true" ]; then - set +x + run-suite install "$1" | tee "$LOGFILE" #This is the default run, if no options is used. fi return 0 } -function upgrade-suite { - if [ "$(id -u)" != "0" ]; then - echo "This script must be run with sudo. Use 'sudo hassbian-config upgrade $1'" 1>&2 - return 1 - fi - if [ "$DEBUG" == "true" ]; then - set -x - fi - UPGRADE=$(grep "$1"-upgrade-package $SUITE_INSTALL_DIR/"$1".sh) - if [ "$UPGRADE" == "" ]; then - echo "Upgrade script is not available..." - echo "You can force run the install script like this:" - echo "sudo hassbian-config -f install $1" - fi +function upgrade-suite { #This function do checks if we can to upgrade. check-permission - source $SUITE_INSTALL_DIR/"$1".sh - "$1"-upgrade-package | tee $LOGFILE - if [ "$DEBUG" == "true" ]; then - set +x + UPGRADE=$(grep "$1"-upgrade-package "$SUITE_INSTALL_DIR/$1".sh) #Checking if suite has upgrade function. + if [ "$UPGRADE" == "" ]; then + printf "Upgrade script is not available...\\n\\nYou can force run the install script like this:\\nsudo hassbian-config install %s --force\\n" "$1" + return 0 fi + run-suite upgrade "$1" | tee "$LOGFILE" #This is the default run. return 0 } @@ -230,13 +210,12 @@ do COMMAND=$1 SUITE=$2 - case $COMMAND in - "-f"|"--force") + "-F"|"-f"|"--force") FORCE="true" shift # past argument ;; - "-y"|"--accept") + "-Y"|"-y"|"--accept") ACCEPT="true" shift # past argument ;; @@ -304,6 +283,6 @@ esac done if [ "$RUN" != "" ]; then $RUN - exit + exit 0 fi exit 0