-
Notifications
You must be signed in to change notification settings - Fork 1
/
start
152 lines (132 loc) · 3.78 KB
/
start
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
146
147
148
149
150
151
152
#!/bin/bash
if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi
START_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $START_DIR/settings.sh
chmod u+x -R $START_DIR
function defaultsettings {
cp -f $START_DIR/defaultsettings.sh $START_DIR/settings.sh
echo "settings.sh replaced by defaultsettings.sh"
}
function testgame {
local platform=$1
if [ $# -ne 1 ] ; then
echo "No parameters provided, assuming: '$TARGETSYSTEM'."
platform=$TARGETSYSTEM
fi
if [ $platform == "linux" ] ; then
cd $TESTBUILDFOLDER/$TESTBUILDNAME-$platform
./OneLife
cd -
elif [ $platform == "windows" ] ; then
cd $TESTBUILDFOLDER/$TESTBUILDNAME-$platform
./OneLife.exe
cd -
fi
}
function testserver {
local platform=$1
if [ $# -ne 1 ] ; then
echo "No parameters provided, assuming: '$TARGETSYSTEM'."
platform = $TARGETSYSTEM
fi
if [ $platform == "linux" ] ; then
cd $TESTBUILDFOLDER/$TESTBUILDNAME-$platform
./OneLifeServer
cd -
elif [ $platform == "windows" ] ; then
cd $TESTBUILDFOLDER/$TESTBUILDNAME-$platform
./OneLifeServer.exe
cd -
fi
}
function runtest {
$START_DIR/scripts/makeTestBuild.sh $TARGETSYSTEM
testgame $TARGETSYSTEM & testserver $TARGETSYSTEM
}
function makegame {
( cd $GAMEDIR/gameSource ; make )
}
function makeeditor {
( cd $GAMEDIR/gameSource ; ./makeEditor.sh )
}
function makeserver {
( cd $GAMEDIR/server ; make )
}
function makeall {
makegame
makeeditor
makeserver
}
function xla {
# Update TIMESTAMP everytime we want to run a script
export TIMESTAMP=$(date '+(%F,%H%M)')
if [ $# -lt 1 ] ; then
echo "Usage: xla [SCRIPT_NAME]"
else
if $(find $START_DIR/scripts -iname "$1.sh" -exec false {} +) ; then
echo "No script '$1' found."
elif [ $(find $START_DIR/scripts -iname "$1.sh" | wc -l) -ne 1 ] ; then
echo "More than one script named '$1'."
else
find $START_DIR/scripts -iname "$1.sh" -exec echo -e "Running: {}\n" \; -exec {} ${@:2} \;
fi
fi
}
function x-cat {
find $START_DIR/scripts -iname "$1.sh" -exec cat {} \;
echo
}
function x-cd {
if [ $# -ne 1 ] ; then
echo "Parameters: assistant, scripts, minorgems, onelife or onelifedata"
return
fi
if [ $1 == "assistant" ] ; then
cd $ASSISTANTDIR
elif [ $1 == "scripts" ] ; then
cd $ASSISTANTDIR/scripts
elif [ $1 == "minorgems" ] ; then
cd $MINORDIR
elif [ $1 == "onelife" ] ; then
cd $GAMEDIR
elif [ $1 == "onelifedata" ] ; then
cd $DATADIR
fi
}
function x-platform {
cd $GAMEDIR
./configure
cd $GAMEDIR/server
./configure
cd $START_DIR
}
function x-reconfigure {
local setting
local old_value
local prompt
local list_item
local list="TARGETSYSTEM RELEASENAME REMOTEGAME_USER REMOTEGAME_BRANCH REMOTEMINOR_USER REMOTEMINOR_BRANCH REMOTEDATA_USER REMOTEDATA_BRANCH"
for list_item in $list; do
setting="export $list_item="
old_value=$(grep "$setting" $START_DIR/settings.sh | sed 's/.*=//')
read -e -p "$list_item= " -i "$old_value" prompt
sed -i "/$setting/ s/=.*/=$prompt/" $START_DIR/settings.sh
done
source $START_DIR/settings.sh
}
function x-reload {
source $START_DIR/start
}
echo
echo -e "The following functions can be used:\n"
#declare -F | awk '{print $NF}' | sort | egrep -v "^_"
cat $START_DIR/info-commands.txt
echo
echo -e "The following scripts are avaliable:\n"
find $START_DIR/scripts -type f -exec basename -s .sh {} \;
echo
echo "You can use the xla function to run scripts above."
echo