forked from frc971/971-Robot-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rehost.sh
executable file
·23 lines (16 loc) · 1.07 KB
/
rehost.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
#
# This script makes it easy to rehost dependencies on software.frc971.org so
# we are self hosted everywhere consistently.
# ./rehost.sh github.com/bazelbuild/rules_nodejs/releases/download/4.4.6/rules_nodejs-4.4.6.tar.gz
set -e
readonly LOCALPATH="$(basename "${1}")"
# Strip off any http/https prefix to make things easy below.
STRIPPED_URL="${1#"https://"}"
STRIPPED_URL="${STRIPPED_URL#"http://"}"
curl -L "https://${STRIPPED_URL}" -o "${LOCALPATH}"
echo "https://software.frc971.org/Build-Dependencies/${STRIPPED_URL}"
readonly TARGET_DIR="/data/files/frc971/Build-Dependencies"
ssh software.frc971.org mkdir --m=775 -p "$(dirname "${TARGET_DIR}/${STRIPPED_URL}")"
rsync --progress -v --ignore-existing "${LOCALPATH}" software.frc971.org:"${TARGET_DIR}/${STRIPPED_URL}"
ssh software.frc971.org "find ${TARGET_DIR}/ -type f ! -user www-data ! -group www-data -exec chmod 444 {} \; && find ${TARGET_DIR}/ -type d ! -user www-data ! -group www-data -exec chmod 775 {} \; && find ${TARGET_DIR}/ -type d ! -user www-data ! -group www-data -exec chown www-data:www-data {} \;"