Skip to content

Commit 0822fea

Browse files
authored
Merge pull request #8 from henkall/henkall-update
Henkall update
2 parents e7a6aab + 00a4242 commit 0822fea

2 files changed

Lines changed: 88 additions & 58 deletions

File tree

Dockerfile

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
FROM ubuntu
2-
3-
# Running options to COD4 server
2+
# Running options to COD4 server
43
ENV READY=""
54
ENV PORT="28960"
65
ENV MODNAME=""
76
ENV MAP="+map_rotate"
87
ENV EXTRA=""
98
ENV SERVERTYPE=""
109
ENV EXECFILE=""
11-
10+
ENV PUID="1000"
11+
ENV GUID="1000"
12+
# Setting a volume
13+
VOLUME ["/home/cod4/gamefiles/"]
14+
# Installing dependencies
1215
RUN apt-get update && \
1316
apt-get install -y gcc-multilib g++-multilib unzip curl
14-
15-
RUN groupadd -r cod4 && useradd --no-log-init -r -g cod4 cod4
16-
ADD cod4 /home/cod4/
17-
RUN chown -R cod4:cod4 /home/cod4
18-
19-
USER cod4
20-
WORKDIR /home/cod4
21-
RUN chmod +x script.sh
17+
WORKDIR /home/cod4/gamefiles
18+
# Adding files from github
19+
COPY --chown=1000 cod4/script.sh /home/cod4/
20+
# Adding user "cod4" and setting permissions
21+
RUN adduser --system cod4 --home /home/cod4 --uid 1000 && \
22+
chown -R cod4 /home/cod4 && \
23+
chmod -R 777 /home/cod4 && \
24+
chown -R cod4 /home/cod4/gamefiles && \
25+
chmod -R 777 /home/cod4/gamefiles && \
26+
# Making file executable
27+
chmod +x /home/cod4/script.sh
2228
ENTRYPOINT ["/home/cod4/script.sh"]
23-
24-
VOLUME ["/home/cod4/gamefiles/"]
29+
USER cod4

cod4/script.sh

