trents_blog/docs/posts/xmpp-apt-notifications.md

69 lines
1.6 KiB
Markdown
Raw Normal View History

2021-01-09 16:45:08 -08:00
---
title: "Xmpp Apt Notifications"
date: 2021-01-09
draft: false
tags: ["apt","apt-get","prosody","debian"]
authors: ["trent"]
---
date: 2021-01-09
## **Introduction**
In order to save yourself the work of checking your computer for
updates, configure it to send you a weekly notification for updates
using cron and sendxmpp.
## **Register an Xmpp User**
`ssh` into your prosody server and use `prosodyctl` to create a user
for your computer.
i.e. for your htpc:
```console
# prosodyctl adduser htpc@example.com
```
You will be prompted to create a password.
## **Install sendxmpp**
`ssh` into your computer and install `sendxmpp`.
i.e. for your htpc:
```console
$ sudo apt-get install sendxmpp
```
## **Configure sendxmpp**
`ssh` into your computer and login as the root user
using
```console
$ sudo su
```
write the following contents into `/root/.sendxmpprc`, i.e.
for your htpc
```conf
htpc@example.com;example.com <password>
```
secure your `.sendxmpprc` file by making it read-only, and
only accessible by the root user
```console
# chmod 600 /root/.sendxmpprc
```
## **Create Cron Job**
While still logged in as root, open `crontab` for editing.
```console
# crontab -e
```
And then write a command in `crontab`, i.e. for your htpc.
```conf
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
15 3 * * 4 apt-get update && apt-get -u upgrade --assume-no | sendxmpp -t -u htpc <yourself>@example.com
```
## **Receive Notifications on Android Device**
<div align="center">
<em>Example Notification in Yaxim on Android</em>
</div>
!["Yaxim ScreenShot"](https://photos.boringonian.com/1280_IMG_20210109_155515.jpg){: .center }