forked from HerculesWS/Hercules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis.sh
executable file
·145 lines (137 loc) · 4.17 KB
/
travis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# This file is part of Hercules.
# http://herc.ws - http://github.com/HerculesWS/Hercules
#
# Copyright (C) 2014-2015 Hercules Dev Team
#
# Hercules is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Base Author: Haru @ http://herc.ws
MODE="$1"
shift
function foo {
for i in "$@"; do
echo "> $i"
done
}
function usage {
echo "usage:"
echo " $0 createdb <dbname> [dbuser] [dbpassword]"
echo " $0 importdb <dbname> [dbuser] [dbpassword]"
echo " $0 build [configure args]"
echo " $0 test <dbname> [dbuser] [dbpassword]"
echo " $0 getplugins"
exit 1
}
function aborterror {
echo $@
exit 1
}
case "$MODE" in
createdb|importdb|test)
DBNAME="$1"
DBUSER="$2"
DBPASS="$3"
if [ -z "$DBNAME" ]; then
usage
fi
if [ "$MODE" != "test" ]; then
if [ -n "$DBUSER" ]; then
DBUSER="-u $DBUSER"
fi
if [ -n "$DBPASS" ]; then
DBPASS="-p$DBPASS"
fi
fi
;;
esac
case "$MODE" in
createdb)
echo "Creating database $DBNAME..."
mysql $DBUSER $DBPASS -e "create database $DBNAME;" || aborterror "Unable to create database."
;;
importdb)
echo "Importing tables into $DBNAME..."
mysql $DBUSER $DBPASS $DBNAME < sql-files/main.sql || aborterror "Unable to import main database."
mysql $DBUSER $DBPASS $DBNAME < sql-files/logs.sql || aborterror "Unable to import logs database."
;;
build)
(cd tools && ./validateinterfaces.py silent) || aborterror "Interface validation error."
./configure $@ || aborterror "Configure error, aborting build."
make sql -j3 || aborterror "Build failed."
make plugin.script_mapquit -j3 || aborterror "Build failed."
;;
test)
cat >> conf/import/login_conf.txt << EOF
ipban.sql.db_username: $DBUSER
ipban.sql.db_password: $DBPASS
ipban.sql.db_database: $DBNAME
account.sql.db_username: $DBUSER
account.sql.db_password: $DBPASS
account.sql.db_database: $DBNAME
account.sql.db_hostname: localhost
EOF
[ $? -eq 0 ] || aborterror "Unable to import configuration, aborting tests."
cat >> conf/import/inter_conf.txt << EOF
sql.db_username: $DBUSER
sql.db_password: $DBPASS
sql.db_database: $DBNAME
sql.db_hostname: localhost
char_server_id: $DBUSER
char_server_pw: $DBPASS
char_server_db: $DBNAME
char_server_ip: localhost
map_server_id: $DBUSER
map_server_pw: $DBPASS
map_server_db: $DBNAME
map_server_ip: localhost
log_db_id: $DBUSER
log_db_pw: $DBPASS
log_db_db: $DBNAME
log_db_ip: localhost
EOF
[ $? -eq 0 ] || aborterror "Unable to import configuration, aborting tests."
ARGS="--load-script npc/dev/test.txt "
ARGS="--load-plugin script_mapquit $ARGS --load-script npc/dev/ci_test.txt"
echo "Running Hercules with command line: ./map-server --run-once $ARGS"
./map-server --run-once $ARGS 2>runlog.txt
export errcode=$?
export teststr=$(cat runlog.txt)
if [[ -n "${teststr}" ]]; then
echo "Sanitizer errors found."
cat runlog.txt
aborterror "Sanitize errors found."
else
echo "No sanitizer errors found."
fi
if [ ${errcode} -ne 0 ]; then
echo "server terminated with exit code ${errcode}"
aborterror "Test failed"
fi
;;
getplugins)
echo "Cloning plugins repository..."
# Nothing to clone right now, all relevant plugins are part of the repository.
#git clone http://github.com/HerculesWS/StaffPlugins.git || aborterror "Unable to fetch plugin repository"
#if [ -f StaffPlugins/Haru/script_mapquit/script_mapquit.c -a -f StaffPlugins/Haru/script_mapquit/examples/ci_test.txt ]; then
# pushd src/plugins || aborterror "Unable to enter plugins directory."
# ln -s ../../StaffPlugins/Haru/script_mapquit/script_mapquit.c ./
# popd
#else
# echo "Plugin not found, skipping advanced tests."
#fi
;;
*)
usage
;;
esac