View difference between Paste ID: G1aNCdPY and kk5QPV5f
SHOW: | | - or go back to the newest paste.
1
#!/bin/bash
2
#
3-
# ACE Update script for linux
3+
# Mod Update script for linux
4
#
5
# by Dr.Pulp - www.FAKKer.de
6
# with modifications by Kindling
7
#
8
#
9
#
10
# READ FIRST!!!
11
#
12
# In order to use this script you need to have gunzip, convmv and rsync installed!
13
# Be sure to adjust the ARMA_DIR to point to your ARMA/OA game directory and ARMA_SYNC_DIR to point to an alternative storage directory. 
14
#
15
##################################
16
# Configuration start            #
17
##################################
18
19
# ARMA II (for ARMA II) or Operation Arrowhead (for OA or CO) directory.
20
ARMA_DIR="/home/XXXX/.wine/drive_c/Program Files (x86)/Steam/steamapps/common/arma 2 operation arrowhead"
21
22
# Rsync storage directory for caching files - if this is removed, mods will need to be redownloaded in full to update.
23
# This will retain a copy of each mod to avoid problems caused by case-sensitive filesystems.
24
ARMA_SYNC_DIR=/home/XXXX/arma-temp
25
26
# Space-delimited list of available mirrors.
27
MIRRORLIST=(dev-heaven.net six.bssnet.dk zeus2.zeus-community.net)
28
29
# If parameters are passed to the script, use each parameter as a mod to download.
30
if  [ $# != 0 ]
31
  then MODS="$@"
32
else
33
# MODS contains mods that you'd like to synchronize if no parameters are given. 
34
# For a complete list of available mods, check http://updater.dev-heaven.net/main
35
# Use the mod's name without the @, seperate multiple mods by spaces.
36
  MODS="rh_m14 ace acex cba cba_oa cba_a2 acex_ru acex_usnavy"
37
fi
38
39
##################################
40
# Advanced Configuration         #
41
##################################
42
RM="`which rm` -r"
43
RSYNC="`which rsync` --times -O --no-whole-file -r --delete --progress -h --exclude=.rsync rsync://"
44
CP="`which cp` -r"
45
GUNZIP="`which gunzip` -r"
46
CONVMV="`which convmv` --lower --notest"
47
48
##################################
49
# Configuration end              #
50
##################################
51
52
# Function: random mirror selection
53
RANDOM_MIRROR() {
54
MIRRORCOUNT=${#MIRRORLIST[*]}
55
MIRRORCOUNT=`expr $MIRRORCOUNT - 1`
56
MIRRORCOUNT=`expr 32767 / $MIRRORCOUNT`
57
MIRROR=${MIRRORLIST[$(($RANDOM/$MIRRORCOUNT))]}
58
}
59
60
if [ ! -d "$ARMA_DIR" ]
61
  then echo "ARMAII/OA directory does not exist!"
62
  exit
63
fi
64
65
if [ ! -d "$ARMA_SYNC_DIR" ]
66
  then echo "Rsync storage directory does not exist!"
67
  exit
68
fi
69
70
# Loop: deleting folder, rsync, decompress and copy for each mod you selected
71
for MOD in $MODS
72
do
73
  if [ -d "$ARMA_DIR/@$MOD" ]
74
    then $RM "$ARMA_DIR/@$MOD"
75
  fi
76
  INFOSYNC='Synchronising '$MOD'...'
77
  echo '   -------------------'
78
  echo $INFOSYNC
79
  OK=1
80
  BAILOUT=0
81
  until [ "$OK" -lt "1" ]
82
  do
83
    RANDOM_MIRROR
84
    $RSYNC$MIRROR/rel/$MOD/./.pack/ ${ARMA_SYNC_DIR}/@$MOD
85
    OK=$?
86
    BAILOUT=`expr $BAILOUT + 1`
87
    if [ "$BAILOUT" -gt 10 ]
88
    then
89
      ENDE='There was a problem during rsync of '$MOD' from '$MIRROR'! Aborting Script to prevent a loop. Check output directories and permissions or add more mirrors.'
90
      echo $ENDE
91
      exit
92
    fi
93
  done
94
  INFOCOPY='Copying '$MOD' to the destination folder...'
95
  echo $INFOCOPY
96
  $CP ${ARMA_SYNC_DIR}/@$MOD "${ARMA_DIR}"
97
  INFOZIP='Decompressing '$MOD'...'
98
  echo $INFOZIP
99
  $GUNZIP "${ARMA_DIR}/@$MOD/"*
100
done
101
102
# Converting filenames to lower case letters
103
$CONVMV "${ARMA_DIR}/@"*
104
105
# Copying keys mpmissions, store/userconfig and userconfig to the correct directories
106
for MOD in $MODS
107
do
108
  if test -e "${ARMA_DIR}/@$MOD/store/keys"
109
    then $CP "${ARMA_DIR}/@$MOD/store/keys/"* "${ARMA_DIR}/keys"
110
  elif test -e "${ARMA_DIR}/@$MOD/keys"
111
    then $CP "${ARMA_DIR}/@$MOD/keys/"* "${ARMA_DIR}/keys"
112
  else
113
    continue
114
  fi
115
  if test -e "${ARMA_DIR}/@$MOD/mpmissions"
116
    then $CP "${ARMA_DIR}/@ace/mpmissions/"* "${ARMA_DIR}/mpmissions"
117
  else
118
    continue
119
  fi
120
  if test -e "${ARMA_DIR}/@$MOD/userconfig"
121
    then
122
    if test -e "${ARMA_DIR}/userconfig/$MOD"
123
      then
124
      $CP "${ARMA_DIR}/@$MOD/userconfig/"* "${ARMA_DIR}/userconfig/$MOD/"
125
    else
126
      /bin/mkdir -p "${ARMA_DIR}/userconfig/$MOD"
127
      $CP "${ARMA_DIR}/@$MOD/userconfig/"* "${ARMA_DIR}/userconfig/$MOD/"
128
    fi
129
  else
130
    continue
131
  fi
132
  if test -e "${ARMA_DIR}/@$MOD/store/userconfig"
133
    then
134
    if test -e "${ARMA_DIR}/userconfig/$MOD"
135
      then
136
      $CP "${ARMA_DIR}/@$MOD/store/userconfig/"* "${ARMA_DIR}/userconfig/$MOD/"
137
    else
138
      /bin/mkdir -p "${ARMA_DIR}/userconfig/$MOD"
139
      $CP "${ARMA_DIR}/@$MOD/store/userconfig/"* "${ARMA_DIR}/userconfig/$MOD/"
140
    fi
141
  else
142
    continue
143
  fi
144
done
145
exit