-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.sh
executable file
·204 lines (186 loc) · 5.69 KB
/
installer.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
# set default values for directories
USER_DIR=${HOME}/.loki/sof
INSTALL_DIR=${HOME}/.loki/sof-runtime
SILENT=0
# parse command line arguments
for arg in "$@"; do
case "$arg" in
-s)
SILENT=1
echo "Silent: True"
;;
--build-arg*)
BUILD_ARGS="${BUILD_ARGS} ${arg}"
;;
esac
done
echo "Soldier of Fortune Linux Installer based on 1.06jLINUXF"
echo
# check the option and take action
case "$1" in
--dir)
echo "--dir"
if [[ -n "$2" ]]; then
echo "Installing to $2"
read -p "Is this correct. Do you want to proceed? (y/n) " confirm
if [[ "$confirm" = [yY] ]]; then
INSTALL_DIR="$2"
echo "Proceeding..."
else
echo "You did not confirm. Exiting..."
exit 1
fi
else
echo "error: Specify an install directory"
exit 1
fi
;;
--help|-h)
echo "Usage: installer.sh [OPTION]"
echo "--help/-h = Help"
echo "--dir <installdir> - Where to install sof binaries. default: ~/.loki/sof-runtime"
echo "-s = Silent Mode - default: NotSilent"
exit 0
;;
# DEFAULT_CASE
*)
echo "Installing to $INSTALL_DIR"
read -p "Is this correct. Do you want to proceed? (y/n) " confirm
if [[ "$confirm" = [yY] ]]; then
echo "Ok."
else
echo "You did not confirm. Exiting..."
exit 1
fi
;;
esac
# make directories
mkdir -p "${INSTALL_DIR}/static_files/base"
echo "Performing Docker Build..."
# Build the image and copy required files to local system
if [ ${SILENT} -eq 1 ]; then
./docker-build.sh ${BUILD_ARGS} > /dev/null 2>&1
echo "Building compatible libbsd library..."
docker build -t libbsd libbsd-context > /dev/null 2>&1
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
docker create --name tmp-libbsd libbsd > /dev/null 2>&1
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
docker cp tmp-libbsd:/libbsd/libbsd.so.0.2.0 "${INSTALL_DIR}/libbsd.so.0" > /dev/null 2>&1
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
docker rm tmp-libbsd > /dev/null 2>&1
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
elif [ ${SILENT} -eq 0 ]; then
./docker-build.sh ${BUILD_ARGS}
echo "Building compatible libbsd library..."
docker build -t libbsd libbsd-context
docker create --name tmp-libbsd libbsd
docker cp tmp-libbsd:/libbsd/libbsd.so.0.2.0 "${INSTALL_DIR}/libbsd.so.0"
docker rm tmp-libbsd
fi
echo "Installing..."
# After docker is installed, must copy the 3 folders into system.
# docker-build already handles liflg_pak2.pak and demo_pak0.pak @ ~/.loki/sof-addons/base/*
# and folders are ensured to exist. ~/.loki/sof ~/.loki/sof-addons/base
if [ ${SILENT} -eq 0 ]; then
# default not silent
docker create --name temp-sof-linux sof-linux
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
# copy files from container into install dir.
# runtime libraries
for FILE in libSDL-1.1.so.0 libTitan.so liboasnd.so libopenal-0.0.so ref_gl.so sof-bin sof-mp sof-mp-server
do
docker cp temp-sof-linux:/home/mullins/sof/${FILE} ${INSTALL_DIR}/
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
done
# resource paks
for FILE in basicpack2015v2.pak gamex86.so player.so pak0.pak pak1.pak pak2.pak pak3.pak gs.pak
do
docker cp temp-sof-linux:/home/mullins/sof/static_files/base/${FILE} ${INSTALL_DIR}/static_files/base/
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
done
docker rm temp-sof-linux
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
# Run scripts
cp docker-context/start_multiplayer.sh docker-context/start_server.sh docker-context/start_singleplayer.sh ${INSTALL_DIR}
chmod +x ${INSTALL_DIR}/start_singleplayer.sh ${INSTALL_DIR}/start_server.sh ${INSTALL_DIR}/start_multiplayer.sh
elif [ ${SILENT} -eq 1 ]; then
# silent
docker create --name temp-sof-linux sof-linux > /dev/null 2>&1
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
for FILE in libSDL-1.1.so.0 libTitan.so liboasnd.so libopenal-0.0.so ref_gl.so sof-bin sof-mp sof-mp-server
do
docker cp temp-sof-linux:/home/mullins/sof/${FILE} ${INSTALL_DIR}/ > /dev/null 2>&1
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
done
for FILE in basicpack2015v2.pak gamex86.so player.so pak0.pak pak1.pak pak2.pak pak3.pak gs.pak
do
docker cp temp-sof-linux:/home/mullins/sof/static_files/base/${FILE} ${INSTALL_DIR}/static_files/base/ > /dev/null 2>&1
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
done
docker rm temp-sof-linux > /dev/null 2>&1
if ! [ $? -eq 0 ]; then
echo "failed build"
exit 1
fi
# Run scripts
cp docker-context/start_multiplayer.sh docker-context/start_server.sh docker-context/start_singleplayer.sh ${INSTALL_DIR} > /dev/null 2>&1
chmod +x ${INSTALL_DIR}/start_singleplayer.sh ${INSTALL_DIR}/start_server.sh ${INSTALL_DIR}/start_multiplayer.sh > /dev/null 2>&1
fi
echo "Installed."
echo
echo "soflinux is installed to ${INSTALL_DIR}"
echo
echo "game paks are installed to ${INSTALL_DIR}/static_files/base"
echo
echo "user dir is ${USER_DIR} - content downloaded from in-game are saved here"
echo
echo "addons dir is "${USER_DIR}-addons/base" - place extra resources here"
echo
echo "to launch sof single player - run ~/.loki/sof-runtime/start_singleplayer.sh"
echo
echo "to launch sof multi player 1.07f - run ~/.loki/sof-runtime/start_multiplayer.sh"
echo
echo "to launch a dedicated sof server 1.07f - run ~/.loki/sof-runtime/start_server.sh"
echo
echo "recommended aliases to put into ~/.bash_aliases"
echo 'alias sof-sp="~/.loki/sof-runtime/start_singleplayer.sh"
alias sof-mp="~/.loki/sof-runtime/start_multiplayer.sh"
alias sof-mp-s="~/.loki/sof-runtime/start_server.sh"'
echo
echo "ensure your system supports 32 bit libraries"
echo "dependencys needed to run locally: libxext6, libx11-6, [your_glx_drivers]"
echo "run: sudo apt update && sudo apt install libxext6:i386 libx11-6:i386"