Advertisement
Guest User

Untitled

a guest
Jun 4th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # for usage, run without arguments
  4. #
  5. # see ../README for setup instructions.
  6. #
  7.  
  8. show_help() {
  9. echo "usage: ./opensim {start|stop|restart|console} <sim_name>"
  10. echo " where <sim_name> is one of: your_sim"
  11. }
  12.  
  13. check_user() {
  14. if [ $USER != 'opensim' ]; then
  15. echo "This must be run as user opensim"
  16. exit 1
  17. fi
  18. }
  19.  
  20. setup() {
  21. if [ ! $1 ]; then
  22. show_help
  23. exit 1
  24. else
  25. SIM=$1
  26. fi
  27.  
  28. if [ $SIM == "your_sim" ]; then
  29. MONO="/home/opensim/bin/mono"
  30. PID="/home/opensim/bin/pid/${SIM}.pid"
  31. OPENSIM_DIR="/home/opensim/bin"
  32. CONSOLE_PORT="9100"
  33. CONSOLE_USER="Bazman_Doobie"
  34. CONSOLE_PASS="p92koyMEtd"
  35. else
  36. echo "Sorry, I've never heard of sim ${SIM}. Exiting."
  37. exit 1;
  38. fi
  39. }
  40.  
  41. do_start() {
  42. if [ ! $1 ]; then
  43. show_help
  44. exit 1
  45. else
  46. SIM=$1
  47. fi
  48.  
  49. setup $SIM
  50. check_user
  51.  
  52. cd ${OPENSIM_DIR}/bin && $MONO --debug OpenSim.exe -console=rest -name=$SIM > /dev/null 2>&1 &
  53. }
  54.  
  55. do_kill() {
  56. if [ ! $1 ]; then
  57. show_help
  58. exit 1
  59. else
  60. SIM=$1
  61. fi
  62.  
  63. setup $SIM
  64. check_user
  65.  
  66. if [ -f $PID ]; then
  67. kill -9 `cat $PID`
  68. else
  69. echo "Sorry, ${SIM} PID not found."
  70. exit 1
  71. fi
  72. }
  73.  
  74. do_console() {
  75. if [ ! $1 ]; then
  76. show_help
  77. exit 1
  78. fi
  79.  
  80. setup $1
  81.  
  82. cd ${OPENSIM_DIR}/bin && $MONO OpenSim.ConsoleClient.exe -host localhost \
  83. -port $CONSOLE_PORT -user $CONSOLE_USER -pass $CONSOLE_PASS -prompt "$SIM "
  84. }
  85.  
  86. case "$1" in
  87. start)
  88. do_start $2
  89. ;;
  90. stop)
  91. do_kill $2
  92. ;;
  93. kill)
  94. do_kill $2
  95. ;;
  96. restart)
  97. do_kill $2
  98. do_start $2
  99. ;;
  100. console)
  101. do_console $2
  102. ;;
  103. *)
  104. show_help
  105. exit 1
  106. ;;
  107. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement