the new CLI mintupdate-tool does exactly this, combines the functionality of the mintupdate with levels and settings combined with the possibility to run it with cron or in scripts
i decided to start it with the systemd timer, which gives me some more flexibility in configuration
but first the mintupdate-tool:
the help of mintupdate-tool gives the following:
Code: Select all
usage: mintupdate-tool [-h] [-k | -nk] [-s] [-r] [-d] [-y]
[--install-recommends] [-l LEVELS]
command
positional arguments:
command a command
optional arguments:
-h, --help show this help message and exit
-k, --kernel ignore settings and include all kernel updates
-nk, --no-kernel ignore settings and exclude all kernel updates
-s, --security ignore settings and include all security updates
-r, --refresh-cache refresh the APT cache
-d, --dry-run simulation mode, don't upgrade anything
-y, --yes automatically answer yes to all questions
--install-recommends install recommended packages (use with caution)
-l LEVELS, --levels LEVELS
ignore settings and restrict to this list of levels
i wanted just to automatically run the level 1 and 2 updates plus security updates and to refresh the cache, so in my case the full command is
Code: Select all
mintupdate-tool -nk -s -r -y -l 12 upgrade
1. the script itself in this example named autoupdt.sh
Code: Select all
#!/bin/bash
#add the date to the logfile
d="-------------------------------------------------------------------------------\n $(date +%Y-%m-%d) $(date +%H:%M:%S)\n-------------------------------------------------------------------------------"
echo -e $d >> /path/to/your/logfile.log
#to check if the pc is online
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
if [ $? -eq 0 ]; then
#the actual update
mintupdate-tool -nk -s -r -y -l 12 upgrade &>> path/to/your/logfile.log
else
echo "Offline" >> /path/to/your/logfile.log
fi
ok for the systemd timer there are several tutorials and wiki pages on the net for further information, therefore here just the timer and service files to put in the /etc/systemd/system folder with root rights
2. the timer file (here autoupdt.timer)
Code: Select all
# file /etc/systemd/system/autoupdt.timer
[Unit]
Description=automatic update
[Timer]
OnBootSec=10min
# to start the timer 10 minutes after booting
OnUnitActiveSec=24h
# to restart the timer 24 hours after the last run
[Install]
WantedBy=multi-user.target
Code: Select all
# file /etc/systemd/system/autoupdt.service
[Unit]
Description=automatic update
[Service]
ExecStart=/bin/sh /home/torsten/kiste/bin/autoupdt.sh
Code: Select all
systemctl enable --now autoupdt.timer
restart the system (and wait 10 mins) to see if it works
i hope i could help a bit these guys who might need something like this and i'm thankful for any recommendations and improvements