diff --git a/GameUpdate.bat b/GameUpdate.bat index 76f5a6e..a2528a3 100644 --- a/GameUpdate.bat +++ b/GameUpdate.bat @@ -1,8 +1,8 @@ @echo off setlocal -REM Copy GAMEUPDATE.bat to a new file -copy patch.bat patch2.bat +REM Copy patch.bat to a new file +copy dazedpatch\patch.bat patch2.bat REM Run the new file call patch2.bat diff --git a/GameUpdate_linux.sh b/GameUpdate_linux.sh index a2f617e..22f3fd1 100644 --- a/GameUpdate_linux.sh +++ b/GameUpdate_linux.sh @@ -3,8 +3,8 @@ # Enable error handling set -e -# Copy patch.bat to a new file -cp patch.sh patch2.sh +# Copy patch.sh to a new file +cp dazedpatch/patch.sh patch2.sh # Run the new file bash patch2.sh diff --git a/patch-config.txt b/dazedpatch/patch-config.txt similarity index 100% rename from patch-config.txt rename to dazedpatch/patch-config.txt diff --git a/patch.bat b/dazedpatch/patch.bat similarity index 90% rename from patch.bat rename to dazedpatch/patch.bat index 54f3c12..51c12b3 100644 --- a/patch.bat +++ b/dazedpatch/patch.bat @@ -27,15 +27,18 @@ if !errorlevel! neq 0 ( echo Using !_my_shell! for script execution. +REM Get the directory where this script is located +set "SCRIPT_DIR=%~dp0" + REM Check if patch-config.txt exists -if not exist patch-config.txt ( +if not exist "%SCRIPT_DIR%patch-config.txt" ( echo "Config file (patch-config.txt) not found! Assuming no patching needed." pause exit /b ) REM Read configuration from file -for /f "tokens=1,2 delims==" %%a in (patch-config.txt) do ( +for /f "tokens=1,2 delims==" %%a in (%SCRIPT_DIR%patch-config.txt) do ( if "%%a"=="username" set "username=%%b" if "%%a"=="repo" set "repo=%%b" if "%%a"=="branch" set "branch=%%b" diff --git a/patch.sh b/dazedpatch/patch.sh similarity index 91% rename from patch.sh rename to dazedpatch/patch.sh index 4898cdd..d799016 100644 --- a/patch.sh +++ b/dazedpatch/patch.sh @@ -12,7 +12,9 @@ check_dependency jq check_dependency unzip check_dependency curl -CONFIG_FILE="patch-config.txt" +# Get the directory where this script is located +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +CONFIG_FILE="$SCRIPT_DIR/patch-config.txt" # Check if CONFIG_FILE exists if [ ! -f "$CONFIG_FILE" ]; then @@ -25,10 +27,10 @@ sed -i 's/\r$//' "$CONFIG_FILE" # Debug information echo "Current directory: $(pwd)" -echo "Config file path: $(pwd)/$CONFIG_FILE" +echo "Config file path: $CONFIG_FILE" # Read configuration from file -. "$(pwd)/$CONFIG_FILE" +. "$CONFIG_FILE" # Get the latest hash echo "Getting latest commit SHA hash"