Facebook
From Thundering Sloth, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 216
  1. #!/bin/bash
  2. # Colors
  3. ESC_SEQ="\x1b["
  4. COL_RESET=$ESC_SEQ"39;49;00m"
  5. COL_RED=$ESC_SEQ"31;01m"
  6. COL_GREEN=$ESC_SEQ"32;01m"
  7. COL_YELLOW=$ESC_SEQ"33;01m"
  8. COL_BLUE=$ESC_SEQ"34;01m"
  9. COL_MAGENTA=$ESC_SEQ"35;01m"
  10. COL_CYAN=$ESC_SEQ"36;01m"
  11. version="6.2"
  12. dl_version="62"
  13. php_ver="7.2"
  14.  
  15. echo ""
  16. echo "Owner: Mariusz Werton Szczytowski"
  17. echo "Founder: Tymoteusz Razor Meister Bartnik"
  18. echo "Contact TeamSpeak3: XBot-TS3.pl"
  19. echo "Contact FanPage: https://www.facebook.com/xbotts3/"
  20. echo ""
  21. echo ":: XBOT PREMIUM"
  22. echo ":: Version [$version]"
  23. instances=6
  24.  
  25. installing()
  26. {
  27.         echo;
  28.         echo -e "$COL_CYAN ****************************************$COL_RESET";
  29.         echo -e "$COL_GREEN     INSTALLING: $1 $COL_RESET";
  30.         echo -e "$COL_CYAN ****************************************$COL_RESET";
  31.         echo;
  32. }
  33.  
  34. write()
  35. {
  36.         echo;
  37.         echo -e "$COL_CYAN **************************************** $COL_RESET";
  38.         echo -e "$2  $1 $COL_RESET";
  39.         echo -e "$COL_CYAN **************************************** $COL_RESET";
  40.         echo;
  41. }
  42.  
  43. check_installed_packets()
  44. {
  45.         if [ -z `which sudo` ]; then
  46.                 installing "sudo"
  47.                 apt-get install sudo
  48.                 echo -e "$COL_RESET"
  49.         fi
  50.  
  51.         if [ -z `which unzip` ]; then
  52.                 installing "unzip"
  53.                 apt-get install unzip
  54.                 echo -e "$COL_RESET"
  55.         fi
  56.  
  57.         if [ -z `which wget` ]; then
  58.                 installing "wget"
  59.                 apt-get install wget
  60.                 echo -e "$COL_RESET"
  61.         fi
  62.  
  63.         if [ -z `which screen` ]; then
  64.                 installing "screen"
  65.                 apt-get install screen 
  66.                 echo -e "$COL_RESET"
  67.         fi
  68.  
  69.         if [[ -z `which php$pvp_ver` && -z `which php` ]]; then
  70.                 installing "PHP5"
  71.                 apt-get install php7.2
  72.                 echo -e "$COL_RESET"
  73.         fi
  74.  
  75.         if [[ -z `dpkg -l | grep php$php_ver-gd` ]]; then
  76.                 installing "$php_ver-GD"
  77.                 apt-get install php$php_ver-gd
  78.                 echo -e "$COL_RESET"
  79.         fi
  80.  
  81.         if [[ -z `dpkg -l | grep php$php_ver-curl` ]]; then
  82.                 installing "PHP$php_ver-CURL"
  83.                 apt-get install php$php_ver-curl
  84.                 echo -e "$COL_RESET"
  85.         fi
  86.        
  87.         if [[ -z `dpkg -l | grep php$php_ver-mysql` ]]; then
  88.                 installing "PHP$php_ver-Mysql"
  89.                 apt-get install php$php_ver-mysql
  90.                 echo -e "$COL_RESET"
  91.         fi
  92. }
  93.  
  94. if [[ "$1" == "start" ]]; then
  95.         check_installed_packets
  96.  
  97.         if [[ -f include/language_file/eng.txt || "$2" == "eng" ]]; then
  98.                 echo
  99.                 echo "You started `basename $0`"
  100.                 echo Your choice: "$@"
  101.                 for (( i=1; $i <= $instances; i++ )) ; do
  102.                         if  ! screen -list | grep -q "Xbot_instance_$i" ; then
  103.                                 sudo screen -dmS Xbot_instance_$i php core.php -i $i
  104.                                 echo -e "XBot instance $i $COL_GREEN is ON! $COL_RESET"
  105.                                 sleep 3
  106.                         else
  107.                                 echo -e "XBot instance $i $COL_GREEN is already ON! $COL_RESET"
  108.                         fi
  109.                 done
  110.         else
  111.                 echo
  112.                 echo "Uruchomiles program `basename $0`"
  113.                 echo Wybrales: "$@"
  114.                 for (( i=1; $i <= $instances; i++ )) ; do
  115.                         if  ! screen -list | grep -q "Xbot_instance_$i" ; then
  116.                                 sudo screen -dmS Xbot_instance_$i php core.php -i $i
  117.                                 echo -e "XBot instancja $i $COL_GREEN została włączona! $COL_RESET"
  118.                                 sleep 3
  119.                         else
  120.                                 echo -e "XBot instancja $i $COL_GREEN jest już włączony! $COL_RESET"
  121.                         fi
  122.                 done
  123.         fi
  124.  
  125. elif [[ "$1" == "stop" ]]; then
  126.         if [[ -f include/language_file/eng.txt || "$2" == "eng" ]]; then
  127.                 echo
  128.                 echo "You started `basename $0`"
  129.                 echo Your choice: "$@"
  130.                 for (( i=1; $i <= $instances; i++ )) ; do
  131.                         screen -S Xbot_instance_$i -X quit
  132.                 done
  133.                 echo -e "XBot $COL_RED is OFF! $COL_RESET"
  134.         else
  135.                 echo
  136.                 echo "Uruchomiles program `basename $0`"
  137.                 echo Wybrales: "$@"
  138.                 for (( i=1; $i <= $instances; i++ )) ; do
  139.                         screen -S Xbot_instance_$i -X quit
  140.                 done
  141.                 echo -e "XBot $COL_RED został wyłączony! $COL_RESET"
  142.         fi
  143.  
  144. elif [[ "$1" == "restart" ]]; then
  145.         check_installed_packets
  146.  
  147.         if [[ -f include/language_file/eng.txt || "$2" == "eng" ]]; then
  148.                 echo
  149.                 echo "You started `basename $0`"
  150.                 echo Your choice: "$@"
  151.                 for (( i=1; $i <= $instances; i++ )) ; do
  152.                         if [ "$i" == 1 ]; then
  153.                                 echo -n -e "$COL_BLUE Restarting "
  154.                         else
  155.                                 echo -n ". "
  156.                         fi
  157.                         screen -S Xbot_instance_$i -X quit
  158.                         screen -dmS Xbot_instance_$i php core.php -i $i
  159.                         sleep 3
  160.                 done
  161.                 echo ""
  162.                 echo -e "XBot $COL_GREEN has been restarted successfully! $COL_RESET"
  163.         else
  164.                 echo
  165.                 echo "Uruchomiles program `basename $0`"
  166.                 echo Wybrales: "$@"
  167.                 for (( i=1; $i <= $instances; i++ )) ; do
  168.                         if [ "$i" == 1 ]; then
  169.                                 echo -n -e "$COL_BLUE Restartuję "
  170.                         else
  171.                                 echo -n "."
  172.                         fi
  173.                         screen -S Xbot_instance_$i -X quit
  174.                         screen -dmS Xbot_instance_$i php core.php -i $i
  175.                         sleep 3
  176.                 done
  177.                 echo -e "$COL_RESET"
  178.                 echo -e "XBot $COL_GREEN został zrestartowany pomyślnie! $COL_RESET"
  179.         fi
  180.  
  181. elif [[ "$1" == "run" ]]; then
  182.         check_installed_packets
  183.  
  184.         if [[ -f include/language_file/eng.txt || "$2" == "eng" ]]; then
  185.                 echo
  186.                 echo "You started `basename $0`"
  187.                 echo Your choice: "$@"
  188.                 if  ! screen -list | grep -q "Xbot_run" ; then
  189.                         sudo screen -dmS Xbot_run ./starter.sh exec_run yes
  190.                         echo -e "XBot run $COL_GREEN is ON! $COL_RESET"
  191.                 else
  192.                         screen -S Xbot_run -X quit
  193.                         echo -e "XBot run $COL_RED is OFF! $COL_RESET"
  194.                 fi
  195.         else
  196.                 echo
  197.                 echo "Uruchomiles program `basename $0`"
  198.                 echo Wybrales: "$@"
  199.                 if  ! screen -list | grep -q "Xbot_run" ; then
  200.                         sudo screen -dmS Xbot_run ./starter.sh exec_run yes
  201.                         echo -e "XBot run $COL_GREEN została włączona! $COL_RESET"
  202.                 else
  203.                         screen -S Xbot_run -X quit
  204.                         echo -e "XBot run $COL_RED został wyłączony! $COL_RESET"
  205.                 fi
  206.         fi
  207.  
  208.  
  209. elif [[ "$1" == "exec_run" ]]; then
  210.         while [ 1 ]; do
  211.                 sleep 3
  212.                 if [ -f include/cache/command.txt ]; then
  213.                         for (( i=1; $i<=2; i++ )) ; do
  214.                                 command=`sed -n "$i"p include/cache/command.txt`
  215.                                 $command
  216.                         done;
  217.                         rm include/cache/command.txt
  218.                 fi
  219.                 if [[ "$2" == "yes" ]]; then
  220.                         for (( i=1; $i <= $instances; i++ )) ; do
  221.                                 if  ! screen -list | grep -q "Xbot_instance_$i" ; then
  222.                                         sudo screen -dmS Xbot_instance_$i php core.php -i $i
  223.                                         sleep 3
  224.                                 fi
  225.                         done
  226.                 fi
  227.         done
  228. elif [[ "$1" == "update" ]]; then
  229.                
  230.         if [ -z `which php$php_ver` ]; then
  231.                 write "    Aktualizacje tylko pod PHP$php_ver" "$COL_RED"
  232.         else
  233.                 check_installed_packets
  234.                 wget -q "http://license.xbot-ts3.pl/Dl?id=1&version=$dl_version" -O update
  235.        
  236.                 if [  -f "update" ]; then
  237.                         status="$(cat update)"
  238.                 fi
  239.  
  240.         if [ "$status" == "bad_license" ]; then
  241.             write "       Błędna licencja!" "$COL_RED"
  242.             rm update
  243.         elif [ "$status" == "good_version" ]; then
  244.             write "Posiadasz już najnowszą wersję!" "$COL_GREEN"
  245.             rm update
  246.         elif [ "$status" == "bad_file" ]; then
  247.             write "Zglos sie do autora bota!" "$COL_GREEN"
  248.             rm update
  249.                 else
  250.                         write "Instalowanie najnowszej wersji!" "$COL_GREEN"
  251.                         write "  Naciśnij A aby kontynuować" "$COL_GREEN"
  252.  
  253.                         mv update xbot.zip
  254.                         mv include/configs/config.php include/configs/config_old.php    
  255.  
  256.                         unzip xbot.zip
  257.                         rm xbot.zip
  258.  
  259.                         chmod 777 starter.sh
  260.                         write "  Nowa wersja została zainstalowana!" "$COL_GREEN"
  261.                 fi
  262.         fi
  263. elif [[ "$1" == "install" ]]; then
  264.        
  265.         echo;
  266.         echo -e "$COL_CYAN Wybierz jaką masz wersje systemu $COL_RESET"
  267.         echo "[1] Debian 8 lub Debian9"
  268.         echo "[2] Ubuntu 14 lub Ubuntu 16"
  269.         read -p "» " SYSTEM;
  270.        
  271.         apt-get update -y
  272.         apt-get upgrade -y
  273.         apt-get install -y sudo nano screen htop unzip wget
  274.         apt-get install -y mariadb-server
  275.         apt-get install -y apache2
  276.        
  277.         case $SYSTEM in
  278.                 1)
  279.                         sudo apt-get install -y apt-transport-https lsb-release ca-certificates
  280.                         wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
  281.                         echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
  282.                         sudo apt-get update -y;;
  283.                 2)
  284.                         sudo apt-get install -y software-properties-common python-software-properties
  285.                         sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
  286.                         sudo apt-get update -y;;
  287.         esac
  288.        
  289.         apt-get install -y php$php_ver libapache2-mod-php$php_ver php$php_ver-curl php$php_ver-gd php$php_ver-mysql php$php_ver-mbstring php$php_ver-bz2 php$php_ver-xml php$php_ver-fpm php$php_ver-cli
  290.         apt-get install -y phpmyadmin
  291.         ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
  292.         sudo a2dismod php7
  293.         sudo a2dismod php5
  294.         sudo a2dismod php7.1
  295.         sudo a2dismod php5.6
  296.         sudo a2enmod php$php_ver
  297.         service apache2 restart
  298.        
  299.         write " Potrzebne pakiety zostały zainstalowane" "$COL_GREEN"
  300.        
  301. else
  302.         if [[ -f include/language_file/eng.txt || "$2" == "eng" ]]; then
  303.                 echo
  304.                 echo -e "$COL_GREEN USAGE: ${0} {start/stop/restart/run/update/install} $COL_RESET"    
  305.         else
  306.                 echo
  307.                 echo -e "$COL_GREEN UŻYCIE: ${0} {start/stop/restart/run/update/install} $COL_RESET"  
  308.         fi     
  309. fi
  310.  
  311.