├── README.md └── ebot-cs2-install.sh /README.md: -------------------------------------------------------------------------------- 1 | # ebot-cs2-install-script 2 | Installation script for eBot that works with CS2. Tested on Ubuntu 20.04 and Ubuntu 22.04 (Hetzner Cloud). 3 | I will be updating the script with new stuff, this is only first release because many people reached out to me to help them install their own versions. 4 | 5 | RUN THE SCRIPT AS ROOT (everything should be pretty straighforward): 6 | 7 | ``` 8 | git clone https://github.com/Flegma/ebot-cs2-install-script.git ebot-cs2-install && cd ebot-cs2-install && chmod +x ebot-cs2-install.sh && ./ebot-cs2-install.sh 9 | ``` 10 | 11 | After everything is installed, you can check the status of the ebot services by running: 12 | ``` 13 | service ebot-cs2-app status 14 | ``` 15 | or 16 | ``` 17 | service ebot-cs2-logs status 18 | ``` 19 | to check the status respectively. Commands available: service start/stop/restart service_name. 20 | 21 | You can also check/edit the cronjobs with: 22 | ``` 23 | crontab -e 24 | ``` 25 | 26 | TODO: Ask if the installation is on .tld, IP address and/or LAN environment 27 | 28 | ## Credits 29 | * Julien 'deStrO' Pardons (destro@esport-tools.net) 30 | 31 | ## Thanks 32 | * Loic Peron (RegnaM) 33 | * Ph3nol 34 | * Fabian 'Basert' Gruber 35 | * Vintric 36 | -------------------------------------------------------------------------------- /ebot-cs2-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Installer for eBot CS2 by Flegma - Email: Flegma@gmail.com, Web: https://adria.gg, Discord: flegma (feel free to reach out here or on any social network) 3 | # First version of the script, still a lot of things to improve and add (like asking if you want it to run on IP or subdomain, adding various checks, etc.) 4 | # Script tested on Hetzner Cloud - on images "Ubuntu 20.04" and "Ubuntu 22.04". LAMP stack PHP 7.4, MySQL 8.0, Apache 2.4 5 | export DEBIAN_FRONTEND=noninteractive #added this so that the prompts for service restarts doesnt popout 6 | red='\e[1;31m%s\e[0m\n' 7 | green='\e[1;32m%s\e[0m\n' 8 | yellow='\e[1;33m%s\e[0m\n' 9 | blue='\e[1;34m%s\e[0m\n' 10 | magenta='\e[1;35m%s\e[0m\n' 11 | cyan='\e[1;36m%s\e[0m\n' 12 | apt-get update 13 | apt-get upgrade -y 14 | printf "$yellow" "Now installing LEMP stack" 15 | apt-get install -y language-pack-en-base software-properties-common nano wget curl git unzip snapd screen 16 | LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php -y 17 | apt-get install -y libapache2-mod-php7.4 apache2 redis-server mysql-server php7.4-fpm php7.4-redis php7.4-cgi php7.4-cli php7.4-dev php7.4-phpdbg php7.4-bcmath php7.4-bz2 php7.4-common php7.4-curl php7.4-dba php7.4-enchant php7.4-gd php7.4-gmp php7.4-imap php7.4-interbase php7.4-intl php7.4-ldap php7.4-mbstring php7.4-mysql php7.4-odbc php7.4-pgsql php7.4-pspell php7.4-readline php7.4-snmp php7.4-soap php7.4-sqlite3 php7.4-sybase php7.4-tidy php7.4-xml php7.4-xmlrpc php7.4-zip php7.4-opcache php7.4 php7.4-xsl 18 | printf "$green" "LEMP stack installed." 19 | printf "$yellow" "Installing PMA (phpMyAdmin), certbot and node stuff." 20 | cd /usr/share 21 | wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip 22 | unzip phpMyAdmin-5.2.1-all-languages.zip 23 | mv phpMyAdmin-5.2.1-all-languages phpmyadmin 24 | chmod -R 0755 phpmyadmin 25 | mkdir /usr/share/phpmyadmin/tmp 26 | chmod -R 0777 /usr/share/phpmyadmin/tmp 27 | rm -rf /usr/share/phpMyAdmin-5.2.1-all-languages.zip 28 | #todo: need to add pma configuration to apache 29 | cd -- 30 | snap install core 31 | snap refresh core 32 | snap install --classic certbot 33 | ln -s /snap/bin/certbot /usr/bin/certbot 34 | apt-get install -y nodejs npm 35 | npm -g install n 36 | npm -g install yarn 37 | n lts 38 | timedatectl set-timezone Europe/Zagreb 39 | hash -r 40 | cd -- 41 | wget https://getcomposer.org/composer-2.phar && chmod +x composer-2.phar && mv composer-2.phar /usr/bin/composer 42 | printf "$green" "Installed server dependencies, now onto eBot CS2 stuff." 43 | # Prompt for the new root password 44 | read -p "Enter the new MySQL root password: " new_root_password 45 | # Use mysqladmin to change the root password 46 | mysqladmin -u root password "$new_root_password" 47 | #printf "$green" "MySQL root password has been changed." 48 | #echo "MySQL root password has been changed." 49 | # Secure the MySQL installation 50 | mysql_secure_installation <> /etc/php/7.4/cli/php.ini 103 | echo 'date.timezone = Europe/Zagreb' >> /etc/php/7.4/apache2/php.ini 104 | # Wait for the user to press Enter 105 | read -p "Press Enter to continue..." 106 | cd /home/ebot/ebot-cs2-app/ 107 | read -p "Enter a secret key that will be used for websocket: " websocket_secret 108 | 109 | #PUBLIC_IP=$(wget -qO- checkip.amazonaws.com) 110 | #EBOT_IP=$PUBLIC_IP 111 | #interfaces=$(ls /sys/class/net) 112 | #EBOT_IP=$(ip -4 addr show $interface | grep -oP '(?<=inet\s)\d+(\.\d+){3}') 113 | #read -p "Enter your LAN IP:" EBOT_IP 114 | #todo: ask/check if the installation will be on .tld, IP address or LAN env 115 | 116 | while true; do 117 | printf "$yellow" "Do you want to run eBot:" 118 | echo "1. Online" 119 | echo "2. LAN" 120 | read -p "Enter your choice (1 or 2): " environment 121 | 122 | if [[ $environment == "1" || $environment == "2" ]]; then 123 | break 124 | else 125 | printf "$red" "Invalid choice. Please enter 1 or 2." 126 | fi 127 | done 128 | 129 | if [[ $environment == "1" ]]; then 130 | while true; do 131 | printf "$yellow" "Do you want to:" 132 | echo "1. Autodetect IP" 133 | echo "2. Enter IP manually" 134 | read -p "Enter your choice (1 or 2): " ip_choice 135 | 136 | if [[ $ip_choice == "1" || $ip_choice == "2" ]]; then 137 | break 138 | else 139 | printf "$red" "Invalid choice. Please enter 1 or 2." 140 | fi 141 | done 142 | 143 | if [[ $ip_choice == "2" ]]; then 144 | while true; do 145 | printf "$yellow" "Do you want to:" 146 | echo "1. Manually enter IP" 147 | echo "2. Choose from list of network interfaces" 148 | read -p "Enter your choice (1 or 2): " interface_choice 149 | 150 | if [[ $interface_choice == "1" || $interface_choice == "2" ]]; then 151 | break 152 | else 153 | printf "$red" "Invalid choice. Please enter 1 or 2." 154 | fi 155 | done 156 | 157 | if [[ $interface_choice == "2" ]]; then 158 | printf "$green" "Available network interfaces are:" 159 | interfaces=$(ip link show | awk -F: '$0 !~ "lo|vir|wl|^[^0-9]"{print $2;getline}') 160 | echo "$interfaces" 161 | while true; do 162 | read -p "Enter the network interface from the list above: " network_interface 163 | if [[ $interfaces == *"$network_interface"* ]]; then 164 | EBOT_IP=$(ip -4 addr show $network_interface | grep -oP '(?<=inet\s)\d+(\.\d+){3}') 165 | break 166 | else 167 | printf "$red" "Invalid choice. Please enter a network interface from the list above." 168 | fi 169 | done 170 | else 171 | read -p "Enter your IP here:" EBOT_IP 172 | fi 173 | else 174 | PUBLIC_IP=$(wget -qO- checkip.amazonaws.com) 175 | EBOT_IP=$PUBLIC_IP 176 | fi 177 | else 178 | # Run eBot in LAN environment here 179 | while true; do 180 | printf "$yellow" "Do you want to:" 181 | echo "1. Manually enter LAN IP" 182 | echo "2. Choose from list of network interfaces" 183 | read -p "Enter your choice (1 or 2): " interface_choice 184 | 185 | if [[ $interface_choice == "1" || $interface_choice == "2" ]]; then 186 | break 187 | else 188 | printf "$red" "Invalid choice. Please enter 1 or 2." 189 | fi 190 | done 191 | 192 | if [[ $interface_choice == "2" ]]; then 193 | printf "$green" "Available network interfaces are:" 194 | interfaces=$(ip link show | awk -F: '$0 !~ "lo|vir|wl|^[^0-9]"{print $2;getline}') 195 | echo "$interfaces" 196 | while true; do 197 | read -p "Enter the network interface from the list above: " network_interface 198 | if [[ $interfaces == *"$network_interface"* ]]; then 199 | EBOT_IP=$(ip -4 addr show $network_interface | grep -oP '(?<=inet\s)\d+(\.\d+){3}') 200 | break 201 | else 202 | printf "$red" "Invalid choice. Please enter a network interface from the list above." 203 | fi 204 | done 205 | else 206 | read -p "Enter your IP here:" EBOT_IP 207 | fi 208 | fi 209 | 210 | printf "$green" "eBot IP that is in use is now:" $EBOT_IP 211 | # Wait for the user to press Enter 212 | read -p "Press Enter to continue..." 213 | 214 | # Generate config.ini for ebot-cs2-app 215 | echo '; eBot - A bot for match management for CS2 216 | ; @license http://creativecommons.org/licenses/by/3.0/ Creative Commons 3.0 217 | ; @author Julien Pardons 218 | ; @version 3.0 219 | ; @date 21/10/2012 220 | 221 | [BDD] 222 | MYSQL_IP = "127.0.0.1" 223 | MYSQL_PORT = "3306" 224 | MYSQL_USER = "'$ebot_user_name'" 225 | MYSQL_PASS = "'$ebot_user_password'" 226 | MYSQL_BASE = "'$ebot_db_name'" 227 | 228 | [Config] 229 | BOT_IP = "'$EBOT_IP'" 230 | BOT_PORT = 12360 231 | SSL_ENABLED = false 232 | SSL_CERTIFICATE_PATH = "ssl/cert.pem" 233 | SSL_KEY_PATH = "ssl/key.pem" 234 | EXTERNAL_LOG_IP = "" ; use this in case your server isnt binded with the external IP (behind a NAT) 235 | MANAGE_PLAYER = 1 236 | DELAY_BUSY_SERVER = 120 237 | NB_MAX_MATCHS = 0 238 | PAUSE_METHOD = "nextRound" ; nextRound or instantConfirm or instantNoConfirm 239 | NODE_STARTUP_METHOD = "node" ; binary file name or none in case you are starting it with forever or manually 240 | LOG_ADDRESS_SERVER = "http://'$EBOT_IP':12345" ; 241 | WEBSOCKET_SECRET_KEY = "'$websocket_secret'" 242 | 243 | [Redis] 244 | REDIS_HOST = "127.0.0.1" 245 | REDIS_PORT = 6379 246 | REDIS_AUTH_USERNAME = 247 | REDIS_AUTH_PASSWORD = 248 | REDIS_CHANNEL_LOG = "ebot-logs" 249 | REDIS_CHANNEL_EBOT_FROM_WS = "ebot-from-ws" 250 | REDIS_CHANNEL_EBOT_TO_WS = "ebot-to-ws" 251 | 252 | [Match] 253 | LO3_METHOD = "restart" ; restart or csay or esl 254 | KO3_METHOD = "restart" ; restart or csay or esl 255 | DEMO_DOWNLOAD = true ; true or false :: whether gotv demos will be downloaded from the gameserver after matchend or not 256 | REMIND_RECORD = false ; true will print the 3x "Remember to record your own POV demos if needed!" messages, false will not 257 | DAMAGE_REPORT = true ; true will print damage reports at end of round to players, false will not 258 | USE_DELAY_END_RECORD = true ; use the tv_delay to record postpone the tv_stoprecord & upload 259 | TIMEOUT_ENABLED = false 260 | TIMEOUT_USE_MATCH_CONFIG = false ; If false, eBot will sends the RCON commands for the timeout 261 | TIMEOUT_TIME = 120 ; mp_team_timeout_time 262 | TIMEOUT_PER_TEAM_PER_MATCH = 1 ; mp_team_timeout_max 263 | TIMEOUT_OT_ADD_EACH = 0 ; mp_team_timeout_ot_add_each 264 | TIMEOUT_OT_ADD_ONCE = 0 ; mp_team_timeout_ot_add_once 265 | TIMEOUT_OT_MAX = 1 ; mp_team_timeout_ot_max 266 | 267 | [MAPS] 268 | MAP[] = "de_mirage" 269 | MAP[] = "de_dust2" 270 | MAP[] = "de_inferno" 271 | MAP[] = "de_overpass" 272 | MAP[] = "de_nuke" 273 | MAP[] = "de_vertigo" 274 | MAP[] = "de_ancient" 275 | MAP[] = "de_anubis" 276 | 277 | [WORKSHOP IDs] 278 | 279 | [Settings] 280 | COMMAND_STOP_DISABLED = true 281 | RECORD_METHOD = "matchstart" ; matchstart or knifestart 282 | DELAY_READY = true' > /home/ebot/ebot-cs2-app/config/config.ini 283 | 284 | COMPOSER_ALLOW_SUPERUSER=1 composer install --no-interaction 285 | npm install 286 | #run ebot app now 287 | #we dont need to run process in screen anymore since there will be a service at the end 288 | #echo '#!/bin/bash 289 | #screen -S ebot-cs2-app -d -m 290 | #screen -S ebot-cs2-app -X stuff "/usr/bin/php /home/ebot/ebot-cs2-app/bootstrap.php\n" 291 | #screen -S ebot-cs2-app -X detach' > /home/ebot/ebot-cs2-app/ebot.sh 292 | #chmod +x /home/ebot/ebot-cs2-app/ebot.sh 293 | #todo: check if ebot is running before continuing - need to change order of installs 294 | printf "$green" "eBot CS2 app running. Now editing CS2 webpanel configuration." 295 | # Wait for the user to press Enter 296 | read -p "Press Enter to continue..." 297 | cd /home/ebot/ebot-cs2-web/ 298 | # Generate app_user.yml 299 | echo '# ---------------------------------------------------------------------- 300 | # white space are VERY important, dont remove it or it will not work 301 | # ---------------------------------------------------------------------- 302 | 303 | log_match: ../../ebot-csgo/logs/log_match 304 | log_match_admin: ../../ebot-csgo/logs/log_match_admin 305 | demo_path: ../../ebot-csgo/demos 306 | 307 | default_max_round: 12 308 | default_rules: esl5on5 309 | default_overtime_enable: false 310 | default_overtime_max_round: 3 311 | default_overtime_startmoney: 12000 312 | 313 | # true or false, whether demos will be downloaded by the ebot server 314 | # the demos can be downloaded at the matchpage, if its true 315 | 316 | demo_download: true 317 | 318 | websocket_url: 'http://"$EBOT_IP":12360' 319 | ebot_ip: '$EBOT_IP' 320 | ebot_port: 12360 321 | 322 | # lan or net, its to display the server IP or the GO TV IP 323 | # net mode display only started match on home page 324 | mode: net 325 | 326 | # set to 0 if you dont want a refresh 327 | refresh_time: 30 328 | 329 | # Toornament Configuration 330 | toornament_id: 331 | toornament_secret: 332 | toornament_api_key: 333 | toornament_plugin_key: test-123457890 334 | 335 | # Same as eBot config 336 | websocket_secret_key: '$websocket_secret'' > /home/ebot/ebot-cs2-web/config/app_user.yml 337 | 338 | # Generate databases.yml 339 | rm /home/ebot/ebot-cs2-web/config/databases.yml 340 | echo "# You can find more information about this file on the symfony website: 341 | # http://www.symfony-project.org/reference/1_4/en/07-Databases 342 | 343 | all: 344 | doctrine: 345 | class: sfDoctrineDatabase 346 | param: 347 | dsn: mysql:host=127.0.0.1;dbname=$ebot_db_name 348 | username: $ebot_user_name 349 | password: $ebot_user_password" > /home/ebot/ebot-cs2-web/config/databases.yml 350 | 351 | #Edit SF 1.4 class function so that it works with PHP 7.4 - protected function normalizeHeaderName($name) 352 | #Specify the file to edit 353 | file_to_edit="/home/ebot/ebot-cs2-web/lib/vendor/symfony/lib/response/sfWebResponse.class.php" 354 | 355 | # Define the new function 356 | new_function=' 357 | protected function normalizeHeaderName($name) 358 | { 359 | $out = []; 360 | array_map(function($record) use (&$out) { 361 | $out[] = ucfirst(strtolower($record)); 362 | }, explode("-",$name)); 363 | return implode("-",$out); 364 | } 365 | ' 366 | 367 | # Use sed to delete lines 407-410 and then echo the new content starting at line 407 368 | sed -i '407,410d' "$file_to_edit" 369 | echo -e "$new_function" | sed -i '407r /dev/stdin' "$file_to_edit" 370 | # 371 | cd /home/ebot/ebot-cs2-web/ 372 | mkdir /home/ebot/ebot-cs2-web/cache/ 373 | rm -rf /home/ebot/ebot-cs2-web/web/installation/ 374 | php symfony cc 375 | php symfony doctrine:build --all --no-confirmation 376 | 377 | printf "$yellow" "THE LAST QUESTION: You need a username and a password for ebot." 378 | read -p "Email: " -e -i email@domain.com EBOTEMAIL 379 | read -p "Username: " -e -i admin EBOTUSER 380 | read -p "Password: " -e -i password EBOTPASSWORD 381 | php symfony guard:create-user --is-super-admin $EBOTEMAIL $EBOTUSER $EBOTPASSWORD 382 | chown -R www-data:www-data /home/ebot/ 383 | chmod -R 755 /home/ebot/ 384 | chmod -R 777 /home/ebot/ebot-cs2-web/cache/ 385 | printf "$green" "Installed eBot CS2 stuff. Editing Apache configuration now." 386 | # Wait for the user to press Enter 387 | read -p "Press Enter to continue..." 388 | 389 | #check if ebot will run on domain name or ip address (if online option is used, because if lan option is used, than we always run on ip address) 390 | if [ "$environment" == "1" ] 391 | then 392 | while true; do 393 | # Offer the user two choices 394 | echo "Since you're running eBot Online - do you want to run it on IP or .tld (sub)domain:" 395 | echo "1. IP" 396 | echo "2. .tld" 397 | 398 | # Read the user's choice 399 | read ip_tld_choice 400 | 401 | # Do different stuff based on the user's choice 402 | if [ "$ip_tld_choice" == "1" ] 403 | then 404 | echo "We will run the eBot on the" $EBOT_IP 405 | echo "Alias / /home/ebot/ebot-cs2-web/web/ 406 | 407 | AllowOverride All 408 | 409 | Order allow,deny 410 | allow from all 411 | 412 | = 2.4> 413 | Require all granted 414 | 415 | " > /etc/apache2/sites-available/ebotcs2.conf 416 | break 417 | elif [ "$ip_tld_choice" == "2" ] 418 | then 419 | read -p "Enter (sub)domain on which the eBot will be running: " EBOT_DOMAIN 420 | echo "We will run the eBot on the" $EBOT_DOMAIN 421 | echo " 422 | #Edit your email 423 | ServerAdmin $EBOTEMAIL 424 | #Edit your sub-domain 425 | ServerAlias $EBOT_DOMAIN 426 | DocumentRoot /home/ebot/ebot-cs2-web/web 427 | 428 | Options Indexes FollowSymLinks MultiViews 429 | AllowOverride All 430 | 431 | Order allow,deny 432 | allow from all 433 | 434 | = 2.4> 435 | Require all granted 436 | 437 | 438 | " > /etc/apache2/sites-available/ebotcs2.conf 439 | break 440 | else 441 | echo "Invalid choice. Please choose 1 or 2." 442 | fi 443 | done 444 | elif [ "$environment" == "2" ] 445 | then 446 | echo "We're running eBot on LAN IP" $EBOT_IP 447 | echo "Alias / /home/ebot/ebot-cs2-web/web/ 448 | 449 | AllowOverride All 450 | 451 | Order allow,deny 452 | allow from all 453 | 454 | = 2.4> 455 | Require all granted 456 | 457 | " > /etc/apache2/sites-available/ebotcs2.conf 458 | else 459 | echo "Invalid choice. Please choose 1 or 2." 460 | fi 461 | 462 | echo "Options +FollowSymLinks +ExecCGI 463 | 464 | RewriteEngine On 465 | # uncomment the following line, if you are having trouble 466 | # getting no_script_name to work 467 | RewriteBase / 468 | # we skip all files with .something 469 | #RewriteCond %{REQUEST_URI} \..+$ 470 | #RewriteCond %{REQUEST_URI} !\.html$ 471 | #RewriteRule .* - [L] 472 | # we check if the .html version is here (caching) 473 | RewriteRule ^$ index.html [QSA] 474 | RewriteRule ^([^.]+)$ $1.html [QSA] 475 | RewriteCond %{REQUEST_FILENAME} !-f 476 | # no, so we redirect to our front web controller 477 | RewriteRule ^(.*)$ index.php [QSA,L] 478 | " > /home/ebot/ebot-cs2-web/web/.htaccess 479 | 480 | #enable ebot website configuration 481 | a2enmod rewrite && a2ensite ebotcs2.conf && service apache2 restart 482 | 483 | #cd /home/ebot/ebot-cs2-app/ && ./ebot.sh #todo: need to fix this by changing change order of install - ebot logs, ebot web, ebot app 484 | 485 | # Create systemd service for ebot-cs2-app 486 | printf "$yellow" "Installing services for ebot-cs2-app and ebot-cs2-logs." 487 | 488 | echo "[Unit] 489 | Description=eBot CS2 App Background service 490 | 491 | [Service] 492 | User=root 493 | Group=root 494 | ExecStart=/usr/bin/php /home/ebot/ebot-cs2-app/bootstrap.php 495 | WorkingDirectory=/home/ebot/ebot-cs2-app 496 | Restart=always 497 | 498 | [Install] 499 | WantedBy=multi-user.target" > /etc/systemd/system/ebot-cs2-app.service 500 | 501 | # Create systemd service for ebot-cs2-logs service 502 | echo "[Unit] 503 | Description=eBot CS2 Logs Background service 504 | 505 | [Service] 506 | User=root 507 | Group=root 508 | ExecStart=/usr/local/bin/ts-node /home/ebot/ebot-cs2-logs/src/logs-receiver configs/primary.json 509 | WorkingDirectory=/home/ebot/ebot-cs2-logs 510 | Restart=always 511 | 512 | [Install] 513 | WantedBy=multi-user.target" > /etc/systemd/system/ebot-cs2-logs.service 514 | 515 | systemctl daemon-reload 516 | systemctl enable ebot-cs2-app #start this service on boot 517 | systemctl enable ebot-cs2-logs #start this service on boot 518 | systemctl start ebot-cs2-app #start right now 519 | systemctl start ebot-cs2-logs #start right now 520 | 521 | printf "$green" "You can stop/start/restart services with: service ebot-cs2-app restart OR service ebot-cs2-logs restart" 522 | 523 | # Wait for the user to press Enter 524 | read -p "Press Enter to continue..." 525 | 526 | #add script (and run it in cronjob every minute) that will check ebot-cs2-app and ebot-cs2-logs process 527 | printf "$yellow" "Adding scripts and cronjobs to check services periodically." 528 | echo '#!/bin/bash 529 | 530 | SERVICE_NAME="ebot-cs2-logs" 531 | 532 | SERVICE_STATUS=$(systemctl is-active $SERVICE_NAME) 533 | 534 | if [ "$SERVICE_STATUS" = "active" ]; then 535 | echo "$SERVICE_NAME is running." 536 | else 537 | echo "$SERVICE_NAME is not running. Restarting $SERVICE_NAME..." 538 | systemctl restart $SERVICE_NAME 539 | fi' > /home/ebot/check-ebot-cs2-logs.sh 540 | 541 | #make it executable 542 | chmod +x /home/ebot/check-ebot-cs2-logs.sh 543 | 544 | echo '#!/bin/bash 545 | 546 | SERVICE_NAME="ebot-cs2-app" 547 | 548 | SERVICE_STATUS=$(systemctl is-active $SERVICE_NAME) 549 | 550 | if [ "$SERVICE_STATUS" = "active" ]; then 551 | echo "$SERVICE_NAME is running." 552 | else 553 | echo "$SERVICE_NAME is not running. Restarting $SERVICE_NAME..." 554 | systemctl restart $SERVICE_NAME 555 | fi' > /home/ebot/check-ebot-cs2-app.sh 556 | 557 | #make it executable 558 | chmod +x /home/ebot/check-ebot-cs2-app.sh 559 | 560 | #edit crontab 561 | # Write out current crontab 562 | crontab -l > crontab.tmp #check if there is already some cronjob 563 | 564 | # Echo new cron into cron file 565 | echo "* * * * * cd /home/ebot/ && ./check-ebot-cs2-app.sh" >> crontab.tmp 566 | echo "* * * * * cd /home/ebot/ && ./check-ebot-cs2-logs.sh" >> crontab.tmp 567 | 568 | # Install new cron file 569 | crontab crontab.tmp 570 | 571 | # Remove the temporary file 572 | rm crontab.tmp 573 | 574 | printf "$green" "Crontab and services installed and Done." 575 | 576 | if [ "$ip_tld_choice" == "1" ] 577 | then 578 | printf "$green" "Installed everything. You can login now on: '$EBOT_IP'" 579 | elif [ "$ip_tld_choice" == "2" ] 580 | then 581 | printf "$green" "Installed everything. You can login now on: '$EBOT_DOMAIN'" 582 | fi 583 | 584 | if [ "$environment" == "2" ] 585 | then 586 | printf "$green" "Installed everything. You can login now on: '$EBOT_IP'" 587 | fi 588 | 589 | # Wait for the user to press Enter 590 | read -p "Press Enter to continue..." 591 | --------------------------------------------------------------------------------