sync-to-prod.sh 1.33 KB
Newer Older
Louis Abel's avatar
Louis Abel committed
1
2
#!/bin/bash
# Syncs everything from staging to production
3
4

# Source common variables
Louis Abel's avatar
Louis Abel committed
5
# shellcheck disable=SC2046,1091,1090
6
source "$(dirname "$0")/common"
7

Louis Abel's avatar
Louis Abel committed
8
REV=${REVISION}${APPEND_TO_DIR}
9

Louis Abel's avatar
Louis Abel committed
10
cd "${STAGING_ROOT}/${CATEGORY_STUB}/${REV}" || { echo "Failed to change directory"; ret_val=1; exit 1; }
Louis Abel's avatar
Louis Abel committed
11
ret_val=$?
12

Louis Abel's avatar
Louis Abel committed
13
if [ $ret_val -eq "0" ]; then
14
15
  TARGET="${PRODUCTION_ROOT}/${CATEGORY_STUB}/${REV:0:3}"
  mkdir -p "${TARGET}"
Louis Abel's avatar
Louis Abel committed
16
17
18
  # disabling because none of our files should be starting with dashes. If they
  # are something is *seriously* wrong here.
  # shellcheck disable=SC2035
19
  sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable \
Louis Abel's avatar
Louis Abel committed
20
      {} "${TARGET}"
Louis Abel's avatar
Louis Abel committed
21
22
23

  # Full file list update
  cd "${PRODUCTION_ROOT}/${CATEGORY_STUB}/" || { echo "Failed to change directory"; exit 1; }
Louis Abel's avatar
Louis Abel committed
24
25
  # Hardlink everything except xml files
  #hardlink -x '.*\.xml.*' "${REVISION}"
Louis Abel's avatar
Louis Abel committed
26
  find . > fullfilelist
Louis Abel's avatar
Louis Abel committed
27
28
29
30
31
32
  if [[ -f /usr/local/bin/create-filelist ]]; then
    # We're already here, but Justin Case wanted this
    cd "${PRODUCTION_ROOT}/${CATEGORY_STUB}/" || { echo "Failed to change directory"; exit 1; }
    /bin/cp fullfiletimelist-rocky fullfiletimelist-rocky-old
    /usr/local/bin/create-filelist > fullfiletimelist-rocky
  fi
Louis Abel's avatar
Louis Abel committed
33
  chown 10004:10005 fullfilelist fullfiletimelist-rocky
Louis Abel's avatar
Louis Abel committed
34
fi
Louis Abel's avatar
Louis Abel committed
35