shadowm

Untitled

Oct 27th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.05 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Runs Wesnoth using a clean, throwaway config directory.
  4. #
  5. # The configuration directory is created on your temporary
  6. # directory (i.e. /tmp) with a unique name every time, and
  7. # deleted when finished.
  8. #
  9. # Usage:
  10. #     wesnoth-defaults <command line>
  11. #
  12. # Examples:
  13. #     wesnoth-defaults ~/src/wesnoth-1.10/wesnoth
  14. #     wesnoth-defaults ~/src/wesnoth-1.10/wesnoth -s server.wesnoth.org
  15. #     wesnoth-defaults ~/src/wesnoth-trunk/wesnoth-debug --campaign Heir_To_The_Throne
  16. #
  17.  
  18. SELF=`basename $0`
  19.  
  20. do_error()
  21. {
  22.     echo "$SELF: $*" 1>&2
  23. }
  24.  
  25. if test x$1 = x; then
  26.     do_error "You must specify a command line to run!"
  27.     exit 1
  28. fi
  29.  
  30. WESNOTH_BIN_PATH=$1
  31. TEMP_CONFIG_DIR=`mktemp -qd --tmpdir wesnoth-default.XXXXXXXXXX`
  32.  
  33. if test x$TEMP_CONFIG_DIR = x; then
  34.     do_error "Could not create temporary dir before launch!"
  35.     exit 2
  36. fi
  37.  
  38. do_cleanup()
  39. {
  40.     rm -rf $TEMP_CONFIG_DIR || do_error "Could not remove temporary config dir"
  41.     exit $1
  42. }
  43.  
  44. trap do_cleanup INT QUIT HUP TERM EXIT
  45.  
  46. shift
  47.  
  48. $WESNOTH_BIN_PATH --config-dir $TEMP_CONFIG_DIR $@
Advertisement
Add Comment
Please, Sign In to add comment