From 7d295eb836a14e675e62b9044489a2e01d63fd3d Mon Sep 17 00:00:00 2001 From: CosmicScale Date: Tue, 28 Jan 2025 16:42:42 +0000 Subject: [PATCH] Skip update check gracefully if not a Git repository --- 01-Setup.sh | 37 +++++++++++++++++++++---------------- 02-PSBBN-Installer.sh | 39 ++++++++++++++++++++++----------------- 03-Game-Installer.sh | 37 +++++++++++++++++++++---------------- 3 files changed, 64 insertions(+), 49 deletions(-) diff --git a/01-Setup.sh b/01-Setup.sh index 9c3ec87..9c34a16 100755 --- a/01-Setup.sh +++ b/01-Setup.sh @@ -13,23 +13,28 @@ if [[ ! -f "${TOOLKIT_PATH}/helper/PFS Shell.elf" || ! -f "${TOOLKIT_PATH}/helpe exit 1 fi -# Fetch updates from the remote -git fetch > /dev/null 2>&1 - -# Check the current status of the repository -LOCAL=$(git rev-parse @) -REMOTE=$(git rev-parse @{u}) -BASE=$(git merge-base @ @{u}) - -if [ "$LOCAL" = "$REMOTE" ]; then - echo "The repository is up to date." +# Check if the current directory is a Git repository +if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + echo "This is not a Git repository. Skipping update check." else - echo "Downloading update..." - git reset --hard && git pull --force > /dev/null 2>&1 - echo - echo "The script has been updated to the latest version." - read -p "Press any key to exit, then run the script again." - exit 0 + # Fetch updates from the remote + git fetch > /dev/null 2>&1 + + # Check the current status of the repository + LOCAL=$(git rev-parse @) + REMOTE=$(git rev-parse @{u}) + BASE=$(git merge-base @ @{u}) + + if [ "$LOCAL" = "$REMOTE" ]; then + echo "The repository is up to date." + else + echo "Downloading update..." + git reset --hard && git pull --force > /dev/null 2>&1 + echo + echo "The script has been updated to the latest version." + read -p "Press any key to exit, then run the script again." + exit 0 + fi fi echo " _____ _ "; diff --git a/02-PSBBN-Installer.sh b/02-PSBBN-Installer.sh index 07189bf..20052b2 100755 --- a/02-PSBBN-Installer.sh +++ b/02-PSBBN-Installer.sh @@ -18,29 +18,34 @@ if [[ ! -f "${TOOLKIT_PATH}/helper/PFS Shell.elf" || ! -f "${TOOLKIT_PATH}/helpe exit 1 fi -echo "####################################################################">> "${INSTALL_LOG}"; +echo "########################################################################################################">> "${INSTALL_LOG}"; date >> "${INSTALL_LOG}" echo >> "${INSTALL_LOG}" echo "Path set to: $TOOLKIT_PATH" >> "${INSTALL_LOG}" echo "Helper files found." >> "${INSTALL_LOG}" -# Fetch updates from the remote -git fetch >> "${INSTALL_LOG}" 2>&1 - -# Check the current status of the repository -LOCAL=$(git rev-parse @) -REMOTE=$(git rev-parse @{u}) -BASE=$(git merge-base @ @{u}) - -if [ "$LOCAL" = "$REMOTE" ]; then - echo "The repository is up to date." >> "${INSTALL_LOG}" +# Check if the current directory is a Git repository +if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + echo "This is not a Git repository. Skipping update check." >> "${INSTALL_LOG}" else - echo "Downloading update..." - git reset --hard && git pull --force >> "${INSTALL_LOG}" 2>&1 - echo - echo "The script has been updated to the latest version." | tee -a "${INSTALL_LOG}" - read -p "Press any key to exit, then run the script again." - exit 0 + # Fetch updates from the remote + git fetch >> "${INSTALL_LOG}" 2>&1 + + # Check the current status of the repository + LOCAL=$(git rev-parse @) + REMOTE=$(git rev-parse @{u}) + BASE=$(git merge-base @ @{u}) + + if [ "$LOCAL" = "$REMOTE" ]; then + echo "The repository is up to date." >> "${INSTALL_LOG}" + else + echo "Downloading update..." + git reset --hard && git pull --force >> "${INSTALL_LOG}" 2>&1 + echo + echo "The script has been updated to the latest version." | tee -a "${INSTALL_LOG}" + read -p "Press any key to exit, then run the script again." + exit 0 + fi fi # Choose the PS2 storage device diff --git a/03-Game-Installer.sh b/03-Game-Installer.sh index f95f629..a85d2a5 100755 --- a/03-Game-Installer.sh +++ b/03-Game-Installer.sh @@ -36,23 +36,28 @@ echo >> "${LOG_FILE}" echo "Path set to: $TOOLKIT_PATH" >> "${LOG_FILE}" echo "Helper files found." >> "${LOG_FILE}" -# Fetch updates from the remote -git fetch >> "${LOG_FILE}" 2>&1 - -# Check the current status of the repository -LOCAL=$(git rev-parse @) -REMOTE=$(git rev-parse @{u}) -BASE=$(git merge-base @ @{u}) - -if [ "$LOCAL" = "$REMOTE" ]; then - echo "The repository is up to date." >> "${LOG_FILE}" +# Check if the current directory is a Git repository +if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + echo "This is not a Git repository. Skipping update check." >> "${LOG_FILE}" else - echo "Downloading update..." - git reset --hard && git pull --force >> "${LOG_FILE}" 2>&1 - echo - echo "The script has been updated to the latest version." | tee -a "${LOG_FILE}" - read -p "Press any key to exit, set your custom game path if needed, and then run the script again." - exit 0 + # Fetch updates from the remote + git fetch >> "${LOG_FILE}" 2>&1 + + # Check the current status of the repository + LOCAL=$(git rev-parse @) + REMOTE=$(git rev-parse @{u}) + BASE=$(git merge-base @ @{u}) + + if [ "$LOCAL" = "$REMOTE" ]; then + echo "The repository is up to date." >> "${LOG_FILE}" + else + echo "Downloading update..." + git reset --hard && git pull --force >> "${LOG_FILE}" 2>&1 + echo + echo "The script has been updated to the latest version." | tee -a "${LOG_FILE}" + read -p "Press any key to exit, set your custom game path if needed, and then run the script again." + exit 0 + fi fi function clean_up() {