I'm recently tinkering with MacPorts and Gentoo, both of which involve very long-running builds.
This is my setup for receiving a push notification on my phone when a long job finishes.
I use the Pushover iPhone app: https://pushover.net/
You can use it for free for 30 days, after which you have to make a one-time $5 in-app purchase.
To send a push, you need a user key and an application token.
You are assigned a user key when you register at https://pushover.net/, and you get an application token when you register an "application" at https://pushover.net/.
Surprisingly, their API doesn't force you to use HTTPS, which means it even works from a stock Tiger or Leopard install.
Here is a notify.sh script which uses curl:
The above script uses an HTTPS URL, and assumes you have a modern version of curl installed.
If you need a modern curl on PowerPC Tiger or Leopard, you can install one like this:
Alternatively, you can simply change the "https" to "http" if you aren't concerned about someone possibly snooping your key.
To use this script, you'd do something like:
However, if you control+z that port job to suspend it, it will immediately run notify.sh. If you need to be able to suspend and resume the job, you can instead do:
Here's a notify.py script which uses python to do the same thing:
This is my setup for receiving a push notification on my phone when a long job finishes.
Pushover
I use the Pushover iPhone app: https://pushover.net/
You can use it for free for 30 days, after which you have to make a one-time $5 in-app purchase.
To send a push, you need a user key and an application token.
You are assigned a user key when you register at https://pushover.net/, and you get an application token when you register an "application" at https://pushover.net/.
Surprisingly, their API doesn't force you to use HTTPS, which means it even works from a stock Tiger or Leopard install.
The bash script:
Here is a notify.sh script which uses curl:
Code:
#!/bin/bash
# notify.sh: send a push notification from the command-line.
# ./notify.sh "a message"
set -e
# if you need an SSL-capable curl on OS X Tiger or Leopard (PowerPC),
# unpack this tarball into /opt:
# http://leopard.sh/binpkgs/tigersh-deps-0.1.tiger.g3.tar.gz
export PATH="/opt/tigersh-deps-0.1/bin:$PATH"
APP_TOKEN="XXX"
USER_KEY="YYY"
url=https://api.pushover.net/1/messages.json
curl -fsS -X POST \
-H "Content-Type: application/json" \
-d "{ \"token\": \"$APP_TOKEN\", \"user\": \"$USER_KEY\", \"message\": \"$1\" }" \
$url \
> /dev/null
Installing curl with SSL:
The above script uses an HTTPS URL, and assumes you have a modern version of curl installed.
If you need a modern curl on PowerPC Tiger or Leopard, you can install one like this:
Code:
sudo -i
mkdir -p /opt
cd /opt
curl http://leopard.sh/binpkgs/tigersh-deps-0.1.tiger.g3.tar.gz | gunzip | tar x
Alternatively, you can simply change the "https" to "http" if you aren't concerned about someone possibly snooping your key.
Usage:
To use this script, you'd do something like:
Code:
sudo port -v install gcc14 ; notify.sh "gcc14 done"
However, if you control+z that port job to suspend it, it will immediately run notify.sh. If you need to be able to suspend and resume the job, you can instead do:
Code:
bash -c "sudo port -v install gcc14 ; notify.sh 'gcc14 done'"
The Python script:
Here's a notify.py script which uses python to do the same thing:
Code:
#!/usr/bin/env python3
# notify.py: send a push notification from the command-line.
# ./notify.py "a message"
import sys
import urllib.request
import urllib.parse
APP_TOKEN="XXX"
USER_KEY="YYY"
url = "https://api.pushover.net/1/messages.json"
data = {
"token": APP_TOKEN,
"user": USER_KEY,
"message": sys.argv[-1]
}
body = urllib.parse.urlencode(data).encode("utf-8")
urllib.request.urlopen(url, data=body).read().decode("utf-8")