Last active
September 28, 2019 17:10
-
-
Save scovetta/b18c2bf59cf0c5d1640d7209062c93aa to your computer and use it in GitHub Desktop.
Replacing HTTP with HTTPS links in a large repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Takes a list of URLs (output from ishttps) and turns them into a massive sed replacement script. | |
FILENAME="$1" | |
echo "sed -i '" | |
while read -r url; do | |
ESC_IN=$(echo "$url" | sed -e 's/[]\/$*.^[]/\\&/g') | |
ESC_OUT=$(echo "$ESC_IN" | sed -e 's/http:/https:/') | |
echo "s/$ESC_IN/$ESC_OUT/" | |
done < "$FILENAME" | |
echo "'" $(pwd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Checks to see which URLs (from a filename passed in as a parameter) are equivalent to their HTTPS countepart). | |
# Output is the list of HTTP URLs that can safely be changed. | |
FILENAME="$1" | |
while read -r url; do | |
HTTPS_URL=$(echo "$url" | sed 's/http:/https:/') | |
X=$(curl -s -L -k "$url") | |
XX=$(echo "$X" | sha256sum) | |
Y=$(curl -s -L -l "$HTTPS_URL") | |
YY=$(echo "$Y" | sha256sum) | |
if [ ! -z "$X" ]; then | |
if [ "$XX" == "$YY" ]; then | |
echo "$url" | |
fi | |
fi | |
done < "$FILENAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment