From 4b8db8e2abbbb91aa9fb2d633b3dd29821d00992 Mon Sep 17 00:00:00 2001 From: BlackDragon Date: Thu, 2 Oct 2025 13:30:32 +0200 Subject: [PATCH] stuff --- .config example | 9 +++++ .gitignore | 3 +- applypatches.sh | 26 ++++++------- patches/10-offlinemode.sh | 2 - patches/10-segatools.sh | 13 ++++++- patches/11-networking.sh | 12 ++++++ patches/5-pfx.sh | 13 +++++-- versionselect.sh | 81 ++++++++++++++++++++------------------- 8 files changed, 98 insertions(+), 61 deletions(-) create mode 100644 .config example delete mode 100644 patches/10-offlinemode.sh create mode 100644 patches/11-networking.sh diff --git a/.config example b/.config example new file mode 100644 index 0000000..62d1e22 --- /dev/null +++ b/.config example @@ -0,0 +1,9 @@ +# VERSION +VERSION="" +# NETWORKING +NET_KEYCHIP_ID="" +NET_HOSTNAME="" +# PORT BINDINGS +PORT_CONSOLE_LEFT="" +PORT_CONSOLE_RIGHT="" +PORT_AIME_READER="" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2c31100..f91ee75 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -images/* \ No newline at end of file +images/* +.config \ No newline at end of file diff --git a/applypatches.sh b/applypatches.sh index 30c9da5..2b85fa2 100755 --- a/applypatches.sh +++ b/applypatches.sh @@ -7,6 +7,7 @@ fi profile="$1" +source .config source ./profiles/$profile/metadata dir="/tmp/wacca/$profile" PATCHES_DIR="./patches" @@ -22,26 +23,21 @@ for script in $(ls -1v 2>/dev/null); do echo -e "\033[0;34m=== Applying: $script ===\033[0m" - # Use a temporary file to capture exit status and output - temp_file=$(mktemp) + # Create a named pipe for real-time output + pipe=$(mktemp -u) + mkfifo "$pipe" - # Source the script and capture both stdout and stderr - if (source "$script") > "$temp_file" 2>&1; then - # Script succeeded - output with script name prefix - while IFS= read -r line; do - echo "[$script] $line" - done < "$temp_file" + # Execute the script with real-time output + if (source "$script" 2>&1 | while IFS= read -r line; do + echo "[$script] $line" + done); then echo -e "\033[0;32m=== Successfully applied: $script ======\033[0m" else exit_code=$? - # Script failed - output with script name prefix and error message - while IFS= read -r line; do - echo "[$script] $line" - done < "$temp_file" echo -e "\033[0;31m=== Failed: $script (exit code: $exit_code) ===\033[0m" fi - rm -f "$temp_file" + # Clean up the pipe + rm -f "$pipe" echo -done - +done \ No newline at end of file diff --git a/patches/10-offlinemode.sh b/patches/10-offlinemode.sh deleted file mode 100644 index 37a89c3..0000000 --- a/patches/10-offlinemode.sh +++ /dev/null @@ -1,2 +0,0 @@ -sed -i '/^\[\/Script\/Mercury.MercuryNetworkSettings\]/,/^OfflineMode=false/ s/^OfflineMode=false/OfflineMode=true/' $dir/game/WindowsNoEditor/Mercury/Config/DefaultHardware.ini - diff --git a/patches/10-segatools.sh b/patches/10-segatools.sh index cc3a21f..d29e118 100755 --- a/patches/10-segatools.sh +++ b/patches/10-segatools.sh @@ -8,4 +8,15 @@ sed -i '/^\[vfs\]/,/^\[/ { /^amfs=/c\amfs=..\\\\..\\\\segatools\\\\amfs /^option=/c\option=..\\\\..\\\\segatools\\\\option /^appdata=/c\appdata=..\\\\..\\\\segatools\\\\appdata -}' $dir/game/bin/segatools.ini \ No newline at end of file +}' $dir/game/bin/segatools.ini + +if [ -z ${PORT_AIME_READER+x} ]; then echo "\$Card reader binding not set, skipping."; else + echo "Card reader binding set, disabling card reader assembly emulation" + sed -i '/^\[aime\]/,/^enable=1/ s/^enable=1/enable=0/' $dir/game/bin/segatools.ini +fi +if [ -z ${PORT_CONSOLE_LEFT+x} ]; then echo "\$Left console binding not set, skipping."; else + if [ -z ${PORT_CONSOLE_RIGHT+x} ]; then echo "\$Right console binding not set, skipping."; else + echo "Console binding set, disabling mercuryio touch hooks" + sed -i '/^\[touch\]/,/^enable=1/ s/^enable=1/enable=0/' $dir/game/bin/segatools.ini + fi +fi diff --git a/patches/11-networking.sh b/patches/11-networking.sh new file mode 100644 index 0000000..7d57b4a --- /dev/null +++ b/patches/11-networking.sh @@ -0,0 +1,12 @@ +if [ -z ${NET_HOSTNAME+x} ]; then + echo "Server hostname not set, skipping."; + sed -i '/^\[\/Script\/Mercury.MercuryNetworkSettings\]/,/^OfflineMode=false/ s/^OfflineMode=false/OfflineMode=true/' $dir/game/WindowsNoEditor/Mercury/Config/DefaultHardware.ini +else + if [ -z ${NET_KEYCHIP_ID+x} ]; then + echo "Keychip id not set, skipping."; + sed -i '/^\[\/Script\/Mercury.MercuryNetworkSettings\]/,/^OfflineMode=false/ s/^OfflineMode=false/OfflineMode=true/' $dir/game/WindowsNoEditor/Mercury/Config/DefaultHardware.ini + else + sed -i "/^\[dns\]/,/^default=127.0.0.1/ s/^default=127.0.0.1/default=$NET_HOSTNAME/" $dir/game/bin/segatools.ini + sed -i "/^\[keychip\]/,/^id=A69E-01A88888888/ s/^id=A69E-01A88888888/id=$NET_KEYCHIP_ID/" $dir/game/bin/segatools.ini + fi +fi \ No newline at end of file diff --git a/patches/5-pfx.sh b/patches/5-pfx.sh index 738dec2..15ff19d 100755 --- a/patches/5-pfx.sh +++ b/patches/5-pfx.sh @@ -1,3 +1,10 @@ -WINEPREFIX=$dir/prefix umu-run reg add "HKEY_LOCAL_MACHINE\\Software\\Wine\\Ports" /f /v COM1 /t REG_SZ /d "/dev/tnt0" #aime reader -WINEPREFIX=$dir/prefix umu-run reg add "HKEY_LOCAL_MACHINE\\Software\\Wine\\Ports" /f /v COM3 /t REG_SZ /d "/dev/tnt2" #Console touch left -WINEPREFIX=$dir/prefix umu-run reg add "HKEY_LOCAL_MACHINE\\Software\\Wine\\Ports" /f /v COM4 /t REG_SZ /d "/dev/tnt4" #Console touch right +if [ -z ${PORT_CONSOLE_LEFT+x} ]; then echo "Left console binding not set, skipping."; else + WINEPREFIX=$dir/prefix umu-run reg add "HKEY_LOCAL_MACHINE\\Software\\Wine\\Ports" /f /v COM3 /t REG_SZ /d "$PORT_CONSOLE_LEFT" #Console touch left +fi +if [ -z ${PORT_CONSOLE_RIGHT+x} ]; then echo "Right console binding not set, skipping."; else + WINEPREFIX=$dir/prefix umu-run reg add "HKEY_LOCAL_MACHINE\\Software\\Wine\\Ports" /f /v COM4 /t REG_SZ /d "$PORT_CONSOLE_RIGHT" #Console touch right +fi +if [ -z ${PORT_AIME_READER+x} ]; then echo "Card reader binding not set, skipping."; else + WINEPREFIX=$dir/prefix umu-run reg add "HKEY_LOCAL_MACHINE\\Software\\Wine\\Ports" /f /v COM1 /t REG_SZ /d "$PORT_AIME_READER" #aime reader +fi + diff --git a/versionselect.sh b/versionselect.sh index 1971164..7ae3106 100755 --- a/versionselect.sh +++ b/versionselect.sh @@ -1,42 +1,45 @@ #!/bin/bash -versions=() -count=0 -for profile_dir in profiles/*/; do - # Remove the trailing slash to get clean directory name - count=$[count+1] - echo $profile_dir - source $profile_dir/metadata - echo $prettyname - versions+=("$version" "$prettyname") -done -exec 3>&1; -sel=$(dialog --menu "Select major version" 20 60 10 "${versions[@]}" 2>&1 1>&3) -for profile_dir in profiles/*/; do - source $profile_dir/metadata - if [[ "$sel" == "$version" ]]; then - profile=$(basename $profile_dir) - versions2=() - count=0 - while IFS=, read -r vhd version identifier backingversion parent_identifier parent_filename - do - echo $vhd - count=$[count+1] - versions2+=("$version" "$vhd") - done < images/lookup/phase1_$profile.csv - echo "${versions2[@]}" - exec 3>&1; - sel=$(dialog --menu "Select an item:" 20 60 10 "${versions2[@]}" 2>&1 1>&3) - echo $sel - fi -done -# profile="$1" -# versions=() -# count=0 -# while IFS=, read -r vhd version identifier backingversion parent_identifier parent_filename -# do -# count=$[count+1] -# versions+=("$count" "$version") -# done < images/lookup/phase1_$1.csv -# dialog --menu "Select an item:" 20 60 10 "${versions[@]}" \ No newline at end of file +selectversion() { + versions=() + count=0 + for profile_dir in profiles/*/; do + # Remove the trailing slash to get clean directory name + count=$[count+1] + echo $profile_dir + source $profile_dir/metadata + echo $prettyname + versions+=("$version" "$prettyname") + done + exec 3>&1; + sel=$(dialog --menu "Select major version" 20 60 10 "${versions[@]}" 2>&1 1>&3) + for profile_dir in profiles/*/; do + source $profile_dir/metadata + if [[ "$sel" == "$version" ]]; then + profile=$(basename $profile_dir) + versions2=() + count=0 + while IFS=, read -r vhd version identifier backingversion parent_identifier parent_filename + do + echo $vhd + count=$[count+1] + versions2+=("$version" "$vhd") + done < images/lookup/phase1_$profile.csv + exec 3>&1; + sel=$(dialog --menu "Select an item:" 20 60 10 "${versions2[@]}" 2>&1 1>&3) + sed -i "s/VERSION=.*/VERSION=\"$sel\"/" .config + fi + done +} + +setserver() { + source .config + exec 3>&1; + hostname=$(dialog --inputbox "Modify server hostname" 10 30 "${NET_HOSTNAME:-hostname.tld}" 2>&1 1>&3) + keychip=$(dialog --inputbox "Modify keychip id" 10 30 "${NET_KEYCHIP_ID:-A$(printf "%02d" $((RANDOM % 100)))$(shuf -e E X | head -n1)-$(shuf -e 01 20 | head -n1)$(shuf -e A B C D U | head -n1)$(tr -dc 0-9 &1 1>&3) + sed -i "s/NET_HOSTNAME=.*/NET_HOSTNAME=\"$hostname\"/" .config + sed -i "s/NET_KEYCHIP_ID=.*/NET_KEYCHIP_ID=\"$keychip\"/" .config +} +setserver +# selectversion \ No newline at end of file