Skip to content

Instantly share code, notes, and snippets.

@ldericher

ldericher/launchhelper.sh Secret

Last active Jan 1, 2021
Embed
What would you like to do?
POSIX compliant version of launchhelper.sh
#!/bin/sh
#############
# CONSTANTS #
#############
UX_NAME='LeagueClientUx.exe'
SCC_SH='syscall_check.sh'
#############
# FUNCTIONS #
#############
die() {
>&2 echo "ERROR: ${1}"
sleep 5
exit 1
}
wait_for() {
timeout "${1}" sh -c "until ${2}; do \
sleep 1; \
done"
}
########
# MAIN #
########
# call syscall_check
own_dir="$(dirname "$(readlink -f "${0}")")"
if ! [ -x "${own_dir}/${SCC_SH}" ]; then
die "Please place this script into the same directory as '${SCC_SH}'!"
fi
"${own_dir}/${SCC_SH}"
# find pid of LeagueClientUx process
printf 'Waiting for process of "%s" ... ' "${UX_NAME}"
ux_pid=$(wait_for 2m "pidof '${UX_NAME}'")
echo "OK"
if [ -z "${ux_pid}" ]; then
die "Could not find processes of '${UX_NAME}'"
fi
echo "${UX_NAME} pid found: ${ux_pid}"
# find port of LeagueClientUx process
ux_port=$(grep -ao -- '--app-port=[0-9]*' "/proc/${ux_pid}/cmdline" | grep -o '[0-9]*')
if [ -z "${ux_port}" ]; then
die "Could not find port of '${UX_NAME}' process!"
fi
echo "${UX_NAME} port found: ${ux_port}"
# pause LeagueClientUx process
kill -STOP "${ux_pid}"
printf 'Waiting for port %s ... ' "${ux_port}"
wait_for 5m "echo 'Q' | openssl s_client -connect ':${ux_port}' >/dev/null 2>&1"
echo "OK"
# continue LeagueClientUx process
kill -CONT "${ux_pid}"
# finalize
echo "${UX_NAME} continues, my job is done!"
sleep 5
exit 0
@Eragonfr

This comment has been minimized.

Copy link

@Eragonfr Eragonfr commented Nov 1, 2020

Where is the script syscall_check.sh ?

@ldericher

This comment has been minimized.

Copy link
Owner Author

@ldericher ldericher commented Nov 2, 2020

Where is the script syscall_check.sh ?

It's included in the default installation when installed via Lutris. You can find it as a write_file command in the installer script on lutris.net or as a paste on pastebin. However, I'm not sure if the paste is the latest version, but it worked for several people including myself.

@Eragonfr

This comment has been minimized.

Copy link

@Eragonfr Eragonfr commented Nov 3, 2020

Thanks

@legluondunet

This comment has been minimized.

Copy link

@legluondunet legluondunet commented Nov 11, 2020

Where is the script syscall_check.sh ?

It's included in the default installation when installed via Lutris. You can find it as a write_file command in the installer script on lutris.net

Hello, FYI the scripts are no more included in the Lutris installer because it was too difficult to maintain and unreadable.
They are now host here: https://github.com/legluondunet/MyLittleLutrisScripts/tree/master/League%20of%20Legends just for Lutris use.
Could you tell me if the scripts are in their last version, why the launchhelper script I host is different as yours? They are correct?
Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment