You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.4KB

  1. #!/usr/bin/env bash
  2. echo "###########################################################################"
  3. echo "# Ark Server - " `date`
  4. echo "# UID $UID - GID $GID"
  5. echo "###########################################################################"
  6. [ -p /tmp/FIFO ] && rm /tmp/FIFO
  7. mkfifo /tmp/FIFO
  8. export TERM=linux
  9. function stop {
  10. if [ ${BACKUPONSTOP} -eq 1 ] && [ "$(ls -A server/ShooterGame/Saved/SavedArks)" ]; then
  11. echo "[Backup on stop]"
  12. arkmanager backup
  13. fi
  14. if [ ${WARNONSTOP} -eq 1 ];then
  15. arkmanager stop --warn
  16. else
  17. arkmanager stop
  18. fi
  19. exit
  20. }
  21. # Change working directory to /ark to allow relative path
  22. cd /ark
  23. # Add a template directory to store the last version of config file
  24. [ ! -d /ark/template ] && mkdir /ark/template
  25. # We overwrite the template file each time
  26. cp /home/steam/arkmanager.cfg /ark/template/arkmanager.cfg
  27. cp /home/steam/crontab /ark/template/crontab
  28. # Creating directory tree && symbolic link
  29. [ ! -f /ark/arkmanager.cfg ] && cp /home/steam/arkmanager.cfg /ark/arkmanager.cfg
  30. [ ! -d /ark/log ] && mkdir /ark/log
  31. [ ! -d /ark/backup ] && mkdir /ark/backup
  32. [ ! -d /ark/staging ] && mkdir /ark/staging
  33. [ ! -L /ark/Game.ini ] && ln -s server/ShooterGame/Saved/Config/LinuxServer/Game.ini Game.ini
  34. [ ! -L /ark/GameUserSettings.ini ] && ln -s server/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini GameUserSettings.ini
  35. [ ! -f /ark/crontab ] && cp /ark/template/crontab /ark/crontab
  36. if [ ! -d /ark/server ] || [ ! -f /ark/server/arkversion ];then
  37. echo "No game files found. Installing..."
  38. mkdir -p /ark/server/ShooterGame/Saved/SavedArks
  39. mkdir -p /ark/server/ShooterGame/Content/Mods
  40. mkdir -p /ark/server/ShooterGame/Binaries/Linux/
  41. touch /ark/server/ShooterGame/Binaries/Linux/ShooterGameServer
  42. arkmanager install
  43. # Create mod dir
  44. else
  45. if [ ${BACKUPONSTART} -eq 1 ] && [ "$(ls -A server/ShooterGame/Saved/SavedArks/)" ]; then
  46. echo "[Backup]"
  47. arkmanager backup
  48. fi
  49. fi
  50. # If there is uncommented line in the file
  51. CRONNUMBER=`grep -v "^#" /ark/crontab | wc -l`
  52. if [ $CRONNUMBER -gt 0 ]; then
  53. echo "Loading crontab..."
  54. # We load the crontab file if it exist.
  55. crontab /ark/crontab
  56. # Cron is attached to this process
  57. sudo cron -f &
  58. else
  59. echo "No crontab set."
  60. fi
  61. # Launching ark server
  62. if [ $UPDATEONSTART -eq 0 ]; then
  63. arkmanager start -noautoupdate
  64. else
  65. arkmanager start
  66. fi
  67. # Stop server in case of signal INT or TERM
  68. echo "Waiting..."
  69. trap stop INT
  70. trap stop TERM
  71. read < /tmp/FIFO &
  72. wait