Linux_Simple_Installer.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/bin/bash
  2. exec 0</dev/tty
  3. # Open RSC: A replica RSC private server framework
  4. #
  5. # Installs and updates Open RSC
  6. #
  7. # Install with this command (from your Linux machine):
  8. #
  9. # curl -sSL https://raw.githubusercontent.com/Open-RSC/Game/master/Linux_Simple_Cloner.sh | bash
  10. rm install.log
  11. touch install.log && chmod 777 install.log | tee -a install.log &>/dev/null
  12. # Software installations
  13. clear
  14. echo "Installing Oracle JDK 8, MariaDB, nano, htop, screen, Apache Ant, and git. Please wait."
  15. sudo add-apt-repository ppa:webupd8team/java -y | tee -a install.log &>/dev/null
  16. sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php -y | tee -a install.log &>/dev/null
  17. sudo apt-get update | tee -a install.log &>/dev/null
  18. sudo apt remove mysql-server mysql-server-5.7 mysql-client apache2 -y | tee -a install.log &>/dev/null
  19. sudo apt-get install nano htop screen git mariadb-server mariadb-client nginx -y | tee -a install.log &>/dev/null
  20. echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections | tee -a install.log &>/dev/null
  21. sudo apt-get install -y oracle-java8-installer | tee -a install.log &>/dev/null
  22. sudo apt-get install oracle-java8-set-default | tee -a install.log &>/dev/null
  23. sudo apt-get install ant -y | tee -a install.log &>/dev/null
  24. sudo apt-get autoremove -y | tee -a install.log &>/dev/null
  25. # PHPMyAdmin installation
  26. clear
  27. echo "Installing PHP 7.2 and PHPMyAdmin. Please wait."
  28. sudo apt-get install php php-cgi php-common php-pear php-mbstring php-fpm php-mysql php-gettext phpmyadmin -y
  29. sudo phpenmod mbstring | tee -a install.log &>/dev/null
  30. sudo systemctl restart nginx | tee -a install.log &>/dev/null
  31. # Database configuration
  32. clear
  33. sudo mysql_secure_installation
  34. clear
  35. echo "Please enter your MySQL password."
  36. read -s pass
  37. clear
  38. echo "Please enter your server's domain name."
  39. read -s domain
  40. sudo mysql -uroot -Bse "DROP USER 'openrsc'@'localhost';FLUSH PRIVILEGES;" | tee -a install.log &>/dev/null
  41. sudo mysql -uroot -Bse "CREATE USER 'openrsc'@'localhost' IDENTIFIED BY '$pass';GRANT ALL PRIVILEGES ON * . * TO 'openrsc'@'localhost';FLUSH PRIVILEGES;" | tee -a install.log &>/dev/null
  42. # Database imports
  43. clear
  44. echo "Importing databases."
  45. sudo mysql -u"root" -p"$pass" < "Databases/openrsc.sql" | tee -a install.log &>/dev/null
  46. sudo mysql -u"root" -p"$pass" < "Databases/openrsc_config.sql" | tee -a install.log &>/dev/null
  47. sudo mysql -u"root" -p"$pass" < "Databases/openrsc_tools.sql" | tee -a install.log &>/dev/null
  48. sudo mysql -u"root" -p"$pass" < "Databases/openrsc_logs.sql" | tee -a install.log &>/dev/null
  49. # Automated file edits
  50. clear
  51. sudo sed -i 's/DB_LOGIN">root/DB_LOGIN">openrsc/g' server/config/config.xml | tee -a install.log &>/dev/null
  52. sudo sed -i 's/DB_PASS">root/DB_PASS">'$pass'/g' server/config/config.xml | tee -a install.log &>/dev/null
  53. sudo sed -i 's/String IP = "127.0.0.1";/String IP = "'$domain'";/g' client/src/org/openrsc/client/Config.java | tee -a install.log &>/dev/null
  54. sudo sed -i 's/String Domain = "localhost";/String Domain = "'$domain'";/g' Launcher/src/Main.java | tee -a install.log &>/dev/null
  55. sudo sed -i 's/:8080";/:80";/g' Launcher/src/Main.java | tee -a install.log &>/dev/null
  56. sudo sed -i 's/toolBar.getChildren().add(Dev/\/\/toolBar.getChildren().add(Dev/g' Launcher/src/Main.java | tee -a install.log &>/dev/null
  57. sudo sed -i 's/2930.png",/2930.png"/g' Launcher/src/Main.java | tee -a install.log &>/dev/null
  58. sudo sed -i 's/"2937/\/\/"2930.png",/g' Launcher/src/Main.java | tee -a install.log &>/dev/null
  59. sudo sed -i 's/"News",/"News"/g' Launcher/src/Main.java | tee -a install.log &>/dev/null
  60. sudo sed -i 's/"Dev Server News"/\/\/"Dev Server News"/g' Launcher/src/Main.java | tee -a install.log &>/dev/null
  61. sudo sed -i 's/Secure+Domain,/Secure+Domain/g' Launcher/src/Main.java | tee -a install.log &>/dev/null
  62. sudo sed -i 's/Secure+Dev_Domain/\/\/Secure+Dev_Domain/g' Launcher/src/Main.java | tee -a install.log &>/dev/null
  63. # Website
  64. clear
  65. sudo mkdir /var/www/html/downloads | tee -a install.log &>/dev/null
  66. # Server
  67. clear
  68. echo "Compiling the game server. Any errors will be in install.log"
  69. sudo ant -f "server/build.xml" compile | tee -a install.log &>/dev/null
  70. # Client
  71. clear
  72. echo "Compiling and preparing the game client. Any errors will be in install.log"
  73. sudo ant -f "client/build.xml" compile | tee -a install.log &>/dev/null
  74. cd client
  75. sudo zip -r "client.zip" "Open_RSC_Client.jar" | tee -a ../install.log &>/dev/null
  76. cd ../
  77. yes | sudo cp -rf "client/client.zip" "/var/www/html/downloads" | tee -a install.log &>/dev/null
  78. sudo rm "client/client.zip" | tee -a install.log &>/dev/null
  79. # Launcher
  80. clear
  81. echo "Compiling and preparing the game launcher. Any errors will be in install.log"
  82. sudo ant -f "Launcher/build.xml" jar | tee -a install.log &>/dev/null
  83. yes | sudo cp -rf "Launcher/dist/Open_RSC_Launcher.jar" "/var/www/html/downloads" | tee -a install.log &>/dev/null
  84. # Cache
  85. clear
  86. echo "Preparing the cache."
  87. yes | sudo cp -rf "client/cache.zip" "/var/www/html/downloads" | tee -a install.log &>/dev/null
  88. sudo rm /var/www/html/downloads/hashes.txt | tee -a install.log &>/dev/null
  89. md5sum /var/www/html/downloads/client.zip | grep ^[a-zA-Z0-9]* | awk '{print "client="$1}' | sudo tee -a /var/www/html/downloads/hashes.txt | tee -a install.log &>/dev/null
  90. md5sum /var/www/html/downloads/cache.zip | grep ^[a-zA-Z0-9]* | awk '{print "cache="$1}' | sudo tee -a /var/www/html/downloads/hashes.txt | tee -a install.log &>/dev/null
  91. # Completion
  92. myip="$(dig +short myip.opendns.com @resolver1.opendns.com)"
  93. clear
  94. cd Game
  95. echo "The installation script has completed."
  96. echo ""
  97. echo "You should now be able to download the game launcher at: http://${myip}/downloads/Open_RSC_Launcher.jar"
  98. echo ""
  99. echo "Launch the game server via: ./Linux_Simple_Run.sh"