mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-17 05:04:21 +01:00
git_pull 7.1 (#514)
* continue script when internet connection lost once (#511) * continue script when internet connection lost once changed some "exit 1" to "return 1" in function git-synchronize. By this, the script should not terminate when there's no internet connection during a repeat check. I left "exit 1" for the initial, critical and config topics => script should terminate here I think. * improved style of "if" statement * 7.1 Fix repeat option (#511) * 7.1 Fix repeat option (#511) * git_pull: Enhance restart_ignore to support whole directories (#513) * git_pull: Enhance restart_ignore to support whole directories * Missing double-quote
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 7.1
|
||||||
|
- Enhance restart_ignore to support whole directories
|
||||||
|
- Fix repeat option: don't terminate if internet connection unavailable during a check
|
||||||
|
|
||||||
## 7.0
|
## 7.0
|
||||||
- Update Hass.io CLI to 2.0.1
|
- Update Hass.io CLI to 2.0.1
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Git pull",
|
"name": "Git pull",
|
||||||
"version": "7.0",
|
"version": "7.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/",
|
||||||
|
|||||||
@@ -126,13 +126,13 @@ function git-synchronize {
|
|||||||
|
|
||||||
# Always do a fetch to update repos
|
# Always do a fetch to update repos
|
||||||
echo "[Info] Start git fetch..."
|
echo "[Info] Start git fetch..."
|
||||||
git fetch "$GIT_REMOTE" || { echo "[Error] Git fetch failed"; exit 1; }
|
git fetch "$GIT_REMOTE" || { echo "[Error] Git fetch failed"; return 1; }
|
||||||
|
|
||||||
# Prune if configured
|
# Prune if configured
|
||||||
if [ "$GIT_PRUNE" == "true" ]
|
if [ "$GIT_PRUNE" == "true" ]
|
||||||
then
|
then
|
||||||
echo "[Info] Start git prune..."
|
echo "[Info] Start git prune..."
|
||||||
git prune || { echo "[Error] Git prune failed"; exit 1; }
|
git prune || { echo "[Error] Git prune failed"; return 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Do we switch branches?
|
# Do we switch branches?
|
||||||
@@ -149,11 +149,11 @@ function git-synchronize {
|
|||||||
case "$GIT_COMMAND" in
|
case "$GIT_COMMAND" in
|
||||||
pull)
|
pull)
|
||||||
echo "[Info] Start git pull..."
|
echo "[Info] Start git pull..."
|
||||||
git pull || { echo "[Error] Git pull failed"; exit 1; }
|
git pull || { echo "[Error] Git pull failed"; return 1; }
|
||||||
;;
|
;;
|
||||||
reset)
|
reset)
|
||||||
echo "[Info] Start git reset..."
|
echo "[Info] Start git reset..."
|
||||||
git reset --hard "$GIT_REMOTE"/"$GIT_CURRENT_BRANCH" || { echo "[Error] Git reset failed"; exit 1; }
|
git reset --hard "$GIT_REMOTE"/"$GIT_CURRENT_BRANCH" || { echo "[Error] Git reset failed"; return 1; }
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "[Error] Git command is not set correctly. Should be either 'reset' or 'pull'"
|
echo "[Error] Git command is not set correctly. Should be either 'reset' or 'pull'"
|
||||||
@@ -182,11 +182,21 @@ function validate-config {
|
|||||||
CHANGED_FILES=$(git diff "$OLD_COMMIT" "$NEW_COMMIT" --name-only)
|
CHANGED_FILES=$(git diff "$OLD_COMMIT" "$NEW_COMMIT" --name-only)
|
||||||
echo "Changed Files: $CHANGED_FILES"
|
echo "Changed Files: $CHANGED_FILES"
|
||||||
if [ -n "$RESTART_IGNORED_FILES" ]; then
|
if [ -n "$RESTART_IGNORED_FILES" ]; then
|
||||||
for file in $CHANGED_FILES; do
|
for changed_file in $CHANGED_FILES; do
|
||||||
echo "$RESTART_IGNORED_FILES" | grep -qw "${file}"
|
restart_required_file=""
|
||||||
if [ $? -eq 1 ] ; then
|
for restart_ignored_file in $RESTART_IGNORED_FILES; do
|
||||||
|
if [ -z "${restart_ignored_file#*/}" ]; then
|
||||||
|
# file to be ignored is a whole dir
|
||||||
|
restart_required_file=$(echo "${changed_file}" | grep "^${restart_ignored_file}")
|
||||||
|
else
|
||||||
|
restart_required_file=$(echo "${changed_file}" | grep "^${restart_ignored_file}$")
|
||||||
|
fi
|
||||||
|
# break on first match
|
||||||
|
if [ -n "$restart_required_file" ]; then break ; fi
|
||||||
|
done
|
||||||
|
if [ -z "$restart_required_file" ]; then
|
||||||
DO_RESTART="true"
|
DO_RESTART="true"
|
||||||
echo "[Info] Detected Restart Required File $file"
|
echo "[Info] Detected restart-required file: $changed_file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
@@ -217,8 +227,9 @@ cd /config || { echo "[Error] Failed to cd into /config"; exit 1; }
|
|||||||
while true; do
|
while true; do
|
||||||
check-ssh-key
|
check-ssh-key
|
||||||
setup-user-password
|
setup-user-password
|
||||||
git-synchronize
|
if git-synchronize ; then
|
||||||
validate-config
|
validate-config
|
||||||
|
fi
|
||||||
# do we repeat?
|
# do we repeat?
|
||||||
if [ ! "$REPEAT_ACTIVE" == "true" ]; then
|
if [ ! "$REPEAT_ACTIVE" == "true" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user