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

Update upgrade_home-assistant.sh #71

Merged
merged 1 commit into from
Jan 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line has the more descriptive error message, but since its in the pipe of the EOF i did it here otherwise you loose the string value.

source /srv/homeassistant/bin/activate
pip3 show homeassistant
EOF

if [[ $? == 1 ]]; then
echo "Stopping upgrade"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more descriptive error message and this is good to merge

exit 1
fi

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