LibrePortal/scripts/update/check_update.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

127 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
checkUpdates()
{
local param1="$1"
sourceCheckFiles;
# Skip Git updates if installation mode is local or Git updates are disabled
if [[ $CFG_INSTALL_MODE == "local" ]]; then
isNotice "Local installation detected - Git updates are disabled."
if [[ $init_run_flag == "true" ]]; then
startLoad;
fi
return
fi
if [[ $CFG_GIT_UPDATES == "true" ]]; then
isHeader "Checking for Updates"
# Ask user if they want to check for updates
while true; do
if [[ $CFG_GIT_UPDATES == "false" ]]; then
isQuestion "Would you like to check for updates? (y/n): "
read -p "" check_updates_choice
elif [[ $CFG_GIT_UPDATES == "true" ]]; then
check_updates_choice=y
fi
case $check_updates_choice in
[yY])
# DNS Query Test with Quad9
isNotice "Testing internet DNS, please wait..."
if command -v dig >/dev/null 2>&1; then
dns_check_cmd="dig +short +time=3 +tries=1 @9.9.9.9 quad9.net"
elif command -v getent >/dev/null 2>&1; then
dns_check_cmd="getent hosts quad9.net"
else
dns_check_cmd="ping -c 1 -W 3 9.9.9.9"
fi
if $dns_check_cmd >/dev/null 2>&1; then
isSuccessful "Internet DNS is working."
else
isError "Internet DNS is not working."
exit 1
fi
cd "$script_dir" || { isError " Cannot navigate to the repository directory"; exit 1; }
# Update Git to ignore changes in file permissions
sudo -u $sudo_user_name git config core.fileMode false
# Update Git with email address
sudo -u $sudo_user_name git config --global user.name "$CFG_INSTALL_NAME"
sudo -u $sudo_user_name git config --global user.email "noreply@${CFG_INSTALL_NAME,,}.libreportal.local"
# Check if there are edited (modified) files
if git status --porcelain | grep -q "^ M"; then
isNotice "There are uncommitted changes in the repository."
while true; do
isQuestion "Do you want to discard these changes and update the repository? (y/n): "
read -p "" customupdatesfound
case $customupdatesfound in
[yY])
remove_changes=true
gitCheckForUpdate;
gitCheckConfigs;
fixPermissionsBeforeStart "" "update";
sourceCheckFiles;
if [[ $init_run_flag == "true" ]]; then
isSuccessful "Starting/Restarting LibrePortal"
startLoad;
fi
;;
[nN])
isNotice "Custom changes will be kept, continuing..."
remove_changes=false
gitCheckForUpdate;
gitCheckConfigs;
fixPermissionsBeforeStart "" "update";
sourceCheckFiles;
if [[ $init_run_flag == "true" ]]; then
startLoad;
fi
;;
*)
isNotice "Please provide a valid input (y or n)."
;;
esac
done
fi
# Make sure an update happens after custom code check
if [[ $update_done != "true" ]]; then
gitCheckForUpdate;
gitCheckConfigs;
fixPermissionsBeforeStart "" "update";
sourceCheckFiles;
if [[ $init_run_flag == "true" ]]; then
isSuccessful "Starting/Restarting LibrePortal"
startLoad;
fi
fi
;;
[nN])
echo ""
isNotice "Skipping update check. Starting application..."
if [[ $init_run_flag == "true" ]]; then
startLoad;
fi
;;
*)
isNotice "Please enter y or n."
;;
esac
done
else
if [[ $init_run_flag == "true" ]]; then
startLoad;
fi
fi
}