|
|
|
@@ -1,5 +1,7 @@
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scriptRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
|
|
|
|
|
|
|
|
|
|
license() {
|
|
|
|
license() {
|
|
|
|
cat << EOF
|
|
|
|
cat << EOF
|
|
|
|
■The contents of this file are subject to the Common Public Attribution
|
|
|
|
■The contents of this file are subject to the Common Public Attribution
|
|
|
|
@@ -419,7 +421,7 @@ desktop_launcher() {
|
|
|
|
break
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
launchDirectory="$(readlink -e "${0%/*}")"
|
|
|
|
launchDirectory="${scriptRoot}"
|
|
|
|
printf -v execLine "Exec=%s -t \"Linux Game Manager\" -e \"/usr/bin/bash -c 'pushd %q;nohup ./%q 2> /dev/null'\"" "${terminal}" "${launchDirectory}" "${0##*/}"
|
|
|
|
printf -v execLine "Exec=%s -t \"Linux Game Manager\" -e \"/usr/bin/bash -c 'pushd %q;nohup ./%q 2> /dev/null'\"" "${terminal}" "${launchDirectory}" "${0##*/}"
|
|
|
|
dotDesktop=('[Desktop Entry]'
|
|
|
|
dotDesktop=('[Desktop Entry]'
|
|
|
|
'Name=Linux game manager'
|
|
|
|
'Name=Linux game manager'
|
|
|
|
@@ -483,8 +485,9 @@ download_with_fallback() {
|
|
|
|
local firstExitCode=0
|
|
|
|
local firstExitCode=0
|
|
|
|
local secondExitCode=0
|
|
|
|
local secondExitCode=0
|
|
|
|
local thirdExitCode=0
|
|
|
|
local thirdExitCode=0
|
|
|
|
|
|
|
|
local wgetExitCode=0
|
|
|
|
local errorFile=""
|
|
|
|
local errorFile=""
|
|
|
|
downloadCurlExitCodes=""
|
|
|
|
downloadAttemptExitCodes=""
|
|
|
|
downloadErrorLog=""
|
|
|
|
downloadErrorLog=""
|
|
|
|
|
|
|
|
|
|
|
|
if ! errorFile="$(mktemp)"; then
|
|
|
|
if ! errorFile="$(mktemp)"; then
|
|
|
|
@@ -513,7 +516,19 @@ download_with_fallback() {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
thirdExitCode=$?
|
|
|
|
thirdExitCode=$?
|
|
|
|
|
|
|
|
|
|
|
|
downloadCurlExitCodes="${firstExitCode}, ${secondExitCode}, ${thirdExitCode}"
|
|
|
|
if command -v wget > /dev/null 2>&1; then
|
|
|
|
|
|
|
|
rm -f "${outputPath}"
|
|
|
|
|
|
|
|
if wget --tries=10 --output-document="${outputPath}" "${sourceUrl}" 2>> "${errorFile}"; then
|
|
|
|
|
|
|
|
rm -f "${errorFile}"
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
wgetExitCode=$?
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
downloadAttemptExitCodes="curl: ${firstExitCode}, ${secondExitCode}, ${thirdExitCode}"
|
|
|
|
|
|
|
|
if [[ "${wgetExitCode}" -ne 0 ]]; then
|
|
|
|
|
|
|
|
downloadAttemptExitCodes+="; wget: ${wgetExitCode}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
if cp -f "${errorFile}" "${cache}/curl-error.log" 2> /dev/null; then
|
|
|
|
if cp -f "${errorFile}" "${cache}/curl-error.log" 2> /dev/null; then
|
|
|
|
downloadErrorLog="${cache}/curl-error.log"
|
|
|
|
downloadErrorLog="${cache}/curl-error.log"
|
|
|
|
rm -f "${errorFile}"
|
|
|
|
rm -f "${errorFile}"
|
|
|
|
@@ -538,10 +553,10 @@ download() {
|
|
|
|
# Skip if the item is in cache.
|
|
|
|
# Skip if the item is in cache.
|
|
|
|
[[ -e "${cache}/${dest}" ]] && continue
|
|
|
|
[[ -e "${cache}/${dest}" ]] && continue
|
|
|
|
{ if ! download_with_fallback "${cache}/${dest}" "${i}" ; then
|
|
|
|
{ if ! download_with_fallback "${cache}/${dest}" "${i}" ; then
|
|
|
|
ui_msgbox "Linux Game Manager" "Linux Game Manager" "Could not download \"$i\"...\n\ncurl exit codes: ${downloadCurlExitCodes}\nError details: ${downloadErrorLog}"
|
|
|
|
ui_msgbox "Linux Game Manager" "Linux Game Manager" "Could not download \"$i\"...\n\ndownload exit codes: ${downloadAttemptExitCodes}\nError details: ${downloadErrorLog}"
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi; } | ui_progressbox "Linux Game Manager" "Downloading \"$dest\" from \"$i\""
|
|
|
|
fi; } | ui_progressbox "Linux Game Manager" "Downloading \"$dest\" from \"$i\""
|
|
|
|
local downloadError=1
|
|
|
|
local downloadError=0
|
|
|
|
case "${dest##*.}" in
|
|
|
|
case "${dest##*.}" in
|
|
|
|
"pk3"|"zip")
|
|
|
|
"pk3"|"zip")
|
|
|
|
unzip -tq "${cache}/${dest}" | ui_progressbox "Linux Game Manager" "Validating ${dest##*.} file"
|
|
|
|
unzip -tq "${cache}/${dest}" | ui_progressbox "Linux Game Manager" "Validating ${dest##*.} file"
|
|
|
|
@@ -566,6 +581,8 @@ download() {
|
|
|
|
# Add HTML check for other file types
|
|
|
|
# Add HTML check for other file types
|
|
|
|
if file -b "${cache}/${dest}" | grep -q "HTML document" ; then
|
|
|
|
if file -b "${cache}/${dest}" | grep -q "HTML document" ; then
|
|
|
|
downloadError=1
|
|
|
|
downloadError=1
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
downloadError=0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
@@ -594,7 +611,7 @@ download_named() {
|
|
|
|
# Skip if the item is in cache.
|
|
|
|
# Skip if the item is in cache.
|
|
|
|
test -e "${cache}/${dest}" && return
|
|
|
|
test -e "${cache}/${dest}" && return
|
|
|
|
if ! download_with_fallback "${cache}/${dest}" "${2}" ; then
|
|
|
|
if ! download_with_fallback "${cache}/${dest}" "${2}" ; then
|
|
|
|
ui_msgbox "Linux Game Manager" "Linux Game Manager" "Could not download \"$dest\"...\n\ncurl exit codes: ${downloadCurlExitCodes}\nError details: ${downloadErrorLog}"
|
|
|
|
ui_msgbox "Linux Game Manager" "Linux Game Manager" "Could not download \"$dest\"...\n\ndownload exit codes: ${downloadAttemptExitCodes}\nError details: ${downloadErrorLog}"
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -666,7 +683,7 @@ game_installer() {
|
|
|
|
declare -a menuList
|
|
|
|
declare -a menuList
|
|
|
|
# shellcheck disable=SC2154 # installedGames may be populated by sourced config or launch migration
|
|
|
|
# shellcheck disable=SC2154 # installedGames may be populated by sourced config or launch migration
|
|
|
|
# Get all .sh files from .install directory, excluding those starting with #//, and sort them
|
|
|
|
# Get all .sh files from .install directory, excluding those starting with #//, and sort them
|
|
|
|
mapfile -t sortedGames < <(for f in "${0%/*}/.install/"*.sh; do
|
|
|
|
mapfile -t sortedGames < <(for f in "${scriptRoot}/.install/"*.sh; do
|
|
|
|
# Skip if first line starts with #//
|
|
|
|
# Skip if first line starts with #//
|
|
|
|
[[ $(head -n1 "$f") == "#//"* ]] && continue
|
|
|
|
[[ $(head -n1 "$f") == "#//"* ]] && continue
|
|
|
|
# Output filename without .sh extension
|
|
|
|
# Output filename without .sh extension
|
|
|
|
@@ -705,7 +722,7 @@ game_installer() {
|
|
|
|
exit 0
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# Convert game name to filename format
|
|
|
|
# Convert game name to filename format
|
|
|
|
local installScript="${0%/*}/.install/${game}.sh"
|
|
|
|
local installScript="${scriptRoot}/.install/${game}.sh"
|
|
|
|
# Check if install script exists
|
|
|
|
# Check if install script exists
|
|
|
|
if [[ -f "$installScript" ]]; then
|
|
|
|
if [[ -f "$installScript" ]]; then
|
|
|
|
# Source and execute the install script
|
|
|
|
# Source and execute the install script
|
|
|
|
@@ -718,8 +735,8 @@ game_installer() {
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ -e "${0%/*}/.launch/${game}.game" ]] && ! [[ -L "${0%/*}/.launch/${game}.sh" ]]; then
|
|
|
|
if [[ -e "${scriptRoot}/.launch/${game}.game" ]] && ! [[ -L "${scriptRoot}/.launch/${game}.sh" ]]; then
|
|
|
|
ln -srf "${0%/*}/.launch/${game}.game" "${0%/*}/.launch/${game}.sh"
|
|
|
|
ln -srf "${scriptRoot}/.launch/${game}.game" "${scriptRoot}/.launch/${game}.sh"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -730,7 +747,8 @@ game_removal() {
|
|
|
|
# Initialize array for menu construction
|
|
|
|
# Initialize array for menu construction
|
|
|
|
mapfile -t menuList < <(
|
|
|
|
mapfile -t menuList < <(
|
|
|
|
if [[ -d ".launch" ]]; then
|
|
|
|
if [[ -d ".launch" ]]; then
|
|
|
|
find -L "${0%/*}/.launch" -maxdepth 1 -type f -iname "*.sh" -print0 | sort -z | xargs -0 bash -c '
|
|
|
|
# shellcheck disable=SC2016 # variables expand in the child bash, not this single-quoted string
|
|
|
|
|
|
|
|
find -L "${scriptRoot}/.launch" -maxdepth 1 -type f -iname "*.sh" -print0 | sort -z | xargs -0 bash -c '
|
|
|
|
for f; do
|
|
|
|
for f; do
|
|
|
|
name="${f##*/}"
|
|
|
|
name="${f##*/}"
|
|
|
|
echo "$f"
|
|
|
|
echo "$f"
|
|
|
|
@@ -756,7 +774,7 @@ game_removal() {
|
|
|
|
local gameName="${selectedGame##*/}"
|
|
|
|
local gameName="${selectedGame##*/}"
|
|
|
|
gameName="${gameName%.sh}"
|
|
|
|
gameName="${gameName%.sh}"
|
|
|
|
local gameFile
|
|
|
|
local gameFile
|
|
|
|
gameFile="$(readlink -f "${0%/*}/.launch/${gameName}.sh")"
|
|
|
|
gameFile="$(readlink -f "${scriptRoot}/.launch/${gameName}.sh")"
|
|
|
|
# Get the actual installation path from the .game file
|
|
|
|
# Get the actual installation path from the .game file
|
|
|
|
local gameInstallPath
|
|
|
|
local gameInstallPath
|
|
|
|
gameInstallPath="$(grep -F "installPath" "$gameFile" | grep -v 'pushd' | head -n1)"
|
|
|
|
gameInstallPath="$(grep -F "installPath" "$gameFile" | grep -v 'pushd' | head -n1)"
|
|
|
|
@@ -766,7 +784,7 @@ game_removal() {
|
|
|
|
# No install path found, just remove from list
|
|
|
|
# No install path found, just remove from list
|
|
|
|
ui_yesno "Linux Game Manager" "Linux Game Manager" "This will remove the game from your game list, but will not remove any files. Do you want to continue?" || exit 0
|
|
|
|
ui_yesno "Linux Game Manager" "Linux Game Manager" "This will remove the game from your game list, but will not remove any files. Do you want to continue?" || exit 0
|
|
|
|
# Remove only the .sh symlink
|
|
|
|
# Remove only the .sh symlink
|
|
|
|
rm -fv "${0%/*}/.launch/${gameName}.sh" | \
|
|
|
|
rm -fv "${scriptRoot}/.launch/${gameName}.sh" | \
|
|
|
|
ui_progressbox "Linux Game Manager" "Removing game from list..."
|
|
|
|
ui_progressbox "Linux Game Manager" "Removing game from list..."
|
|
|
|
# Show success message
|
|
|
|
# Show success message
|
|
|
|
ui_msgbox "Linux Game Manager" "Linux Game Manager" "${gameName} has been removed from the list."
|
|
|
|
ui_msgbox "Linux Game Manager" "Linux Game Manager" "${gameName} has been removed from the list."
|
|
|
|
@@ -775,7 +793,7 @@ game_removal() {
|
|
|
|
ui_yesno "Linux Game Manager" "Linux Game Manager" "This will remove the directory \"${gameInstallPath}\" and all of its contents. Do you want to continue?" || exit 0
|
|
|
|
ui_yesno "Linux Game Manager" "Linux Game Manager" "This will remove the directory \"${gameInstallPath}\" and all of its contents. Do you want to continue?" || exit 0
|
|
|
|
# Remove the game directory and symlink
|
|
|
|
# Remove the game directory and symlink
|
|
|
|
{ rm -rfv "${gameInstallPath}"
|
|
|
|
{ rm -rfv "${gameInstallPath}"
|
|
|
|
rm -fv "${0%/*}/.launch/${gameName}.sh";
|
|
|
|
rm -fv "${scriptRoot}/.launch/${gameName}.sh";
|
|
|
|
} | ui_progressbox "Linux Game Manager" "Removing game..."
|
|
|
|
} | ui_progressbox "Linux Game Manager" "Removing game..."
|
|
|
|
# Show success message
|
|
|
|
# Show success message
|
|
|
|
ui_msgbox "Linux Game Manager" "Linux Game Manager" "${gameName} has been removed."
|
|
|
|
ui_msgbox "Linux Game Manager" "Linux Game Manager" "${gameName} has been removed."
|
|
|
|
@@ -829,7 +847,8 @@ game_launcher() {
|
|
|
|
# Initialize array for menu construction
|
|
|
|
# Initialize array for menu construction
|
|
|
|
mapfile -t menuList < <(
|
|
|
|
mapfile -t menuList < <(
|
|
|
|
if [[ -d ".launch" ]]; then
|
|
|
|
if [[ -d ".launch" ]]; then
|
|
|
|
find -L "${0%/*}/.launch" -maxdepth 1 -type f -iname "*.sh" -print0 | sort -z | xargs -0 bash -c '
|
|
|
|
# shellcheck disable=SC2016 # variables expand in the child bash, not this single-quoted string
|
|
|
|
|
|
|
|
find -L "${scriptRoot}/.launch" -maxdepth 1 -type f -iname "*.sh" -print0 | sort -z | xargs -0 bash -c '
|
|
|
|
for f; do
|
|
|
|
for f; do
|
|
|
|
[[ $(head -n1 "$f") == "#//"* ]] && continue
|
|
|
|
[[ $(head -n1 "$f") == "#//"* ]] && continue
|
|
|
|
name="${f##*/}"
|
|
|
|
name="${f##*/}"
|
|
|
|
@@ -869,8 +888,8 @@ migrate_launcher() {
|
|
|
|
# Extract game name and path
|
|
|
|
# Extract game name and path
|
|
|
|
gameName="${line%|*}"
|
|
|
|
gameName="${line%|*}"
|
|
|
|
# Create launcher script if it doesn't exist
|
|
|
|
# Create launcher script if it doesn't exist
|
|
|
|
if [[ ! -L "${0%/*}/.launch/${gameName}.sh" ]]; then
|
|
|
|
if [[ ! -L "${scriptRoot}/.launch/${gameName}.sh" ]]; then
|
|
|
|
ln -srf "${0%/*}/.launch/${gameName}.game" "${0%/*}/.launch/${gameName}.sh"
|
|
|
|
ln -srf "${scriptRoot}/.launch/${gameName}.game" "${scriptRoot}/.launch/${gameName}.sh"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done < <(sed '/^$/d' "${configFile}")
|
|
|
|
done < <(sed '/^$/d' "${configFile}")
|
|
|
|
# Move the old config file and notify user
|
|
|
|
# Move the old config file and notify user
|
|
|
|
@@ -906,6 +925,7 @@ mkdir -p "${configFile%/*}"
|
|
|
|
declare -a installedGames=()
|
|
|
|
declare -a installedGames=()
|
|
|
|
# Load any arguments from settings.conf file
|
|
|
|
# Load any arguments from settings.conf file
|
|
|
|
if [[ -r "${configFile%/*}/settings.conf" ]]; then
|
|
|
|
if [[ -r "${configFile%/*}/settings.conf" ]]; then
|
|
|
|
|
|
|
|
# shellcheck disable=SC1091 # settings.conf is optional and resolved from the runtime config directory
|
|
|
|
source "${configFile%/*}/settings.conf"
|
|
|
|
source "${configFile%/*}/settings.conf"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
unset noCache
|
|
|
|
unset noCache
|
|
|
|
|