-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
67 lines (56 loc) · 2.08 KB
/
build.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
#!/usr/bin/env bash
#Set some vars
origDir=$(pwd)
workDir="sdk/examples/server"
mainFile="main.c"
makeFile="Makefile.linux_amd64"
#main.c Magic
#Define changes to the main source
main_ammend1='^#define MAX_CLIENTS [0-9]*'
main_ammend2='int unknownInput = 0'
main_ammend3='^( serverID = createVirtualServer.{2}).*(\".{2})[0-9]*(.*;)'
main_ammend4='^( if\(\(error = ts3server_setVirtualServerVariableAsString\(serverID, VIRTUALSERVER_PASSWORD, \").*(\"\)\) \!= ERROR_ok\) \{)'
#main_ammend4='^( )(int c;)'
#Select the Makefile
if [ "$(uname -a | grep -o 'amd64')" = "amd64" ];
then
makeFile="Makefile.linux_amd64"
elif [ "$(uname -a | grep -o 'i386')" = "i386" ];
then
makeFile="Makefile.linux_x86"
elif [ "$(uname -a | grep -o 'i686')" = "i686" ];
then
makeFile="Makefile.linux_x86"
fi
#Lets go, change to work dir
cd $workDir
#Regex and line magic to ammend the code for EuroScope
#Filter unneeded content
echo '1. Filtering unneeded content'
#Filter unneeded int unknownInput = 0
sed -i "s/$main_ammend2/\/\/$main_ammend2/" $mainFile
grep "\/\/$main_ammend2" $mainFile
#Linehack-comment out some unneeded CLI code in main()
sed -i "883s/.*/ \/\*int c\;/" $mainFile
grep '\/\*int c;' $mainFile
sed -i "941s/.*/ }\*\//" $mainFile
grep '\}\*\/' $mainFile
#Set max. number of clients
echo '2. Set max. Clients'
sed -i -r "s/$main_ammend1/#define MAX_CLIENTS $ESTS_MAXCLIENTS/" $mainFile
grep -Ex "$main_ammend1" $mainFile
#Set name and port
echo '3. Set name and port'
sed -i -r -e "s/$main_ammend3/\1$ESTS_NAME\29988\3/" $mainFile
grep -E "^( serverID = createVirtualServer.{2}).*(\".{2})[0-9]*(.*;)" $mainFile
#Set appropriate password
echo '4. Set appropriate password'
sed -i -r -e "s/$main_ammend4/\1EuroScopeTs3\2/" $mainFile
#grep -E "^if\(\(error = ts3server_setVirtualServerVariableAsString\(serverID\, VIRTUALSERVER_PASSWORD\, \".*\"\)\) != ERROR_ok\) \{" $mainFile
#Makefile Magic
echo '5. Set up makefile'
sed -i "s/ts3_server_sample/$ESTS_EXECNAME/" $makeFile
#Build executable
make -f $makeFile clean
make -f $makeFile all
cd $origDir