add script
This commit is contained in:
parent
cb6136f102
commit
6eff67b701
|
@ -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
|
Loading…
Reference in New Issue