Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.15 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. case "$style" in
  4. --error)
  5. title=$"Error"
  6. ;;
  7. --warning)
  8. title=$"Warning"
  9. ;;
  10. *)
  11. title=$"Note"
  12. ;;
  13. esac
  14.  
  15. # Show the message on standard output, for logging
  16. echo -e "$title: $*"
  17.  
  18. if [ -z "$STEAMOS" ]; then
  19. if ! zenity "$style" --text="$*" 2>/dev/null; then
  20. # Save the prompt in a temporary file because it can have newlines in it
  21. tmpfile="$(mktemp || echo "/tmp/steam_message.txt")"
  22. echo -e "$*" >"$tmpfile"
  23. xterm -bg "#383635" -fg "#d1cfcd" -T "$title" -e "cat $tmpfile; echo -n 'Press enter to continue: '; read input" 2>/dev/null ||
  24. (echo "$title:"; cat "$tmpfile"; echo -n 'Press enter to continue: '; read input)
  25. rm -f "$tmpfile"
  26. fi
  27. else
  28. # Temporary until we have a zenity equivalent for SteamOS
  29. echo -e "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $title: $*" >> /tmp/steam_startup_messages_$USER.txt
  30. fi
  31.  
  32. # See if they have been grandfathered in through the beta
  33. SSAVersion=$(find -L "$STEAMCONFIG/`detect_package`" -name sharedconfig.vdf -exec fgrep SSAVersion {} ;)
  34.  
  35. if [ "$SSAVersion" != "" ]; then
  36. answer=accepted
  37. else
  38. answer=declined
  39. output=$(zenity --width 650 --height 500 --text-info --title=$"Steam Install Agreement" --filename="$LICENSE" --checkbox=$"I have read and accept these terms." 2>&1)
  40. STATUS=$?
  41. if echo $output | grep "status 1:" >/dev/null; then
  42. # Zenity couldn't launch a window
  43. STATUS=-1
  44. fi
  45. case $STATUS in
  46. 0) # The agreement was accepted
  47. answer=accepted
  48. ;;
  49. 1) # The agreement was declined
  50. ;;
  51. *) # zenity wasn't available, try a fallback
  52. tmpfile="$(mktemp || echo "/tmp/steam_message.txt")"
  53. 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"
  54. xterm -bg "#383635" -fg "#d1cfcd" -T $"Steam Install Agreement" -e "$command" ||
  55. /bin/bash -c "$command"
  56. if [ -f "$tmpfile" ]; then
  57. read answer <"$tmpfile"
  58. rm "$tmpfile"
  59. fi
  60. ;;
  61. esac
  62. if [ "$answer" != "accepted" ]; then
  63. exit 0
  64. fi
  65. fi
  66.  
  67. cp "$LICENSE" "$STEAMCONFIG"/
  68. fi
  69.  
  70. # Check for specific supported distribution releases
  71. case "$(detect_distro)-$(detect_release)" in
  72. ubuntu-12.*)
  73. platform=ubuntu12_32
  74. ;;
  75. esac
  76. echo $platform
  77.  
  78. VERSION="$(detect_scriptversion "$SCRIPT" $VERSION_TOKEN)"
  79. if [[ "$VERSION" -lt "$MINIMUM_VERSION" ]]; then
  80. return 1
  81. fi
  82. return 0
  83.  
  84. STATUS=0
  85.  
  86. # Save the umask and set strong permissions
  87. omask=`umask`
  88. umask 0077
  89.  
  90. STEAMBOOTSTRAPARCHIVE=`detect_bootstrap`
  91. if [ -f "$STEAMBOOTSTRAPARCHIVE" ]; then
  92. echo "Installing bootstrap $STEAMBOOTSTRAPARCHIVE"
  93. tar xf "$STEAMBOOTSTRAPARCHIVE"
  94. STATUS=$?
  95. else
  96. show_message --error $"Couldn't start bootstrap and couldn't reinstall from $STEAMBOOTSTRAPARCHIVE. Please contact technical support."
  97. STATUS=1
  98. fi
  99.  
  100. # Restore the umask
  101. umask $omask
  102.  
  103. return $STATUS
  104.  
  105. # This distro doesn't support the Steam Linux Runtime (yet!)
  106. return 1
  107.  
  108. if [ ! -f "$STEAM_RUNTIME.checksum" ]; then
  109. return 1
  110. fi
  111.  
  112. return 0
  113.  
  114. # Make sure we haven't already unpacked them
  115. if [ -f "$STEAM_RUNTIME/checksum" ] && cmp "$STEAM_RUNTIME.checksum" "$STEAM_RUNTIME/checksum" >/dev/null; then
  116. return 0
  117. fi
  118.  
  119. # Unpack the runtime
  120. EXTRACT_TMP="$STEAM_RUNTIME.tmp"
  121. rm -rf "$EXTRACT_TMP"
  122. mkdir "$EXTRACT_TMP"
  123. cat "$STEAM_RUNTIME.$ARCHIVE_EXT".part* >"$STEAM_RUNTIME.$ARCHIVE_EXT"
  124. EXISTING_CHECKSUM="$(cd "$(dirname "$STEAM_RUNTIME")"; md5sum "$(basename "$STEAM_RUNTIME.$ARCHIVE_EXT")")"
  125. EXPECTED_CHECKSUM="$(cat "$STEAM_RUNTIME.checksum")"
  126. if [ "$EXISTING_CHECKSUM" != "$EXPECTED_CHECKSUM" ]; then
  127. echo $"Runtime checksum: $EXISTING_CHECKSUM, expected $EXPECTED_CHECKSUM" >&2
  128. return 2
  129. fi
  130. if ! extract_archive $"Unpacking Steam Runtime" "$STEAM_RUNTIME.$ARCHIVE_EXT" "$EXTRACT_TMP"; then
  131. return 3
  132. fi
  133.  
  134. # Move it into place!
  135. if [ -d "$STEAM_RUNTIME" ]; then
  136. rm -rf "$STEAM_RUNTIME.old"
  137. if ! mv "$STEAM_RUNTIME" "$STEAM_RUNTIME.old"; then
  138. return 4
  139. fi
  140. fi
  141. if ! mv "$EXTRACT_TMP"/* "$EXTRACT_TMP"/..; then
  142. return 5
  143. fi
  144. rm -rf "$EXTRACT_TMP"
  145. if ! cp "$STEAM_RUNTIME.checksum" "$STEAM_RUNTIME/checksum"; then
  146. return 6
  147. fi
  148. return 0
  149.  
  150. # Don't wipe development files
  151. if [ -f "$STEAMROOT/steam_dev.cfg" ]; then
  152. echo "Can't reset development directory"
  153. return 1
  154. fi
  155.  
  156. if [ -z "$INITIAL_LAUNCH" ]; then
  157. show_message --error $"Please exit Steam before resetting it."
  158. return 1
  159. fi
  160.  
  161. if [ ! -f "$(detect_bootstrap)" ]; then
  162. show_message --error $"Couldn't find bootstrap, it's not safe to reset Steam. Please contact technical support."
  163. return 1
  164. fi
  165.  
  166. if [ "$STEAMROOT" = "" ]; then
  167. show_message --error $"Couldn't find Steam, it's not safe to reset Steam. Please contact technical support."
  168. return 1
  169. fi
  170.  
  171. STEAM_SAVE="$STEAMROOT/.save"
  172.  
  173. # Don't let the user interrupt us, or they may corrupt the install
  174. trap ignore_signal INT
  175.  
  176. # /usr/bin/steam uses the existence of the data link to know whether to bootstrap. Remove it before
  177. # continuing, so that if the machine is turned off while this is occuring, a new bootstrap will be
  178. # put in place next time steam is run.
  179. rm -f "$STEAMDATALINK"
  180.  
  181. # Back up games and critical files
  182. # Backup package dir so that we're not hitting CDNs if there is no manifest change
  183. mkdir -p "$STEAM_SAVE"
  184. for i in bootstrap.tar.xz ssfn* SteamApps steamapps userdata package; do
  185. if [ -e "$i" ]; then
  186. mv -f "$i" "$STEAM_SAVE/"
  187. fi
  188. done
  189. for i in "$STEAMCONFIG/registry.vdf"; do
  190. mv -f "$i" "$i.bak"
  191. done
  192.  
  193. # Check before removing
  194. if [ "$STEAMROOT" != "" ]; then
  195. rm -rf "$STEAMROOT/"*
  196. fi
  197.  
  198. # Move things back into place
  199. mv -f "$STEAM_SAVE/"* "$STEAMROOT/"
  200. rmdir "$STEAM_SAVE"
  201.  
  202. # Reinstall the bootstrap and we're done.
  203. if install_bootstrap; then
  204. STATUS=0
  205.  
  206. # Restore the steam data link
  207. ln -s "$STEAMDATA" "$STEAMDATALINK"
  208. echo $"Reset complete!"
  209. else
  210. STATUS=1
  211. echo $"Reset failed!"
  212. fi
  213.  
  214. # Okay, at this point we can recover, so re-enable interrupts
  215. trap '' INT
  216.  
  217. return $STATUS
  218.  
  219. return 1; # 1 == false in bash speak
  220.  
  221. # See if we need to update the /usr/bin/steam script
  222. if [ -z "${STEAMSCRIPT:-}" ]; then
  223. STEAMSCRIPT="/usr/bin/`detect_package`"
  224. fi
  225. if [ -f "$STEAMSCRIPT" ]; then
  226. if ! check_scriptversion "$STEAMSCRIPT" STEAMSCRIPT_VERSION "$MINIMUM_STEAMSCRIPT_VERSION"; then
  227. STEAMSCRIPT_OUTOFDATE=1
  228. warn_outofdate
  229. else
  230. STEAMSCRIPT_OUTOFDATE=0
  231. fi
  232. fi
  233.  
  234. # Install any additional dependencies
  235. if [ -z "$STEAMOS" ]; then
  236. STEAMDEPS="`dirname $STEAMSCRIPT`/`detect_package`deps"
  237. if [ -f "$STEAMDEPS" -a -f "$STEAMROOT/steamdeps.txt" ]; then
  238. "$STEAMDEPS" $STEAMROOT/steamdeps.txt
  239. fi
  240. fi
  241.  
  242. # Create symbolic links for the Steam API
  243. if [ ! -e "$STEAMCONFIG" ]; then
  244. mkdir "$STEAMCONFIG"
  245. fi
  246. if [ "$STEAMROOT" != "$STEAMROOTLINK" -a "$STEAMROOT" != "$STEAMDATALINK" ]; then
  247. rm -f "$STEAMBIN32LINK" && ln -s "$STEAMROOT/$PLATFORM32" "$STEAMBIN32LINK"
  248. rm -f "$STEAMBIN64LINK" && ln -s "$STEAMROOT/$PLATFORM64" "$STEAMBIN64LINK"
  249. rm -f "$STEAMSDK32LINK" && ln -s "$STEAMROOT/linux32" "$STEAMSDK32LINK"
  250. rm -f "$STEAMSDK64LINK" && ln -s "$STEAMROOT/linux64" "$STEAMSDK64LINK"
  251. rm -f "$STEAMROOTLINK" && ln -s "$STEAMROOT" "$STEAMROOTLINK"
  252. if [ "$STEAMDATALINK" ]; then
  253. rm -f "$STEAMDATALINK" && ln -s "$STEAMDATA" "$STEAMDATALINK"
  254. fi
  255. fi
  256.  
  257. # Temporary bandaid until everyone has the new libsteam_api.so
  258. rm -f ~/.steampath && ln -s "$STEAMCONFIG/bin32/steam" ~/.steampath
  259. rm -f ~/.steampid && ln -s "$PIDFILE" ~/.steampid
  260. rm -f ~/.steam/bin && ln -s "$STEAMBIN32LINK" ~/.steam/bin
  261. # Uncomment this line when you want to remove the bandaid
  262. #rm -f ~/.steampath ~/.steampid ~/.steam/bin
  263.  
  264. if unpack_runtime; then
  265. if [ -z "${STEAM_RUNTIME_DEBUG-}" ]; then
  266. STEAM_RUNTIME_DEBUG="$(cat "$STEAM_RUNTIME/version.txt" | sed 's,-release,-debug,')"
  267. fi
  268. if [ -z "{$STEAM_RUNTIME_DEBUG_DIR-}" ]; then
  269. STEAM_RUNTIME_DEBUG_DIR="$STEAMROOT/$PLATFORM"
  270. fi
  271. if [ ! -d "$STEAM_RUNTIME_DEBUG_DIR/$STEAM_RUNTIME_DEBUG" ]; then
  272. # Try to download the debug runtime
  273. STEAM_RUNTIME_DEBUG_URL=$(grep "$STEAM_RUNTIME_DEBUG" "$STEAM_RUNTIME/README.txt")
  274. mkdir -p "$STEAM_RUNTIME_DEBUG_DIR"
  275.  
  276. STEAM_RUNTIME_DEBUG_ARCHIVE="$STEAM_RUNTIME_DEBUG_DIR/$(basename "$STEAM_RUNTIME_DEBUG_URL")"
  277. if [ ! -f "$STEAM_RUNTIME_DEBUG_ARCHIVE" ]; then
  278. echo $"Downloading debug runtime: $STEAM_RUNTIME_DEBUG_URL"
  279. (cd "$STEAM_RUNTIME_DEBUG_DIR" &&
  280. download_archive $"Downloading debug runtime..." "$STEAM_RUNTIME_DEBUG_URL")
  281. fi
  282. if ! extract_archive $"Unpacking debug runtime..." "$STEAM_RUNTIME_DEBUG_ARCHIVE" "$STEAM_RUNTIME_DEBUG_DIR"; then
  283. rm -rf "$STEAM_RUNTIME_DEBUG" "$STEAM_RUNTIME_DEBUG_ARCHIVE"
  284. fi
  285. fi
  286. if [ -d "$STEAM_RUNTIME_DEBUG_DIR/$STEAM_RUNTIME_DEBUG" ]; then
  287. echo "STEAM_RUNTIME debug enabled, using $STEAM_RUNTIME_DEBUG"
  288. export STEAM_RUNTIME="$STEAM_RUNTIME_DEBUG_DIR/$STEAM_RUNTIME_DEBUG"
  289.  
  290. # Set up the link to the source code
  291. ln -sf "$STEAM_RUNTIME/source" /tmp/source
  292. else
  293. echo $"STEAM_RUNTIME couldn't download and unpack $STEAM_RUNTIME_DEBUG_URL, falling back to $STEAM_RUNTIME"
  294. fi
  295. fi
  296.  
  297. 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-}"
  298. else
  299. echo "Unpack runtime failed, error code $?"
  300. show_message --error $"Couldn't set up the Steam Runtime. Are you running low on disk space?nContinuing..."
  301. fi
  302.  
  303. # Set the LD_PRELOAD varname in the debugger, and unset the global version.
  304. : "${LD_PRELOAD=}"
  305. if [ "$LD_PRELOAD" ]; then
  306. echo set env LD_PRELOAD=$LD_PRELOAD >> "$ARGSFILE"
  307. echo show env LD_PRELOAD >> "$ARGSFILE"
  308. unset LD_PRELOAD
  309. fi
  310.  
  311. $STEAM_DEBUGGER -x "$ARGSFILE" --args "$STEAMROOT/$STEAMEXEPATH" "$@"
  312. rm "$ARGSFILE"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement