You are not logged in.
got it from all commands:
sudo apt-get -s upgrade | awk '/Inst.+/ { print \$2}'
Offline
^that one will still need 'sudo apt-get update' to be run first.
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
sudo apt-get update >/dev/null 2>&1 && sudo apt-get -s upgrade | awk '/Inst.+/ { print \$2}'
that should do it.
i wouldn't execute this more often than once a day.
Offline
^that one will still need 'sudo apt-get update' to be run first.
indeed.
Offline
Regarding the need to run apt-get update as root/su, how do utilities like unattended-upgrades get around this? I'm looking at that package's wiki page and I don't see...
Be excellent to each other, and...party on, dudes!
BunsenLabs Forum Rules
Tending and defending the Flame since 2009
Offline
Regarding the need to run apt-get update as root/su, how do utilities like unattended-upgrades get around this? I'm looking at that package's wiki page and I don't see...
Probably it installs a rules file.
EDIT `/etc/apt/apt.conf.d/50unattended-upgrades`?
The postinst file in the deb sets up a systemd unattended-upgrades.service
Last edited by damo (2016-02-05 23:03:53)
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
I took the time to build up an update notifcation system using systemd unit files and output parsed to conky today.
First, I created a simple bash script that runs sudo apt update, then redirects the output to journalctl. I saved this file to /usr/local/bin/debupdates.
#!/bin/bash
systemd-cat sudo apt update
exit 0;
Next, comes the systemd service file save to /etc/systemd/system/debupdates.service. Please note the lack of an Install portion to this unit file. That is because the timer will handle the stopping and starting of the service.
[Unit]
Description=Service file to run Debian Updates
After=network-online.target
Wants=network-online.target
[Service]
type=oneshot
ExecStart=/usr/local/bin/debupdates
Next, I needed a timer unit file which will handle starting and stopping the debupdates.service. It is set to run once, 15s after boot, then every 24 hours after that. If you find that systemd is not running the service on boot, then it is likely you will need to up the OnBootSec=15s value some more. Since debupdates.service requires network-online.target, I would set that value based on how long it takes to boot to desktop and get connected to the internet. This file is saved as /etc/systemd/system/debupdates.timer
[Unit]
Description=Checking for Debian Updates.....
[Timer]
OnBootSec=15s
OnUnitActiveSec=24h
[Install]
WantedBy=timers.target
Finally, I created a shell script save to ~/bin/list-updates that runs apt list --upgradable, then outputs a count of the number of available updates, along with a listing of the packages. apt outputs a number of informational lines that I had to remove from the output and also had to reduce the count to account for those extra informational lines. One thing I noticed, is that apt list --upgradable is outputting the wrong count in it's output. For instance, it was showing me 11 packages needing to be upgraded but the list only held 10 packages. This is likely due to the fact that somebody ran a count based on a 1-based index as a opposed to a 0-based index. I have double-checked this with the raw output from the command line and it has nothing to do with my code.
#!/bin/bash
oldfifs="$IFS"
IFS=$'n'
updates=($(apt list --upgradable))
IFS="$oldifs"
echo -e "$((${#updates[*]}-6)) updates available.\n"
echo "${updates[@]:2}"
exit 0;
Finally, the code that you put in your conky.
${execpi 43200 $HOME/bin/list-updates}
I will gather all of the various files I created up and publish them to my github.
Offline
....
I will gather all of the various files I created up and publish them to my github.
Awesome!
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
Done. I suppose I ought to learn how to package things now.
Forgot the link, though the link to the main repository is in my sig
list-updated github
Last edited by tknomanzr (2016-02-05 23:31:07)
Offline
Small corrections to your script:
#!/bin/bash
oldifs="$IFS"
IFS=$'\n'
updates=($(apt list --upgradable 2>/dev/null))
IFS="$oldifs"
echo -e "$((${#updates[*]}-1)) updates available.\n"
echo "${updates[@]:1}"
exit 0
Typo in IFS=$'n' - missing \
typo in oldfifs="$IFS" - should be oldifs, but has no influence on the results.
But you should only exclude the first element of the array - "${updates[@]:1}"
Offline
Fixed a couple of errors and made some changes to list-updates. For whatever reason, the script had stopped properly splitting elements via newlines. Also, I felt it wise to truncate list output for the available updates to some number so that lots of pending updates don't break conkies. For the moment I just hard-coded 20 elements in the printf statement. Given that this code is not meant to be run directly, I am not sure if an args parser is needed for this script. I could set a variable for the number of elements and/or an args parser to pass the maximum number of elements to display in. With all that being said, sooner or later a text file would need to be modified regardless how I choose to go about setting the max number of elements to display.
I found a small typo in the debupdates.service file. Those files are case-sensitive.
All changes are pushed to git.
Here's the new code for list-updates:
#!/bin/bash
readarray -t updates <<< "$(apt list --upgradable 2>/dev/null)"
numupdates=$((${#updates[*]}-1))
echo $numupdates "updates available."
echo "\${hr 1}"
printf -- "%s\n" "${updates[@]:1:20}"
if [ $numupdates -gt "20" ]; then
echo -e "\${hr 1}"
echo "\$alignr More Updates Available..."
fi
exit 0;
The horizontal rule statements are optional. They are just there to pretty up the formatting in my conky some.
Offline
My 2 cents.
gnome-packagekit is broken in BunsenLabs and maybe even in GNOME, I don't know. When it worked, it was very cool to see the systray icon appear, but then it wouldn't work. And then you're running apt anyway to find out what's up, so just
sudo apt update && sudo apt upgrade
and be done with it. #firstworldproblems my auto-notification is busted
Another 2 cents:
Is gnome-packagekit really broken?
I succesfully managed to use it for notification of updates. It works fine for several weeks already. What I did:
sudo apt-get install gnome-packagekit
sudo apt-get install update-notifier
sudo apt-get install pk-update-icon
NOTE: pk-update-icon comes from jessie-backports, so the next line has to be present in /etc/apt/sources.list:
deb http://ftp.de.debian.org/debian jessie-backports main
At first it seemed not to work at all, but I didn't realize that the check for updates is done only once a day in the default configuration. The next day I was pleasantly surprised that after booting the packagekitd daemon was running and I automatically got notified about some pending updates... Since then it seems to work flawlessly. Just like the old update-notifier in Crunchbang Waldorf
To manually view pending updates, use:
gpk-update-viewer
To view installed/available software (an alternative for synaptic, however I prefer the last):
gpk-application
Some interesting info I found at: http://www.freedesktop.org/software/Pac … k-faq.html
Bunsenlabs Hydrogen - Solus 1.0 Shannon
Offline
Might I suggest using the logic from the byobu package? (You folks do use tmux and byobu, right? ) It's licensed GPLv3. Something like this for displaying the number of available updates:
renice 10 $$ >/dev/null 2>&1 || true
ionice -c3 -p $$ >/dev/null 2>&1 || true
flock -xn updates_available.lock apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst >updates_available.cache 2>/dev/null &
Then, you only need to "cat updates_available.cache" at regular intervals or "tail -F updates_available.cache". Have a look especially at the ___update_cache() and ___print_updates() functions in updates_available (from whence the foregoing is paraphrased) and reboot_required in the source code (shell scripts) at bzr:trunk/head:/usr/lib/byobu/
The result of updates_available is an integer followed by an exclamation point when an update is available and two exclamation points when security update is available, and the result of reboot_required is (R) when a reboot is required after an upgrade.
Here, the term cache seems internal to byobu's logic. The apt cache will still have to be updated periodically. This can be done by configuring apt to update daily, as follows:
cat << EOF | sudo tee /etc/apt/apt.conf.d/02periodic
// Do "apt-get update" automatically every n-days (0=disable)
APT::Periodic::Update-Package-Lists "1";
EOF
[edited to include apt periodic config, see /etc/cron.daily/apt and man apt.conf]
Last edited by toobuntu (2016-02-08 12:39:20)
Offline
Just a note about granting sudo privileges: in general, it should be done only if necessary and with caution because of the security risks. In this case it is not necessary. /etc/cron.daily/apt already contains instructions for running apt-get update once a day. Even though the Debian archive is updated four times a day, a once daily update of the apt cache should still be sufficient. Finally, please see my post above with code glommed from the byobu package. If you delve into Dustin Kirkland's source code (he's a core-dev at Canonical, btw), you can see he makes some good points about renice-ing this process and using apt-get without apt's locking. As has been pointed out already, there's no need to have aptitude installed to accomplish this.
Offline
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
Hi @ all,
thanks for the many suggestions and ideas! Since I have kindled a really exciting discussion ...
@tknomanzr: nice idea to implement in Conky, have tried that same time and it works really great!
Thanks @ all
English by Google - blame them, Ich bin Deutscher.
Offline
I use a script that check the updates in cron.weekly and exector (execp) plugin in tint2 (i beleave only available in v0.12, not in bunsen repos yet) to show in the bar the warning text with the pending updates if there. When I click in the text bar terminator is open to install the updates.
Mod Note: Oversized image replaced with thumbnail link, please limit images to ~250x250px
-HoaS
Last edited by pepemopap (2016-04-30 14:37:10)
Offline
^ sweet.
wanna share the script and tint2 config?
Offline
Sure:
Script: /etc/cron.weekly/update-notification.sh
This script is executed weekly for checking updates and saving the output in /var/cache/update-notification/aptitude-updates:
#!/bin/bash
un_dir="/var/cache/update-notification"
# CHECK INTERNET CONNECTION
echo "Checking connection..."
nc -z 8.8.8.8 53 || exit 1
# UPDATE REPOSITORY AND SAVE RESULTS
echo "Updating package repository..."
aptitude update &> /dev/null
echo "Checking pending updates..."
aptitude search "~U" &> $un_dir/aptitude-updates
Tint2 config:
Version 0.12 is needed for execp plugin.
#Add E to panel_items:
panel_items = LTESC
...
execp = new
execp_command = [ -r /var/cache/update-notification/aptitude-updates ] && echo "| UPDATES: "$(wc /var/cache/update-notification/aptitude-updates -l | cut -f 1 -d " ")" | "
execp_interval = 0
execp_background_id = 2
execp_font = Droid Sans 9
execp_font_color = #FFFFFF 100
execp_centered = 1
execp_padding = 0 0 0
execp_tooltip = Pending updates
execp_lclick_command = x-terminal-emulator -b -e ~/bin/update-notification.sh
Script: ~/bin/update-notification.sh
This script is called when user clic on the taskbar message for install packages.
#!/bin/bash
un_dir="/var/cache/update-notification"
if ! [ -r $un_dir/aptitude-updates ]; then exit 0; fi
echo "PENDING SYSTEM UPDATES:"
cat $un_dir/aptitude-updates
echo
read -p "Press enter to continue installing..."
sudo aptitude full-upgrade
if ! [ $? -eq 0 ]; then read; exit 1; fi
sudo rm $un_dir/aptitude-updates;
bl-tint2restart &>/dev/null &
read
Last edited by pepemopap (2016-05-07 22:22:32)
Offline
Typo on the first line - causes an error in the constructed filepath
un_dir="/var/cache/update-notification/"
Should be
un_dir="/var/cache/update-notification"
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline