Guest User

Untitled

a guest
Jan 28th, 2026
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # PROVIDE: terraria
  4. # REQUIRE: LOGIN DAEMON NETWORKING mountcritlocal
  5. # KEYWORD: shutdown
  6. #
  7. # Add the following lines to /etc/rc.conf.local to enable the terraria server:
  8. #
  9. # terraria_enable="YES"
  10. # terraria_user="<run server as this user>"
  11. # terraria_chdir="<run server in this directory>"
  12. # terraria_path="<path to terraria_server.jar>"
  13. # terraria_flags="<set as needed>"
  14. #
  15. # For default setup, create a user named 'terraria', set its home directory
  16. # to /srv/terraria, and place terraria_server.jar into /srv/terraria
  17. #
  18. # See terraria_server.jar for flags
  19.  
  20. . /etc/rc.subr
  21.  
  22. name=terraria
  23. rcvar=terraria_enable
  24.  
  25. load_rc_config ${name}
  26.  
  27. command=/usr/local/bin/screen
  28. pidfile=/var/run/terraria.pid
  29.  
  30. start_cmd="${name}_start"
  31. stop_cmd="${name}_stop"
  32. status_cmd="${name}_status"
  33.  
  34. : ${terraria_enable="NO"}
  35. : ${terraria_session="terraria-session"}
  36. : ${terraria_user="terraria"}
  37. : ${terraria_chdir="/home/terraria"}
  38. : ${terraria_path="/home/terraria/TerrariaServer.exe"}
  39. : ${terraria_flags="-world /usr/home/terraria/Terraria/Worlds/Jotunheim.wld"}
  40. : ${terraria_args="/usr/local/bin/mono --server --gc=sgen -O=all \
  41. ${terraria_path} ${terraria_flags}"}
  42.  
  43. terraria_start() {
  44. unset "${rc_arg}_cmd"
  45. terraria_flags="-d -m -S ${terraria_session} ${terraria_args}"
  46. if terraria_running; then
  47. echo "terraria already running?"
  48. else
  49. run_rc_command "start"
  50. fi
  51. }
  52.  
  53. terraria_stop() {
  54. local cmd
  55. cmd="${command} -p 0 -S ${terraria_session} -X eval 'stuff stop\015'"
  56. if terraria_running; then
  57. echo "Stopping terraria."
  58. su -m ${terraria_user} -c "${cmd}"
  59. fi
  60. }
  61.  
  62. terraria_status() {
  63. if terraria_running; then
  64. echo "terraria is running."
  65. else
  66. echo "terraria is not running."
  67. fi
  68. }
  69.  
  70. terraria_running() {
  71. local check ses
  72. ses="${terraria_session}"
  73. check=`su -m ${terraria_user} -c "${command} -list | grep ${ses}"`
  74. if [ "$check" ]; then
  75. return 0
  76. else
  77. return 1
  78. fi
  79. }
  80.  
  81. run_rc_command "$1"
  82.  
Advertisement
Add Comment
Please, Sign In to add comment