fn_stop 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # LGSM fn_stop function
  3. # Author: Daniel Gibbs
  4. # Website: http://danielgibbs.co.uk
  5. # Version: 080214
  6. # Description: Stops the server.
  7. local modulename="Stopping"
  8. fn_stop_teamspeak3(){
  9. fn_check_root
  10. fn_check_systemdir
  11. fn_printdots "${servername}"
  12. fn_scriptlog "${servername}"
  13. sleep 1
  14. fn_check_ts3status
  15. if [ "${ts3status}" = "No server running (ts3server.pid is missing)" ];then
  16. fn_printfail "${servername} is already stopped"
  17. fn_scriptlog "${servername} is already stopped"
  18. else
  19. ${filesdir}/ts3server_startscript.sh stop inifile=${ini} > /dev/null 2>&1
  20. fn_printok "${servername}"
  21. fn_scriptlog "Stopped ${servername}"
  22. fi
  23. # Remove lock file
  24. rm -f "${rootdir}/${lockselfname}"
  25. sleep 1
  26. echo -en "\n"
  27. }
  28. fn_stop_tmux(){
  29. fn_check_root
  30. fn_check_systemdir
  31. fn_details_config
  32. fn_printdots "${servername}"
  33. fn_scriptlog "${servername}"
  34. sleep 1
  35. fn_check_tmux
  36. pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
  37. if [ "${pid}" == "0" ]; then
  38. fn_printfail "${servername} is already stopped"
  39. fn_scriptlog "${servername} is already stopped"
  40. else
  41. tmux kill-session -t ${servicename}
  42. fn_printok "${servername}"
  43. fn_scriptlog "Stopped ${servername}"
  44. fi
  45. # Remove lock file
  46. rm -f "${rootdir}/${lockselfname}"
  47. sleep 1
  48. echo -en "\n"
  49. }
  50. if [ "${gamename}" == "Teamspeak 3" ]; then
  51. fn_stop_teamspeak3
  52. else
  53. fn_stop_tmux
  54. fi