2022-08-29 16:08:44 -04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Super simple installer. You should probably run this as root.
|
|
|
|
# If you are getting permission issues, this is probably why.
|
|
|
|
#
|
|
|
|
# If this doesn't work for you, or you're not on Linux, just
|
|
|
|
# - locate your Discord folder
|
|
|
|
# - inside the resources folder, create a new folder "app"
|
|
|
|
# - inside app create the files index.js and package.json.
|
|
|
|
# See the two tee commands at the end of the file for their contents
|
|
|
|
|
2022-08-29 16:11:31 -04:00
|
|
|
patcher="$PWD/dist/patcher.js"
|
2022-08-29 16:08:44 -04:00
|
|
|
|
2022-09-16 13:26:03 -04:00
|
|
|
discord_bin="$(which discord)"
|
|
|
|
discord_actual="$(readlink "$discord_bin")"
|
2022-08-29 16:08:44 -04:00
|
|
|
|
2022-09-16 13:26:03 -04:00
|
|
|
if [ -z "$discord_actual" ]; then
|
|
|
|
case "$(head -n1 "$discord_bin")" in
|
|
|
|
# has shebang?
|
|
|
|
\#!/*)
|
|
|
|
# Wrapper script, assume 2nd line has exec electron call and try to match asar path
|
2022-09-16 13:45:40 -04:00
|
|
|
path="$(tail -1 "$discord_bin" | grep -Eo "\S+/app.asar" | sed 's/${name}/discord/')"
|
|
|
|
if [ -z "$path" ]; then
|
|
|
|
echo "Unsupported Install. $discord_bin is wrapper script but last line isn't exec call?"
|
|
|
|
exit
|
|
|
|
elif [ -e "$path" ]; then
|
2022-09-16 13:26:03 -04:00
|
|
|
discord="$(dirname "$path")"
|
|
|
|
else
|
2022-09-16 13:45:40 -04:00
|
|
|
echo "Unsupported Install. $path not found"
|
2022-09-16 13:26:03 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
2022-09-16 13:45:40 -04:00
|
|
|
echo "Unsupported Install. $discord_bin is neither symlink nor a wrapper script.";
|
2022-09-16 13:26:03 -04:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
discord="$(dirname "$discord_actual")"
|
2022-08-29 16:08:44 -04:00
|
|
|
fi
|
|
|
|
|
2022-09-16 13:26:03 -04:00
|
|
|
resources="$discord/resources"
|
2022-08-29 16:08:44 -04:00
|
|
|
app="$resources/app"
|
2022-09-16 13:26:03 -04:00
|
|
|
app_asar="app.asar"
|
|
|
|
|
|
|
|
if [ ! -e "$resources" ]; then
|
|
|
|
if [ -e "$discord/app.asar.unpacked" ]; then
|
|
|
|
# System Electron Install
|
|
|
|
mv "$discord/app.asar" "$discord/_app.asar"
|
|
|
|
mv "$discord/app.asar.unpacked" "$discord/_app.asar.unpacked"
|
|
|
|
app="$discord/app.asar"
|
|
|
|
app_asar="_app.asar"
|
|
|
|
else
|
2022-09-16 13:45:40 -04:00
|
|
|
echo "Unsupported Install. $discord has no resources folder but also isn't system electron install"
|
2022-09-16 13:26:03 -04:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-08-29 16:08:44 -04:00
|
|
|
if [ -e "$app" ]; then
|
|
|
|
echo "app folder exists. Looks like your Discord is already modified."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir "$app"
|
|
|
|
tee > "$app/index.js" << EOF
|
|
|
|
require("$patcher");
|
2022-09-16 13:26:03 -04:00
|
|
|
require("../$app_asar");
|
2022-08-29 16:08:44 -04:00
|
|
|
EOF
|
|
|
|
|
|
|
|
tee > "$app/package.json" << EOF
|
|
|
|
{
|
|
|
|
"main": "index.js",
|
|
|
|
"name": "discord"
|
|
|
|
}
|
|
|
|
EOF
|