blob: 0f04017b76192e64ba93f23e9af91358f8220365 [file] [log] [blame]
Austin Schuhc26a2902022-01-14 16:34:25 -08001#!/bin/bash
2#
3# This script makes it easy to rehost dependencies on software.frc971.org so
4# we are self hosted everywhere consistently.
5
6# ./rehost.sh github.com/bazelbuild/rules_nodejs/releases/download/4.4.6/rules_nodejs-4.4.6.tar.gz
Austin Schuha870abe2023-11-18 14:31:53 -08007set -e
Austin Schuhc26a2902022-01-14 16:34:25 -08008
9readonly LOCALPATH="$(basename "${1}")"
10
Austin Schuha870abe2023-11-18 14:31:53 -080011# Strip off any http/https prefix to make things easy below.
12STRIPPED_URL="${1#"https://"}"
13STRIPPED_URL="${STRIPPED_URL#"http://"}"
Brian Silverman6088e2b2022-02-02 02:01:12 -080014
Austin Schuha870abe2023-11-18 14:31:53 -080015curl -L "https://${STRIPPED_URL}" -o "${LOCALPATH}"
Austin Schuhc26a2902022-01-14 16:34:25 -080016
Austin Schuha870abe2023-11-18 14:31:53 -080017echo "https://software.frc971.org/Build-Dependencies/${STRIPPED_URL}"
Austin Schuhc26a2902022-01-14 16:34:25 -080018
Austin Schuha870abe2023-11-18 14:31:53 -080019readonly TARGET_DIR="/data/files/frc971/Build-Dependencies"
20
21ssh software.frc971.org mkdir --m=775 -p "$(dirname "${TARGET_DIR}/${STRIPPED_URL}")"
22rsync --progress -v --ignore-existing "${LOCALPATH}" software.frc971.org:"${TARGET_DIR}/${STRIPPED_URL}"
23ssh 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 {} \;"