NPC Roundup (Phase I)
[swg-src.git] / build_linux.sh
blobce316055111eb2fc2dc95e22043494ed7fb9decf
1 #!/bin/bash
3 basedir=$PWD
4 PATH=$PATH:$basedir/build/bin
6 DBSERVICE=
7 DBUSERNAME=
8 DBPASSWORD=
9 HOSTIP=
10 CLUSTERNAME=
11 NODEID=
12 DSRC_DIR=
13 DATA_DIR=
15 if [ ! -d $basedir/build ]
16 then
17 mkdir $basedir/build
20 if [ ! -f $basedir/.setup ]; then
21 if [[ $(lsb_release -a) =~ .*Ubuntu.* ]] || [ -f "/etc/debian_version" ]
22 then
23 read -p "!!!ONLY RUN ONCE!!! Do you want to install dependencies (y/n)?" response
24 response=${response,,} # tolower
25 if [[ $response =~ ^(yes|y| ) ]]; then
26 $basedir/utils/init/ubuntu.sh
27 source /etc/profile.d/java.sh
28 source /etc/profile.d/oracle.sh
29 $basedir/utils/init/buildCurl.sh
30 touch $basedir/.setup
32 echo "Please login and out or reboot as changes have been made to your PATH "
37 read -p "Do you want to build the server now? (y/n) " response
38 response=${response,,} # tolower
39 if [[ $response =~ ^(yes|y| ) ]]; then
40 cd $basedir/build
42 cmake $basedir/src -DCMAKE_BUILD_TYPE=Release
44 make -j$(nproc)
46 cd $basedir
49 read -p "Do you want to build the config environment now? (y/n) " response
50 response=${response,,} # tolower
51 if [[ $response =~ ^(yes|y| ) ]]; then
53 # Prompt for configuration environment.
54 read -p "Configure environment (local, live, tc, design)? You probably want local. " config_env
56 # Make sure the configuration environment exists.
57 if [ ! -d $basedir/configs/$config_env ]; then
58 echo "Invalid configuration environment."
59 exit
63 echo "Enter your IP address (LAN for port forwarding or internal, outside IP for DMZ)"
64 read HOSTIP
66 echo "Enter the DSN for the database connection "
67 read DBSERVICE
69 echo "Enter the database username "
70 read DBUSERNAME
72 echo "Enter the database password "
73 read DBPASSWORD
75 echo "Enter a name for the galaxy cluster "
76 read CLUSTERNAME
78 if [ -d $basedir/exe ]; then
79 rm -rf $basedir/exe
82 mkdir -p $basedir/exe/linux/logs
83 mkdir -p $basedir/exe/shared
85 ln -s $basedir/build/bin $basedir/exe/linux/bin
87 cp -u $basedir/configs/$config_env/linux/* $basedir/exe/linux
88 cp -u $basedir/configs/$config_env/shared/* $basedir/exe/shared
90 for filename in $(find $basedir/exe -name '*.cfg'); do
91 sed -i -e "s@DBSERVICE@$DBSERVICE@g" -e "s@DBUSERNAME@$DBUSERNAME@g" -e "s@DBPASSWORD@$DBPASSWORD@g" -e "s@CLUSTERNAME@$CLUSTERNAME@g" -e "s@HOSTIP@$HOSTIP@g" $filename
92 done
95 # Generate other config files if their template exists.
98 # Generate at least 1 node that is the /etc/hosts IP.
99 $basedir/utils/build_node_list.sh
102 read -p "Do you want to build the scripts? (y/n) " response
103 response=${response,,} # tolower
104 if [[ $response =~ ^(yes|y| ) ]]; then
105 #prepare environment to run data file builders
106 oldPATH=$PATH
107 PATH=$basedir/build/bin:$PATH
109 read -p "Do you wanna use multicore scripts or the safe option? (multi/safe) " response
110 response=${response,,}
111 if [[ $response =~ ^(multi|m| ) ]]; then
112 $basedir/utils/mocha/prepare_all_scripts_multi.sh $basedir/dsrc/sku.0/sys.server/compiled/game/script
113 $basedir/utils/build_java_multi.sh
114 $basedir/utils/build_miff.sh
115 $basedir/utils/build_tab_multi.sh
116 $basedir/utils/build_tpf_multi.sh
117 else
118 $basedir/utils/mocha/prepare_all_scripts.sh $basedir/dsrc/sku.0/sys.server/compiled/game/script
119 $basedir/utils/build_java.sh
120 $basedir/utils/build_miff.sh
121 $basedir/utils/build_tab.sh
122 $basedir/utils/build_tpf.sh
125 $basedir/utils/build_object_template_crc_string_tables.py
126 $basedir/utils/build_quest_crc_string_tables.py
128 PATH=$oldPATH
131 read -p "Import database? (y/n) " response
132 response=${response,,}
133 if [[ $response =~ ^(yes|y| ) ]]; then
134 cd $basedir/src/game/server/database/build/linux
136 if [[ -z "$DBSERVICE" ]]; then
137 echo "Enter the DSN for the database connection "
138 read DBSERVICE
141 if [[ -z "$DBUSERNAME" ]]; then
142 echo "Enter the database username "
143 read DBUSERNAME
146 if [[ -z "$DBPASSWORD" ]]; then
147 echo "Enter the database password "
148 read DBPASSWORD
151 ./database_update.pl --username=$DBUSERNAME --password=$DBPASSWORD --service=$DBSERVICE --goldusername=$DBUSERNAME --loginusername=$DBUSERNAME --createnewcluster --packages
153 echo "Loading template list"
154 perl ../../templates/processTemplateList.pl < ../../../../../../dsrc/sku.0/sys.server/built/game/misc/object_template_crc_string_table.tab > $basedir/build/templates.sql
155 sqlplus ${DBUSERNAME}/${DBPASSWORD}@${DBSERVICE} @$basedir/build/templates.sql > $basedir/build/templates.out
158 echo "Build complete!"