• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[Linux] Automated All In One Patcher & Restarter

Sylica

Exalted Member
Hey guys,

Was going through some old servers I have laying around at my place and came across a shell script that was used back in the day running retail game servers.

Don't think anyone posted nor shared this script. Basically it does what the title says. This script will take care of everything which you would normally have to do manually without this script.
This can be used for any projects out there, if you modify the paths to your own. Just update the mysql command with your database login information and database names.

What this script does:
  • Checks for source updates and compiles them
  • Updates your databases with updates that are in the update folders
  • Restarts your game server after words

Please note, the speed of these processes highly depends on your host. Not sure if this would be useful to anyone though, but who knows.
Code:
#!/bin/bash
# Automatic server patcher and restarter

while :
do

# Lets prepare our source and install it
cd /opt/source/build
make -j 2 -k && make install

# Prepare required files and update account database from here
mv /opt/source/sql/updates/auth/*.sql /opt/server/updates/accounts

# Prepare update file and apply to account database
cat /opt/server/updates/accounts/*.sql > /opt/server/updates/accounts/account_update.sql
mysql -uroot -p12345 account < /opt/server/updates/accounts/account_update.sql
sudo rm /opt/server/updates/accounts/*.sql

# Prepare required files for character database
mv /opt/source/sql/updates/characters/*.sql /opt/server/updates/characters

# Prepare update file and apply to character database
cat /opt/server/updates/characters/*.sql > /opt/server/updates/characters/character_update.sql
mysql -uroot -p12345 characters < /opt/server/updates/characters/character_update.sql
sudo rm /opt/server/updates/characters/*.sql

# Prepare required files for world database
mv /opt/source/sql/updates/world/*.sql /opt/server/updates/world

# Prepare update file and apply to world database
cat /opt/server/sql/updates/world/*.sql /opt/server/updates/world/world_update.sql
mysql -uroot -p12345 world < /opt/server/updates/world/world_update.sql
sudo rm /opt/server/sql/updates/world/*.sql

# Lets prepare the world server now
cd /opt/server/bin
./characterserver
./instanceserver
./mapserver
sleep 5
done

Please take warning when using this script, when playing with mysql scripts. If you make a typo in your files, your database can be messed up, if not backed up before applying new updates. This goes for your source as well, if compiling is not tested before applied to your localhost or public box, you'll have start up issues which will keep the server down.
 
Top