diff options
author | stuebinm | 2022-04-07 21:44:23 +0200 |
---|---|---|
committer | stuebinm | 2022-04-07 22:19:37 +0200 |
commit | a22a0346524910c596f97aba955b7346b7479c2d (patch) | |
tree | 29385eeb7113ebdf64c990726e1f722b836d0258 /flora/services/urlwatcher.scm | |
parent | b7a97a0076d7ce261f67573115e14bbcd0d6d679 (diff) |
flora: fix the trainspotter script
Diffstat (limited to 'flora/services/urlwatcher.scm')
-rw-r--r-- | flora/services/urlwatcher.scm | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/flora/services/urlwatcher.scm b/flora/services/urlwatcher.scm deleted file mode 100644 index 0519903..0000000 --- a/flora/services/urlwatcher.scm +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env gosh - -(use gauche.process) -(use srfi-13) -(use srfi-19) -(use file.util) - -(define url "https://ilztalbahn.eu/wp-content/uploads/2020/07/gtfs.zip") -(define cachefile "/tmp/urlwatch-cache") -(define storagedir "/var/lib/urlwatch-ilztal") - -(do-process `(mkdir "-p" ,storagedir)) - -(define (get-hash url) - (string-trim-both - (process-output->string `((curl ,url) - (sha256sum))))) - -(define hash - (get-hash url)) - -(define pretty-date - (date->string (time-utc->date (current-time)) "~5")) - -(define (hash-did-change oldhash newhash) - (print (format "the url's hash has changed to ~s!" newhash)) - (let ([newfile (string-append storagedir "/" newhash)]) - (do-process `(curl ,url "-o" ,newfile)) - (let ([diff (if oldhash - (let ([oldfile (string-append storagedir "/" oldhash)]) - (process-output->string `(zipcmp ,oldfile ,newfile))) - "")]) - (do-pipeline `((echo ,(format " -From: urlwatcher@flora.stuebinm.eu -Subject: Ilztalbahn GTFS Update - -Neuer hash: ~a -Link: ~a - -~a - -(~a) - -" newhash url diff pretty-date)) - (sendmail "stuebinm@disroot.org" "-t"))) - (sexp-list->file - cachefile - (list (list pretty-date newhash)) - :if-exists :append)))) - -(if (file-is-writable? cachefile) - (let ([oldhash (cadr (last (file->sexp-list cachefile)))]) - (if (equal? (cadr (last (file->sexp-list cachefile))) hash) - (print (format "url did not change, hash remains ~a" hash)) - (hash-did-change oldhash hash))) - (hash-did-change #f hash)) |