This repository has been archived by the owner on Oct 30, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update upgrade_home-assistant.sh (#71)
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
|