Skip to content
Snippets Groups Projects
wrapper.sh 5.19 KiB
Newer Older
#! /usr/bin/env bash
## Here are some configuration options for Linux Client Testers.
James Cook's avatar
James Cook committed

## - Avoids using any FMOD STUDIO audio driver.
#export LL_BAD_FMODSTUDIO_DRIVER=x
## - Avoids using any OpenAL audio driver.
#export LL_BAD_OPENAL_DRIVER=x
James Cook's avatar
James Cook committed

## - Avoids using the FMOD Studio or FMOD Ex PulseAudio audio driver.
#export LL_BAD_FMOD_PULSEAUDIO=x
## - Avoids using the FMOD Studio or FMOD Ex ALSA audio driver.
#export LL_BAD_FMOD_ALSA=x
James Cook's avatar
James Cook committed

# Completely prevent gamemode from enabling even if set to true in the settings
# This can be useful if you run Alchemy on a battery-operated device (i.e. laptop)
# export DISABLE_GAMEMODE=1

James Cook's avatar
James Cook committed
## - Avoids the optional OpenGL extensions which have proven most problematic
##   on some hardware.  Disabling this option may cause BETTER PERFORMANCE but
##   may also cause CRASHES and hangs on some unstable combinations of drivers
##   and hardware.
## NOTE: This is now disabled by default.
James Cook's avatar
James Cook committed

## - Avoids *all* optional OpenGL extensions.  This is the safest and least-
##   exciting option.  Enable this if you experience stability issues, and
##   report whether it helps in the Linux Client Testers forum.
James Cook's avatar
James Cook committed
#export LL_GL_NOEXT=x

## - For advanced troubleshooters, this lets you disable specific GL
##   extensions, each of which is represented by a letter a-o.  If you can
##   narrow down a stability problem on your system to just one or two
##   extensions then please post details of your hardware (and drivers) to
##   the Linux Client Testers forum along with the minimal
James Cook's avatar
James Cook committed
##   LL_GL_BLACKLIST which solves your problems.
#export LL_GL_BLACKLIST=abcdefghijklmno

Adam Moss's avatar
Adam Moss committed
if [ "`uname -m`" = "x86_64" ]; then
Adam Moss's avatar
Adam Moss committed
fi
## Everything below this line is just for advanced troubleshooters.
##-------------------------------------------------------------------

## - For advanced debugging cases, you can run the viewer under the
##   control of another program, such as strace, gdb, or valgrind.  If
##   you're building your own viewer, bear in mind that the executable
##   in the bin directory will be stripped: you should replace it with
##   an unstripped binary before you run.
if [[ -v AL_GDB ]]; then
    export LL_WRAPPER='gdb --args'
fi

if [[ -v AL_VALGRIND ]]; then
    export LL_WRAPPER='valgrind --smc-check=all --error-limit=no --log-file=secondlife.vg --leak-check=full --suppressions=/usr/lib/valgrind/glibc-2.5.supp --suppressions=secondlife-i686.supp'
fi

if [[ -v AL_MANGO ]]; then
    export MANGOHUD_DLSYM=1
	export LL_WRAPPER='mangohud'
fi
Rye Mutt's avatar
Rye Mutt committed
## For controlling various sanitizer options
#export ASAN_OPTIONS="halt_on_error=0 detect_leaks=1 symbolize=1"
#export UBSAN_OPTIONS="print_stacktrace=1 print_summary=1 halt_on_error=0"
Rye Mutt's avatar
Rye Mutt committed

## Allow Gnome 3 to properly display window title in app bar
export SDL_VIDEO_X11_WMCLASS=Alchemy

## - Enable threaded mesa GL impl
export mesa_glthread=true

James Cook's avatar
James Cook committed
## Nothing worth editing below this line.
##-------------------------------------------------------------------

SCRIPTSRC=`readlink -f "$0" || echo "$0"`
RUN_PATH=`dirname "${SCRIPTSRC}" || echo .`
echo "Running from ${RUN_PATH}"
James Cook's avatar
James Cook committed
cd "${RUN_PATH}"

# Re-register the secondlife:// protocol handler every launch, for now.
./etc/register_secondlifeprotocol.sh

# Re-register the application with the desktop system every launch, for now.
./etc/refresh_desktop_app_entry.sh

## Before we mess with LD_LIBRARY_PATH, save the old one to restore for
##  subprocesses that care.
export SAVED_LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"
# Add our library directory
export LD_LIBRARY_PATH="$PWD/lib:${LD_LIBRARY_PATH}"
# Copy "$@" to ARGS array specifically to delete the --skip-gridargs switch.
# The gridargs.dat file is no more, but we still want to avoid breaking
# scripts that invoke this one with --skip-gridargs.
ARGS=()
    if [ "--skip-gridargs" != "$ARG" ]; then
        ARGS[${#ARGS[*]}]="$ARG"
# Check chrome-sandbox permissions, and try to set them if they are not already
SANDBOX_BIN=bin/llplugin/chrome-sandbox
# if set-user-id = false || is writable || executable = false || read is false || is owned by effective uid || is owned by effective gid
if [[ !(-u $SANDBOX_BIN) || (-w $SANDBOX_BIN) || !(-x $SANDBOX_BIN) || !(-r $SANDBOX_BIN) || ( -O $SANDBOX_BIN) || (-G $SANDBOX_BIN) ]]; then
    echo "$SANDBOX_BIN permissions are incorrect and will be reset"
    SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
    pkexec "$SCRIPT_DIR/etc/chrome_sandboxing_permissions_setup.sh"
fi

# Run the program.
# Don't quote $LL_WRAPPER because, if empty, it should simply vanish from the
# command line. But DO quote "${ARGS[@]}": preserve separate args as
# individually quoted.
$LL_WRAPPER bin/do-not-directly-run-alchemy-bin "${ARGS[@]}"

# Handle any resulting errors
	# generic error running the binaryecho '*** Bad shutdown ($LL_RUN_ERR). ***'
	if [ "$(uname -m)" = "x86_64" ]; then
		echo
		cat << EOFMARKER
You are running Alchemy Viewer on a x86_64 platform.
James Cook's avatar
James Cook committed

echo
echo '*******************************************************'
echo 'This is a BETA release of the Alchemy Viewer Linux client.'
James Cook's avatar
James Cook committed
echo 'Thank you for testing!'
echo 'Please see README-linux.txt before reporting problems.'
echo