Last active
April 15, 2024 10:49
-
-
Save MateuszKubuszok/3bb02c2be0388fd1f63635fc438f851c to your computer and use it in GitHub Desktop.
Revisions
-
MateuszKubuszok revised this gist
Apr 15, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/bin/bash defaultURL='https://github.com/ledgersmb/LedgerSMB' defaultFILE='' -
MateuszKubuszok revised this gist
Apr 15, 2024 . No changes.There are no files selected for viewing
-
MateuszKubuszok created this gist
Apr 15, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,87 @@ !/bin/bash defaultURL='https://github.com/ledgersmb/LedgerSMB' defaultFILE='' HELP() { cat <<-EOF usage: github-badge-cache-buster.sh [ -h | --help | [ repoURL | "auto" [ badgeFile ] ] ] repoURL defaults to '$defaultURL' badgeFile defaults to '$defaultFILE' EOF exit 1; } [[ "$@" =~ --help|-h ]] && HELP; paramURL="${1:-auto}" paramFile="$2" init() { [[ -x `which curl` ]] || { cat <<-EOF =============================== =============================== == FATAL ERROR == =============================== =============================== == we need to be able to run == == curl == =============================== == please install it == == then rerun this script == =============================== EOF exit 9 } # try reading a repo url from the current repo. otherwise default to ledgersm/LedgerSMB read -t30 autoURL < <( git config --get remote.origin.url ) || autoURL="$defaultURL" # if a URL was passed on the command line use it, otherwise use $autoURL [[ "${paramURL:-auto}" == "auto" ]] && unset paramURL; repoURL="${paramURL:-$autoURL}"; # if a URL was passed on the command line use it, otherwise use $autoURL badge_mdFILE="${paramFile:-$defaultFILE}" COLUMNS=`tput cols` UserAgentString='KLUDGE (Linux;) (please fix github tickets 224 116 111 218 414 etc)' } GetBadgeURLs() { curl --silent --user-agent "$UserAgentString" --output /dev/stdout "${repoURL}${badge_mdFILE}" | grep -o 'https://camo.githubusercontent.com.*alt="[^"]*' } PurgeBadges() { rm -f results.txt while read -t5 URL Badge; do URL="${URL%\"*}"; Badge="'${Badge#*\"}' " echo -n "Purging Badge ${Badge:0:25}: "; read -t60 result < <( curl --silent --request 'PURGE' -H 'Content-Type:application/json' --user-agent "$UserAgentString" --output '/dev/stdout' $URL | jq .status ) result="${result//\"/}" echo "${result:-???}" done } main() { init; cat <<-EOF ============================================ == about to purge cached badge images for == ============================================ ${repoURL}${badge_mdFILE} ============================================ EOF PurgeBadges < <( GetBadgeURLs ) echo } main;