Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Commit

Permalink
Update upgrade_home-assistant.sh (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
riemers authored and Landrash committed Jan 27, 2018
1 parent dbfe175 commit 36cf324
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions package/opt/hassbian/suites/upgrade_home-assistant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ function home-assistant-upgrade-package {
home-assistant-show-short-info
home-assistant-show-copyright-info

echo "Checking current version"

function jsonValue() {
KEY=$1
num=$2
awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'$KEY'\042/){print $(i+1)}}}' | tr -d '"' | sed -n ${num}p
}

versiongit=$(curl -s -X GET https://api.github.com/repos/home-assistant/home-assistant/releases/latest | jsonValue tag_name 1|sed -e 's/^[[:space:]]*//')

sudo -u homeassistant -H /bin/bash << EOF | grep Version|awk '{print $2'}|while read version; do if [[ ${versiongit} == ${version} ]]; then echo "You already have the latest version: $version";exit 1;fi;done
source /srv/homeassistant/bin/activate
pip3 show homeassistant
EOF

if [[ $? == 1 ]]; then
echo "Stopping upgrade"
exit 1
fi

echo "Stopping Home Assistant"
systemctl stop [email protected]
Expand Down

0 comments on commit 36cf324

Please sign in to comment.