Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- case "$style" in
- --error)
- title=$"Error"
- ;;
- --warning)
- title=$"Warning"
- ;;
- *)
- title=$"Note"
- ;;
- esac
- # Show the message on standard output, for logging
- echo -e "$title: $*"
- if [ -z "$STEAMOS" ]; then
- if ! zenity "$style" --text="$*" 2>/dev/null; then
- # Save the prompt in a temporary file because it can have newlines in it
- tmpfile="$(mktemp || echo "/tmp/steam_message.txt")"
- echo -e "$*" >"$tmpfile"
- xterm -bg "#383635" -fg "#d1cfcd" -T "$title" -e "cat $tmpfile; echo -n 'Press enter to continue: '; read input" 2>/dev/null ||
- (echo "$title:"; cat "$tmpfile"; echo -n 'Press enter to continue: '; read input)
- rm -f "$tmpfile"
- fi
- else
- # Temporary until we have a zenity equivalent for SteamOS
- echo -e "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $title: $*" >> /tmp/steam_startup_messages_$USER.txt
- fi
- # See if they have been grandfathered in through the beta
- SSAVersion=$(find -L "$STEAMCONFIG/`detect_package`" -name sharedconfig.vdf -exec fgrep SSAVersion {} ;)
- if [ "$SSAVersion" != "" ]; then
- answer=accepted
- else
- answer=declined
- output=$(zenity --width 650 --height 500 --text-info --title=$"Steam Install Agreement" --filename="$LICENSE" --checkbox=$"I have read and accept these terms." 2>&1)
- STATUS=$?
- if echo $output | grep "status 1:" >/dev/null; then
- # Zenity couldn't launch a window
- STATUS=-1
- fi
- case $STATUS in
- 0) # The agreement was accepted
- answer=accepted
- ;;
- 1) # The agreement was declined
- ;;
- *) # zenity wasn't available, try a fallback
- tmpfile="$(mktemp || echo "/tmp/steam_message.txt")"
- command="more "$LICENSE" || cat "$LICENSE"; echo -n $'Do you accept the terms of this agreement? [y/N]: '; read input; if [ x$input = xy -o x$input = xY ]; then echo accepted >"$tmpfile"; fi"
- xterm -bg "#383635" -fg "#d1cfcd" -T $"Steam Install Agreement" -e "$command" ||
- /bin/bash -c "$command"
- if [ -f "$tmpfile" ]; then
- read answer <"$tmpfile"
- rm "$tmpfile"
- fi
- ;;
- esac
- if [ "$answer" != "accepted" ]; then
- exit 0
- fi
- fi
- cp "$LICENSE" "$STEAMCONFIG"/
- fi
- # Check for specific supported distribution releases
- case "$(detect_distro)-$(detect_release)" in
- ubuntu-12.*)
- platform=ubuntu12_32
- ;;
- esac
- echo $platform
- VERSION="$(detect_scriptversion "$SCRIPT" $VERSION_TOKEN)"
- if [[ "$VERSION" -lt "$MINIMUM_VERSION" ]]; then
- return 1
- fi
- return 0
- STATUS=0
- # Save the umask and set strong permissions
- omask=`umask`
- umask 0077
- STEAMBOOTSTRAPARCHIVE=`detect_bootstrap`
- if [ -f "$STEAMBOOTSTRAPARCHIVE" ]; then
- echo "Installing bootstrap $STEAMBOOTSTRAPARCHIVE"
- tar xf "$STEAMBOOTSTRAPARCHIVE"
- STATUS=$?
- else
- show_message --error $"Couldn't start bootstrap and couldn't reinstall from $STEAMBOOTSTRAPARCHIVE. Please contact technical support."
- STATUS=1
- fi
- # Restore the umask
- umask $omask
- return $STATUS
- # This distro doesn't support the Steam Linux Runtime (yet!)
- return 1
- if [ ! -f "$STEAM_RUNTIME.checksum" ]; then
- return 1
- fi
- return 0
- # Make sure we haven't already unpacked them
- if [ -f "$STEAM_RUNTIME/checksum" ] && cmp "$STEAM_RUNTIME.checksum" "$STEAM_RUNTIME/checksum" >/dev/null; then
- return 0
- fi
- # Unpack the runtime
- EXTRACT_TMP="$STEAM_RUNTIME.tmp"
- rm -rf "$EXTRACT_TMP"
- mkdir "$EXTRACT_TMP"
- cat "$STEAM_RUNTIME.$ARCHIVE_EXT".part* >"$STEAM_RUNTIME.$ARCHIVE_EXT"
- EXISTING_CHECKSUM="$(cd "$(dirname "$STEAM_RUNTIME")"; md5sum "$(basename "$STEAM_RUNTIME.$ARCHIVE_EXT")")"
- EXPECTED_CHECKSUM="$(cat "$STEAM_RUNTIME.checksum")"
- if [ "$EXISTING_CHECKSUM" != "$EXPECTED_CHECKSUM" ]; then
- echo $"Runtime checksum: $EXISTING_CHECKSUM, expected $EXPECTED_CHECKSUM" >&2
- return 2
- fi
- if ! extract_archive $"Unpacking Steam Runtime" "$STEAM_RUNTIME.$ARCHIVE_EXT" "$EXTRACT_TMP"; then
- return 3
- fi
- # Move it into place!
- if [ -d "$STEAM_RUNTIME" ]; then
- rm -rf "$STEAM_RUNTIME.old"
- if ! mv "$STEAM_RUNTIME" "$STEAM_RUNTIME.old"; then
- return 4
- fi
- fi
- if ! mv "$EXTRACT_TMP"/* "$EXTRACT_TMP"/..; then
- return 5
- fi
- rm -rf "$EXTRACT_TMP"
- if ! cp "$STEAM_RUNTIME.checksum" "$STEAM_RUNTIME/checksum"; then
- return 6
- fi
- return 0
- # Don't wipe development files
- if [ -f "$STEAMROOT/steam_dev.cfg" ]; then
- echo "Can't reset development directory"
- return 1
- fi
- if [ -z "$INITIAL_LAUNCH" ]; then
- show_message --error $"Please exit Steam before resetting it."
- return 1
- fi
- if [ ! -f "$(detect_bootstrap)" ]; then
- show_message --error $"Couldn't find bootstrap, it's not safe to reset Steam. Please contact technical support."
- return 1
- fi
- if [ "$STEAMROOT" = "" ]; then
- show_message --error $"Couldn't find Steam, it's not safe to reset Steam. Please contact technical support."
- return 1
- fi
- STEAM_SAVE="$STEAMROOT/.save"
- # Don't let the user interrupt us, or they may corrupt the install
- trap ignore_signal INT
- # /usr/bin/steam uses the existence of the data link to know whether to bootstrap. Remove it before
- # continuing, so that if the machine is turned off while this is occuring, a new bootstrap will be
- # put in place next time steam is run.
- rm -f "$STEAMDATALINK"
- # Back up games and critical files
- # Backup package dir so that we're not hitting CDNs if there is no manifest change
- mkdir -p "$STEAM_SAVE"
- for i in bootstrap.tar.xz ssfn* SteamApps steamapps userdata package; do
- if [ -e "$i" ]; then
- mv -f "$i" "$STEAM_SAVE/"
- fi
- done
- for i in "$STEAMCONFIG/registry.vdf"; do
- mv -f "$i" "$i.bak"
- done
- # Check before removing
- if [ "$STEAMROOT" != "" ]; then
- rm -rf "$STEAMROOT/"*
- fi
- # Move things back into place
- mv -f "$STEAM_SAVE/"* "$STEAMROOT/"
- rmdir "$STEAM_SAVE"
- # Reinstall the bootstrap and we're done.
- if install_bootstrap; then
- STATUS=0
- # Restore the steam data link
- ln -s "$STEAMDATA" "$STEAMDATALINK"
- echo $"Reset complete!"
- else
- STATUS=1
- echo $"Reset failed!"
- fi
- # Okay, at this point we can recover, so re-enable interrupts
- trap '' INT
- return $STATUS
- return 1; # 1 == false in bash speak
- # See if we need to update the /usr/bin/steam script
- if [ -z "${STEAMSCRIPT:-}" ]; then
- STEAMSCRIPT="/usr/bin/`detect_package`"
- fi
- if [ -f "$STEAMSCRIPT" ]; then
- if ! check_scriptversion "$STEAMSCRIPT" STEAMSCRIPT_VERSION "$MINIMUM_STEAMSCRIPT_VERSION"; then
- STEAMSCRIPT_OUTOFDATE=1
- warn_outofdate
- else
- STEAMSCRIPT_OUTOFDATE=0
- fi
- fi
- # Install any additional dependencies
- if [ -z "$STEAMOS" ]; then
- STEAMDEPS="`dirname $STEAMSCRIPT`/`detect_package`deps"
- if [ -f "$STEAMDEPS" -a -f "$STEAMROOT/steamdeps.txt" ]; then
- "$STEAMDEPS" $STEAMROOT/steamdeps.txt
- fi
- fi
- # Create symbolic links for the Steam API
- if [ ! -e "$STEAMCONFIG" ]; then
- mkdir "$STEAMCONFIG"
- fi
- if [ "$STEAMROOT" != "$STEAMROOTLINK" -a "$STEAMROOT" != "$STEAMDATALINK" ]; then
- rm -f "$STEAMBIN32LINK" && ln -s "$STEAMROOT/$PLATFORM32" "$STEAMBIN32LINK"
- rm -f "$STEAMBIN64LINK" && ln -s "$STEAMROOT/$PLATFORM64" "$STEAMBIN64LINK"
- rm -f "$STEAMSDK32LINK" && ln -s "$STEAMROOT/linux32" "$STEAMSDK32LINK"
- rm -f "$STEAMSDK64LINK" && ln -s "$STEAMROOT/linux64" "$STEAMSDK64LINK"
- rm -f "$STEAMROOTLINK" && ln -s "$STEAMROOT" "$STEAMROOTLINK"
- if [ "$STEAMDATALINK" ]; then
- rm -f "$STEAMDATALINK" && ln -s "$STEAMDATA" "$STEAMDATALINK"
- fi
- fi
- # Temporary bandaid until everyone has the new libsteam_api.so
- rm -f ~/.steampath && ln -s "$STEAMCONFIG/bin32/steam" ~/.steampath
- rm -f ~/.steampid && ln -s "$PIDFILE" ~/.steampid
- rm -f ~/.steam/bin && ln -s "$STEAMBIN32LINK" ~/.steam/bin
- # Uncomment this line when you want to remove the bandaid
- #rm -f ~/.steampath ~/.steampid ~/.steam/bin
- if unpack_runtime; then
- if [ -z "${STEAM_RUNTIME_DEBUG-}" ]; then
- STEAM_RUNTIME_DEBUG="$(cat "$STEAM_RUNTIME/version.txt" | sed 's,-release,-debug,')"
- fi
- if [ -z "{$STEAM_RUNTIME_DEBUG_DIR-}" ]; then
- STEAM_RUNTIME_DEBUG_DIR="$STEAMROOT/$PLATFORM"
- fi
- if [ ! -d "$STEAM_RUNTIME_DEBUG_DIR/$STEAM_RUNTIME_DEBUG" ]; then
- # Try to download the debug runtime
- STEAM_RUNTIME_DEBUG_URL=$(grep "$STEAM_RUNTIME_DEBUG" "$STEAM_RUNTIME/README.txt")
- mkdir -p "$STEAM_RUNTIME_DEBUG_DIR"
- STEAM_RUNTIME_DEBUG_ARCHIVE="$STEAM_RUNTIME_DEBUG_DIR/$(basename "$STEAM_RUNTIME_DEBUG_URL")"
- if [ ! -f "$STEAM_RUNTIME_DEBUG_ARCHIVE" ]; then
- echo $"Downloading debug runtime: $STEAM_RUNTIME_DEBUG_URL"
- (cd "$STEAM_RUNTIME_DEBUG_DIR" &&
- download_archive $"Downloading debug runtime..." "$STEAM_RUNTIME_DEBUG_URL")
- fi
- if ! extract_archive $"Unpacking debug runtime..." "$STEAM_RUNTIME_DEBUG_ARCHIVE" "$STEAM_RUNTIME_DEBUG_DIR"; then
- rm -rf "$STEAM_RUNTIME_DEBUG" "$STEAM_RUNTIME_DEBUG_ARCHIVE"
- fi
- fi
- if [ -d "$STEAM_RUNTIME_DEBUG_DIR/$STEAM_RUNTIME_DEBUG" ]; then
- echo "STEAM_RUNTIME debug enabled, using $STEAM_RUNTIME_DEBUG"
- export STEAM_RUNTIME="$STEAM_RUNTIME_DEBUG_DIR/$STEAM_RUNTIME_DEBUG"
- # Set up the link to the source code
- ln -sf "$STEAM_RUNTIME/source" /tmp/source
- else
- echo $"STEAM_RUNTIME couldn't download and unpack $STEAM_RUNTIME_DEBUG_URL, falling back to $STEAM_RUNTIME"
- fi
- fi
- export LD_LIBRARY_PATH="$STEAM_RUNTIME/i386/lib/i386-linux-gnu:$STEAM_RUNTIME/i386/lib:$STEAM_RUNTIME/i386/usr/lib/i386-linux-gnu:$STEAM_RUNTIME/i386/usr/lib:$STEAM_RUNTIME/amd64/lib/x86_64-linux-gnu:$STEAM_RUNTIME/amd64/lib:$STEAM_RUNTIME/amd64/usr/lib/x86_64-linux-gnu:$STEAM_RUNTIME/amd64/usr/lib:${LD_LIBRARY_PATH-}"
- else
- echo "Unpack runtime failed, error code $?"
- show_message --error $"Couldn't set up the Steam Runtime. Are you running low on disk space?nContinuing..."
- fi
- # Set the LD_PRELOAD varname in the debugger, and unset the global version.
- : "${LD_PRELOAD=}"
- if [ "$LD_PRELOAD" ]; then
- echo set env LD_PRELOAD=$LD_PRELOAD >> "$ARGSFILE"
- echo show env LD_PRELOAD >> "$ARGSFILE"
- unset LD_PRELOAD
- fi
- $STEAM_DEBUGGER -x "$ARGSFILE" --args "$STEAMROOT/$STEAMEXEPATH" "$@"
- rm "$ARGSFILE"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement