diff --git a/docs/homeassistant.md b/docs/homeassistant.md index e80f61ec..691c3d90 100644 --- a/docs/homeassistant.md +++ b/docs/homeassistant.md @@ -23,6 +23,11 @@ $ sudo hassbian-config upgrade homeassistant --beta $ sudo hassbian-config upgrade homeassistant --dev ``` +## Upgrade to to a spesific version +``` +$ sudo hassbian-config upgrade homeassistant=0.65.6 +``` + ## Additional info Running as: `homeassistant` Configuration dir: `/home/homeassistant/.homeassistant/` diff --git a/package/opt/hassbian/suites/homeassistant.sh b/package/opt/hassbian/suites/homeassistant.sh index 0c119839..0e5f50da 100644 --- a/package/opt/hassbian/suites/homeassistant.sh +++ b/package/opt/hassbian/suites/homeassistant.sh @@ -77,10 +77,19 @@ else echo "Checking current version" if [ "$BETA" == "true" ]; then newversion=$(curl -s https://pypi.python.org/pypi/homeassistant/json | grep '"version":' | awk -F'"' '{print $4}') + elif [ ! -z "${VERSIONNUMBER}" ]; then + verify=$(curl -s https://pypi.python.org/pypi/homeassistant/"$VERSIONNUMBER"/json) + if [[ "$verify" = *"Not Found"* ]]; then + echo "Version $VERSIONNUMBER not found..." + echo "Exiting..." + return 0 + else + newversion="$VERSIONNUMBER" + fi else newversion=$(curl -s https://api.github.com/repos/home-assistant/home-assistant/releases/latest | grep tag_name | awk -F'"' '{print $4}') fi - sudo -u homeassistant -H /bin/bash << EOF | grep Version | awk '{print $2}'|while read -r version; do if [[ "${newversion}" == "${version}" ]]; then echo "You already have the latest version: $version";exit 1;fi;done + sudo -u homeassistant -H /bin/bash << EOF | grep Version | awk '{print $2}'|while read -r version; do if [[ "${newversion}" == "${version}" ]]; then echo "You already have version: $version";exit 1;fi;done source /srv/homeassistant/bin/activate pip3 show homeassistant EOF @@ -99,7 +108,7 @@ sudo -u homeassistant -H /bin/bash << EOF echo "Changing to Home Assistant venv" source /srv/homeassistant/bin/activate -echo "Installing latest version of Home Assistant" +echo "Upgrading Home Assistant" pip3 install --upgrade setuptools wheel if [ "$DEV" == "true" ]; then pip3 install git+https://github.com/home-assistant/home-assistant@dev diff --git a/package/usr/local/bin/hassbian-config b/package/usr/local/bin/hassbian-config index 45378e75..5b8be7bb 100755 --- a/package/usr/local/bin/hassbian-config +++ b/package/usr/local/bin/hassbian-config @@ -256,6 +256,12 @@ case $COMMAND in shift # past value ;; "upgrade") + if [[ "$SUITE" = *"="* ]]; then + VERSIONNUMBER=$(echo "$SUITE" | awk -F'=' '{print $2}') + SUITE=$(echo "$SUITE" | awk -F'=' '{print $1}') + else + VERSIONNUMBER="" + fi if verify-suite "$SUITE"; then RUN="upgrade-suite $SUITE" else