From fc823050c7fa73980cc7e0c114e07f96f21c848a Mon Sep 17 00:00:00 2001 From: snappyapple632 <40573129+snappyapple632@users.noreply.github.com> Date: Sat, 29 Jun 2024 21:26:42 -0700 Subject: [PATCH 1/6] Add automated install script for Linux --- scripts/install-openasar.sh | 103 ++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100755 scripts/install-openasar.sh diff --git a/scripts/install-openasar.sh b/scripts/install-openasar.sh new file mode 100755 index 000000000..7edd078d9 --- /dev/null +++ b/scripts/install-openasar.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +# _______ _______ _______ _ _______ _______ _______ _______ +# ( ___ )( ____ )( ____ \( ( /|( ___ )( ____ \( ___ )( ____ ) +# | ( ) || ( )|| ( \/| \ ( || ( ) || ( \/| ( ) || ( )| +# | | | || (____)|| (__ | \ | || (___) || (_____ | (___) || (____)| +# | | | || _____)| __) | (\ \) || ___ |(_____ )| ___ || __) +# | | | || ( | ( | | \ || ( ) | ) || ( ) || (\ ( +# | (___) || ) | (____/\| ) \ || ) ( |/\____) || ) ( || ) \ \__ +# (_______)|/ (_______/|/ )_)|/ \|\_______)|/ \||/ \__/ +# +# Installation Script for Linux. +# +# Main program: +# Checks for the existance of several common directories that Discord installs itself into. +# If one is found, it `cd`s into it and hands over to checkForExistingInstall. +# +# checkForExistingInstall: +# If no current installation of OpenAsar is found (indicated by the abscence of an "app.asar.bak" file), +# the script renames the current "app.asar" to "app.asar.bak", then downloads OpenAsar from +# the nightly GitHub page (via wget) into the current working directory. +# A sudo prompt will appear to place OpenAsar into the directory. +# +# If a current installation of OpenAsar DOES exist, the script will prompt the user asking if they want +# to replace it. If user says yes, the installation process will be executed. + + +checkForExistingInstall() +{ + echo + if [ -a "app.asar.bak" ] + then + echo -n "OpenAsar is already installed in `pwd`. Would you like to replace it? [y/N] " + read -r PROMPT + if [ "$PROMPT" == 'y' ] || [ "$PROMPT" == 'Y' ] + then + sudo rm app.asar + sudo wget https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar + echo + echo "OpenAsar has been installed! If Discord is still running, restart it." + + exit 0 + else + exit 2 + fi + else + sudo mv app.asar app.asar.bak + sudo wget https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar + echo + echo "OpenAsar has been installed! If Discord is still running, restart it." + exit 0 + fi +} + +echo "Checking file directories..." +echo +#Find which directory Discord is installed in. If it exists, move to checkForExistingInstall +if [ -d "/opt/discord/resources/" ]; then + cd /opt/discord/resources/ + checkForExistingInstall +else + echo "/opt/discord/resources/ dosen't exist" +fi + +if [ -d "/usr/lib/discord/resources/" ]; then + cd /usr/lib/discord/resources/ + checkForExistingInstall +else + echo "/usr/lib/discord/resources/ dosen't exist" +fi + +if [ -d "/usr/lib64/discord/resources/" ]; then + cd /usr/lib64/discord/resources/ + checkForExistingInstall +else + echo "/usr/lib64/discord/resources/ dosen't exist" +fi + +if [ -d "/usr/share/discord/resources/" ]; then + cd /usr/share/discord/resources/ + checkForExistingInstall +else + echo "/usr/share/discord/resources/ dosen't exist" +fi + +if [ -d "/var/lib/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/" ]; then + cd /var/lib/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ + checkForExistingInstall +else + echo "/var/lib/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ dosen't exist" +fi + +if [ -d "$HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/" ]; then + cd $HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ + checkForExistingInstall +else + echo "$HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ dosen't exist" +fi + +#None of the directory searches are successful +echo "No Discord directories were found. Exiting..." +exit 1 + From 0ffd1e90f768ffbe8d67b1a2123c5d96043e40cc Mon Sep 17 00:00:00 2001 From: snappyapple632 <40573129+snappyapple632@users.noreply.github.com> Date: Sat, 29 Jun 2024 21:51:22 -0700 Subject: [PATCH 2/6] Remove prompt for existing installation --- scripts/install-openasar.sh | 58 ++++++++++++++----------------------- 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/scripts/install-openasar.sh b/scripts/install-openasar.sh index 7edd078d9..27e3273c4 100755 --- a/scripts/install-openasar.sh +++ b/scripts/install-openasar.sh @@ -13,86 +13,72 @@ # # Main program: # Checks for the existance of several common directories that Discord installs itself into. -# If one is found, it `cd`s into it and hands over to checkForExistingInstall. +# If one is found, it `cd`s into it and hands over to oAsarInstall. # -# checkForExistingInstall: +# oAsarInstall: # If no current installation of OpenAsar is found (indicated by the abscence of an "app.asar.bak" file), # the script renames the current "app.asar" to "app.asar.bak", then downloads OpenAsar from # the nightly GitHub page (via wget) into the current working directory. # A sudo prompt will appear to place OpenAsar into the directory. -# -# If a current installation of OpenAsar DOES exist, the script will prompt the user asking if they want -# to replace it. If user says yes, the installation process will be executed. +# If a current installation of OpenAsar DOES exist, the script will replace it. -checkForExistingInstall() +oAsarInstall() { - echo - if [ -a "app.asar.bak" ] - then - echo -n "OpenAsar is already installed in `pwd`. Would you like to replace it? [y/N] " - read -r PROMPT - if [ "$PROMPT" == 'y' ] || [ "$PROMPT" == 'Y' ] - then - sudo rm app.asar - sudo wget https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar - echo - echo "OpenAsar has been installed! If Discord is still running, restart it." + echo + + if [ -a "app.asar.bak" ]; then + sudo rm app.asar.bak + fi - exit 0 - else - exit 2 - fi - else - sudo mv app.asar app.asar.bak - sudo wget https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar - echo - echo "OpenAsar has been installed! If Discord is still running, restart it." - exit 0 - fi + sudo mv app.asar app.asar.bak + sudo wget https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar + echo + echo "OpenAsar has been installed! If Discord is still running, restart it." + exit 0 } echo "Checking file directories..." echo -#Find which directory Discord is installed in. If it exists, move to checkForExistingInstall +#Find which directory Discord is installed in. If it exists, move to oAsarInstall if [ -d "/opt/discord/resources/" ]; then cd /opt/discord/resources/ - checkForExistingInstall + oAsarInstall else echo "/opt/discord/resources/ dosen't exist" fi if [ -d "/usr/lib/discord/resources/" ]; then cd /usr/lib/discord/resources/ - checkForExistingInstall + oAsarInstall else echo "/usr/lib/discord/resources/ dosen't exist" fi if [ -d "/usr/lib64/discord/resources/" ]; then cd /usr/lib64/discord/resources/ - checkForExistingInstall + oAsarInstall else echo "/usr/lib64/discord/resources/ dosen't exist" fi if [ -d "/usr/share/discord/resources/" ]; then cd /usr/share/discord/resources/ - checkForExistingInstall + oAsarInstall else echo "/usr/share/discord/resources/ dosen't exist" fi if [ -d "/var/lib/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/" ]; then cd /var/lib/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ - checkForExistingInstall + oAsarInstall else echo "/var/lib/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ dosen't exist" fi if [ -d "$HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/" ]; then - cd $HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ - checkForExistingInstall + cd "$HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/" + oAsarInstall else echo "$HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ dosen't exist" fi From 25a8ff90650b196242a2dd9457b7f7a317c21d9c Mon Sep 17 00:00:00 2001 From: snappyapple632 <40573129+snappyapple632@users.noreply.github.com> Date: Sat, 3 Aug 2024 05:56:30 +0000 Subject: [PATCH 3/6] Update install-openasar.sh --- scripts/install-openasar.sh | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/install-openasar.sh b/scripts/install-openasar.sh index 27e3273c4..f5220762d 100755 --- a/scripts/install-openasar.sh +++ b/scripts/install-openasar.sh @@ -13,7 +13,7 @@ # # Main program: # Checks for the existance of several common directories that Discord installs itself into. -# If one is found, it `cd`s into it and hands over to oAsarInstall. +# If one is found, it `cd`s into it, alerts user of incoming sudo prompt, and hands over to oAsarInstall. # # oAsarInstall: # If no current installation of OpenAsar is found (indicated by the abscence of an "app.asar.bak" file), @@ -25,14 +25,14 @@ oAsarInstall() { - echo + echo if [ -a "app.asar.bak" ]; then sudo rm app.asar.bak fi sudo mv app.asar app.asar.bak - sudo wget https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar + sudo wget --no-verbose https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar echo echo "OpenAsar has been installed! If Discord is still running, restart it." exit 0 @@ -43,34 +43,44 @@ echo #Find which directory Discord is installed in. If it exists, move to oAsarInstall if [ -d "/opt/discord/resources/" ]; then cd /opt/discord/resources/ + + echo "Found Discord installation in /opt/. You will now see a sudo prompt to download and install OpenAsar." oAsarInstall else - echo "/opt/discord/resources/ dosen't exist" + echo "/opt/discord/resources/ not found" fi if [ -d "/usr/lib/discord/resources/" ]; then cd /usr/lib/discord/resources/ + + echo "Found Discord installation in /usr/lib/. You will now see a sudo prompt to download and install OpenAsar." oAsarInstall else - echo "/usr/lib/discord/resources/ dosen't exist" + echo "/usr/lib/discord/resources/ not found" fi if [ -d "/usr/lib64/discord/resources/" ]; then cd /usr/lib64/discord/resources/ + + echo "Found Discord installation in /usr/lib64/. You will now see a sudo prompt to download and install OpenAsar." oAsarInstall else - echo "/usr/lib64/discord/resources/ dosen't exist" + echo "/usr/lib64/discord/resources/ not found" fi if [ -d "/usr/share/discord/resources/" ]; then cd /usr/share/discord/resources/ + + echo "Found Discord installation in /usr/share/. You will now see a sudo prompt to download and install OpenAsar." oAsarInstall else - echo "/usr/share/discord/resources/ dosen't exist" + echo "/usr/share/discord/resources/ not found" fi if [ -d "/var/lib/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/" ]; then cd /var/lib/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ + + echo "Found Discord installation in /var/lib/flatpak/app/. You will now see a sudo prompt to download and install OpenAsar." oAsarInstall else echo "/var/lib/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ dosen't exist" @@ -78,12 +88,13 @@ fi if [ -d "$HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/" ]; then cd "$HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/" + + echo "Found Discord installation in ~/.local/share/flatpak/app/. You will now see a sudo prompt to download and install OpenAsar." oAsarInstall else - echo "$HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ dosen't exist" + echo "$HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ not found" fi #None of the directory searches are successful echo "No Discord directories were found. Exiting..." exit 1 - From 2d48008ead28c217f8213c8a45ad6b01435ca5e3 Mon Sep 17 00:00:00 2001 From: snappyapple632 <40573129+snappyapple632@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:29:20 +0000 Subject: [PATCH 4/6] Fix mistake in oAsarInstall --- scripts/install-openasar.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install-openasar.sh b/scripts/install-openasar.sh index f5220762d..d9133e05d 100755 --- a/scripts/install-openasar.sh +++ b/scripts/install-openasar.sh @@ -28,7 +28,7 @@ oAsarInstall() echo if [ -a "app.asar.bak" ]; then - sudo rm app.asar.bak + sudo rm app.asar fi sudo mv app.asar app.asar.bak From a51352879ff5a839a8146172c46da760e30d0fec Mon Sep 17 00:00:00 2001 From: snappyapple632 <40573129+snappyapple632@users.noreply.github.com> Date: Sat, 7 Sep 2024 10:28:57 -0700 Subject: [PATCH 5/6] Added message for Snap installations --- scripts/install-openasar.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/install-openasar.sh b/scripts/install-openasar.sh index d9133e05d..bd348b887 100755 --- a/scripts/install-openasar.sh +++ b/scripts/install-openasar.sh @@ -95,6 +95,15 @@ else echo "$HOME/.local/share/flatpak/app/com.discordapp.Discord/current/active/files/discord/resources/ not found" fi +if [ -d "/snap/discord/current/usr/share/discord/resources/" ]; then + cd /snap/discord/current/usr/share/discord/resources/ + + echo + echo "Found Discord installation in Snap, but Snap packages are read-only. Consider using Flatpak or your distribution's native installation option." + + exit 2 +fi + #None of the directory searches are successful echo "No Discord directories were found. Exiting..." exit 1 From e5faf6a117a028265d28ac8a4964c911d8cf47d7 Mon Sep 17 00:00:00 2001 From: snappyapple632 <40573129+snappyapple632@users.noreply.github.com> Date: Fri, 28 Mar 2025 14:15:17 -0700 Subject: [PATCH 6/6] Remove redundant cd for Snap check --- scripts/install-openasar.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install-openasar.sh b/scripts/install-openasar.sh index bd348b887..50eb04457 100755 --- a/scripts/install-openasar.sh +++ b/scripts/install-openasar.sh @@ -96,8 +96,6 @@ else fi if [ -d "/snap/discord/current/usr/share/discord/resources/" ]; then - cd /snap/discord/current/usr/share/discord/resources/ - echo echo "Found Discord installation in Snap, but Snap packages are read-only. Consider using Flatpak or your distribution's native installation option."