- ajout d'une mise à jour du script au démarage

This commit is contained in:
Frogg 2026-05-11 20:15:22 +02:00
parent c6d479b423
commit 7ad617381b
2 changed files with 30 additions and 1 deletions

View File

@ -9,6 +9,7 @@ WELCOME_SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "${WELCOME_SCRIPT_PATH}/func/common.sh"
. "${WELCOME_SCRIPT_PATH}/func/message_display.sh"
. "${WELCOME_SCRIPT_PATH}/func/system_info.sh"
. "${WELCOME_SCRIPT_PATH}/func/git.sh"
#endregion
##################
@ -57,7 +58,7 @@ display_dashboard
### UPDATE SCRIPT ###
######################
git -C "${WELCOME_SCRIPT_PATH}" fetch origin && git -C "${WELCOME_SCRIPT_PATH}" --hard origin/$(git -C "${WELCOME_SCRIPT_PATH}" --show-current)
script_update
################
### INSTALL ###

View File

@ -58,6 +58,34 @@ giturl(){
gitssl() {
local choice="${1:-true}"
git config --global http.sslVerify "$choice"
}
script_update() {
local BRANCH LOCAL REMOTE
cd "$WELCOME_SCRIPT_PATH" || exit 2
git fetch origin
if [ $? -ne 0 ]; then
msg_error "Erreur lors du Fetch"
exit 3
fi
BRANCH=$(git rev-parse --abbrev-ref HEAD)
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/"$BRANCH")
if [ "$LOCAL" = "$REMOTE" ]; then
exit 0
fi
# update
git reset --hard origin/"$BRANCH"
if [ $? -eq 0 ]; then
msg_success "Les script de welcome a été mis à jour"
exit 1
else
msg_error "Erreur lors de la mise à jour du script"
exit 4
fi
}