|
1 | 1 | #!/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." |
11 | 5 | else |
12 | | -echo "ERROR Main is Empty" |
| 6 | + echo "ERROR: Directory main is missing." |
13 | 7 | fi |
14 | | - |
15 | | -if [ "$(ls -A gamefiles/mods)" ]; then |
16 | | - echo "Mods Good" |
| 8 | +if [ -d "zone" ] |
| 9 | +then |
| 10 | + echo "Directory zone exists." |
17 | 11 | else |
18 | | - echo "ERROR Mods is Empty" |
| 12 | + echo "ERROR: Directory zone is missing" |
19 | 13 | fi |
20 | | -if [ "$(ls -A gamefiles/usermaps)" ]; then |
21 | | - echo "Usermaps Good" |
| 14 | +if [ -d "mods" ] |
| 15 | +then |
| 16 | + echo "Directory mods exists." |
22 | 17 | else |
23 | | - echo "ERROR Usermaps is Empty" |
| 18 | + echo "ERROR: Directory mods is missing" |
24 | 19 | fi |
25 | | -if [ "$(ls -A gamefiles/zone)" ]; then |
26 | | - echo "Zone is Good" |
| 20 | +if [ -d "usermaps" ] |
| 21 | +then |
| 22 | + echo "Directory usermaps exists." |
27 | 23 | else |
28 | | - echo "ERROR Zone is Empty" |
| 24 | + echo "ERROR: Directory usermaps is missing" |
29 | 25 | 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 |
39 | 54 | fi |
| 55 | + |
40 | 56 | echo "Setting server type" |
41 | | -if [[ -z "${SERVERTYPE}" ]]; then |
| 57 | +if [ -z "${SERVERTYPE}" ] |
| 58 | +then |
42 | 59 | echo "The SERVERTYPE variable is empty." |
43 | 60 | SERVERTYPE="1" |
44 | 61 | fi |
45 | 62 | echo "Setting port" |
46 | | -if [[ -z "${PORT}" ]]; then |
| 63 | +if [ -z "${PORT}" ] |
| 64 | +then |
47 | 65 | echo "The PORT variable is empty." |
48 | 66 | PORT="28960" |
49 | 67 | fi |
50 | 68 | echo "Setting EXTRA arg" |
51 | | -if [[ -z "${EXTRA}" ]]; then |
| 69 | +if [ -z "${EXTRA}" ] |
| 70 | +then |
52 | 71 | echo "The EXTRA variable is empty." |
53 | 72 | EXTRA="+set sv_authorizemode -1" |
54 | 73 | fi |
55 | 74 | echo "Setting exec file" |
56 | | -if [[ -z "${EXECFILE}" ]]; then |
| 75 | +if [ -z "${EXECFILE}" ] |
| 76 | +then |
57 | 77 | echo "The EXECFILE variable is empty." |
58 | 78 | EXECFILE="server.cfg" |
59 | 79 | fi |
60 | 80 | echo "Setting MAP" |
61 | | -if [[ -z "${MAP}" ]]; then |
| 81 | +if [ -z "${MAP}" ] |
| 82 | +then |
62 | 83 | echo "The MAP variable is empty." |
63 | 84 | MAP="+map_rotate" |
64 | 85 | fi |
65 | 86 | 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 |
76 | 100 | fi |
77 | | - |
| 101 | +else |
| 102 | + echo "ERROR: Permissions on gamefiles folder has to be 777 or 2777" |
78 | 103 | fi |
0 commit comments