Skip to content

Commit

Permalink
Autoupdate (#8)
Browse files Browse the repository at this point in the history
New installer compatible with autoupdating
  • Loading branch information
maouw authored Oct 25, 2023
1 parent 4c9f6f3 commit cd8624a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions hyakvnc
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,15 @@ function hyakvnc_check_updates {

local cur_branch
cur_branch="$(git -C "${HYAKVNC_REPO_DIR}" branch --show-current 2>&1 || true)"
[[ -z "${cur_branch}" ]] && {
[[ -z "${cur_branch}" ]] && {
log ERROR "Couldn't determine current branch. Can't pull updates."
return 1
}

[[ "${cur_branch}" != "main" ]] && {
log WARN "Current branch is ${cur_branch}, not main. Be warned that this branch may not be up to date."
return 1
}

local cur_date
cur_date="$(git -C "${HYAKVNC_REPO_DIR}" show -s --format=%cd --date=human-local "${cur_branch}" || echo ???)"
log INFO "The installed version was published ${cur_date}"
Expand Down Expand Up @@ -1537,9 +1536,18 @@ EOF

# cmd_update()
function cmd_update {
hyakvnc_check_updates || return 1
hyakvnc_pull_updates || return 1
return 0
log INFO "Checking for updates..."
if ! hyakvnc_check_updates; then
log INFO "No updates to apply."
else
log INFO "Applying updates..."
if ! hyakvnc_pull_updates; then
log WARN "No updates applied."
exit 1
else
log INFO "Update complete."
fi
fi
}

# ## COMMAND: config
Expand Down

0 comments on commit cd8624a

Please sign in to comment.