Lines changed: 70 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,103 @@
11
#!/usr/bin/env bash
2-
if [ "$(ls -A gamefiles/main)" ]; then
3-
echo "Main is Good"
4-
echo "Testing if xbase_00.iwd is in main"
5-
if [[ ! -f gamefiles/main/xbase_00.iwd ]]; then
6-
echo "Xbase_00.iwd not found copying it now"
7-
cp xbase_00.iwd gamefiles/main/
8-
else
9-
echo "Xbase_00.iwd is Good"
10-
fi
2+
if [ -d "main" ]
3+
then
4+
echo "Directory main exists."
115
else
12-
echo "ERROR Main is Empty"
6+
echo "ERROR: Directory main is missing."
137
fi
14-
15-
if [ "$(ls -A gamefiles/mods)" ]; then
16-
echo "Mods Good"
8+
if [ -d "zone" ]
9+
then
10+
echo "Directory zone exists."
1711
else
18-
echo "ERROR Mods is Empty"
12+
echo "ERROR: Directory zone is missing"
1913
fi
20-
if [ "$(ls -A gamefiles/usermaps)" ]; then
21-
echo "Usermaps Good"
14+
if [ -d "mods" ]
15+
then
16+
echo "Directory mods exists."
2217
else
23-
echo "ERROR Usermaps is Empty"
18+
echo "ERROR: Directory mods is missing"
2419
fi
25-
if [ "$(ls -A gamefiles/zone)" ]; then
26-
echo "Zone is Good"
20+
if [ -d "usermaps" ]
21+
then
22+
echo "Directory usermaps exists."
2723
else
28-
echo "ERROR Zone is Empty"
24+
echo "ERROR: Directory usermaps is missing"
2925
fi
30-
if [ ! -f gamefiles/cod4x18_dedrun ]; then
31-
echo "cod4x18_dedrun not found... trying to download it."
32-
curl https://raw.githubusercontent.com/henkall/docker-cod4/master/cod4xfiles.zip -o cod4xfiles.zip && unzip -o cod4xfiles.zip -d gamefiles && rm cod4xfiles.zip
33-
echo "Download Done"
34-
chmod +x gamefiles/cod4x18_dedrun
35-
echo ready
36-
else
37-
chmod +x gamefiles/cod4x18_dedrun
38-
echo "cod4x18_dedrun found"
26+
if [ -d "/home/cod4/gamefiles" ]
27+
then
28+
echo "Directory gamefiles exists"
29+
folderperm=$(stat --format '%a' /home/cod4/gamefiles)
30+
echo $folderperm
31+
if [ $folderperm -eq 2777 -o $folderperm -eq 777 ]
32+
then
33+
echo "Permissions fine"
34+
if [ ! -f cod4x18_dedrun ]
35+
then
36+
echo "cod4x18_dedrun not found... trying to download it."
37+
curl https://raw.githubusercontent.com/henkall/docker-cod4/master/cod4xfiles.zip -o cod4xfiles.zip && unzip -o cod4xfiles.zip && rm cod4xfiles.zip
38+
echo "Download Done"
39+
chmod +x cod4x18_dedrun
40+
echo ready
41+
servergood=1
42+
echo $servergood
43+
else
44+
chmod +x cod4x18_dedrun
45+
echo "cod4x18_dedrun found"
46+
servergood=1
47+
echo $servergood
48+
fi
49+
else
50+
servergood=0
51+
echo $servergood
52+
echo "ERROR: Permissions on gamfiles folder has to be 777 or 2777"
53+
fi
3954
fi
55+
4056
echo "Setting server type"
41-
if [[ -z "${SERVERTYPE}" ]]; then
57+
if [ -z "${SERVERTYPE}" ]
58+
then
4259
echo "The SERVERTYPE variable is empty."
4360
SERVERTYPE="1"
4461
fi
4562
echo "Setting port"
46-
if [[ -z "${PORT}" ]]; then
63+
if [ -z "${PORT}" ]
64+
then
4765
echo "The PORT variable is empty."
4866
PORT="28960"
4967
fi
5068
echo "Setting EXTRA arg"
51-
if [[ -z "${EXTRA}" ]]; then
69+
if [ -z "${EXTRA}" ]
70+
then
5271
echo "The EXTRA variable is empty."
5372
EXTRA="+set sv_authorizemode -1"
5473
fi
5574
echo "Setting exec file"
56-
if [[ -z "${EXECFILE}" ]]; then
75+
if [ -z "${EXECFILE}" ]
76+
then
5777
echo "The EXECFILE variable is empty."
5878
EXECFILE="server.cfg"
5979
fi
6080
echo "Setting MAP"
61-
if [[ -z "${MAP}" ]]; then
81+
if [ -z "${MAP}" ]
82+
then
6283
echo "The MAP variable is empty."
6384
MAP="+map_rotate"
6485
fi
6586
echo "Checking if READY"
66-
if [[ ! -z "${READY}" ]]; then
67-
echo "Config is Ready"
68-
if [[ ! -z "${MODNAME}" ]]; then
69-
echo "Mod enabled (using $MODNAME mod)"
70-
cd gamefiles
71-
./cod4x18_dedrun "+set dedicated $SERVERTYPE" "+set net_port $PORT" "+set fs_game mods/$MODNAME" "$EXTRA" "+exec $EXECFILE" "$MAP"
72-
else
73-
echo "Not using Mod"
74-
cd gamefiles
75-
./cod4x18_dedrun "+set dedicated $SERVERTYPE" "+set net_port $PORT" "$EXTRA" "+exec $EXECFILE" "$MAP"
87+
if [ $servergood -eq 1 ]
88+
then
89+
echo "server is good"
90+
if [ ! -z "${READY}" ]
91+
then
92+
echo "Config is Ready"
93+
if [[ ! -z "${MODNAME}" ]]; then
94+
echo "Mod enabled (using $MODNAME mod)"
95+
./cod4x18_dedrun "+set dedicated $SERVERTYPE" "+set net_port $PORT" "+set fs_game mods/$MODNAME" "$EXTRA" "+exec $EXECFILE" "$MAP"
96+
else
97+
echo "Not using Mod"
98+
./cod4x18_dedrun "+set dedicated $SERVERTYPE" "+set net_port $PORT" "$EXTRA" "+exec $EXECFILE" "$MAP"
99+
fi
76100
fi
77-
101+
else
102+
echo "ERROR: Permissions on gamefiles folder has to be 777 or 2777"
78103
fi

0 commit comments

Comments
 (0)