sync-to-prod.sh 745 Bytes
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
fi