Fix `update.sh`

Move global, prefixed variables to local ones
Correct update timing logic
Correct update URL
Ensure cache directory exists before trying to write files in it
Test for cURL failure