Browse Source

init

master
Evan Burkey 9 months ago
commit
277dac759b
  1. 13
      LICENSE
  2. 44
      README.md
  3. 7
      codescripts/build.sh
  4. 6
      codescripts/db.sh
  5. 21
      codescripts/reset.sh
  6. 12
      codescripts/test.sh
  7. 12
      codescripts/vars
  8. 3
      codescripts/world_reset.sql
  9. 6
      serverscripts/auth.sh
  10. 4
      serverscripts/shutdown.sh
  11. 3
      serverscripts/start.sh
  12. 4
      serverscripts/world.sh

13
LICENSE

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
Copyright 2022 Evan Burkey <dev@fputs.com>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

44
README.md

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
# azcore-scripts
Scripts to help automate building and testing [azerothcore](https://github.com/azerothcore/azerothcore-wotlk)
## Setup
These scripts depend on a properly setup azerothcore installation. Follow [the instructions](https://www.azerothcore.org/wiki/installation) and verify that your install is working before trying to use these scripts. These scripts also require `bash` and `screen`. Most major Linux distros include both packages but it is up to the user to verify these are on the system.
The scripts in `codescripts` are placed into the `build` directory of the azerothcore-wotlk repository. The scripts in `serverscripts` are placed into the `bin` directory of an azerothcore installation.
The `vars` file in `codescripts` must be modified to fit your local installation of azerothcore and mysql
## Code Scripts
`build.sh` builds azerothcore and is called by several other scripts
`db.sh` looks for an update to the `acore_world` database in the current branch and applies it
`reset.sh` does the following:
- Resets the repo to a clean, updated copy of the master branch from upstream
- Deletes any branches with the `pr-` prefix
- Wipes the `acore_world` database
- Builds and installs clean copy of azerothcore
- Runs the server for 90 seconds to allow the `acore_world` database to rebuild and repopulate
- Kills the server
`test.sh` does the following:
- The script requires a pr number passed to it
- A new branch will be created named `pr-####` with the pr number
- The branch is built and installed
The user is responsible for running `db.sh` afterwards if the pr includes an update to the `acore_world` database
`world_reset.sql` is an SQL script to wipe the `acore_world` database. This is used by `reset.sh`
## Server Scripts
`auth.sh` and `world.sh` are not intended to be run manually. They contain loops that keep the servers up and running. If either crashes then the script sleeps 20 second and restarts the servers. These are designed to be run inside of `screen` sessions.
`start.sh` and `shutdown.sh` start and stop the auth and world servers. They place the servers inside of `screen` sessions.
To access your world server session, type `screen -r world` into a shell. This will attach you to the `screen` session containg the world server. To leave the session without closing the world server, type `Ctrl-A` then `Ctrl-D`. Reference the `screen` man page for more details on usage.

7
codescripts/build.sh

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
#!/bin/sh
n=$(nproc) || 1
cmake ../ -DCMAKE_INSTALL_PREFIX=$serverdir -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DWITH_WARNINGS=1 -DTOOLS=0 -DSCRIPTS=static
make "-j$n"
make install

6
codescripts/db.sh

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
#!/usr/bin/env bash
. vars || exit 1
path="$azdir/data/sql/updates/pending_db_world"
rev=$(ls $path | grep rev)
sudo mysql -u $mysql_user -p"$mysql_password" acore_world < "$path/$rev"

21
codescripts/reset.sh

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
#!/usr/bin/env bash
. vars || exit 1
$serverdir/bin/shutdown.sh
pushd $azdir || die "failed pushd $azdir"
git reset --hard origin/master
git checkout master
git clean -fd
git pull
for pr in $(git branch | grep pr); do git branch -D "$pr"; done
popd || die "failed popd"
sudo mysql -u $mysql_user -p"$mysql_password" < world_reset.sql
bash ./build.sh
pushd $serverdir || die "failed pushd $serverdir"
./start.sh
sleep 90s
./shutdown.sh
popd || die "failed popd"

12
codescripts/test.sh

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
#!/usr/bin/env bash
[ "$#" -eq 1 ] || die "1 argument required, $# provided"
echo "$1" | grep -E -q '^[0-9]+$' || die "Numeric argument required, $1 provided"
pushd "$azdir" || die "failed pushd $azdir"
git checkout master
git pull origin master
git checkout -b "pr-$1"
git pull origin "pull/$1/head"
popd || die "failed popd, run build.sh manually"
bash ./build.sh

12
codescripts/vars

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
#!/usr/bin/env bash
export mysql_user="user"
export mysql_password="password"
export azdir="/path/to/azerothcore-wotlk"
export serverdir="/path/to/server"
die () {
echo >&2 "$@"
exit 1
}

3
codescripts/world_reset.sql

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
DROP DATABASE acore_world;
CREATE DATABASE `acore_world` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON `acore_world` . * TO 'acore'@'localhost' WITH GRANT OPTION;

6
serverscripts/auth.sh

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
#!/usr/bin/env bash
while :; do
./authserver
sleep 20
done

4
serverscripts/shutdown.sh

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
#!/usr/bin/env bash
killall screen
screen -ls

3
serverscripts/start.sh

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
#!/bin/bash
screen -AmdS auth ./auth.sh
screen -AmdS world ./world.sh

4
serverscripts/world.sh

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
while :; do
./worldserver
sleep 20
done
Loading…
Cancel
Save