[feature request] When there is a YunoHost update to download, email the administrator

What type of hardware are you using: VPS bought online
What YunoHost version are you running: 12.0.17
How are you able to access your server: The webadmin

Describe your issue

I’d like to have an option to send an email to the administrator when an update is available in the YunoHost update section. This could probably be achieved with a script and a cron job.
I posted in this section because I can’t open a thread in “discuss”.

Share relevant logs or error messages

none

1 Like
#!/bin/bash

# Configura la tua email qui:
EMAIL_DEST="your@email.com

# File temporaneo per memorizzare i risultati
TMP_FILE=$(mktemp)

# Controlla aggiornamenti di sistema
echo "=== Aggiornamenti di sistema ===" > "$TMP_FILE"
sudo yunohost tools upgrade system  >> "$TMP_FILE" 2>&1

# Controlla aggiornamenti delle app
echo -e "\n=== Aggiornamenti delle app ===" >> "$TMP_FILE"
sudo yunohost app upgrade app  >> "$TMP_FILE" 2>&1

# Se il file contiene qualcosa di diverso da 'Nothing to upgrade'
if ! grep -q "Nothing to upgrade" "$TMP_FILE"; then
    mail -s "Aggiornamenti disponibili su $(hostname)" "$EMAIL_DEST" < "$TMP_FILE"
fi

# Rimuove il file temporaneo
rm "$TMP_FILE"

I tried making this script but I don’t know if the “sudo yunohost tools upgrade system” command does the installation and/or if there is a way to just do a check without doing the installation.
Thank you!

You can try this script

I’m using it. It sends notifications every day when updates are available

I believe that this app:

can be configured to only send a message (if you don’t want to use the auto update part)

2 Likes

I take a look to the script.
It is very useful.
This is the last script i made:

#!/bin/bash

# your email
EMAIL_DEST="myEmail@myDomain.com"

# temp file
TMP_FILE=$(mktemp)

# check
echo "=== YunoHost updates ===" > "$TMP_FILE"
yunohost tools update >> "$TMP_FILE" 2>&1

# check for a string
if ! grep -q "Nothing to do. Everything is already up-to-date." "$TMP_FILE"; then
    mail -s "update on $(hostname)" "$EMAIL_DEST" < "$TMP_FILE"
fi

# remove temp
rm "$TMP_FILE"

Yes this is the app to look for in case you need to be warned about debian package updates, as well as automated updates for all or security-only updates.
It does not handle Yunohost app however.

Only could maybe enhance it with something like the scripts quoted here, to add Yunohost updates to the list ? :light_bulb:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.