Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.20 KB | None | 0 0
  1. #!/bin/bash
  2. #put this script in ~/spaceengineers/start.sh
  3. #run 'chmod +x ~/spaceengineers/start.sh'
  4. #and '~/spaceengineers/start.sh setup'
  5. service=spaceengineers
  6. procname=SpaceEngineersDedicated.exe
  7. cd $HOME/spaceengineers
  8. WINEDEBUG=-all
  9. whoami=`whoami` #but who AM I, really?
  10. case "$1" in
  11. start)
  12. #login to steam and fetch the latest gamefiles
  13. cd $HOME/spaceengineers
  14. steamuser=`cat $HOME/spaceengineers/Steamcmd/.steamuser`
  15. cd Steamcmd
  16. WINEDEBUG=-all wine steamcmd.exe +force_install_dir C:\\users\\$whoami\\Desktop\\spaceengineers\\client +login $steamuser +app_update 244850 -verify +quit
  17. cd ..
  18.  
  19. #clear old binaries and get new ones
  20. rm -rf DedicatedServer DedicatedServer64 Content
  21. unzip client/Tools/DedicatedServer.zip
  22. cd config/Saves/SEDSWorld
  23. echo "Cleaning world of dead NPC entries - Credits to Andy_S of #space-engineers"
  24. wget -q -O ../../worldcleaner.py https://github.com/deltaflyer4747/SE_Cleaner/raw/master/clean.py
  25. python ../../worldcleaner.py
  26.  
  27. #start the DS
  28. cd $HOME/.wine/drive_c/users/$whoami/Desktop/spaceengineers/DedicatedServer
  29. WINEDEBUG=-all wine SpaceEngineersDedicated.exe -console
  30. logstamper=`date +%s`
  31.  
  32. #copy server world and log to backups and logs directories
  33. cd ../config
  34. mv SpaceEngineersDedicated.log logs/server-$logstamper.log
  35. cp -rf Saves/SEDSWorld backups/world-$logstamper-svhalt
  36. ;;
  37. setup) #run only once.
  38. echo "Press enter to confirm complete wipe of your WINE's configuration directory. If you have installed anything under regular WINE and want to keep it, press Ctrl-C now!"
  39. read things
  40. echo "ARE YOU SURE?"
  41. read things
  42. echo "ARE YOU REALLY SURE?"
  43. read things
  44. echo "Wiping WINE installation."
  45. rm -rf $HOME/.wine
  46.  
  47. #grab steamcmd, make some directories.
  48. mkdir $HOME/spaceengineers/config
  49. mkdir $HOME/spaceengineers/client
  50. mkdir $HOME/spaceengineers/config/backups
  51. mkdir $HOME/spaceengineers/config/logs
  52. rm -rf $HOME/spaceengineers/Steamcmd
  53. mkdir -p $HOME/spaceengineers/Steamcmd
  54. cd $HOME/spaceengineers/Steamcmd
  55. echo "Downloading SteamCMD"
  56. wget -q -O steamcmd.zip http://media.steampowered.com/installer/steamcmd.zip
  57. unzip steamcmd.zip >/dev/null
  58.  
  59. #configure our wine directory and make some symlinks
  60. cd $HOME
  61. echo "Configuring WINE and installing dependencies."
  62. WINEDEBUG=-all WINEARCH=win32 winecfg > /dev/null
  63. WINEDEBUG=-all winetricks -q msxml3 > /dev/null
  64. WINEDEBUG=-all winetricks -q dotnet40 > /dev/null
  65. ln -s $HOME/spaceengineers $HOME/.wine/drive_c/users/$whoami/Desktop/spaceengineers
  66. ln -s $HOME/spaceengineers/config $HOME/.wine/drive_c/users/$whoami/Application\ Data/SpaceEngineersDedicated
  67. echo "Initial setup complete."
  68.  
  69. #login to steam for the first time, and allow steamcmd to run itself
  70. echo "We'll now try and run steamcmd. In order to install the DS, you need to have a steam account with the game purchased and activated."
  71. echo "Steam username:"
  72. read steamuser
  73. echo $steamuser > $HOME/spaceengineers/Steamcmd/.steamuser
  74. echo "Steam password (Not stored, if you have steamguard enabled like a smart person, go get the code when it asks for one.):"
  75. read steampass
  76. #run twice because the first time we need to make steamcmd download its files before attempting a login
  77. cd $HOME/spaceengineers/Steamcmd/
  78. WINEDEBUG=-all wine steamcmd.exe +exit
  79. WINEDEBUG=-all wine steamcmd.exe +login $steamuser $steampass +exit
  80. echo "Setup complete. Please place your server's .cfg file in ~/spaceengineers/config/SpaceEngineers-Dedicated.cfg. You'll need to edit it and change the <LoadWorld /> part to read: <LoadWorld>C:\users\$whoami\Application Data\SpaceEngineersDedicated\Saves\SEDSWorld</LoadWorld>."
  81. ;;
  82. backupworld) #put an entry in your crontab pointing to this script with the first argument being 'backupworld'.
  83. logstampworld=`date +%s`
  84. cd $HOME/spaceengineers/config
  85. cp -rf Saves/SEDSWorld backups/world-$logstampworld
  86. ;;
  87. *)
  88. if ps ax | grep -v grep | grep $procname > /dev/null
  89. then
  90. echo "$service is running, not starting"
  91. exit
  92. else
  93. echo "$service is not running, starting"
  94. screen -dmS $service -t $service $0 start
  95. fi
  96. ;;
  97. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement