Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
Shellcheck + clean up scripts and README
Browse files Browse the repository at this point in the history
  • Loading branch information
kyechou committed Aug 5, 2022
1 parent a503e81 commit 37e8a6e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 150 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ install:
install -Dm644 LICENSE -t $(licensesdir)
install -Dm644 completion.bash $(bashcompdir)/$(pkgname)

install-ge:
sed -i leagueoflegends -e 's,/opt/wine-lol/bin,/opt/wine-ge-lol/bin,'
make install

uninstall:
@rm -vf $(bindir)/leagueoflegends
@rm -vf $(datarootdir)/applications/leagueoflegends.desktop
Expand All @@ -40,4 +36,4 @@ uninstall:
@rm -vf $(licensesdir)/LICENSE
@rm -vf $(bashcompdir)/$(pkgname)

.PHONY: nop install install-ge uninstall
.PHONY: nop install uninstall
69 changes: 26 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# League of Legends

League of Legends (www.leagueoflegends.com) helper script for installing and
[League of Legends](https://www.leagueoflegends.com) helper script for installing and
running on Linux.


## Dependencies

The following dependencies should be included in the AUR packages and the
generated `.deb` package. If there's anything incorrect or missing, pull
requests are appreciated.
The following dependencies are included in the AUR package and the generated
`.deb` package. If there's anything incorrect or missing, pull requests are
appreciated.

- [wine-lol](https://github.com/M-Reimer/wine-lol)
([AUR](https://aur.archlinux.org/packages/wine-lol))
or [wine-ge-lol](https://github.com/GloriousEggroll/wine-ge-custom)
([AUR](https://aur.archlinux.org/packages/wine-ge-lol))
- winetricks
- bash
- curl
Expand All @@ -35,7 +33,8 @@ requests are appreciated.
- lib32-nvidia-utils (Debian/Ubuntu: libnvidia-glvkspirv:i386 libglx-nvidia0:i386)
- lib32-vulkan-radeon
- lib32-amdvlk
- zenity (optional for loading screen indication, see [#9](https://github.com/kyechou/leagueoflegends/pull/9))
- zenity (optional for loading screen indication, see
[#9](https://github.com/kyechou/leagueoflegends/pull/9))

Note that the above package names are based on Arch Linux. For other
distributions that are not Arch-based, the names will most likely differ.
Expand All @@ -53,48 +52,35 @@ script.

## Usage

### Install the helper script
### Install the LoL helper script

Please choose either of the two versions. The first one (recommended) depends
on M-Reimer's wine-lol and wine-lol-glibc, and does not require changing kernel
parameters. The second one depends on GloriousEggroll's wine-ge-custom, and
requires setting `abi.vsyscall32=0`, which may have a negative impact on the
performance of other 32-bit wine applications.
| Distribution | Installation method |
|---------------|------------------------------------------------------------------------------------|
| Arch Linux | AUR: [leagueoflegends-git](https://aur.archlinux.org/packages/leagueoflegends-git) |
| Debian/Ubuntu | `./package.sh debian` <br/> `sudo dpkg -i <deb_file>` |
| Others | Manual installation: `sudo make install` |

For more information about setting kernel parameters at run time and preserving
changes between reboots, please checkout the documentation of your own
distribution. Typically you may want to do something like `echo 'abi.vsyscall32
= 0' >> /etc/sysctl.d/99-league.conf`.
### Pre-client-installation checks (Important!)

| Arch User Repository (AUR) | Debian/Ubuntu | Manual installation |
|-------------------------------------------------------------------------------------|-----------------------------------------------------|------------------------|
| [leagueoflegends-git](https://aur.archlinux.org/packages/leagueoflegends-git) | `./package.sh debian`<br/>`sudo dpkg -i <deb_file>` | `sudo make install` |
| [leagueoflegends-ge-git](https://aur.archlinux.org/packages/leagueoflegends-ge-git) | `./package.sh debian`<br/>`sudo dpkg -i <deb_file>` | `sudo make install-ge` |

### Pre-installation checks (Important!)

* Please make sure you have installed the Vulkan driver for your graphic card
that you will be using. You can check what is installed by running `pacman
-Qi <pkg-name>` or `ls /usr/share/vulkan/icd.d/`.
* Please make sure you have installed the correct Vulkan driver for your
graphics card that you will be using. You can check what is installed with
```
ls /usr/share/vulkan/icd.d/
```

### Install the League client

* First install the game: `leagueoflegends install`.
* Please do not log in or launch the game during installation.
* When the Riot client appears and if the installation progress stucks at 100%,
close the window, and run `leagueoflegends install` again.
* For more detail, check out [this thread](https://www.reddit.com/r/leagueoflinux/comments/qavc89/install_stuck_on_downloading_100/).
* If the installation progress stucks at 100%, close the window, and run
`leagueoflegends install` again.
* For more detail, check out [this thread](https://www.reddit.com/r/leagueoflinux/comments/qavc89/install_stuck_on_downloading_100/).
* Exit the window when the game installation is finished. (The progress circle
disappears.)
* Start the game: `leagueoflegends start`.
* It may take a while (usually less than 5 minutes) before the game shows
up, due to this
[issue](https://www.reddit.com/r/leagueoflinux/comments/j07yrg/starting_the_client_script/).
Please check out [here](https://bugs.winehq.org/show_bug.cgi?id=49412#c23)
for more details.
* Log in with your Riot credentials.
* Now the League client should show up. Please try a practice match to make
sure everything works.
* Log in with your Riot credentials and start LoL as usual.
* Once the League client shows up, please try a practice match to make sure
everything works.
* To remove the game: `leagueoflegends uninstall`.

Note that if you use Nvidia graphics card and have trouble launching the League
Expand Down Expand Up @@ -153,9 +139,6 @@ troubleshooting section](#blank-screen-with-nvidia-graphics-card).
* Because the process will only be minimized to system tray upon exit.
* Start the game: `leagueoflegends start-garena`.
* This will start Garena. Navigate to LoL and press "Play" from Garena.
* Similarly, it may take a while (usually less than 5 minutes) before the
game shows up, due to this
[issue](https://www.reddit.com/r/leagueoflinux/comments/j07yrg/starting_the_client_script/).
* To remove the game: `leagueoflegends uninstall-garena`.
* To also remove the environment from which the game is launched:
`leagueoflegends uninstall`.
Expand Down Expand Up @@ -189,7 +172,7 @@ If the issue still remains, you may want to purge and reinstall the Nvidia
related packages as described
[here](https://www.reddit.com/r/leagueoflinux/comments/r0oo0p/i_got_league_working_again_on_my_nvidia_drivers/).

Alternatively, as a quick (and dirty?) solution, remove the `nvidia` package and
install `nvidia-dkms` instead. Remember to also install the kernel headers
Alternatively, as a quick (and dirty) workaround, remove the `nvidia` package
and install `nvidia-dkms` instead. Remember to also install the kernel headers
packages according to your kernel (e.g., `linux-headers`). Then reboot and
reinstall LoL.
99 changes: 26 additions & 73 deletions leagueoflegends
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,28 @@ version_le() {

askQ() {
count=1
first_arg="$2"
echo
echo " $1"
for var in "${@:2}"; do
echo " #$count - $2"
shift
for region in "$@"; do
echo " #$count - $region"
((count++))
shift
done
echo
}

check_depends() {
depends=(wine wineboot winetricks winecfg wineserver winepath curl glxinfo)
for dep in ${depends[@]}; do
for dep in "${depends[@]}"; do
if ! command -v "$dep" >/dev/null 2>&1; then
die "Missing $dep"
fi
done

optdepends=(zenity)
for dep in ${optdepends[@]}; do
for dep in "${optdepends[@]}"; do
if command -v "$dep" >/dev/null 2>&1; then
export "HAS_$(echo $dep | awk '{ print toupper($0) }')"=1
export "HAS_$(echo "$dep" | awk '{ print toupper($0) }')"=1
fi
done
}
Expand Down Expand Up @@ -94,8 +93,9 @@ export_env_variables_garena() {
export WINE_REQ_MOD
export INSTALL_DIR="$WINEPREFIX/drive_c/Program Files/Garena"
export GARENA_EXE="$INSTALL_DIR/Garena/Garena.exe"
if ls "$INSTALL_DIR"/Games/*/lol.version &>/dev/null; then
export GAME_DIR="$(dirname "$(ls "$INSTALL_DIR"/Games/*/lol.version | head -n1)")"
if find "$INSTALL_DIR/Games/" -type f -name lol.version &>/dev/null; then
GAME_DIR="$(dirname "$(find "$INSTALL_DIR/Games/" -type f -name lol.version | head -n1)")"
export GAME_DIR
export CLIENT_EXE="$GAME_DIR/Riot Client/RiotClientServices.exe"
export RUNES_FILE="$GAME_DIR/League of Legends/Config/PerksPreferences.yaml"
else
Expand All @@ -105,15 +105,8 @@ export_env_variables_garena() {
fi

WINE_VERSION="$(wine --version | cut -d ' ' -f 1 | sed 's/wine-//')"
if version_le "6.0" "$WINE_VERSION"; then
export PATH_GARENA="$PATH"
else
local PATH="$(echo "$PATH" | sed 's,/opt/wine-lol/bin:,,g')"
export PATH_GARENA="$PATH"
WINE_GARENA_VERSION="$(wine --version | cut -d ' ' -f 1 | sed 's/wine-//')"
if ! version_le "6.0" "$WINE_GARENA_VERSION"; then
die "The wine version $WINE_GARENA_VERSION is too old for running Garena client"
fi
if ! version_le "6.0" "$WINE_VERSION"; then
die "Wine version $WINE_VERSION is too old for running Garena client"
fi
}

Expand All @@ -130,7 +123,7 @@ create_wineprefix() {
for link in "$WINEPREFIX/dosdevices"/*; do
[[ "$link" =~ 'c:' ]] && continue # for drive_c
[[ "$link" =~ 'z:' ]] && continue # for /
msg "Removing unnecessary device $(basename $link)"
msg "Removing unnecessary device $(basename "$link")"
unlink "$link"
done
msg "Modifying WINE registry with $REGFILE"
Expand All @@ -147,7 +140,7 @@ install_LoL() {
elif [ -f "$CLIENT_EXE" ]; then
while :; do
echo -n "[!] The game has been installed. Install anyway? [Y/n] "
read force
read -r force
force="$(echo "$force" | tr '[:upper:]' '[:lower:]')"
if [ -z "${force##y*}" ]; then
break
Expand All @@ -161,7 +154,7 @@ install_LoL() {
"North America" "EU West" "EU Nordic & East" "Latin America North" \
"Latin America South" "Brazil" "Turkey" "Russia" "Japan" "Oceania" \
"Republic of Korea"
read -p " #: " answer
read -r -p " #: " answer

case "${answer}" in
1) # North America
Expand Down Expand Up @@ -219,7 +212,7 @@ install_garena() {
elif [ -f "$CLIENT_EXE" ]; then
while :; do
echo -n "[!] The game has been installed. Remove it and reinstall? [Y/n] "
read remove
read -r remove
remove="$(echo "$remove" | tr '[:upper:]' '[:lower:]')"
if [ -z "${remove##y*}" ]; then
rm -rf "$INSTALL_DIR"
Expand All @@ -235,7 +228,7 @@ install_garena() {
"Singapore, Malaysia, Indonesia, Philippines" \
"Vietnam" \
"Thailand"
read -p " #: " answer
read -r -p " #: " answer

case "${answer}" in
1) # Taiwan, Hong Kong, Macau
Expand Down Expand Up @@ -308,43 +301,10 @@ uninstall_garena() {
rm -rf "$WINEPREFIX"
}

#
# https://www.reddit.com/r/leagueoflinux/comments/j07yrg/starting_the_client_script/
#
port_waiting_daemon() {
# Find PID
process=LeagueClientUx.exe
uxpid=$(timeout 2m sh -c "until ps -C $process -o pid=; do sleep 1; done | sed 's/[[:space:]]*//g'")
if [ -z "$uxpid" ]; then
die "Could not find process ${process}"
fi

# Get the app-port parameter
port=$(xargs -0 <"/proc/${uxpid}/cmdline" | sed -n 's/.*--app-port=\([[:digit:]]*\).*/\1/p')
if [ -z "$port" ]; then
die "Could not find --app-port of LeagueClientUx.exe"
fi

# Suspend the league client until app-port gets available
kill -STOP ${uxpid}
timeout 5m bash -c "
until openssl s_client -connect :${port} <<< Q >/dev/null 2>&1; do
sleep 1
done"
kill -CONT ${uxpid}
}

loading_screen() {
if [ ${HAS_ZENITY-0} -eq 1 ]; then
zenity --progress --pulsate --auto-close --no-cancel \
--title="League of Legends" --window-icon="$ICON" \
--text="Waiting for the League client port to open..."
fi
}

save_runes() {
# Temporary workaround to prevent the rune pages getting overwritten when
# the League client launches (https://github.com/kyechou/leagueoflegends/issues/38)
# the League client launches
# (https://github.com/kyechou/leagueoflegends/issues/38)
if [ -f "$RUNES_FILE" ]; then
chmod a-w "$RUNES_FILE"
fi
Expand All @@ -354,7 +314,7 @@ start_LoL() {
if [ ! -f "$CLIENT_EXE" ]; then
while :; do
echo -n "[!] The game is not installed. Install it? [Y/n] "
read install
read -r install
install="$(echo "$install" | tr '[:upper:]' '[:lower:]')"
if [ -z "${install##y*}" ]; then
install_LoL
Expand All @@ -378,7 +338,7 @@ start_garena() {
if [ ! -f "$CLIENT_EXE" ]; then
while :; do
echo -n "[!] The game is not installed. Install it? [Y/n] "
read install
read -r install
install="$(echo "$install" | tr '[:upper:]' '[:lower:]')"
if [ -z "${install##y*}" ]; then
install_garena
Expand All @@ -390,15 +350,12 @@ start_garena() {
fi

# Remove libEGL.dll files for Garena client having blank screen
find "$INSTALL_DIR" -type f -name '*libEGL.dll' -exec rm {} +
# find "$INSTALL_DIR" -type f -name '*libEGL.dll' -exec rm {} +

# Start Garena in the background with wine >= 6.0
# Note that Garena is unsupported if wine-lol=5.18 is used.
# Start Garena in the background
# https://github.com/nhubaotruong/league-of-legends-linux-garena-script
# https://www.reddit.com/r/leagueoflinux/comments/jzbfzb/
# https://www.reddit.com/r/leagueoflinux/comments/jzbfzb/comment/gt7td4k/
OLD_PATH=$PATH
export PATH=$PATH_GARENA
wine "$(winepath -w "$GARENA_EXE")" &

# Get the Riot Client pid and command-line argument
Expand All @@ -410,14 +367,10 @@ start_garena() {
wineserver --kill
wineserver --wait

# prelaunch helper
( port_waiting_daemon ) | loading_screen &

# Launch the game directly with the riot argument (garena tokens)
msg "Starting..."
save_runes
export PATH=$OLD_PATH
wine "$(winepath -w "$CLIENT_EXE")" $riot_argument
wine "$(winepath -w "$CLIENT_EXE")" "$riot_argument"
wineserver --wait
wait
}
Expand Down Expand Up @@ -546,13 +499,13 @@ main() {
wineserver --kill
pkill -f -- '--title=League of Legends' # kill the zenity dialog
;;
run) shift; $@ ;;
run-garena) shift; export_env_variables_garena; $@ ;;
run) shift; "$@" ;;
run-garena) shift; export_env_variables_garena; "$@" ;;
*) die "Unknown command: ${1-}\n$(usage)" ;;
esac
}


main $@
main "$@"

# vim: set ts=4 sw=4 et:
Loading

0 comments on commit 37e8a6e

Please sign in to comment.