v2 scripts

This commit is contained in:
Marwolf
2018-08-27 22:20:47 -04:00
parent dd7936475c
commit b0fcd8cc8e
7 changed files with 449 additions and 12 deletions

4
.gitignore vendored
View File

@@ -40,6 +40,4 @@ etc/ghost/content/data/\.DS_Store
etc/ghost/content/themes/ etc/ghost/content/themes/
etc/ghost/content/logs/http___localhost_blog_production\.log\.0 etc/ghost/content/logs/*.log.*
etc/ghost/content/logs/http___localhost_blog_production\.error\.log\.0

View File

@@ -18,9 +18,15 @@ restart: init
clone-game: clone-game:
@$(shell git clone https://github.com/Open-RSC/Game.git) @$(shell git clone https://github.com/Open-RSC/Game.git)
clone-game-v2:
@$(shell git clone -b 2.0.0 https://github.com/Open-RSC/Game.git)
clone-website: clone-website:
@$(shell git clone https://github.com/Open-RSC/Website.git) @$(shell git clone https://github.com/Open-RSC/Website.git)
clone-website-v2:
@$(shell git clone -b 2.0.0 https://github.com/Open-RSC/Website.git)
clone-wiki: clone-wiki:
@$(shell cd Website && git clone https://github.com/Open-RSC/Wiki.git) @$(shell cd Website && git clone https://github.com/Open-RSC/Wiki.git)
@@ -73,13 +79,12 @@ import-game:
@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-game-v2:
@docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Game/openrsc_game.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:
@docker exec -i $(shell sudo docker-compose ps -q mysqldb) mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" -Bse "DROP DATABASE IF EXISTS ghost;" 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
@@ -92,9 +97,6 @@ import-windows-game:
import-windows-website: import-windows-website:
@docker exec -i mysql mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Website/openrsc_forum.sql @docker exec -i mysql mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Website/openrsc_forum.sql
import-windows-ghost:
@docker exec -i mysql mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < ghost.sql
import-windows-wiki: import-windows-wiki:
@docker exec -i mysql mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Website/Wiki/openrsc_wiki.sql @docker exec -i mysql mysql -u"$(MARIADB_ROOT_USER)" -p"$(MARIADB_ROOT_PASSWORD)" < Website/Wiki/openrsc_wiki.sql
@@ -104,5 +106,3 @@ flush:
flush-windows: flush-windows:
@rmdir "Website" /s /Q @rmdir "Website" /s /Q
@rmdir "Game" /s /Q @rmdir "Game" /s /Q
.PHONY: clean test code-sniff init

11
v2_Linux_Cloner.sh Normal file
View File

@@ -0,0 +1,11 @@
# Open RSC: A replica RSC private server framework
#
# Installs and updates Open RSC
#
# Install with this command (from your Linux machine):
#
# curl -sSL https://raw.githubusercontent.com/Open-RSC/Docker-Home/master/Linux_Cloner.sh | bash
sudo git clone https://github.com/Open-RSC/Docker-Home.git
cd Docker-Home
"./v2_Linux_Installer.sh"

View File

@@ -0,0 +1,59 @@
#!/bin/bash
exec 0</dev/tty
# Open RSC: A replica RSC private server framework
#
# Installs and updates Open RSC
#
# Install with this command (from your Linux machine):
#
# curl -sSL https://raw.githubusercontent.com/Open-RSC/Docker-Home/master/Linux_Cloner.sh | bash
source .env
rm updater.log
touch updater.log && chmod 777 updater.log | tee updater.log | &>/dev/null
# Check for any updates to the game server
clear
echo "Pulling recent updates from the Open-RSC Game repository."
cd Game
sudo git pull | tee -a ../updater.log &>/dev/null
# Verifies permissions are set correctly
sudo chmod -R 777 Game | tee -a ../updater.log &>/dev/null
sudo setfacl -m user:$USER:rw /var/run/docker.sock | tee -a ../updater.log &>/dev/null
cd ..
# Server
clear
echo "Compiling the game server. Any errors will be in updater.log"
sudo ant -f "Game/server/build.xml" compile | tee updater.log &>/dev/null
# Client
clear
echo "Compiling and preparing the game client. Any errors will be in updater.log"
sudo ant -f "Game/client/build.xml" compile | tee -a ../../updater.log &>/dev/null
yes | sudo cp -rf "Game/client/Open_RSC_Client.jar" "Website/downloads/" | tee -a ../../updater.log &>/dev/null
# Launcher
clear
echo "Compiling and preparing the game launcher. Any errors will be in updater.log"
sudo ant -f "Game/Launcher/nbbuild.xml" jar | tee -a updater.log &>/dev/null
yes | sudo cp -rf "Game/Launcher/dist/Open_RSC_Launcher.jar" "Website/downloads/" | tee -a updater.log &>/dev/null
# Cache
clear
echo "Preparing the cache."
yes | sudo cp -rf "Game/client/Cache/" "Website/downloads/cache" | tee -a updater.log &>/dev/null
sudo rm Website/downloads/cache/MD5CHECKSUM | tee -a updater.log &>/dev/null
sudo touch Website/downloads/cache/MD5CHECKSUM && sudo chmod 777 Website/downloads/cache/MD5CHECKSUM | tee updater.log | &>/dev/null
md5sum Website/downloads/cache/* | sed 's/Website\/downloads\/cache\///g' | grep ^[a-zA-Z0-9]* | awk '{print $2"="$1}' | tee Website/downloads/cache/MD5CHECKSUM | tee -a updater.log &>/dev/null
# Database
clear
echo "Preparing the database."
docker exec -i $(sudo docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < Game/openrsc_game.sql 2>/dev/null
# Run the game server in a detached screen
./v2_Linux_Run_Production_Server.sh

306
v2_Linux_Installer.sh Normal file
View File

@@ -0,0 +1,306 @@
#!/bin/bash
exec 0</dev/tty
# Open RSC: A replica RSC private server framework
#
# Installs and updates Open RSC
#
# Install with this command (from your Linux machine):
#
# curl -sSL https://raw.githubusercontent.com/Open-RSC/Docker-Home/master/Linux_Cloner.sh | bash
rm installer.log
touch installer.log && chmod 777 installer.log | tee installer.log &>/dev/null
choice=""
RED=`tput setaf 1`
GREEN=`tput setaf 2`
NC=`tput sgr0` # No Color
# Install Choice ===================================================>
clear
echo "${RED}Open RSC Installer:${NC}
An easy to use RSC private server environment using Docker magic.
Do you wish to have all the pre-requiste software installed by this script?
Choices:
${RED}1${NC} - Yes please, install for me!
${RED}2${NC} - No thanks, continue (default)"
echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter."
read install
# OS Selection ===================================================>
if [ "$install" == "1" ]; then
clear
echo "Which operating system are you running?"
echo ""
echo "${RED}1${NC} - Ubuntu Linux 18.04 or above"
echo "${RED}2${NC} - Mac OS High Sierra or above"
echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter."
read os
# Ubuntu OS ===================================================>
if [ "$os" == "1" ]; then
clear
sudo dpkg-reconfigure tzdata
clear
echo "Installing required software. Please wait, this will take a while."
echo "Installing certbot, screen, zip, fail2ban, unzip, git, build-essential, "
echo "software-properties-common, apt-transport-https, ca-certificates, and curl."
echo ""
echo "Installation logs are being sent to installer.log"
sudo apt-get update | tee -a installer.log &>/dev/null
sudo apt-get install software-properties-common -y | tee -a installer.log &>/dev/null
sudo add-apt-repository ppa:certbot/certbot -y | tee -a installer.log &>/dev/null
sudo apt-get update | tee -a installer.log &>/dev/null
sudo apt-get install certbot screen zip fail2ban unzip git build-essential apt-transport-https ca-certificates curl -y | tee -a installer.log &>/dev/null
clear
echo "Attempting to install Docker CE and Docker Compose. Please wait."
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | tee -a installer.log &>/dev/null
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" | tee -a installer.log &>/dev/null
sudo apt-get update | tee -a installer.log &>/dev/null && sudo apt-get install docker-ce docker-compose -y | tee -a installer.log &>/dev/null
sudo setfacl -m user:$USER:rw /var/run/docker.sock | tee -a ../installer.log &>/dev/null
clear
echo "Setting Docker to have the correct storage driver and restarting the service."
echo '{
"storage-driver": "devicemapper"
}' | sudo tee /etc/docker/daemon.json && sudo service docker restart | tee -a installer.log &>/dev/null
clear
echo "Setting Ubuntu Firewall permissions."
sudo ufw allow 22/tcp | tee -a installer.log &>/dev/null && sudo ufw allow 80/tcp | tee -a installer.log &>/dev/null && sudo ufw allow 8080/tcp | tee -a installer.log &>/dev/null && sudo ufw allow 443/tcp | tee -a installer.log &>/dev/null && sudo ufw allow 9000/tcp | tee -a installer.log &>/dev/null && sudo ufw allow 53595/tcp | tee -a installer.log &>/dev/null && sudo ufw deny 3306/tcp | tee -a installer.log &>/dev/null
sudo sed -i 's/DEFAULT_FORWARD_POLICY="DENY"/DEFAULT_FORWARD_POLICY="ACCEPT"/g' /etc/default/ufw | tee -a installer.log &>/dev/null
sudo ufw reload | tee -a installer.log &>/dev/null
sudo ufw --force enable | tee -a installer.log &>/dev/null
clear
echo "Installing Oracle Java JDK 8, openjfx, and Apache ant. Please wait."
sudo apt-get remove -y openjdk-6-jre default-jre default-jre-headless | tee -a installer.log &>/dev/null
sudo add-apt-repository -y ppa:webupd8team/java | tee -a installer.log &>/dev/null
sudo apt update | tee -a installer.log &>/dev/null
sudo apt install -y openjfx ant | tee -a installer.log &>/dev/null
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections | tee -a installer.log &>/dev/null
sudo apt-get install -y oracle-java8-installer | tee -a installer.log &>/dev/null
sudo apt install oracle-java8-set-default | tee -a installer.log &>/dev/null
fi
# Ubuntu OS <===================================================
# Mac OS ===================================================>
elif [ "$os" == "2" ]; then
clear
echo "Do you have Brew 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."
read brew
# Mac Brew ===================================================>
if [ "$brew" == "1" ]; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | tee -a installer.log &>/dev/null
brew install git | tee -a installer.log &>/dev/null
fi
# Mac Brew <===================================================
clear
echo "Verifying the basics are installed via Brew."
brew install unzip wget git curl zip screen | tee -a installer.log &>/dev/null
brew tap AdoptOpenJDK/openjdk | tee -a installer.log &>/dev/null
brew install adoptopenjdk-openjdk8 ant openjfx | tee -a installer.log &>/dev/null
clear
echo "Downloading the Docker for Mac installer."
wget https://download.docker.com/mac/stable/Docker.dmg | tee -a installer.log &>/dev/null
hdiutil attach Docker.dmg | tee -a installer.log &>/dev/null
echo ""
echo "Please drag Docker as instructed in the popup."
echo ""
echo "Press enter when finished."
read
clear
open /Applications/Docker.app
echo "Docker is launching. Please follow the directions that it gives you."
echo ""
echo "Press enter when finished."
read
fi
# Mac OS <===================================================
# OS Selection <===================================================
# Install Choice <===================================================
clear
echo "Fetching updates from the Docker-Home GitHub repository."
sudo git pull | tee -a installer.log &>/dev/null
clear
echo "${RED}Open RSC Installer:${NC}
An easy to use RSC private server using Docker magic.
Choices:
${RED}1${NC} - Set up for single player
${RED}2${NC} - Deploy to a VPS
${RED}3${NC} - Backup all databases
"
echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter."
read choice
# Selection ===================================================>
# 1. Set up for single player ===================================================>
if [ "$choice" == "1" ]; then
clear
echo "You have picked ${GREEN}set up for single player!${NC}"
echo ""
echo ""
echo "Starting up the Docker containers. Please wait, this will take a while."
echo ""
echo "Installation logs are being sent to installer.log"
sudo make start-single-player | tee -a installer.log &>/dev/null
clear
echo "Fetching the Game from the Open RSC git repo."
sudo make clone-game-v2 | tee -a installer.log &>/dev/null
sudo chmod -R 777 Game | tee -a installer.log &>/dev/null
clear
echo "Importing the game databases."
sudo make import-game-v2 | tee -a installer.log &>/dev/null
clear
./v2_Linux_Single_Player.sh
# 1. Set up for single player <===================================================
# 2. Deployment for a publicly hosted server ===================================================>
elif [ "$choice" == "2" ]; then
clear
echo "You have picked ${GREEN}deploy to a VPS!${NC}"
echo ""
echo ""
echo "Starting up the Docker containers."
sudo chmod -R 777 . | tee -a installer.log &>/dev/null
sudo make stop | tee -a installer.log &>/dev/null
sudo make start | tee -a installer.log &>/dev/null
# Website
clear
echo "Fetching the Website and Game from the Open RSC git repo."
sudo make clone-game-v2 | tee -a installer.log &>/dev/null
sudo make clone-website-v2 | tee -a installer.log &>/dev/null
sudo chmod -R 777 . | tee -a installer.log &>/dev/null
clear
echo "Please enter your desired password for SQL user 'root'."
read -s dbpass
clear
echo "Please enter your server's public domain name."
read -s publicdomain
clear
echo "Please enter your server's private domain name if one exists or re-enter the public domain name again."
read -s privatedomain
clear
echo "Do you want a Lets Encrypt HTTPS certificate installed?
Choices:
${RED}1${NC} - Yes
${RED}2${NC} - No
"
echo ""
echo "Which of the above do you wish to do? Type the choice number and press enter."
read httpsask
if [ "$httpsask" == "1" ]; then
clear
echo "Please enter your email address for Lets Encrypt HTTPS registration."
read -s email
sudo docker stop nginx | tee -a installer.log &>/dev/null
sudo mv etc/nginx/default.conf etc/nginx/default.conf.BAK | tee -a installer.log &>/dev/null
sudo mv etc/nginx/HTTPS_default.conf.BAK etc/nginx/default.conf | tee -a installer.log &>/dev/null
sudo sed -i 's/live\/openrsc.com/live\/'"$publicdomain"'/g' etc/nginx/default.conf | tee -a installer.log &>/dev/null
clear
echo "Enabling HTTPS"
sudo certbot certonly --standalone --preferred-challenges http --agree-tos -n --config-dir ./etc/letsencrypt -d $publicdomain -d $privatedomain --expand -m $email | tee -a installer.log &>/dev/null
elif [ "$httpsask" == "2" ]; then
continue
fi
#clear
#echo "Please enter the name of your game."
#read -s gamename
#clear
#echo "What should the combat xp multiplier be? ex: 1, 1.5, 2, 5, 10"
#read -s xprate
#clear
#echo "What should the skill xp multiplier be? ex: 1, 1.5, 2, 5, 10"
#read -s skillrate
#clear
#echo "Should batched skills be enabled? 0 = disabled, 1 = try till success, 2 = full auto till empty"
#read -s loopmode
# Automated edits of the .env file
clear
sudo sed -i 's/URL=http:\/\/localhost\/blog/URL=http:\/\/'"$publicdomain"'\/blog/g' .env | tee -a installer.log &>/dev/null
sudo sed -i 's/NGINX_HOST=localhost/NGINX_HOST='"$publicdomain"'/g' .env | tee -a installer.log &>/dev/null
sudo sed -i 's/MARIADB_PASS=pass/MARIADB_PASS='"$dbpass"'/g' .env | tee -a installer.log &>/dev/null
sudo sed -i 's/MARIADB_ROOT_PASSWORD=root/MARIADB_ROOT_PASSWORD='"$dbpass"'/g' .env | tee -a installer.log &>/dev/null
clear
echo "Restarting Docker containers to enact changes."
sudo make stop | tee -a installer.log &>/dev/null && sudo make start | tee -a installer.log &>/dev/null
# Automated file edits
#clear
#echo "Configuring Open RSC based on your input."
#sudo sed -i 's/DB_PASS">root/DB_PASS">'"$dbpass"'/g' Game/server/config/config.xml | tee -a installer.log &>/dev/null
#sudo sed -i 's/NAME">Open RSC/NAME">'"$gamename"'/g' Game/server/config/config.xml | tee -a installer.log &>/dev/null
#sudo sed -i 's/\@OpenRSC/\@'"$gamename"'/g' Game/server/config/config.xml | tee -a installer.log &>/dev/null
#sudo sed -i 's/COMBAT\_XP\_RATE">1/COMBAT\_XP\_RATE">'"$xprate"'/g' Game/server/config/config.xml | tee -a installer.log &>/dev/null
#sudo sed -i 's/SKILL_XP_RATE">1/SKILL_XP_RATE">'"$skillrate"'/g' Game/server/config/config.xml | tee -a installer.log &>/dev/null
#sudo sed -i 's/SKILL_LOOP_MODE">0/SKILL_LOOP_MODE">'"$loopmode"'/g' Game/server/config/config.xml | tee -a installer.log &>/dev/null
#sudo sed -i 's/String IP = "127.0.0.1";/String IP = "'$privatedomain'";/g' Game/client/src/org/openrsc/client/Config.java | tee -a installer.log &>/dev/null
clear
echo "Importing the game database."
sudo make import-game-v2 | tee -a installer.log &>/dev/null
clear
./v2_Linux_Fetch_Updates_Production.sh
# 2. Deployment for a publicly hosted server <===================================================
# 3. Backup ===================================================>
elif [ "$choice" == "3" ]; then
echo "You have picked ${GREEN}backup all databases!${NC}"
sudo make backup | tee -a installer.log &>/dev/null
clear
echo "Done! - Press enter to return back to the menu."
read
./v2_Linux_Installer.sh
# 3. Backup <===================================================
else
clear
echo "Error! ${RED}$choice${NC} is not a valid option. Press enter to try again."
echo ""
read
./v2_Linux_Installer.sh
continue
fi

View File

@@ -0,0 +1,16 @@
#!/bin/bash
# Backs up all databases
./Linux_Backup_Databases.sh
# Run the game server in a detached screen
clear
echo "Launching the game server in a new screen."
echo ""
echo "Type 'screen -r' to access the game server screen."
echo "Use CTRL + A + D to detach the live server screen so it runs in the background."
echo ""
echo ""
touch gameserver.log && chmod 777 gameserver.log &>/dev/null
cd Game/server
screen -dmS name ./ant_launcher.sh

47
v2_Linux_Single_Player.sh Normal file
View File

@@ -0,0 +1,47 @@
#!/bin/bash
exec 0</dev/tty
# Open RSC: A replica RSC private server framework
#
# Installs and updates Open RSC
#
# Install with this command (from your Linux machine):
#
# curl -sSL https://raw.githubusercontent.com/Open-RSC/Docker-Home/master/Linux_Cloner.sh | bash
source .env
rm singleplayer.log
touch singleplayer.log && chmod 777 singleplayer.log | tee -a singleplayer.log &>/dev/null
# Check for any updates to the game server
clear
echo "Pulling recent updates from the Open-RSC Game repository."
sudo git pull | tee -a singleplayer.log &>/dev/null
sudo make pull-game | tee -a singleplayer.log &>/dev/null
sudo chmod -R 777 Game | tee -a installer.log &>/dev/null
clear
echo "Starting Docker containers."
sudo make stop | tee -a singleplayer.log &>/dev/null
sudo make start-single-player | tee -a singleplayer.log &>/dev/null
# Compile the game server and client
clear
echo "Compiling the game client. Any errors will be in singleplayer.log"
sudo ant -f "Game/client/build.xml" compile | tee -a singleplayer.log &>/dev/null
clear
echo "Compiling the game server. Any errors will be in singleplayer.log"
sudo ant -f "Game/server/build.xml" compile_core | tee -a singleplayer.log &>/dev/null
sudo ant -f "Game/server/build.xml" compile_plugins | tee -a singleplayer.log &>/dev/null
# Run the game client in a new window
clear
echo "Launching the game client."
sudo ant -f Game/client/build.xml runclient &
# Run the game server in the current window
clear
echo "Launching the game server."
sudo ant -f Game/server/build.xml runservermembers