diff --git a/CHANGELOG.md b/CHANGELOG.md index 952c17e..fd5a63c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog +### Sun Oct 30 2022 Rankyn Bass +Fixed an error in the xivlauncher.sh script +- The xivlauncher-custom.sh script being created was malformed, resulting in a crash. +- The xivlauncher script now checks it for syntax errors, and backs it up and creates a new one if there are problems. This should fix it for people who got a poorly formed script file. + ### Sat Oct 29 2022 Rankyn Bass Minor update to launcher scripts - The `/usr/bin/xivlauncher` script now checks `~/.local/bin/xivlauncher-custom.sh` for an openssl config line diff --git a/XIVLauncher.desktop b/XIVLauncher.desktop old mode 100755 new mode 100644 diff --git a/_version b/_version index 22888d6..8b75541 100644 --- a/_version +++ b/_version @@ -4,4 +4,4 @@ ad6b701 https://github.com/goatcorp/FFXIVQuickLauncher 223db56 1.0.2 -3 \ No newline at end of file +4 \ No newline at end of file diff --git a/badge.json b/badge.json index 5189c3d..814945a 100644 --- a/badge.json +++ b/badge.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, "label": "copr", - "message": "1.0.2-3", + "message": "1.0.2-4", "color": "success" } \ No newline at end of file diff --git a/xivlauncher.sh b/xivlauncher.sh index 327311b..bccf26a 100755 --- a/xivlauncher.sh +++ b/xivlauncher.sh @@ -1,14 +1,11 @@ #!/bin/bash -export OPENSSL_CONF=/opt/XIVLauncher/openssl_fix.cnf + xlpath=$HOME/.local/bin/xivlauncher-custom.sh -# Check to see if $HOME/.local/bin/xivlauncher exists -echo "Checking for $xlpath" -if [ ! -x "$xlpath" ]; -then - echo "File $xlpath doesn't exist or can't be executed. Creating..." + +makeCustomScript () { + echo "Creating new file $xlpath." { echo '#!/bin/bash' - echo "# Always keep the next line. It works around an ssl bug on Square's end" echo 'export OPENSSL_CONF=/opt/XIVLauncher/openssl_fix.cnf' echo '# Edit this file for custom launch options.' echo '# For example, add "export MANGOHUD=1" to enable mangohud' @@ -22,15 +19,51 @@ then echo '/opt/XIVLauncher/XIVLauncher.Core' } > "$xlpath" chmod +x "$xlpath" -else - echo "xivlauncher-custom.sh exists. Checking for SSL config" - sslfix=$(grep -c 'OPENSSL_CONF=/opt/XIVLauncher/openssl_fix.cnf' "$xlpath") - if [ "$sslfix" -eq 0 ]; +} + +echo "=========================/usr/bin/xivlauncher=========================" +echo "Checking $xlpath" +# Code to check for bad or missing $HOME/.local/bin/xivlauncher-custom.sh +if [ -f "$xlpath" ]; +then + # Make it executable if it isn't + if [ ! -x "$xlpath" ]; then - echo "Updating xivlauncher-custom.sh with SSL config" - sed -i '2i\export OPENSSL_CONF=/opt/XIVLauncher/openssl_fix.cnf\' "$xlpath" + chmod +x "$xlpath" + fi + # Check the file for bash syntax errors. + errval=$(bash -n $xlpath 2>&1) + retcode=$? + if [ ! $retcode == 0 ]; + then + # If errors are found, backup the file and create a fresh one. + rm -f "$xlpath.bak" + mv "$xlpath" "$xlpath.bak" + echo "Couldn't run $xlpath. It has the following error:" + echo "$errval" + echo "It has been renamed to $xlpath.bak." + makeCustomScript else - echo "SSL config found." + # Otherwise, check for the SSL fix. + echo "File exists. Checking for SSL fix." + sslfix=$(grep -c 'OPENSSL_CONF=/opt/XIVLauncher/openssl_fix.cnf' "$xlpath") + if [ "$sslfix" -eq 0 ]; + then + # If the OPENSSL_CONF line is not found, insert it. + echo "Updating xivlauncher-custom.sh with SSL fix." + sed -i '2i\export OPENSSL_CONF=/opt/XIVLauncher/openssl_fix.cnf\' "$xlpath" + else + echo "SSL config found." + fi fi +else + # xivlauncher-custom.sh wasn't found, so create it. + makeCustomScript fi -$xlpath +echo "Running script $xlpath." +echo "If it crashes, please delete it, and run /usr/bin/xivlauncher again." +echo "If the problem persists, please file a ticket on" +echo "https://github.com/rankynbass/XIVLauncher4rpm describing the error," +echo "along with the contents of ~/.local/bin/xivlauncher-custom.sh" +echo "=========================/usr/bin/xivlauncher=========================" +$xlpath