A program to check for updates and make the list of updates available through a JSON file or a simple API. By default it will check for updates every 12 hours, if run in daemon mode then it will refresh every 12 hours, otherwise it simply does nothing when run before 12 hours has passed since the previous update.
The default cache file may change, the first choice is /tmp/go-check-updates.json.
If the file exists but it isn't writable, it will fallback to $HOME/.cache/go-check-updates/cache.json instead.
It can be disabled completely with --no-cache.
The refresh interval can be changed with the --cache.interval option, disable with --no-refresh.
Disabled without daemon mode will refresh every time it is run, with daemon mode there is no auto-refresh.
It is also possible to monitor the package manager logs, this functionality can be enabled with -w or --watch.enable.
Enabled by default when using setup.sh to generate systemd units.
See go-check-updates -h for up to date information on the parameters.
This can then be read by other scripts, for example my own go-motd.
| Manager | Name | Old Ver | New Ver | Repo | Logs |
|---|---|---|---|---|---|
| pacman | Y | Y | Y | N* | Y |
| dnf/yum | Y | N | Y | Y | Y |
* Repo is set to "pacman"
NOTE: pacman only tested on Arch Linux, dnf/yum only tested on Fedora
| Manager | Name | Old Ver | New Ver | Repo | Logs |
|---|---|---|---|---|---|
| yay | Y | Y | Y | N* | N/A |
| pikaur | Y | Y | Y | N* | N/A |
| paru | Y | Y | Y | N* | N/A |
* Repo to "aur"
NOTE: Only tested on Arch Linux
git clone https://github.com/cosandr/go-check-updates.git
cd go-check-updates/PKGBUILD
makepkg -siEnable and start go-check-updates.socket, the pacman hook triggers after every update/remove.
Use setup.sh, read the help it prints out setup.sh -h
Assuming it is listening on localhost:8100.
See API section for more details.
# Update now, returns after update has completed
$ curl 'http://localhost:8100/api?refresh'
{}
# Refresh internal cache by reading package manager log file
# Best used in post-install hooks as it is quite fast
$ curl 'http://localhost:8100/api?refresh&log_file'
{}
# Update now, return file location immediately
$ curl 'http://localhost:8100/api?refresh&filepath&immediate'
{"filePath":"/tmp/go-check-updates.json","queued":true}
# Get current list of updates
$ curl 'http://localhost:8100/api?updates'
{"data":{"checked":"2020-06-02T13:28:16+02:00","updates":[]}}
# Get current updates, update if file is older than 1 hour and return immediately
# Status code will be 202 and the "queued" key will be present and true if an update was queued
# If no update is needed, status code is 200 and there is no queued key present
$ curl 'http://localhost:8100/api?refresh&updates&immediate&every=1h'
{"data":{"checked":"2020-09-11T14:47:21+02:00","updates":[{"pkg":"snapper","oldVer":"0.8.12-1","newVer":"0.8.13-1","repo":"pacman"}]},"queued":true}
# Can run directly as well (-every can be passed as argument)
$ go-check-updatesNote this is what the API returns in the data key, the websocket returns exactly this data directly.
{
"checked": "2020-06-01T23:10:23+02:00",
"updates": [
{
"pkg": "archiso",
"oldVer": "43-2",
"newVer": "44-2",
"repo": "pacman"
},
{
"pkg": "ca-certificates-mozilla",
"oldVer": "3.52.1-2",
"newVer": "3.53-1",
"repo": "pacman"
},
{
"pkg": "imagemagick",
"oldVer": "7.0.10.15-1",
"newVer": "7.0.10.16-2",
"repo": "pacman"
}
]
}Run with --daemon argument to start a web server,
listen address and port can be adjusted with --web.listen-address.
Alternatively, systemd socket activation can be used with the --systemd argument, socket and service units can be
created with the setup.sh script.
/api endpoint
One of these parameters must be present:
filepathreturns path to the cache file in useupdatesreturns currently cached updatesrefreshrefreshes cached update list, the other commands run after this one. The following parameters can be combined with this oneeveryvalue parsed as time duration, it will only refresh if the file is older than this durationimmediatewon't wait for the request to finish before returning, returned data (if requested) is likely out of datelog_filerefresh using package manager log file
Status codes:
200request was successful400bad argument(s)202update queued500something went wrong server side,Erroris included in response with more details
Requires web server (daemon or systemd mode). Connect to /ws endpoint to receive
data (same as the JSON file) when updates are refreshed.
Example usage in my Polybar setup.
Edit /etc/sysconfig/go-check-updates and add NOTIFY_ENABLE=1 and WEBHOOK_URL="<url>".
By default notifications are only sent every hour at most (to prevent spam when upgrading packages),
this can be adjusted with the NOTIFY_INTERVAL env variable.
Enabling delta notifications NOTIFY_DELTA or --notify.delta will only send updates which were not present in the last notification, this is particularly useful when a large number of updates are pending.