OpenWRT Update v19.07.4

Today I received an rss feed about the new version of openwrt. If you use it, keep an eye on your specific device.
GitHub

The following also reminds you to keep your packages up to date. The script is from kuketz-blog.de (German).

Update notification for packages

Packages

opkg update && opkg install msmtp nano

msmtp

nano /etc/msmtprc
# Set default values for all following accounts.
defaults
auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        ~/.msmtp.log

# Your Provider
account        your-provider
host           smtp.your-provider.org
port           587
from           user@your-provider.org
user           user@your-provider.org
password       your-password

# Set a default account
account default : your-provider

# Syslog logging with facility LOG_MAIL instead of the default LOG_USER.
syslog LOG_MAIL

Script

nano /root/update-notification
#!/bin/sh

opkg update
opkg list-upgradable > updates.txt

if [ -s updates.txt ]
then
        sed -i '1i To: user@your-provider.org' updates.txt
        sed -i '2i Subject: OpenWrt Updates' updates.txt
        cat updates.txt | msmtp -a default user@your-provider.org
fi
rm updates.txt
chmod +x /root/update-notification

Crontab

crontab -e
# Update list of available packages | Send notification mail
45 06 * * * /root/update-notification

If there is no crontab defined (i.e. /etc/crontabs/ is empty), then cron won't start! Make sure you already defined cron jobs before trying to start cron.

/etc/init.d/cron start
/etc/init.d/cron enable

SSH login info

nano ~/.profile
#!/bin/sh

opkgInstalled="$(opkg list-installed 2> /dev/null | wc -l)" #silencing error output
opkgUpgradable="$(opkg list-upgradable 2> /dev/null | wc -l)" #silencing error output

echo "$opkgInstalled packages are installed." && echo "$opkgUpgradable packages can be upgraded." && echo
echo "Upgrade commands:"
echo "List available updates: opkg list-upgradable"
echo "Upgrade package: opkg upgrade <PACKAGE>"
echo "Upgrade all packages: opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg upgrade" && echo

Leave a Reply

Your email address will not be published. Required fields are marked *