mirror of
https://github.com/the-sane/lug-helper.git
synced 2024-12-28 17:24:23 +00:00
Rename to debug_print
This commit is contained in:
parent
9689a4a60b
commit
762c069fb5
@ -112,10 +112,10 @@ menu_option_height="25"
|
|||||||
# Echo a formatted debug message to the terminal and optionally exit
|
# Echo a formatted debug message to the terminal and optionally exit
|
||||||
# Accepts either "continue" or "exit" as the first argument
|
# Accepts either "continue" or "exit" as the first argument
|
||||||
# followed by the string to be echoed
|
# followed by the string to be echoed
|
||||||
debug_echo() {
|
debug_print() {
|
||||||
# This function expects two string arguments
|
# This function expects two string arguments
|
||||||
if [ "$#" -lt 2 ]; then
|
if [ "$#" -lt 2 ]; then
|
||||||
printf "\nScript error: The debug_echo function expects two arguments. Aborting.\n"
|
printf "\nScript error: The debug_print function expects two arguments. Aborting.\n"
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -132,7 +132,7 @@ debug_echo() {
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "lug-helper.sh: Unknown argument provided to debug_echo function. Aborting.\n" 1>&2
|
printf "lug-helper.sh: Unknown argument provided to debug_print function. Aborting.\n" 1>&2
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
@ -148,7 +148,7 @@ debug_echo() {
|
|||||||
message() {
|
message() {
|
||||||
# Sanity check
|
# Sanity check
|
||||||
if [ "$#" -lt 2 ]; then
|
if [ "$#" -lt 2 ]; then
|
||||||
debug_echo exit "Script error: The message function expects two arguments. Aborting."
|
debug_print exit "Script error: The message function expects two arguments. Aborting."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use zenity messages if available
|
# Use zenity messages if available
|
||||||
@ -170,7 +170,7 @@ message() {
|
|||||||
margs=("--question" "--text=")
|
margs=("--question" "--text=")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
debug_echo exit "Script Error: Invalid message type passed to the message function. Aborting."
|
debug_print exit "Script Error: Invalid message type passed to the message function. Aborting."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ message() {
|
|||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
debug_echo exit "Script Error: Invalid message type passed to the message function. Aborting."
|
debug_print exit "Script Error: Invalid message type passed to the message function. Aborting."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
@ -249,15 +249,15 @@ message() {
|
|||||||
menu() {
|
menu() {
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
if [ "${#menu_options[@]}" -eq 0 ]; then
|
if [ "${#menu_options[@]}" -eq 0 ]; then
|
||||||
debug_echo exit "Script error: The array 'menu_options' was not set\nbefore calling the menu function. Aborting."
|
debug_print exit "Script error: The array 'menu_options' was not set\nbefore calling the menu function. Aborting."
|
||||||
elif [ "${#menu_actions[@]}" -eq 0 ]; then
|
elif [ "${#menu_actions[@]}" -eq 0 ]; then
|
||||||
debug_echo exit "Script error: The array 'menu_actions' was not set\nbefore calling the menu function. Aborting."
|
debug_print exit "Script error: The array 'menu_actions' was not set\nbefore calling the menu function. Aborting."
|
||||||
elif [ -z "$menu_text_zenity" ]; then
|
elif [ -z "$menu_text_zenity" ]; then
|
||||||
debug_echo exit "Script error: The string 'menu_text_zenity' was not set\nbefore calling the menu function. Aborting."
|
debug_print exit "Script error: The string 'menu_text_zenity' was not set\nbefore calling the menu function. Aborting."
|
||||||
elif [ -z "$menu_text_terminal" ]; then
|
elif [ -z "$menu_text_terminal" ]; then
|
||||||
debug_echo exit "Script error: The string 'menu_text_terminal' was not set\nbefore calling the menu function. Aborting."
|
debug_print exit "Script error: The string 'menu_text_terminal' was not set\nbefore calling the menu function. Aborting."
|
||||||
elif [ -z "$menu_height" ]; then
|
elif [ -z "$menu_height" ]; then
|
||||||
debug_echo exit "Script error: The string 'menu_height' was not set\nbefore calling the menu function. Aborting."
|
debug_print exit "Script error: The string 'menu_height' was not set\nbefore calling the menu function. Aborting."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use Zenity if it is available
|
# Use Zenity if it is available
|
||||||
@ -343,14 +343,14 @@ getdirs() {
|
|||||||
if [ -f "$conf_dir/$conf_subdir/$wine_conf" ]; then
|
if [ -f "$conf_dir/$conf_subdir/$wine_conf" ]; then
|
||||||
wine_prefix="$(cat "$conf_dir/$conf_subdir/$wine_conf")"
|
wine_prefix="$(cat "$conf_dir/$conf_subdir/$wine_conf")"
|
||||||
if [ ! -d "$wine_prefix" ]; then
|
if [ ! -d "$wine_prefix" ]; then
|
||||||
debug_echo continue "The saved wine prefix does not exist, ignoring."
|
debug_print continue "The saved wine prefix does not exist, ignoring."
|
||||||
wine_prefix=""
|
wine_prefix=""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then
|
if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then
|
||||||
game_path="$(cat "$conf_dir/$conf_subdir/$game_conf")"
|
game_path="$(cat "$conf_dir/$conf_subdir/$game_conf")"
|
||||||
if [ ! -d "$game_path" ] || [ "$(basename "$game_path")" != "StarCitizen" ]; then
|
if [ ! -d "$game_path" ] || [ "$(basename "$game_path")" != "StarCitizen" ]; then
|
||||||
debug_echo continue "Unexpected game path found in config file, ignoring."
|
debug_print continue "Unexpected game path found in config file, ignoring."
|
||||||
game_path=""
|
game_path=""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -481,17 +481,17 @@ sanitize() {
|
|||||||
if message question "This helper will delete the following directory:\n\n$user_dir\n\nDo you want to proceed?"; then
|
if message question "This helper will delete the following directory:\n\n$user_dir\n\nDo you want to proceed?"; then
|
||||||
# Back up keybinds
|
# Back up keybinds
|
||||||
if [ "$exported" -eq 1 ]; then
|
if [ "$exported" -eq 1 ]; then
|
||||||
debug_echo continue "Backing up keybinds to $backup_path/keybinds..."
|
debug_print continue "Backing up keybinds to $backup_path/keybinds..."
|
||||||
mkdir -p "$backup_path/keybinds" && cp -r "$keybinds_dir/." "$backup_path/keybinds/"
|
mkdir -p "$backup_path/keybinds" && cp -r "$keybinds_dir/." "$backup_path/keybinds/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Wipe the user directory
|
# Wipe the user directory
|
||||||
debug_echo continue "Wiping $user_dir..."
|
debug_print continue "Wiping $user_dir..."
|
||||||
rm -r "$user_dir"
|
rm -r "$user_dir"
|
||||||
|
|
||||||
# Restore custom keybinds
|
# Restore custom keybinds
|
||||||
if [ "$exported" -eq 1 ]; then
|
if [ "$exported" -eq 1 ]; then
|
||||||
debug_echo continue "Restoring keybinds..."
|
debug_print continue "Restoring keybinds..."
|
||||||
mkdir -p "$keybinds_dir" && cp -r "$backup_path/keybinds/." "$keybinds_dir/"
|
mkdir -p "$keybinds_dir" && cp -r "$backup_path/keybinds/." "$keybinds_dir/"
|
||||||
message info "To re-import your keybinds, select it in-game from the list:\nOptions->Keybindings->Control Profiles"
|
message info "To re-import your keybinds, select it in-game from the list:\nOptions->Keybindings->Control Profiles"
|
||||||
fi
|
fi
|
||||||
@ -647,7 +647,7 @@ rm_shaders() {
|
|||||||
|
|
||||||
# Delete the shader directory
|
# Delete the shader directory
|
||||||
if message question "This helper will delete the following directory:\n\n$shaders_dir\n\nDo you want to proceed?"; then
|
if message question "This helper will delete the following directory:\n\n$shaders_dir\n\nDo you want to proceed?"; then
|
||||||
debug_echo continue "Deleting $shaders_dir..."
|
debug_print continue "Deleting $shaders_dir..."
|
||||||
rm -r "$shaders_dir"
|
rm -r "$shaders_dir"
|
||||||
message info "Your shaders have been deleted!"
|
message info "Your shaders have been deleted!"
|
||||||
fi
|
fi
|
||||||
@ -673,7 +673,7 @@ rm_vidcache() {
|
|||||||
|
|
||||||
# Delete the cache file
|
# Delete the cache file
|
||||||
if message question "This helper will delete the following file:\n\n$dxvk_cache\n\nDo you want to proceed?"; then
|
if message question "This helper will delete the following file:\n\n$dxvk_cache\n\nDo you want to proceed?"; then
|
||||||
debug_echo continue "Deleting $dxvk_cache..."
|
debug_print continue "Deleting $dxvk_cache..."
|
||||||
rm "$dxvk_cache"
|
rm "$dxvk_cache"
|
||||||
message info "Your DXVK cache has been deleted!"
|
message info "Your DXVK cache has been deleted!"
|
||||||
fi
|
fi
|
||||||
@ -685,7 +685,7 @@ rm_vidcache() {
|
|||||||
lutris_restart() {
|
lutris_restart() {
|
||||||
if [ "$lutris_needs_restart" = "true" ] && [ "$(pgrep lutris)" ]; then
|
if [ "$lutris_needs_restart" = "true" ] && [ "$(pgrep lutris)" ]; then
|
||||||
if message question "Lutris must be restarted to detect runner changes.\nWould you like this helper to restart it for you?"; then
|
if message question "Lutris must be restarted to detect runner changes.\nWould you like this helper to restart it for you?"; then
|
||||||
debug_echo continue "Restarting Lutris..."
|
debug_print continue "Restarting Lutris..."
|
||||||
pkill -SIGTERM lutris && nohup lutris </dev/null &>/dev/null &
|
pkill -SIGTERM lutris && nohup lutris </dev/null &>/dev/null &
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -697,13 +697,13 @@ runner_delete() {
|
|||||||
# This function expects an index number for the array
|
# This function expects an index number for the array
|
||||||
# installed_runners to be passed in as an argument
|
# installed_runners to be passed in as an argument
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
debug_echo exit "Script error: The runner_delete function expects an argument. Aborting."
|
debug_print exit "Script error: The runner_delete function expects an argument. Aborting."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
runner_to_delete="$1"
|
runner_to_delete="$1"
|
||||||
if message question "Are you sure you want to delete the following runner?\n\n${installed_runners[$runner_to_delete]}"; then
|
if message question "Are you sure you want to delete the following runner?\n\n${installed_runners[$runner_to_delete]}"; then
|
||||||
rm -r "${installed_runners[$runner_to_delete]}"
|
rm -r "${installed_runners[$runner_to_delete]}"
|
||||||
debug_echo continue "Deleted ${installed_runners[$runner_to_delete]}"
|
debug_print continue "Deleted ${installed_runners[$runner_to_delete]}"
|
||||||
lutris_needs_restart="true"
|
lutris_needs_restart="true"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -753,7 +753,7 @@ runner_install() {
|
|||||||
# This function expects an index number for the array
|
# This function expects an index number for the array
|
||||||
# runner_versions to be passed in as an argument
|
# runner_versions to be passed in as an argument
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
debug_echo exit "Script error: The runner_install function expects a numerical argument. Aborting."
|
debug_print exit "Script error: The runner_install function expects a numerical argument. Aborting."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the runner filename including file extension
|
# Get the runner filename including file extension
|
||||||
@ -770,7 +770,7 @@ runner_install() {
|
|||||||
runner_name="$(basename "$runner_file" .tgz)"
|
runner_name="$(basename "$runner_file" .tgz)"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
debug_echo exit "Unknown archive filetype in runner_install function. Aborting."
|
debug_print exit "Unknown archive filetype in runner_install function. Aborting."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ runner_install() {
|
|||||||
if [ "$runner_url_type" = "github" ]; then
|
if [ "$runner_url_type" = "github" ]; then
|
||||||
runner_dl_url="$(curl -s "$contributor_url" | grep "browser_download_url.*$runner_file" | cut -d \" -f4)"
|
runner_dl_url="$(curl -s "$contributor_url" | grep "browser_download_url.*$runner_file" | cut -d \" -f4)"
|
||||||
else
|
else
|
||||||
debug_echo exit "Script error: Unknown api/url format in runner_sources array. Aborting."
|
debug_print exit "Script error: Unknown api/url format in runner_sources array. Aborting."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sanity check
|
# Sanity check
|
||||||
@ -790,7 +790,7 @@ runner_install() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Download the runner to the tmp directory
|
# Download the runner to the tmp directory
|
||||||
debug_echo continue "Downloading $runner_dl_url into $tmp_dir/$runner_file..."
|
debug_print continue "Downloading $runner_dl_url into $tmp_dir/$runner_file..."
|
||||||
if [ "$has_zen" -eq 1 ]; then
|
if [ "$has_zen" -eq 1 ]; then
|
||||||
# Format the curl progress bar for zenity
|
# Format the curl progress bar for zenity
|
||||||
mkfifo "$tmp_dir/lugpipe"
|
mkfifo "$tmp_dir/lugpipe"
|
||||||
@ -804,7 +804,7 @@ runner_install() {
|
|||||||
|
|
||||||
if [ "$?" -eq 1 ]; then
|
if [ "$?" -eq 1 ]; then
|
||||||
# User clicked cancel
|
# User clicked cancel
|
||||||
debug_echo continue "Download aborted. Removing $tmp_dir/$runner_file..."
|
debug_print continue "Download aborted. Removing $tmp_dir/$runner_file..."
|
||||||
rm "$tmp_dir/$runner_file"
|
rm "$tmp_dir/$runner_file"
|
||||||
rm "$tmp_dir/lugpipe"
|
rm "$tmp_dir/lugpipe"
|
||||||
return 1
|
return 1
|
||||||
@ -817,7 +817,7 @@ runner_install() {
|
|||||||
|
|
||||||
# Sanity check
|
# Sanity check
|
||||||
if [ ! -f "$tmp_dir/$runner_file" ]; then
|
if [ ! -f "$tmp_dir/$runner_file" ]; then
|
||||||
debug_echo exit "Script error: The requested runner file was not downloaded. Aborting"
|
debug_print exit "Script error: The requested runner file was not downloaded. Aborting"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the path of the first item listed in the archive
|
# Get the path of the first item listed in the archive
|
||||||
@ -829,7 +829,7 @@ runner_install() {
|
|||||||
case "$first_filepath" in
|
case "$first_filepath" in
|
||||||
# If the files in the archive begin with ./ there is no subdirectory
|
# If the files in the archive begin with ./ there is no subdirectory
|
||||||
./*)
|
./*)
|
||||||
debug_echo continue "Installing runner into $runners_dir/$runner_name..."
|
debug_print continue "Installing runner into $runners_dir/$runner_name..."
|
||||||
if [ "$has_zen" -eq 1 ]; then
|
if [ "$has_zen" -eq 1 ]; then
|
||||||
# Use Zenity progress bar
|
# Use Zenity progress bar
|
||||||
mkdir -p "$runners_dir/$runner_name" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir/$runner_name" | \
|
mkdir -p "$runners_dir/$runner_name" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir/$runner_name" | \
|
||||||
@ -841,7 +841,7 @@ runner_install() {
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Runners with a subdirectory in the archive
|
# Runners with a subdirectory in the archive
|
||||||
debug_echo continue "Installing runner into $runners_dir..."
|
debug_print continue "Installing runner into $runners_dir..."
|
||||||
if [ "$has_zen" -eq 1 ]; then
|
if [ "$has_zen" -eq 1 ]; then
|
||||||
# Use Zenity progress bar
|
# Use Zenity progress bar
|
||||||
mkdir -p "$runners_dir" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir" | \
|
mkdir -p "$runners_dir" && tar -xzf "$tmp_dir/$runner_file" -C "$runners_dir" | \
|
||||||
@ -854,7 +854,7 @@ runner_install() {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Cleanup tmp download
|
# Cleanup tmp download
|
||||||
debug_echo continue "Removing $tmp_dir/$runner_file..."
|
debug_print continue "Removing $tmp_dir/$runner_file..."
|
||||||
rm "$tmp_dir/$runner_file"
|
rm "$tmp_dir/$runner_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,7 +863,7 @@ runner_select_install() {
|
|||||||
# This function expects an element number for the array
|
# This function expects an element number for the array
|
||||||
# runner_sources to be passed in as an argument
|
# runner_sources to be passed in as an argument
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
debug_echo exit "Script error: The runner_select_install function expects a numerical argument. Aborting."
|
debug_print exit "Script error: The runner_select_install function expects a numerical argument. Aborting."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Store the url from the selected contributor
|
# Store the url from the selected contributor
|
||||||
@ -877,7 +877,7 @@ runner_select_install() {
|
|||||||
runner_url_type="github"
|
runner_url_type="github"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
debug_echo exit "Script error: Unknown api/url format in runner_sources array. Aborting."
|
debug_print exit "Script error: Unknown api/url format in runner_sources array. Aborting."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -887,7 +887,7 @@ runner_select_install() {
|
|||||||
if [ "$runner_url_type" = "github" ]; then
|
if [ "$runner_url_type" = "github" ]; then
|
||||||
runner_versions=($(curl -s "$contributor_url" | grep "browser_download_url" | awk '{print $2}' | xargs basename -a))
|
runner_versions=($(curl -s "$contributor_url" | grep "browser_download_url" | awk '{print $2}' | xargs basename -a))
|
||||||
else
|
else
|
||||||
debug_echo exit "Script error: Unknown api/url format in runner_sources array. Aborting."
|
debug_print exit "Script error: Unknown api/url format in runner_sources array. Aborting."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sanity check
|
# Sanity check
|
||||||
@ -918,7 +918,7 @@ runner_select_install() {
|
|||||||
runner_name="$(basename "${runner_versions[i]}" .tgz)"
|
runner_name="$(basename "${runner_versions[i]}" .tgz)"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
debug_echo exit "Unknown archive filetype in runner_select_install function. Aborting."
|
debug_print exit "Unknown archive filetype in runner_select_install function. Aborting."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -1026,7 +1026,7 @@ set_version() {
|
|||||||
live_or_ptu="LIVE"
|
live_or_ptu="LIVE"
|
||||||
message info "The helper will now target your Star Citizen LIVE installation."
|
message info "The helper will now target your Star Citizen LIVE installation."
|
||||||
else
|
else
|
||||||
debug_echo continue "Unexpected game version provided. Defaulting to the LIVE installation."
|
debug_print continue "Unexpected game version provided. Defaulting to the LIVE installation."
|
||||||
live_or_ptu="LIVE"
|
live_or_ptu="LIVE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user