Advertisement
Guest User

script_v0.5.16

a guest
Jan 7th, 2016
7,388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 24.21 KB | None | 0 0
  1. #!/bin/bash
  2. #TS3 Server crack install script
  3. #Written by: Supervisor for www.r4p3.net
  4.  
  5. #Configuration settings. Change those to your needs or leave them as provided for standart use.
  6. timeout="5"                                                 #Timeout for update check in s
  7. COLOR1='\033[0;32m'                                         #green color
  8. COLOR2='\033[0;31m'                                         #red color
  9. NC='\033[0m'                                                #no color
  10. check_for_updates="1"                                       #put 1=YES or 0=NO to check for updates
  11. #Don't change the variables below to make sure the script runs without problems!
  12. scriptversion="0516"                                        #scriptversion
  13. tsversion="3.0.11.4"                                        #version of teamspeak server
  14. call_home="http://r4p3.6te.net"                             #check for updates
  15. serverdir="/home/$teamspeakuser/teamspeak3-server$version"  #Don't change this!
  16.  
  17. #################################################################################################
  18.  
  19. show_credits(){
  20. printf "${COLOR1}#######################################################\n#     TS3 Server crack script ${COLOR2}$scriptversion ${COLOR1}by ${COLOR2}Supervisor${COLOR1}      #\n#     Join our community at ${COLOR2}r4p3.net${COLOR1}                  #\n#######################################################\n${NC}"
  21. }
  22.  
  23. show_special_credits(){
  24. printf "${COLOR1}#######################################################\n#     Special credits go to:                          #\n#                                                     #\n#     - Team ${COLOR2}MESMERiZE / Kube${COLOR1} for making the crack    #\n#     - ${COLOR2}Asphyxia${COLOR1}                                      #\n#     - ${COLOR2}Derp${COLOR1}                                          #\n#     - ${COLOR2}Darksephiro${COLOR1}                                   #\n#######################################################\n${NC}"
  25. }
  26.  
  27. show_success(){
  28. printf "${COLOR1}#######################################################\n#     Thank you for using this script!                #\n#     If you didn't experience any errors your        #\n#     server is now successful updated to $tsversion    #\n#######################################################\n${NC}"
  29. }
  30.  
  31. show_menu(){
  32. printf "${COLOR1}#######################################################\n#     1) Install Crack                                #\n#     2) Update from 3.0.11.${COLOR2}X${COLOR1} to 3.0.11.${COLOR2}4${COLOR1}             #\n#     3) Anticrash scripts                            #\n#     4) Autostart scripts                            #\n#     5) AntiCrack                                    #\n#     6) Status                                       #\n#     7) Debug                                        #\n#     8) Show special credits                         #\n#     9) Show changelog + infos                       #\n#     CTRL-C to escape the script                     #\n#######################################################\nAnswer:   ${NC}"
  33. read answer
  34. }
  35.  
  36. show_changelog(){
  37. printf "${COLOR1}#######################################################\n#             ${COLOR2}Additional information:${COLOR1}                 #\n#                                                     #\n#   Alter the script with your favorite editor to     #\n#   change the following settings:                    #\n#                                                     #\n#   - change script colors                            #\n#   - script checking for updates: yes/no             #\n#   - change timout when checking for new s_versions  #\n#                                                     #\n#                                                     #\n#                    ${COLOR2}Changelog:${COLOR1}                       #\n#                                                     #\n#   v0.4.0.1 - added Status and debug                 #\n#   v0.4.2.1 - added anticrash and autostart scripts  #\n#   v0.4.3.6 - added Update function                  #\n#   v0.5.0.1 - added changelog to the script          #\n#   v0.5.07  - fixed some errors                      #\n#   v0.5.08  - added AntiCrack                        #\n#   v0.5.09  - fixed a c/p error                      #\n#   v0.5.10  - fixed a few typos                      #\n#   v0.5.11  - added infos                            #\n#            - fixed AntiCrash                        #\n#   v0.5.15  - fixed some errors                      #\n#   v0.5.16  - fixed iptables rule                    #\n#            - fixed anticrash again                  #\n#######################################################\n${NC}"
  38. }
  39.  
  40. set_user(){
  41. printf "${COLOR1}Choose a user for installation. If the user does not exist, it will be created:   ${NC}"
  42. read answer
  43. case $answer in
  44. [rR][oO0][oO0][tT])
  45.     printf "${COLOR1}User ${COLOR2}$answer${COLOR1} is not valid. Aborting...\n${NC}"
  46.     exit 1
  47. ;;
  48. [a-zA-Z0-9]*)
  49.     teamspeakuser="$answer"
  50.     if id -u "$teamspeakuser" >/dev/null 2>&1;
  51.     then    if [ ! -d /home/$teamspeakuser/ ]
  52.             then    printf "${COLOR1}Could not find home directory, creating it..\n${NC}"
  53.                     mkdir /home/$teamspeakuser
  54.                     chown $teamspeakuser:$teamspeakuser /home/$teamspeakuser
  55.             fi
  56.     else
  57.        printf "${COLOR1}User does not exist. Creating it...\n${NC}"
  58.     adduser $teamspeakuser
  59.     fi
  60. ;;
  61. *)  printf "${COLOR1}User '$answer' is not valid. Aborting...\n${NC}"
  62.     exit 1
  63. ;;
  64. esac
  65. }
  66.  
  67. set_hosts_file(){
  68. grep -v '.*teamspeak.*' /etc/hosts > /etc/hosts_temporary
  69. mv /etc/hosts_temporary /etc/hosts
  70. grep -v '.*ocsp\.digicert.com.*' /etc/hosts > /etc/hosts_temporary
  71. mv /etc/hosts_temporary /etc/hosts
  72. sed -i '1i127.0.0.1     teamspeak.com' /etc/hosts
  73. sed -i '1i127.0.0.1     accounting.teamspeak.com' /etc/hosts
  74. sed -i '1i127.0.0.1     backupaccounting.teamspeak.com' /etc/hosts
  75. sed -i '1i127.0.0.1     blacklist.teamspeak.com' /etc/hosts
  76. sed -i '1i127.0.0.1     ipcheck.teamspeak.com' /etc/hosts
  77. sed -i '1i127.0.0.1     ocsp.digicert.com' /etc/hosts
  78. sed -i '1i127.0.0.1     hardy.teamspeak.4players.de' /etc/hosts
  79. sed -i '1i::1           teamspeak.com' /etc/hosts
  80. sed -i '1i::1           accounting.teamspeak.com' /etc/hosts
  81. sed -i '1i::1           backupaccounting.teamspeak.com' /etc/hosts
  82. sed -i '1i::1           blacklist.teamspeak.com' /etc/hosts
  83. sed -i '1i::1           ipcheck.teamspeak.com' /etc/hosts
  84. sed -i '1i::1           ocsp.digicert.com' /etc/hosts
  85. sed -i '1i::1           hardy.teamspeak.4players.de' /etc/hosts
  86. echo " "
  87. }
  88.  
  89. set_ts3server_ini(){
  90. printf 'machine_id=\ndefault_voice_port=9987\nvoice_ip=0.0.0.0\nlicensepath=\nfiletransfer_port=30033\nfiletransfer_ip=0.0.0.0\nquery_port=10011\nquery_ip=0.0.0.0\nquery_ip_whitelist=query_ip_whitelist.txt\nquery_ip_blacklist=query_ip_blacklist.txt\ndbplugin=ts3db_sqlite3\ndbpluginparameter=\ndbsqlpath=sql/\ndbsqlcreatepath=create_sqlite/\ndbconnections=10\nlogpath=logs\nlogquerycommands=1\ndbclientkeepdays=90\ndblogkeepdays=30\nlogappend=0\nquery_skipbruteforcecheck=0\n' > /home/$teamspeakuser/teamspeak3-server$version/ts3server.ini
  91. printf "${COLOR1}Do you want to change the default query port? (Y)es | (N)o  :${NC}"
  92. read stuff
  93. case "$stuff" in
  94. N*|n*)
  95. ;;
  96. *)
  97. printf "${COLOR1}Enter query_port (Default: 10011)   :${NC}"
  98. read qport
  99. grep -v '.*query_port.*' /home/$teamspeakuser/teamspeak3-server$version/ts3server.ini > /home/$teamspeakuser/teamspeak3-server$version/ts3server.ini_temp
  100. mv /home/$teamspeakuser/teamspeak3-server$version/ts3server.ini_temp /home/$teamspeakuser/teamspeak3-server$version/ts3server.ini
  101. echo "query_port=$qport" >> /home/$teamspeakuser/teamspeak3-server$version/ts3server.ini
  102. ;;
  103. esac
  104. }
  105.  
  106. set_permissions(){
  107. chown -R $teamspeakuser:$teamspeakuser /home/$teamspeakuser
  108. }
  109.  
  110. check_os(){
  111. unamestr=`uname`
  112. unamever=`uname -m`
  113. #check Linux or FreeBSD
  114. if [[ "$unamestr" == 'Linux' ]]
  115. then os="_linux"
  116. elif [[ "$unamestr" == 'FreeBSD' ]]
  117. then os="_freebsd"
  118. fi
  119. #check 32bit or 64bit
  120. if [[ "$unamever" == 'x86_64' ]]
  121. then osv="-amd64"
  122. else osv="-x86"
  123. fi
  124. #set version
  125. version="$os$osv"
  126. }
  127.  
  128. download_server(){
  129. cd /home/$teamspeakuser/
  130. case $version in
  131. \_linux\-x86)
  132. wget 'https://www.cubbyusercontent.com/pl/teamspeak3-server_linux-x86.tar.gz/_8e7157551fa84314b4989718a2317ce0' -O crack.tar.gz
  133. ;;
  134. \_linux\-amd64)
  135. wget 'https://www.cubbyusercontent.com/pl/teamspeak3-server_linux-amd64.tar.gz/_b1bb0cfd7f9a44fe8270866574fcbfc1' -O crack.tar.gz
  136. ;;
  137. \_freeBSD\-x86)
  138. printf "${COLOR1}FreeBSD 32bit is not yet supported with this script.\n${NC}"
  139. exit 1
  140. #wget --no-check-certificate '' -O crack.tar.gz
  141. ;;
  142. \_freeBSD\-amd64)
  143. echo "${COLOR1}FreeBSD 64bit is not yet supported with this script.\n${NC}"
  144. exit 1
  145. #wget --no-check-certificate '' -O crack.tar.gz
  146. ;;
  147. esac
  148. tar xf crack.tar.gz
  149. rm crack.tar.gz
  150. }
  151.  
  152. update_server(){
  153. case $version in
  154. \_linux\-x86)
  155. wget 'https://www.cubbyusercontent.com/pl/ts3server_linux_x86/_1fcc69e235324971a2a9c0191badc3b7' -O ts3server_linux_x86
  156. stop_ts3_server
  157. mv "ts3server_linux_x86" "$serverdir/ts3server_linux_x86"
  158. chown "$teamspeakuser":"$teamspeakuser" "$serverdir/ts3server_linux_x86"
  159. ;;
  160. \_linux\-amd64)
  161. wget 'https://www.cubbyusercontent.com/pl/ts3server_linux_amd64/_19090f9a8a634822b91b3f4692eb0136' -O ts3server_linux_amd64
  162. stop_ts3_server
  163. mv "ts3server_linux_amd64" "$serverdir/ts3server_linux_amd64"
  164. chown "$teamspeakuser":"$teamspeakuser" "$serverdir/ts3server_linux_amd64"
  165. ;;
  166. \_freeBSD\-x86)
  167. printf "${COLOR2}FreeBSD 32bit is not yet supported with this script.\n${NC}"
  168. exit 1
  169. #wget --no-check-certificate '' -O crack.tar.gz
  170. ;;
  171. \_freeBSD\-amd64)
  172. echo "${COLOR2}FreeBSD 64bit is not yet supported with this script.\n${NC}"
  173. exit 1
  174. #wget --no-check-certificate '' -O crack.tar.gz
  175. ;;
  176. esac
  177. }
  178.  
  179. stop_ts3_server(){
  180. su $teamspeakuser /home/$teamspeakuser/teamspeak3-server$version/./ts3server_startscript.sh stop
  181. }
  182.  
  183. kill_ts3_server(){
  184. pkill -f ts3server
  185. }
  186.  
  187. stop_acc_server(){
  188. pkill -f AccountingServerEmulator-Linux
  189. }
  190.  
  191. start_ts3_server(){
  192. su $teamspeakuser -c "/home/$teamspeakuser/teamspeak3-server$version/./ts3server_startscript.sh start"
  193. }
  194.  
  195. start_acc_server(){
  196. su - $teamspeakuser -c "/home/$teamspeakuser/teamspeak3-server$version/./AccountingServerEmulator-Linux"
  197. }
  198.  
  199. check_for_root(){
  200. if [ "$(id -u)" != "0" ]; then
  201.     printf "${COLOR1}\nThis script must be run as root!\n${NC}" 1>&2
  202.     exit 1
  203. fi
  204. }
  205.  
  206. get_teamspeakuser(){
  207. printf "${COLOR1}Please type the username you run TeamSpeak with:   ${NC}"
  208. read teamspeakuser
  209. serverdir="/home/$teamspeakuser/teamspeak3-server$version"
  210. }
  211.  
  212. get_dir(){
  213. printf "${COLOR1}Did you install the TeamSpeak Server in ${COLOR2}$serverdir${COLOR1} ?\n (Y)es | (N)o:   ${NC}"
  214. read answer
  215. case $answer in
  216. n*|N*)  printf "${COLOR1}Type the ${COLOR2}exact${COLOR1} directory here (like the one above):   ${NC}"
  217.         read new_dir
  218.         serverdir=$new_dir
  219. ;;
  220. esac
  221. }
  222.  
  223. install_anticrash(){
  224. rm /etc/init.d/ts3anticrash.sh 2>/dev/null
  225. printf "#!/bin/bash\ncase "\$1" in\nts3server)\nt3server=\`ps ax | grep ts3server$version | grep -v grep | wc -l\`\nif [ \$t3server -eq 1 ]\nthen exit\nelse cd $serverdir/\n./ts3server_startscript.sh start\nfi\n;;\nts3accounting)\nt3accounting=\`ps ax | grep AccountingServer | grep -v grep | wc -l\`\nif [ \$t3accounting -eq 1 ]\nthen exit\nelse\ncd $serverdir/\n./AccountingServerEmulator-Linux\nfi\n;;\nts3tsdns)\nt3tsdns=\`ps ax | grep tsdnsserver$version | grep -v grep | wc -l\`\nif [ \$t3tsdns -eq 2 ]\nthen exit\nelse\ncd $serverdir/tsdns\nscreen -AmdS tsdnsserver ./tsdnsserver$version\nfi\n;;\nesac\n" >> /etc/init.d/ts3anticrash.sh
  226. chown $teamspeakuser:$teamspeakuser /etc/init.d/ts3anticrash.sh
  227. chmod +x /etc/init.d/ts3anticrash.sh
  228.  
  229. printf "${COLOR1}(A)ctivate or (D)eactivate the TS3 server anticrash script?\n(A)ctivate | (D)eactivate:   ${NC}"
  230. read answer
  231. case $answer in
  232.     A*|a*)
  233.     crontab -l -u $teamspeakuser > crontab_temp
  234.     cat crontab_temp | grep -v ts3server >crontab_temp2
  235.     printf "*/1 * * * * /etc/init.d/ts3anticrash.sh ts3server\n" >>crontab_temp2
  236.     crontab -u $teamspeakuser crontab_temp2
  237.     rm crontab_temp2 crontab_temp
  238.     printf "${COLOR1}Anticrash activated.\n${NC}"
  239.     ;;
  240.     *)
  241.     crontab -l -u $teamspeakuser > crontab_temp
  242.     cat crontab_temp | grep -v ts3server >crontab_temp2
  243.     crontab -u $teamspeakuser crontab_temp2
  244.     rm crontab_temp2 crontab_temp
  245.     printf "${COLOR2}Anticrash deactivated.\n${NC}"
  246.     ;;
  247. esac
  248.  
  249. printf "${COLOR1}(A)ctivate or (D)eactivate the AccServer anticrash script?\n(A)ctivate | (D)eactivate:   ${NC}"
  250. read answer
  251. case $answer in
  252.     A*|a*)
  253.     crontab -l -u $teamspeakuser > crontab_temp
  254.     cat crontab_temp | grep -v ts3accounting >crontab_temp2
  255.     printf "*/25 * * * * /etc/init.d/ts3anticrash.sh ts3accounting\n" >>crontab_temp2
  256.     crontab -u $teamspeakuser crontab_temp2
  257.     rm crontab_temp2 crontab_temp
  258.     printf "${COLOR1}Anticrash activated.\n${NC}"
  259.     ;;
  260.     *)
  261.     crontab -l -u $teamspeakuser > crontab_temp
  262.     cat crontab_temp | grep -v ts3accounting >crontab_temp2
  263.     crontab -u $teamspeakuser crontab_temp2
  264.     rm crontab_temp2 crontab_temp
  265.     printf "${COLOR2}Anticrash deactivated.\n${NC}"
  266.     ;;
  267. esac
  268.  
  269. printf "${COLOR1}(A)ctivate or (D)eactivate the TSDNS server anticrash script?\nIf you are not sure about it, set it to Deactivate.\n(A)ctivate | (D)eactivate:   ${NC}"
  270. read answer
  271. case $answer in
  272.     A*|a*)
  273.     crontab -l -u $teamspeakuser > crontab_temp
  274.     cat crontab_temp | grep -v ts3tsdns >crontab_temp2
  275.     printf "*/1 * * * * /etc/init.d/ts3anticrash.sh ts3tsdns\n" >>crontab_temp2
  276.     crontab -u $teamspeakuser crontab_temp2
  277.     rm crontab_temp2 crontab_temp
  278.     printf "${COLOR1}Anticrash activated.\n${NC}"
  279.     ;;
  280.     *)
  281.     crontab -l -u $teamspeakuser > crontab_temp
  282.     cat crontab_temp | grep -v ts3tsdns >crontab_temp2
  283.     crontab -u $teamspeakuser crontab_temp2
  284.     rm crontab_temp2 crontab_temp
  285.     printf "${COLOR2}Anticrash deactivated.\n${NC}"
  286.     ;;
  287. esac
  288.  
  289. }
  290.  
  291. install_autostart_scripts(){
  292. printf "#!/bin/sh\n### BEGIN INIT INFO\n# Provides:                     ts3server\n# Required-Start:               \$local_fs \$network\n# Required-Stop:                \$local_fs \$network\n# Default-Start:                2 3 4 5\n# Default-Stop:                 0 1 6\n# Description:                  Teamspeak 3 Server\n#\n### END INIT INFO#!/bin/sh\n\ncase "\$1" in\nstart)\nsleep 1\ncd $serverdir\nsu $teamspeakuser -c \"./ts3server_startscript.sh start\"\n;;\nstop)\ncd $serverdir\nsu $teamspeakuser -c \"./ts3server_startscript.sh stop\"\n;;\nesac\nexit 0" >> /etc/init.d/ts3server
  293. printf "#!/bin/sh\n### BEGIN INIT INFO\n# Provides:                     accserver\n# Required-Start:               \$local_fs \$network\n# Required-Stop:                \$local_fs \$network\n# Default-Start:                2 3 4 5\n# Default-Stop:                 0 1 6\n# Description:                  AccountingServerEmulator-Linux\n#\n### END INIT INFO#!/bin/sh\n\ncase "\$1" in\nstart)\nsleep 1\ncd $serverdir\nsu $teamspeakuser -c \"./AccountingServerEmulator-Linux\"\n;;\nstop)\ncd $serverdir\nsu $teamspeakuser -c \"./AccountingServerEmulator-Linux stop\"\n;;\nesac\nexit 0" >> /etc/init.d/accserver
  294. chmod +x /etc/init.d/ts3server
  295. chmod +x /etc/init.d/accserver
  296. update-rc.d ts3server defaults
  297. update-rc.d accserver defaults
  298. printf "${COLOR1}Would you like to install an autostart script for the TSDNS server?\nIf you are not sure about it, set it to NO.\n(Y)es | (N)o:   ${NC}"
  299. read answer
  300. case $answer in
  301. Y*|y*|j|J*)
  302. printf "#!/bin/sh\n### BEGIN INIT INFO\n# Provides:                     tsdnsserver\n# Required-Start:               \$local_fs \$network\n# Required-Stop:                \$local_fs \$network\n# Default-Start:                2 3 4 5\n# Default-Stop:                 0 1 6\n# Short-Description:\n# Description:                  Teamspeak 3 TSDNS Server\n#\n### END INIT INFO#!/bin/sh\n\ncase "$1" in\nstart)\ncd $serverdir/tsdns\nsu $teamspeakuser -c \"screen -AmdS tsdnsserver ./tsdnsserver_$version\"\n;;\nstop)\nsu ts3 -c "screen -S tsdnsserver -X quit"\n;;\nesac\nexit 0" >> /etc/init.d/tsdnsserver
  303. chmod +x /etc/init.d/tsdnsserver
  304. update-rc.d tsdnsserver defaults
  305. ;;
  306. esac
  307. printf "${COLOR1}Autostart scripts installed.\n${NC}"
  308. }
  309.  
  310. get_status_ts3server(){
  311. t3server=`ps ax | grep ts3server | grep -v grep | wc -l`
  312. printf "${COLOR1}#######################################################\n${NC}"
  313. if [ $t3server -eq 0 ]
  314.     then printf "${COLOR1}#       ${COLOR2}-> TeamSpeak server not running!${COLOR1}              #\n${NC}"
  315.     else printf "${COLOR1}#       -> TeamSpeak Server is running.               #\n${NC}"
  316. fi
  317. }
  318.  
  319. get_status_accserver(){
  320. t3accounting=`ps ax | grep AccountingServerEmulator-Linux | grep -v grep | wc -l`
  321. if [ $t3accounting -eq 0 ]
  322.     then printf "${COLOR1}#       ${COLOR2}-> Accounting server is not running!${COLOR1}          #\n${NC}"
  323.     else printf "${COLOR1}#       -> Accounting server is running.              #\n${NC}"
  324. fi
  325. }
  326.  
  327. get_status_tsdnsserver(){
  328. t3tsdns=`ps ax | grep tsdnsserver | grep -v grep | wc -l`
  329. if [ $t3tsdns -eq 2 ]
  330.     then printf "${COLOR1}#       -> TSDNS server is running.                   #\n${NC}"
  331.     else printf "${COLOR1}#       ${COLOR2}-> TSDNS server is not running!${COLOR1}               #\n${NC}"
  332. fi
  333. }
  334.  
  335. get_status_hosts(){
  336. ts3hosts=`grep -o '.*teamspeak.*' /etc/hosts | wc -l`
  337. if [ $ts3hosts -gt 11 ]
  338.     then printf "${COLOR1}#       -> Hosts file is set up correct.              #\n${NC}"
  339.     else printf "${COLOR2}#       ${COLOR2}-> Hosts file is not set up correct.${COLOR1}          #\n${NC}"
  340. fi
  341. printf "${COLOR1}#######################################################\n${NC}"
  342. }
  343.  
  344. check_version(){
  345. if [ $check_for_updates -eq 1 ]; then
  346.     printf "${COLOR1}Checking for updates..."
  347.     curl -s -m $timeout --head $call_home/script.php | head -n 1 | grep "HTTP/1.[01] [2].." > /dev/$
  348.     if [ $? = 1 ];
  349.     then  printf "${COLOR2}\nScript on Update Server is not available.\nYou may restart the script to retry.\nPlease check r4p3.net for news\n${NC}"
  350.     else
  351.         sversion=$(wget $call_home/script.php?version -q -O -)
  352.         if [ $sversion \> $scriptversion ];
  353.             then printf "${COLOR1}\nA new script version is available, downloading it...\n${NC}"
  354.             update_script
  355.             else printf "${COLOR1}       ...script is up to date!\n${NC}"
  356.         fi
  357.     fi
  358. fi
  359. }
  360.  
  361. update_script(){
  362. slink=$(wget $call_home/script.php?link -q -O -)
  363. wget $slink -q -O ts3crack_$sversion
  364. chmod +x ts3crack_$sversion
  365. rm ts3crack_$scriptversion
  366. ./ts3crack_$sversion
  367. }
  368.  
  369. restart_script(){
  370. printf "${COLOR1}Done. Press any key to continue...\n${NC}"
  371. read -n 1
  372. clear
  373. $0
  374. }
  375.  
  376. check_packages(){
  377. command -v iptables >/dev/null 2>&1 || error_iptables="1"
  378. if [[ $error_iptables -eq 1 ]]
  379.     then
  380.     printf >&2 "${COLOR1}IPTABLES are not installed, but required.\n Please type ${COLOR2}apt-get install iptables${COLOR1} if you run Ubuntu or Debian or ${COLOR2}yum install iptables${COLOR1} if you run CentOS\n${NC}"
  381.     read answer
  382.     $answer
  383.     restart_script
  384. fi
  385. command -v curl >/dev/null 2>&1 || error_curl="1"
  386. if [[ $error_curl -eq 1 ]]
  387.     then
  388.     printf >&2 "${COLOR1}CURL is not installed, but required.\n Please type ${COLOR2}apt-get install curl${COLOR1} if you run Ubuntu or Debian or ${COLOR2}yum install curl${COLOR1} if you run CentOS\n${NC}"
  389.     read answer
  390.     $answer
  391.     restart_script
  392. fi
  393. command -v screen >/dev/null 2>&1 || error_curl="1"
  394. if [[ $error_curl -eq 1 ]]
  395.     then
  396.     printf >&2 "${COLOR1}Screen is not installed, but required.\n Please type ${COLOR2}apt-get install screen${COLOR1} if you run Ubuntu or Debian or ${COLOR2}yum install curl${COLOR1} if you run CentOS\n${NC}"
  397.     read answer
  398.     $answer
  399.     restart_script
  400. fi
  401. }
  402.  
  403. set_iptables(){
  404. printf "${COLOR1}#######################################################\n#     Note: Your server will appear as                #\n#     \"not cracked\" to CrackCheckers if activated.    #\n#     1) Activate AntiCrack                           #\n#     2) Deactivate AntiCrack                         #\n#######################################################\nAnswer:   ${NC}"
  405. read answer
  406. iptables -D INPUT -p tcp --dport 2008 -j DROP 2>/dev/null
  407. iptables -D INPUT -p tcp --dport 2008 -s 127.0.0.1 -j ACCEPT 2>/dev/null
  408. case $answer in
  409. 1)
  410. iptables -I INPUT -p tcp --dport 2008 -j DROP
  411. iptables -I INPUT -p tcp --dport 2008 -s 127.0.0.1 -j ACCEPT
  412. iptables-save
  413. printf "${COLOR1}AntiCrack activated.\n${NC}"
  414. ;;
  415. *)
  416. iptables-save
  417. printf "${COLOR2}AntiCrack deactivated.\n${NC}"
  418. ;;
  419. esac
  420. }
  421.  
  422. help(){
  423. printf "${COLOR1}#######################################################\n#       1) back to main menu                          #\n#       show_credits                                  #\n#       show_special_credits                          #\n#       show_success                                  #\n#       show_menu                                     #\n#       set_user                                      #\n#       set_hosts_file                                #\n#       set_ts3server_ini                             #\n#       set_permissions                               #\n#       check_os                                      #\n#       download_server                               #\n#       update_server                                 #\n#       stop_ts3_server                               #\n#       kill_ts3_server                               #\n#       stop_acc_server                               #\n#       start_ts3_server                              #\n#       start_acc_server                              #\n#       check_for_root                                #\n#       get_teamspeakuser                             #\n#       get_dir                                       #\n#       install_anticrash                             #\n#       install_autostart_scripts                     #\n#       check_version                                 #\n#       check_packages                                #\n#       set_iptables                                  #\n#       update_script                                 #\n#       help                                          #\n#######################################################\n${NC}"
  424. }
  425.  
  426. debug(){
  427. printf "${COLOR1}Type a comand:   ${NC}"
  428. read command
  429. case $command in
  430. show_credits)               show_credits                ;;
  431. show_special_credits)       show_special_credits        ;;
  432. show_success)               show_success                ;;
  433. show_menu)                  show_menu                   ;;
  434. set_user)                   set_user                    ;;
  435. set_hosts_file)             set_hosts_file              ;;
  436. set_ts3server_ini)          set_ts3server_ini           ;;
  437. set_permissions)            set_permissions             ;;
  438. check_os)                   check_os                    ;;
  439. download_server)            download_server             ;;
  440. update_server)              update_server               ;;
  441. stop_ts3_server)            stop_ts3_server             ;;
  442. kill_ts3_server)            kill_ts3_server             ;;
  443. stop_acc_server)            stop_acc_server             ;;
  444. start_ts3_server)           start_ts3_server            ;;
  445. start_acc_server)           start_acc_server            ;;
  446. check_for_root)             check_for_root              ;;
  447. get_teamspeakuser)          get_teamspeakuser           ;;
  448. get_dir)                    get_dir                     ;;
  449. install_anticrash)          install_anticrash           ;;
  450. install_autostart_scripts)  install_autostart_scripts   ;;
  451. get_status_ts3server)       get_status_ts3server        ;;
  452. get_status_accserver)       get_status_accserver        ;;
  453. get_status_tsdnsserver)     get_status_tsdnsserver      ;;
  454. check_version)              check_version               ;;
  455. update_script)              update_script               ;;
  456. check_packages)             check_packages              ;;
  457. set_iptables)               set_iptables                ;;
  458. help)                       help                        ;;
  459. 1)                          $0                          ;;
  460. esac
  461. }
  462.  
  463. #################################################################################################
  464. # todo for debug/help:          -
  465. #################################################################################################
  466.  
  467. show_credits
  468. check_for_root
  469. check_packages
  470. check_os
  471. check_version
  472. show_menu
  473. case $answer in
  474. 1*)
  475. check_os
  476. set_user
  477. kill_ts3_server
  478. stop_acc_server
  479. set_hosts_file
  480. download_server
  481. set_ts3server_ini
  482. set_permissions
  483. start_ts3_server
  484. start_acc_server
  485. ;;
  486. 2*)
  487. get_teamspeakuser
  488. get_dir
  489. update_server
  490. start_ts3_server
  491. show_success
  492. ;;
  493. 3*)
  494. check_os
  495. get_teamspeakuser
  496. get_dir
  497. install_anticrash
  498. sleep 0.5
  499. restart_script
  500. ;;
  501. 4*)
  502. check_os
  503. get_teamspeakuser
  504. get_dir
  505. install_autostart_scripts
  506. sleep 0.5
  507. restart_script
  508. ;;
  509. 5)
  510. set_iptables
  511. restart_script
  512. ;;
  513. 6*)
  514. check_os
  515. get_status_ts3server
  516. get_status_accserver
  517. get_status_tsdnsserver
  518. get_status_hosts
  519. sleep 0.5
  520. restart_script
  521. ;;
  522. 7*)
  523. printf "${COLOR1}#######################################################\n#     Type ${COLOR2}CTRL-C${COLOR1} to exit this mode!                  #\n#     Type ${COLOR2}help${COLOR1} to view all commands available        #\n#######################################################\n${NC}"
  524. i=0
  525. while [ $i -lt 1 ]
  526. do
  527. debug
  528. done
  529. ;;
  530. 8*)
  531. show_special_credits
  532. sleep 0.5
  533. restart_script
  534. ;;
  535. 9*)
  536. show_changelog
  537. sleep 0.5
  538. restart_script
  539. ;;
  540. *)
  541. clear
  542. show_menu
  543. ;;
  544. esac
  545. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement