fix sb-price: touch missing files

fixed a case where on first run, the file will not exist and the `cat` inside `printf` in line 40 will show give an error instead of doing something useful
This commit is contained in:
Kipras Melnikovas 2021-06-17 17:49:30 +03:00 committed by GitHub
parent 4231d6bd33
commit 968ebffdde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,8 @@ updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 &&
curl -s "rate.sx/$1$interval" > "$chartfile" ;}
[ -d "$dir" ] || mkdir -p "$dir"
[ -f "$pricefile" ] || touch "$pricefile"
[ -f "$chartfile" ] || touch "$chartfile"
[ "$(stat -c %x "$pricefile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
updateprice "$1"