mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-18 13:44:20 +01:00
Git_pull check config before restart (#174)
* Update run.sh * Update config.json * report invalid config
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Git pull",
|
"name": "Git pull",
|
||||||
"version": "1.0",
|
"version": "1.1",
|
||||||
"slug": "git_pull",
|
"slug": "git_pull",
|
||||||
"description": "Simple git pull to update the local configuration",
|
"description": "Simple git pull to update the local configuration",
|
||||||
"url": "https://home-assistant.io/addons/git_pull/",
|
"url": "https://home-assistant.io/addons/git_pull/",
|
||||||
|
|||||||
@@ -26,12 +26,24 @@ while true; do
|
|||||||
echo "[Info] pull from $REPOSITORY"
|
echo "[Info] pull from $REPOSITORY"
|
||||||
git pull 2&> /dev/null || true
|
git pull 2&> /dev/null || true
|
||||||
|
|
||||||
|
# Enable autorestart of homeassistant
|
||||||
if [ "$AUTO_RESTART" == "true" ]; then
|
if [ "$AUTO_RESTART" == "true" ]; then
|
||||||
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
|
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
|
||||||
|
|
||||||
|
# Files have changed & check config
|
||||||
if [ ! -z "$changed_files" ]; then
|
if [ ! -z "$changed_files" ]; then
|
||||||
echo "[Info] files changed, restart Home-Assistant"
|
echo "[Info] check Home-Assistant config"
|
||||||
curl -s http://hassio/homeassistant/restart 2&> /dev/null || true
|
if api_ret="$(curl -s -X POST http://hassio/homeassistant/check)"; then
|
||||||
|
result="$(echo "$api_ret" | jq --raw-output ".result")"
|
||||||
|
|
||||||
|
# Config is valid
|
||||||
|
if [ "$result" != "error" ]; then
|
||||||
|
echo "[Info] restart Home-Assistant"
|
||||||
|
curl -s -X POST http://hassio/homeassistant/restart 2&> /dev/null || true
|
||||||
|
else
|
||||||
|
echo "[Error] invalid config!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user