On Thu, Feb 2, 2017 at 4:32 PM, Brandon Curtis
<procure(a)brandoncurtis.net> wrote:
Awesome! Can you share the code and the commands for
installing and
enabling it as a service? I'm curious how that compares to writing an
executable script somewhere and e.g. adding it to crontab with `crontab -e`.
yar$ cat /etc/systemd/system/routercheck.service
[Unit]
Description=Cheap Router Check Daemon
After=network.target
[Service]
User=yar
ExecStart=/home/yar/bin/router-check.sh
WorkingDirectory=/home/yar
Restart=always
RestartSec=60min
[Install]
WantedBy=multi-user.target
yar$ cat /home/yar/bin/router-check.sh
#!/bin/bash
url=http://computers.woot.com/offers/wd-mynet-n600-2x2-wireless-n-router-56
sender=routeralert(a)sudoroom.org
recipient=mesh(a)lists.sudoroom.org
echo "checking for cheap routers..."
while :; do
if curl -sD - -o /dev/null "$url" | grep -qE '^HTTP/1.1 404 Not
Found'; then
# it's still a 404
#echo "no cheap routers found. sleeping for 1h..."
sleep 1h
continue
else
# it's no longer a 404
echo "cheap router found, mailing the list"
echo "This url no longer returns a 404 error: $url" \
| mailx -r "$sender" -s "cheap router alert"
"$recipient"
echo "list mailed. exiting."
exit
fi
done
yar 445T~$ sudo systemctl enable routercheck
[sudo] password for yar:
Created symlink from
/etc/systemd/system/multi-user.target.wants/routercheck.service to
/etc/systemd/system/routercheck.service.
yar$ sudo systemctl start routercheck
yar$