add update script
This commit is contained in:
parent
355ac86d69
commit
a57e1c9684
2 changed files with 37 additions and 0 deletions
7
Dockerfile
Normal file
7
Dockerfile
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
FROM alpine/git
|
||||||
|
|
||||||
|
RUN apk add --no-cache curl
|
||||||
|
|
||||||
|
ADD update /update
|
||||||
|
|
||||||
|
ENTRYPOINT /update
|
30
update
Executable file
30
update
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
update() {
|
||||||
|
url="$1"
|
||||||
|
pad="$(basename $url).txt"
|
||||||
|
dst="$pad"
|
||||||
|
gitdir="$(dirname $dst)"
|
||||||
|
|
||||||
|
curl --silent -k -o "${dst}" "${url}/export/txt"
|
||||||
|
status="$?"
|
||||||
|
|
||||||
|
if [ ${status} -ne 0 ]; then
|
||||||
|
echo "Failed to get pad at ${url}"
|
||||||
|
exit ${status}
|
||||||
|
else
|
||||||
|
git -C "${gitdir}" add "${dst}"
|
||||||
|
changes=$(git -C "${gitdir}" diff --cached | wc -l)
|
||||||
|
if [ "$changes" -gt 0 ]; then
|
||||||
|
git -C "${gitdir}" commit -m "Updated: ${dst} from ${url}"
|
||||||
|
else
|
||||||
|
echo "Nothing changed for ${url}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
git -C "${gitdir}" reset --hard HEAD
|
||||||
|
}
|
||||||
|
|
||||||
|
while read -r pad; do
|
||||||
|
update "$pad"
|
||||||
|
done
|
Loading…
Add table
Add a link
Reference in a new issue