add script

This commit is contained in:
Joe 2019-12-26 10:14:02 -06:00
parent cb6136f102
commit 6eff67b701
Signed by: joe
GPG Key ID: 8595A3F8F2CE1B74
1 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,38 @@
#!/bin/bash
version=0.0.2
UserInput() {
read -r -p "$(echo -e 'Domain:\n')" domain
read -r -p "$(echo -e 'Time:\n')" time
read -r -p "$(echo -e 'Token:\n')" token
}
ExecutePurge() {
echo 'Purging remote media, please wait.'
UntilLoop "https://$1/_synapse/admin/v1/purge_media_cache?before_ts=$2&access_token=$3" "error"
echo 'Error encountered. Please try again.'
}
UntilLoop() {
until curl -X POST "$1" --data '{}' \
grep -m 1 "$2"; do
sleep 1
done
}
UnixTimeMs() {
unix_time_ms="$(($(date -d "$1" +'%s') * 1000))"
}
EchoVersion() {
echo $version
}
main() {
EchoVersion;
UserInput;
UnixTimeMs "$time";
ExecutePurge "$domain" "$unix_time_ms" "$token"
}
main