Advertisement
Guest User

HSAADGDSFHSHSDH

a guest
Jan 22nd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.59 KB | None | 0 0
  1. #!/bin/bash
  2. # armaserver: ArmA 3 Linux Dedicated Server Control Script
  3. #
  4. # original was:
  5. # armaserver: ArmA 2 Linux Dedicated Server Control Script
  6. # (c) 2010 BIStudio
  7. # ArmA 2 binary version must be 1.04 or later
  8. #
  9. ##
  10. ### modified by Nasdero
  11. ### V 1.01 - 28.03.2015
  12. ### added BEPATH and changed handling of logfiles in ${ARMA_DIR}
  13. #### modified by [VB]AWOL for Official Epoch Linux Support
  14. #=======================================================================
  15. #======== CONFIGURATION PARAMETERS ========
  16. #======== MUST BE EDITED MANUALLY TO FIT YOUR SYSTEM PARAMETERS ========
  17. #=======================================================================
  18. export LD_LIBRARY_PATH=.:$HOME/epoch:$HOME/epoch/@epochhive:$LD_LIBRARY_PATH;
  19. ARMA_DIR=/home/arma3
  20. PORT=2302
  21. NAME=sc
  22. #NAME= your game name, if you run a Team Death Match server Name=tdm
  23. #but you need a folder called tdm in the ${CFG_DIR} folder
  24. #run the "check" parameter on this file here, it will give you all infos
  25. DELDAYS=7
  26. #DELDAYS=7 => old logfiles will be deleted after 7 days
  27. #
  28. OTHERPARAMS="-maxMem=2047 -nosound -exthreads=1 -noCB -autoinit -loadMissionToMemory"
  29. # sample in the next row
  30. #OTHERPARAMS="-cpucount=4 -maxMem=2047 -nosound -exthreads=1 -noCB"
  31. #MODS=
  32. # sample in the next row
  33. #MODS=@CBA_A3\;@tmr_alt\;@a3mp
  34. MODS=@epoch
  35. SERVERMODS=@epochhive
  36. #=======================================================================
  37. # !!!!!!!!!! DO NOT EDIT ANYTHING BELOW THIS LINE !!!!!!!!!!
  38. #=======================================================================
  39. CFG_DIR=${ARMA_DIR}
  40. CONFIG=${CFG_DIR}/${NAME}/server.cfg
  41. CFG=${CFG_DIR}/${NAME}/basic.cfg
  42. LOG_DIR=${ARMA_DIR}/logs
  43. BEPATH=${CFG_DIR}/${NAME}/battleye/
  44. #PROFILES= not working on linux as far as I know, arma 3 uses Player
  45. #what ever we try until now, don't use -profiles= in startcmd !!!!!
  46. #PROFILES=${CFG_DIR}/${NAME}
  47. PROFILES=${NAME}
  48. PIDFILE=${ARMA_DIR}/${PORT}.pid
  49. RUNFILE=${ARMA_DIR}/${PORT}.run
  50. LOGFILE=${LOG_DIR}/port_${PORT}.`date +%d.%m.%y_%H%M`.log
  51. SERVER=${ARMA_DIR}/arma3server
  52. #=======================================================================
  53. ulimit -c 1000000
  54.  
  55. case "$1" in
  56.  
  57.  
  58. start)
  59. # check if there is a server running or not
  60. ps ax | grep ${SERVER} | grep ${PORT} > /dev/null
  61. if [ $? -eq 0 ]; then
  62. echo -e "\033[31mThere is a Server already running (${SERVER} at Port ${PORT})\033[0m"
  63. echo -e "\033[31mIt can happen, when you started a Server and stopped it to fast!\033[0m"
  64. echo -e "\033[31mJust stop the Server again and it should be good to start!\033[0m"
  65. echo $output | ps ax | grep ${SERVER} | grep ${PORT}
  66. else
  67. echo -e "Starting A3 server @PORT \033[35m${PORT}\033[0m..."
  68. # file to mark we want server running...
  69. echo "go" >${RUNFILE}
  70. # launch the background watchdog process to run the server
  71. nohup </dev/null >/dev/null $0 watchdog &
  72. fi
  73. ;;
  74.  
  75. stop)
  76. echo -e "Stopping A3 server if there is one (Port=\033[35m${PORT}\033[0m)..."
  77. if [ -f ${RUNFILE} ]; then
  78. # ask watcher process to exit by deleting its runfile...
  79. rm -f ${RUNFILE}
  80. else
  81. echo -e "\033[31mThere is no runfile (${RUNFILE}), Server shouldn't be up, will shut it down if it is up!\033[0m"
  82. fi
  83. # and terminate ArmA 3 server process
  84. if [ -f ${PIDFILE} ]; then
  85. kill -TERM $(< ${PIDFILE})
  86. if [ -f ${PIDFILE} ]; then
  87. rm -f ${PIDFILE}
  88. fi
  89. fi
  90. ;;
  91.  
  92. status)
  93. if [ -f ${RUNFILE} ]; then
  94. echo -e "\033[32mRunfile exist, Server should be up or is starting...\033[0m"
  95. echo -e "\033[35mIf the Server is \033[31mnot done\033[35m with its start, you will \033[31mnot get\033[35m a PID file info in the next rows.\033[0m"
  96. echo -e "\033[35mIf the Server is \033[32mdone\033[35m with its start, you will \033[32mget\033[35m a PID file and process info in the next rows.\033[0m"
  97. else
  98. echo -e "\033[31mRunfile doesn't exist, Server should be down or is going down...\033[0m"
  99. fi
  100. if [ -f ${PIDFILE} ]; then
  101. PID=$(< ${PIDFILE})
  102. echo -e "\033[32mPID file exists (PID=\033[35m${PID}\033[0m)..."
  103. if [ -f /proc/${PID}/cmdline ]; then
  104. echo -e "\033[32mServer process seems to be running...\033[0m"
  105. echo $output | ps ax | grep ${SERVER} | grep ${PORT}
  106. fi
  107. fi
  108. ;;
  109.  
  110. restart)
  111. $0 stop
  112. sleep 5s
  113. $0 start
  114. ;;
  115.  
  116. watchdog)
  117. # zip old logfile and move it to old directory
  118. cd ${LOG_DIR}
  119. if [ -f port_${PORT}*.log ]; then
  120. for i in port_${PORT}*.log; do tar -cvzf $i.tgz $i; rm $i; done
  121. mv port_${PORT}*.tgz old/
  122. echo >>${LOGFILE} "WATCHDOG ($$): [$(date)] Zipping logfiles from ${LOG_DIR} to ${LOG_DIR}/old"
  123. else
  124. echo >>${LOGFILE} "WATCHDOG ($$): [$(date)] No old logfile to zip in ${LOG_DIR}"
  125. fi
  126.  
  127. # zip old logfiles and move them to old directory
  128. cd ${ARMA_DIR}
  129. if find ./*.log -type f; then
  130. for i in *.log; do tar -cvzf $i.`date +%d.%m.%y_%H%M`.tgz $i; rm $i; done
  131. mv *.tgz log ${LOG_DIR}/old
  132. echo >>${LOGFILE} "WATCHDOG ($$): [$(date)] Zipping logfiles from ${ARMA_DIR} to ${LOG_DIR}/old"
  133. else
  134. echo >>${LOGFILE} "WATCHDOG ($$): [$(date)] No old logfiles to zip in ${ARMA_DIR}"
  135. fi
  136.  
  137. # delete old logs when older then ${DELDAYS} days
  138. find ${LOG_DIR}/old -iname "*log.tgz" -mtime +${DELDAYS} -delete
  139. echo >>${LOGFILE} "WATCHDOG ($$): [$(date)] Deleting all zipped logfile in ${LOG_DIR}/old when older then ${DELDAYS} days."
  140.  
  141. # this is a background watchdog process. Do not start directly
  142. while [ -f ${RUNFILE} ]; do
  143. # launch the server...
  144. cd ${ARMA_DIR}
  145. echo >>${LOGFILE} "WATCHDOG ($$): [$(date)] Starting server (port ${PORT})..."
  146. export LD_LIBRARY_PATH=.:${ARMA_DIR}:${ARMA_DIR}/@epochhive:$LD_LIBRARY_PATH
  147.  
  148. ${SERVER} >>${LOGFILE} 2>&1 -config=${CONFIG} -cfg=${CFG} -port=${PORT} -name=${NAME} -pid=${PIDFILE} -mod=${MODS} -servermod=${SERVERMODS} -bepath=${BEPATH} ${OTHERPARAMS}
  149.  
  150. if [ -f ${RUNFILE} ]; then
  151. echo >>${LOGFILE} "WATCHDOG ($$): [$(date)] Server died, waiting to restart..."
  152. sleep 5s
  153. else
  154. echo >>${LOGFILE} "WATCHDOG ($$): [$(date)] Server shutdown intentional, watchdog terminating"
  155. fi
  156. done
  157. ;;
  158.  
  159. check)
  160. clear
  161. echo -ne "\033[33mArmA 3 directory:\033[0m ${ARMA_DIR} "
  162. if [ -d ${ARMA_DIR} ]; then
  163. echo -e "\033[32mOK\033[0m"
  164. else
  165. echo -e "\033[31mMISSING!\033[0m"
  166. echo -e "========= Check your settings (ARMA_DIR)! =========\n"
  167. fi
  168.  
  169. echo -ne "\033[33mServer executable:\033[0m ${SERVER} "
  170. if [ -x ${SERVER} ]; then
  171. echo -e "\033[32mOK\033[0m"
  172. else
  173. echo -e "\033[31mMISSING!\033[0m"
  174. echo -e "========= Server executable not found, arma3server should be in that folder when path is right =========\n"
  175. fi
  176.  
  177. echo -ne "\033[33mCFG directory:\033[0m ${CFG_DIR}/${NAME} "
  178. if [ -d ${CFG_DIR}/${NAME} ]; then
  179. echo -e "\033[32mOK\033[0m"
  180. else
  181. echo -e "\033[31mMISSING!\033[0m"
  182. echo -e "========= We need that folder for the config files! You can use the next row to create it: ========="
  183. echo -e "\033[35mmkdir ${CFG_DIR}/${NAME}\033[0m\n"
  184. fi
  185.  
  186. echo -ne "\033[33mConfig file:\033[0m ${CONFIG} "
  187. if [ -f ${CONFIG} ]; then
  188. echo -e "\033[32mOK\033[0m"
  189. else
  190. echo -e "\033[31mMISSING!\033[0m"
  191. echo -e "========= We need this file in that folder =========\n"
  192. fi
  193.  
  194. echo -ne "\033[33mBasic file:\033[0m ${CFG} "
  195. if [ -f ${CFG} ]; then
  196. echo -e "\033[32mOK\033[0m"
  197. else
  198. echo -e "\033[31mMISSING!\033[0m"
  199. echo -e "========= We need this file in that folder =========\n"
  200. fi
  201.  
  202. echo -ne "\033[33mBattleye directory:\033[0m ${BEPATH} "
  203. if [ -d ${BEPATH} ]; then
  204. echo -e "\033[32mOK\033[0m"
  205. else
  206. echo -e "\033[31mMISSING!\033[0m"
  207. echo -e "========= We need that folder for the Battleye files! You can use the next row to create it: ========="
  208. echo -e "\033[35mmkdir ${BEPATH}\033[0m\n"
  209. fi
  210.  
  211. echo -ne "\033[33mArma3Profile:\033[0m ${CFG_DIR}/${NAME}/users/${NAME}/${NAME}.arma3profile "
  212. if [ -f ${CFG_DIR}/${NAME}/users/${NAME}/${NAME}.arma3profile ]; then
  213. echo -e "\033[32mOK\033[0m"
  214. else
  215. echo -e "\033[31mMISSING!\033[0m"
  216. echo -e "========= We need that file! You can create it like this, edit it then for your need later: ========="
  217. echo -e "========= ( https://community.bistudio.com/wiki/Arma_3_Dedicated_Server) ****.Arma3Profile =========\033[35m"
  218. echo -n 'echo -e "version=2;\nviewDistance=3000;\npreferredObjectViewDistance=3000;\nterrainGrid=12.5;\nactiveKeys[]=\n{\n};" > '
  219. echo -n "${CFG_DIR}/${NAME}/users/${NAME}/${NAME}.arma3profile"
  220. echo -e "\n\033[0m"
  221. fi
  222.  
  223. echo -ne "\033[33mLog directory:\033[0m ${LOG_DIR} "
  224. if [ -d ${LOG_DIR} ]; then
  225. echo -e "\033[32mOK\033[0m"
  226. else
  227. echo -e "\033[31mMISSING!\033[0m"
  228. echo -e "========= We need that folder. You can use the next row to create it: ========="
  229. echo -e "\033[35mmkdir ${LOG_DIR}\033[0m\n"
  230. fi
  231.  
  232. echo -ne "\033[33mOld Log directory:\033[0m ${LOG_DIR}/old "
  233. if [ -d ${LOG_DIR}/old ]; then
  234. echo -e "\033[32mOK\033[0m"
  235. else
  236. echo -e "\033[31mMISSING!\033[0m"
  237. echo -e "========= We need that folder. You can use the next row to create it: ========="
  238. echo -e "\033[35mmkdir ${LOG_DIR}/old\033[0m\n"
  239. fi
  240.  
  241. echo -ne "\033[33mProfile directory:\033[0m ~/.local/share/Arma\ 3\ -\ Other\ Profiles/${NAME} "
  242. if [ -d ~/.local/share/Arma\ 3\ -\ Other\ Profiles/${NAME} ]; then
  243. echo -e "\033[32mOK\033[0m"
  244. else
  245. echo -e "\033[31mMISSING!\033[0m"
  246. echo -e "========= You should create this folder. You can use the next row for that: ========="
  247. echo -e "========= ( Not sure if we need this? Capital letters are ok ?) ========="
  248. echo -e "\033[35mmkdir -p ~/.local/share/Arma\ 3\ -\ Other\ Profiles/${NAME}\033[0m\n"
  249. fi
  250.  
  251. echo -ne "\033[33mArma3Profile symlink:\033[0m ~/.local/share/Arma\ 3\ -\ Other\ Profiles/${NAME}/${NAME}.Arma3Profile "
  252. if [ -L ~/.local/share/Arma\ 3\ -\ Other\ Profiles/${NAME}/${NAME}.Arma3Profile ]; then
  253. echo -e "\033[32mOK\033[0m"
  254. else
  255. echo -e "\033[31mMISSING!\033[0m"
  256. echo -e "========= You should creat this symlink. You can use the next row for that: ========="
  257. echo -e "========= ( Capital letters are ok in ~/.local/share/Arma 3.. !) ========="
  258. echo -e "\033[35mln -s ${CFG_DIR}/${NAME}/${NAME}.arma3profile ~/.local/share/Arma\ 3\ -\ Other\ Profiles/${NAME}/${NAME}.Arma3Profile\033[0m\n"
  259. fi
  260.  
  261. echo -e "\n\033[33mPort number will be: \033[0m${PORT}"
  262. echo -e "\033[33mPID file will be: \033[0m${PIDFILE}"
  263. echo -e "\033[33mRUN file will be: \033[0m${RUNFILE}"
  264.  
  265. echo -e "\n\033[33mStart cmd will be:\033[0m"
  266. echo -e "${SERVER} >>${LOGFILE} 2>&1 -config=${CONFIG} -cfg=${CFG} -port=${PORT} -name=${NAME} -pid=${PIDFILE} -mod=${MODS} ${OTHERPARAMS}"
  267.  
  268. echo -e "\n\033[31mIf you got something MISSING, you have to work from the top to the bottom, fix the top issue and start the check again!\033[0m"
  269. ;;
  270.  
  271. log)
  272. # you can see the logfile in realtime, no more need for screen or something else
  273. clear
  274. echo "To stop viewing the logfile press CTRL+C"
  275. echo "========================================"
  276. sleep 1s
  277. tail -f ${LOG_DIR}/port_${PORT}*.log
  278. ;;
  279.  
  280. *)
  281. echo "$0 (start|stop|restart|status|check|log)"
  282. ;;
  283. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement