| 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) Meta Platforms, Inc. and affiliates. |
| 4 | # All rights reserved. |
| 5 | # |
| 6 | # This source code is licensed under the terms described in the LICENSE file in |
| 7 | # the root directory of this source tree. |
| 8 | |
| 9 | set -euo pipefail |
| 10 | |
| 11 | if [ $# -eq 0 ]; then |
| 12 | echo "Please provide a URL as an argument." |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | URL=$1 |
| 17 | |
| 18 | HEADERS_FILE=$(mktemp) |
| 19 | curl -s -I "$URL" >"$HEADERS_FILE" |
| 20 | FILENAME=$(grep -i "x-manifold-obj-canonicalpath:" "$HEADERS_FILE" | sed -E 's/.*nodes\/[^\/]+\/(.+)/\1/' | tr -d "\r\n") |
| 21 | |
| 22 | if [ -z "$FILENAME" ]; then |
| 23 | echo "Could not find the x-manifold-obj-canonicalpath header." |
| 24 | echo "HEADERS_FILE contents: " |
| 25 | cat "$HEADERS_FILE" |
| 26 | echo "" |
| 27 | exit 1 |
| 28 | fi |
| 29 | |
| 30 | echo "Downloading $FILENAME..." |
| 31 | |
| 32 | curl -s -L -o "$FILENAME" "$URL" |
| 33 | |
| 34 | echo "Installing $FILENAME..." |
| 35 | pip install "$FILENAME" |
| 36 | echo "Successfully installed $FILENAME" |
| 37 | |
| 38 | rm -f "$FILENAME" |