Last active
March 26, 2017 15:28
-
-
Save nadavkav/de1adae835eb7310b339eff642a1cc41 to your computer and use it in GitHub Desktop.
get security patch for moodle (bash script)
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 | |
# | |
# Example: | |
# ./get-security-patch-for-moodle.sh MOODLE_31_STABLE MDL-57596 --dry-run | |
# | |
SECURITY_FIX=$(curl -k "https://git.moodle.org/gw?p=moodle.git&a=search&h=$1&st=commit&s=$2") | |
SF_COMMIT=$(echo $SECURITY_FIX | grep -oP '<td class="link"><a href="(.*)">commit<\/a>' | grep -oP 'f=\"(.*)\"' | cut -d\" -f2) | |
SF_COMMIT_URL=$(echo "https://git.moodle.org".$SF_COMMIT | sed "s/a=commit/a=patch/") | |
curl -k $SF_COMMIT_URL > "security_fix_$2.patch" | |
patch -p1 $3 < "security_fix_$2.patch" | |
# Uncomment the following line to delete the redundant security patch file. | |
#rf -rf "security_fix_$2.patch" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment