Merge pull request #28 from Marwolf/master

Install script clean up
This commit is contained in:
Marwolf
2018-08-21 10:56:55 -04:00
committed by GitHub
4 changed files with 131 additions and 267 deletions

View File

@@ -3,20 +3,23 @@
source .env source .env
# Check for any updates to the game server # Check for any updates to the game server
cd Game clear
echo "Pulling recent updates from the Open-RSC Game repository." echo "Pulling recent updates from the Open-RSC Game repository."
echo "" echo ""
echo "" echo ""
cd Game
sudo git pull sudo git pull
echo "" echo ""
echo "" # Verifies permissions are set correctly
sudo chmod -R 777 Game
sudo setfacl -m user:$USER:rw /var/run/docker.sock
cd ..
echo "" clear
echo "" echo "Do you need to do any manual file editing?"
echo "Do you need to do manual file editing for the website domain and SQL user/pass?"
echo "" echo ""
echo "${RED}1${NC} - Yes, lets begin." echo "${RED}1${NC} - Yes, lets begin."
echo "${RED}2${NC} - Im all set" echo "${RED}2${NC} - No, continue."
echo "" echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter." echo "Which of the above do you wish to do? Type the choice number and press enter."
echo "" echo ""
@@ -24,98 +27,58 @@ echo ""
read edit read edit
if [ "$edit" == "1" ]; then if [ "$edit" == "1" ]; then
echo "" clear
echo ""
echo "(Use Ctrl + X to save each file when done editing) - Press enter when ready."
read next
sudo nano .env sudo nano .env
sudo nano client/src/org/openrsc/client/Config.java sudo nano Game/client/src/org/openrsc/client/Config.java
sudo nano Launcher/src/Main.java sudo nano Game/Launcher/src/Main.java
sudo nano server/config/config.xml sudo nano Game/server/config/config.xml
sudo nano ../etc/ghost/config.production.json sudo nano etc/ghost/config.production.json
echo ""
echo ""
echo "File edits complete. Restarting Docker containers."
echo ""
sudo make stop && sudo make start sudo make stop && sudo make start
fi fi
if [ "$edit" == "2" ]; then if [ "$edit" == "2" ]; then
echo "" echo ""
echo "Moving on..."
echo ""
echo ""
fi fi
#cd ../ # Server
#touch new_md5sum.txt cd Game
#tar -cf - Game | md5sum | grep -o '^[a-zA-Z0-9]*' > new_md5sum.txt clear
#cd Game echo "Preparing the game server."
echo ""
sudo ant -f "server/build.xml" compile
#if [ "(cat current_md5sum.txt)" == "(cat new_md5sum.txt)" ]; then # Client
# Echo "No file changes have been detected since last run." clear
#else echo "Preparing the game client."
# Compile server echo ""
echo "Compiling the game server." sudo ant -f "client/build.xml" compile
echo "" cd client
echo "" sudo zip -r "client.zip" "Open_RSC_Client.jar"
sudo ant -f "server/build.xml" compile cd ../
echo "" yes | sudo cp -rf "client/client.zip" "../Website/downloads/"
echo "" sudo rm "client/client.zip"
# Compile client # Launcher
echo "Compiling the game client." clear
echo "" echo "Preparing the game launcher."
sudo ant -f "client/build.xml" compile echo ""
echo "" sudo ant -f "Launcher/build.xml" jar
echo "" yes | sudo cp -rf "Launcher/dist/Open_RSC_Launcher.jar" "../Website/downloads/"
echo "Compressing jar into zip"
echo ""
cd client
sudo zip -r "client.zip" "Open_RSC_Client.jar"
cd ../
echo ""
echo ""
echo "Copying result to Website/downloads/"
echo ""
yes | sudo cp -rf "client/client.zip" "../Website/downloads/"
sudo rm "client/client.zip"
echo ""
echo ""
# Compile launcher # Cache
echo "Compiling the game launcher." clear
echo "" echo "Preparing the cache."
sudo ant -f "Launcher/build.xml" jar yes | sudo cp -rf "client/cache.zip" "../Website/downloads/"
echo "" cd ..
echo "" sudo rm Website/downloads/hashes.txt
echo "Copying result to Website/downloads/" md5sum Website/downloads/client.zip | grep ^[a-zA-Z0-9]* | awk '{print "client="$1}' | sudo tee -a Website/downloads/hashes.txt
echo "" md5sum Website/downloads/cache.zip | grep ^[a-zA-Z0-9]* | awk '{print "cache="$1}' | sudo tee -a Website/downloads/hashes.txt
yes | sudo cp -rf "Launcher/dist/Open_RSC_Launcher.jar" "../Website/downloads/"
echo ""
echo ""
# Cache # Database
echo "Copying Game/client/cache.zip to Website/downloads/" clear
yes | sudo cp -rf "client/cache.zip" "../Website/downloads/" echo "Preparing the database."
echo ""
# MD5sum client.zip and cache.zip > hashes.txt docker exec -i $(sudo docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < Game/Databases/openrsc_config.sql 2>/dev/null
cd ../
sudo rm Website/downloads/hashes.txt
md5sum Website/downloads/client.zip | grep ^[a-zA-Z0-9]* | awk '{print "client="$1}' | sudo tee -a Website/downloads/hashes.txt
md5sum Website/downloads/cache.zip | grep ^[a-zA-Z0-9]* | awk '{print "cache="$1}' | sudo tee -a Website/downloads/hashes.txt
# Replace the openrsc_config database with a fresh version
echo ""
echo ""
echo "Importing fresh openrsc_config.sql database."
echo ""
sudo docker exec -i $(sudo docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < Game/Databases/openrsc_config.sql 2>/dev/null
#fi
# Run the game server in a detached screen # Run the game server in a detached screen
./Linux_Run_Production_Server.sh sudo ./Linux_Run_Production_Server.sh
#cd ../../
#touch current_md5sum.txt
#tar -cf - Game | md5sum | grep -o '^[a-zA-Z0-9]*' > current_md5sum.txt

View File

@@ -5,15 +5,15 @@ GREEN=`tput setaf 2`
NC=`tput sgr0` # No Color NC=`tput sgr0` # No Color
# Install Choice ===================================================> # Install Choice ===================================================>
clear
echo "${RED}Open RSC Installer:${NC} echo "${RED}Open RSC Installer:${NC}
An easy to run RSC private server environment using Docker magic. An easy to run RSC private server environment using Docker magic.
Before continuing, Open RSC needs to know if you have Java, Docker, and Git installed. Do you wish to have all the pre-requiste software installed by this script?
This installer can install one or both for you if needed.
Choices: Choices:
${RED}1${NC} - Install for me! ${RED}1${NC} - Yes please, install for me!
${RED}2${NC} - Im all set, continue! (default)" ${RED}2${NC} - No thanks, continue (default)"
echo "" echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter." echo "Which of the above do you wish to do? Type the choice number and press enter."
echo "" echo ""
@@ -25,11 +25,8 @@ if [ "$install" == "1" ]; then
clear clear
echo "Which operating system are you running?" echo "Which operating system are you running?"
echo "" echo ""
echo "${RED}1${NC} - Ubuntu Linux" echo "${RED}1${NC} - Ubuntu Linux 18.04 or above"
echo "${RED}2${NC} - Fedora 28 Linux" echo "${RED}2${NC} - Mac OS High Sierra or above"
echo "${RED}3${NC} - CentOS 7 Linux"
echo "${RED}4${NC} - Mac OS High Sierra"
echo "${RED}5${NC} - Other"
echo "" echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter." echo "Which of the above do you wish to do? Type the choice number and press enter."
echo "" echo ""
@@ -38,30 +35,10 @@ if [ "$install" == "1" ]; then
# Ubuntu OS ===================================================> # Ubuntu OS ===================================================>
if [ "$os" == "1" ]; then if [ "$os" == "1" ]; then
echo "" clear
sudo dpkg-reconfigure tzdata sudo dpkg-reconfigure tzdata
echo ""
echo ""
echo "Which Ubuntu Linux version are you running?"
echo ""
echo "${RED}1${NC} - Bionic 18.04"
echo "${RED}2${NC} - Cosmic 18.10"
echo ""
read ubuntu
# Ubuntu Version ===================================================> clear
if [ "$ubuntu" == "1" ]; then
vers="bionic"
elif [ "$ubuntu" == "2" ]; then
vers="cosmic"
else
vers="bionic"
continue
fi
# UBUNTU Version <===================================================
echo ""
echo ""
echo "Verifying the basics are installed." echo "Verifying the basics are installed."
echo "" echo ""
sudo apt-get update sudo apt-get update
@@ -69,71 +46,40 @@ if [ "$install" == "1" ]; then
sudo add-apt-repository ppa:certbot/certbot -y sudo add-apt-repository ppa:certbot/certbot -y
sudo apt-get update sudo apt-get update
sudo apt-get install certbot screen zip fail2ban unzip git build-essential apt-transport-https ca-certificates curl software-properties-common -y sudo apt-get install certbot screen zip fail2ban unzip git build-essential apt-transport-https ca-certificates curl software-properties-common -y
echo ""
echo ""
echo "Do you have Docker installed? It is required for this."
echo ""
echo "${RED}1${NC} - No, install it for me!"
echo "${RED}2${NC} - Yes"
echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter."
echo ""
echo ""
read docker
# Ubuntu Docker ===================================================> clear
if [ "$docker" == "1" ]; then echo "Attempting to install Docker now"
echo "Attempting to install Docker now"
echo ""
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $vers stable"
sudo apt-get update && sudo apt-get install docker-ce docker-compose -y
else
continue
fi
# Ubuntu Docker <===================================================
echo "" echo ""
echo "Setting Docker to have the correct storage driver." curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt-get update && sudo apt-get install docker-ce docker-compose -y
clear
echo "Setting Docker to have the correct storage driver and reloading service."
echo "" echo ""
echo '{ echo '{
"storage-driver": "devicemapper" "storage-driver": "devicemapper"
}' | sudo tee --append /etc/docker/daemon.json && sudo service docker restart }' | sudo tee /etc/docker/daemon.json && sudo service docker restart
echo ""
clear
echo "Configuring UFW."
echo "" echo ""
echo "Configuring UFW to allow good ports and block MySQL from outside." sudo ufw allow 22/tcp && sudo ufw allow 80/tcp && sudo ufw allow 8080/tcp && sudo ufw allow 443/tcp && sudo ufw allow 9000/tcp && sudo ufw allow 53595/tcp && sudo ufw deny 3306/tcp
echo ""
sudo ufw allow 22/tcp && ufw allow 80/tcp && ufw allow 8080/tcp && ufw allow 443/tcp && ufw allow 9000/tcp && ufw allow 53595/tcp && ufw deny 3306/tcp
sudo sed -i 's/DEFAULT_FORWARD_POLICY="DENY"/DEFAULT_FORWARD_POLICY="ACCEPT"/g' /etc/default/ufw sudo sed -i 's/DEFAULT_FORWARD_POLICY="DENY"/DEFAULT_FORWARD_POLICY="ACCEPT"/g' /etc/default/ufw
sudo ufw reload sudo ufw reload
echo "" sudo ufw --force enable
echo ""
echo "UFW firewall rules have been added. Enable it later via:"
echo "sudo ufw enable"
echo ""
echo ""
echo "Do you have Oracle Java JDK 8 and Ant installed already? It is required for this."
echo ""
echo "${RED}1${NC} - Install for me!"
echo "${RED}2${NC} - Im all set"
echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter."
echo ""
echo ""
read java
# Ubuntu Java ===================================================> clear
if [ "$java" == "1" ]; then echo "Installing Oracle Java JDK 8"
sudo apt-get remove openjdk-6-jre default-jre default-jre-headless -y echo ""
sudo add-apt-repository ppa:webupd8team/java -y && sudo apt update && sudo apt install ant oracle-java8-set-default openjfx -y sudo apt-get remove openjdk-6-jre default-jre default-jre-headless -y
else echo ""
continue sudo add-apt-repository ppa:webupd8team/java -y && sudo apt update && sudo apt install ant oracle-java8-set-default openjfx -y
fi fi
# Ubuntu Java <===================================================
# Ubuntu OS <=================================================== # Ubuntu OS <===================================================
# Mac OS ===================================================> # Mac OS ===================================================>
elif [ "$os" == "4" ]; then elif [ "$os" == "2" ]; then
clear clear
echo "Do you have brew installed? It is required for this." echo "Do you have brew installed? It is required for this."
echo "" echo ""
@@ -152,82 +98,44 @@ if [ "$install" == "1" ]; then
fi fi
# Mac Brew <=================================================== # Mac Brew <===================================================
echo "" clear
echo ""
echo "Verifying the basics are installed." echo "Verifying the basics are installed."
echo "" echo ""
brew install unzip wget git curl zip screen brew install unzip wget git curl zip screen
echo "" brew tap AdoptOpenJDK/openjdk
echo "" brew install adoptopenjdk-openjdk8 ant openjfx
echo "Do you have Oracle Java JDK 8 and Ant installed already? It is required for this."
echo ""
echo "${RED}1${NC} - Install for me!"
echo "${RED}2${NC} - Im all set"
echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter."
echo ""
echo ""
read java
# Mac Java ===================================================> clear
if [ "$java" == "1" ]; then echo "Downloading the Docker for Mac installer."
brew tap AdoptOpenJDK/openjdk echo ""
brew install adoptopenjdk-openjdk8 ant openjfx wget https://download.docker.com/mac/stable/Docker.dmg
hdiutil attach Docker.dmg
echo ""
echo "Please drag Docker as instructed in the popup."
echo ""
echo "Press enter when finished."
echo ""
read
clear
open /Applications/Docker.app
echo ""
echo "Docker is launching. Please follow the directions that it gives you."
echo ""
echo "Press enter when finished."
echo ""
read
fi fi
# Mac Java <===================================================
echo ""
echo ""
echo "Do you have Docker installed? It is required for this."
echo ""
echo "${RED}1${NC} - No, install it for me!"
echo "${RED}2${NC} - Yes"
echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter."
echo ""
echo ""
read docker
# Mac Docker ===================================================>
if [ "$docker" == "1" ]; then
echo "Downloading the Docker for Mac installer."
echo ""
wget https://download.docker.com/mac/stable/Docker.dmg
hdiutil attach Docker.dmg
echo ""
echo "Please drag Docker as instructed in the popup."
echo ""
echo "Press enter when finished."
echo ""
read
echo ""
open /Applications/Docker.app
echo ""
echo "Docker is launching. Please follow the directions that it gives you."
echo ""
echo "Press enter when finished."
echo ""
read
fi
# Mac Docker <===================================================
# Mac OS <=================================================== # Mac OS <===================================================
else
continue
fi
# OS Selection <=================================================== # OS Selection <===================================================
else
continue
fi
# Install Choice <=================================================== # Install Choice <===================================================
clear clear
echo "Checking for updates to the Docker-Home repository." echo "Checking for updates to the Docker-Home repository."
echo "" echo ""
sudo git pull sudo git pull
echo ""
echo ""
clear clear
echo "${RED}Open RSC Installer:${NC} echo "${RED}Open RSC Installer:${NC}
An easy to run RSC private server using Docker magic. An easy to run RSC private server using Docker magic.
@@ -247,31 +155,31 @@ read choice
# 1. Set up for single player ===================================================> # 1. Set up for single player ===================================================>
if [ "$choice" == "1" ]; then if [ "$choice" == "1" ]; then
clear clear
echo "You have picked ${GREEN}Set up for single player!${NC}" echo "You have picked ${GREEN}set up for single player!${NC}"
echo "" echo ""
echo "" echo ""
echo "Starting up the Docker containers. If error, do \"sudo make stop\" and rerun script." echo "Starting up the Docker containers. If error, do \"sudo make stop\" and rerun script."
echo "" echo ""
sudo make start-single-player sudo make start-single-player
echo ""
echo "" clear
echo "Fetching the Game from the Open RSC git repo." echo "Fetching the Game from the Open RSC git repo."
echo "" echo ""
sudo make clone-game sudo make clone-game
sudo chmod -R 777 Game sudo chmod -R 777 Game
echo ""
echo "" clear
echo "Creating the client cache in your home folder." echo "Creating the client cache in your home folder."
echo "" echo ""
mkdir ~/OpenRSC mkdir ~/OpenRSC
unzip -o Game/client/cache.zip -d ~/OpenRSC unzip -o Game/client/cache.zip -d ~/OpenRSC
echo ""
echo "" clear
echo "Importing the game databases." echo "Importing the game databases."
echo "" echo ""
sudo make import-game sudo make import-game
echo ""
echo "" clear
echo "Ready to launch \"./Linux_Single_Player.sh\" - Press enter when ready." echo "Ready to launch \"./Linux_Single_Player.sh\" - Press enter when ready."
echo "" echo ""
echo "" echo ""
@@ -289,21 +197,21 @@ elif [ "$choice" == "2" ]; then
echo "" echo ""
sudo chmod -R 777 . sudo chmod -R 777 .
sudo make start sudo make start
echo ""
echo "" clear
echo "Fetching the Website and Game from the Open RSC git repo." echo "Fetching the Website and Game from the Open RSC git repo."
echo "" echo ""
sudo make clone-game sudo make clone-game
sudo make clone-website sudo make clone-website
sudo chmod -R 777 . sudo chmod -R 777 .
echo ""
echo "" clear
echo "Creating the client cache in your home folder." echo "Creating the client cache in your home folder."
echo "" echo ""
mkdir ~/OpenRSC mkdir ~/OpenRSC
unzip -o Game/client/cache.zip -d ~/OpenRSC unzip -o Game/client/cache.zip -d ~/OpenRSC
echo ""
echo "" clear
echo "Next is manual file editing for the website domain and SQL user/pass." echo "Next is manual file editing for the website domain and SQL user/pass."
echo "" echo ""
echo "It is suggested that you first navigate to your VPS's http://domain:9000" echo "It is suggested that you first navigate to your VPS's http://domain:9000"
@@ -320,22 +228,19 @@ elif [ "$choice" == "2" ]; then
sudo nano Game/Launcher/src/Main.java sudo nano Game/Launcher/src/Main.java
sudo nano Game/server/config/config.xml sudo nano Game/server/config/config.xml
sudo nano etc/ghost/config.production.json sudo nano etc/ghost/config.production.json
echo ""
echo "" clear
echo "File edits complete."
echo ""
echo ""
echo "Importing the databases." echo "Importing the databases."
echo "" echo ""
sudo make import-game sudo make import-game
sudo make import-ghost sudo make import-ghost
echo ""
echo "" clear
echo "Restarting Docker containers" echo "Restarting Docker containers"
echo "" echo ""
sudo make stop && sudo make start sudo make stop && sudo make start
echo ""
echo "" clear
echo "Ready to launch \"./Linux_Fetch_Updates_Production.sh\" - Press enter when ready." echo "Ready to launch \"./Linux_Fetch_Updates_Production.sh\" - Press enter when ready."
echo "" echo ""
echo "" echo ""
@@ -359,7 +264,7 @@ elif [ "$choice" == "3" ]; then
# 3. Backup <=================================================== # 3. Backup <===================================================
else else
echo "" clear
echo "Error! ${RED}$choice${NC} is not a valid option. Press enter to try again." echo "Error! ${RED}$choice${NC} is not a valid option. Press enter to try again."
echo "" echo ""
read read

View File

@@ -1,9 +1,5 @@
#!/bin/bash #!/bin/bash
# Verifies permissions are set correctly
sudo chmod -R 777 Game
sudo setfacl -m user:$USER:rw /var/run/docker.sock
# Backs up all databases # Backs up all databases
./Linux_Backup_Databases.sh ./Linux_Backup_Databases.sh

View File

@@ -68,19 +68,19 @@ restore-windows:
@docker exec -i mysql mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < $(MYSQL_DUMPS_DIR)/db.sql @docker exec -i mysql mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < $(MYSQL_DUMPS_DIR)/db.sql
import-game: import-game:
docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Game/Databases/openrsc_config.sql 2>/dev/null @docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Game/Databases/openrsc_config.sql 2>/dev/null
docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Game/Databases/openrsc_logs.sql 2>/dev/null @docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Game/Databases/openrsc_logs.sql 2>/dev/null
docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Game/Databases/openrsc.sql 2>/dev/null @docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Game/Databases/openrsc.sql 2>/dev/null
docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Game/Databases/openrsc_tools.sql 2>/dev/null @docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Game/Databases/openrsc_tools.sql 2>/dev/null
import-website: import-website:
docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Website/openrsc_forum.sql 2>/dev/null @docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Website/openrsc_forum.sql 2>/dev/null
import-ghost: import-ghost:
docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < ghost.sql 2>/dev/null @docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < ghost.sql 2>/dev/null
import-wiki: import-wiki:
docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Website/Wiki/openrsc_wiki.sql 2>/dev/null @docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Website/Wiki/openrsc_wiki.sql 2>/dev/null
import-windows-game: import-windows-game:
@docker exec -i mysql mysql -u"root" -p"root" < Game/Databases/openrsc_logs.sql @docker exec -i mysql mysql -u"root" -p"root" < Game/Databases/openrsc_logs.sql