LibrePortal/scripts/update/git/checks/update_git_check.sh
librelad 875a60f90f LibrePortal v0.1.0 — initial release
A free, open, self-hosted app platform (GNU AGPLv3): one-click app deploys,
Traefik reverse proxy with automatic SSL, rootless Docker support, gluetun
VPN routing, and a web dashboard to manage it all.

Free & open forever to self-host; optional paid hosted services fund it.
See PROMISE.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-21 20:37:54 +01:00

52 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
gitCheckForUpdate()
{
# Check the status of the local repository
cd "$script_dir"
# If Git login is required, get credentials first
if [[ $CFG_INSTALL_MODE == "git" ]]; then
while true; do
gitCheckGitDetails;
# Test the credentials by trying to fetch
if sudo -u $sudo_user_name git -c "credential.helper=" -c "credential.helper=!f() { echo username=$CFG_GIT_USER; echo password=$CFG_GIT_KEY; }; f" fetch > /dev/null 2>&1; then
isSuccessful "Git authentication successful"
break
else
runReinstall;
fi
done
fi
# Proceed with the fetch using the credentials if they were provided
if [[ $CFG_INSTALL_MODE == "git" ]]; then
sudo -u $sudo_user_name git -c "credential.helper=" -c "credential.helper=!f() { echo username=$CFG_GIT_USER; echo password=$CFG_GIT_KEY; }; f" fetch > /dev/null 2>&1
else
sudo -u $sudo_user_name git fetch > /dev/null 2>&1
fi
if sudo -u $sudo_user_name git status | grep -q "Your branch is ahead"; then
isSuccessful "The repository is up to date...continuing..."
elif sudo -u $sudo_user_name git status | grep -q "Your branch is up to date with"; then
isSuccessful "The repository is up to date...continuing..."
else
isNotice "Updates found."
if [[ $CFG_GIT_AUTO_UPDATES == "true" ]]; then
gitFolderResetAndBackup;
else
while true; do
isQuestion "Do you want to update LibrePortal now? (y/n): "
read -rp "" acceptupdates
if [[ "$acceptupdates" =~ ^[yYnN]$ ]]; then
break
fi
isNotice "Please provide a valid input (y/n)."
done
if [[ $acceptupdates == [yY] ]]; then
gitFolderResetAndBackup;
fi
fi
fi
}