Skip to content

Commit

Permalink
Merge pull request #18 from rankynbass/pre-1.0.2-4
Browse files Browse the repository at this point in the history
Can now detect and replace broken user script.
  • Loading branch information
rankynbass authored Oct 31, 2022
2 parents 5c520ce + 6b63e9a commit ce4fade
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog
### Sun Oct 30 2022 Rankyn Bass <[email protected]>
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 <[email protected]>
Minor update to launcher scripts
- The `/usr/bin/xivlauncher` script now checks `~/.local/bin/xivlauncher-custom.sh` for an openssl config line
Expand Down
Empty file modified XIVLauncher.desktop
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion _version
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ ad6b701
https://github.com/goatcorp/FFXIVQuickLauncher
223db56
1.0.2
3
4
2 changes: 1 addition & 1 deletion badge.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "copr",
"message": "1.0.2-3",
"message": "1.0.2-4",
"color": "success"
}
63 changes: 48 additions & 15 deletions xivlauncher.sh
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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

0 comments on commit ce4fade

Please sign in to comment.