Austin Schuh | c26a290 | 2022-01-14 16:34:25 -0800 | [diff] [blame] | 1 | #!/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 Schuh | a870abe | 2023-11-18 14:31:53 -0800 | [diff] [blame] | 7 | set -e |
Austin Schuh | c26a290 | 2022-01-14 16:34:25 -0800 | [diff] [blame] | 8 | |
| 9 | readonly LOCALPATH="$(basename "${1}")" |
| 10 | |
Austin Schuh | a870abe | 2023-11-18 14:31:53 -0800 | [diff] [blame] | 11 | # Strip off any http/https prefix to make things easy below. |
| 12 | STRIPPED_URL="${1#"https://"}" |
| 13 | STRIPPED_URL="${STRIPPED_URL#"http://"}" |
Brian Silverman | 6088e2b | 2022-02-02 02:01:12 -0800 | [diff] [blame] | 14 | |
Austin Schuh | a870abe | 2023-11-18 14:31:53 -0800 | [diff] [blame] | 15 | curl -L "https://${STRIPPED_URL}" -o "${LOCALPATH}" |
Austin Schuh | c26a290 | 2022-01-14 16:34:25 -0800 | [diff] [blame] | 16 | |
Austin Schuh | a870abe | 2023-11-18 14:31:53 -0800 | [diff] [blame] | 17 | echo "https://software.frc971.org/Build-Dependencies/${STRIPPED_URL}" |
Austin Schuh | c26a290 | 2022-01-14 16:34:25 -0800 | [diff] [blame] | 18 | |
Austin Schuh | a870abe | 2023-11-18 14:31:53 -0800 | [diff] [blame] | 19 | readonly TARGET_DIR="/data/files/frc971/Build-Dependencies" |
| 20 | |
| 21 | ssh software.frc971.org mkdir --m=775 -p "$(dirname "${TARGET_DIR}/${STRIPPED_URL}")" |
| 22 | rsync --progress -v --ignore-existing "${LOCALPATH}" software.frc971.org:"${TARGET_DIR}/${STRIPPED_URL}" |
| 23 | 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 {} \;" |