How to use "slackpkg check-updates" in a script
by gegechris99 from LinuxQuestions.org on (#5BX10)
drgibbon asked in thread "Requests for -current (14.2-->15.0)" (see post here)
Quote:
I want to provide a "workaround" solution here and not pollute the above-mentioned thread.
For the avoidance of doubt, we'll discuss the stock slackpkg, not the slackpkg+ extension. Checking updates with slackpkg+ is covered in this post.
If there is no update, you'll get:
Code:$ slackpkg check-updates
No updated packages since last check.If there is an update:
Code:$ slackpkg check-updates
Updated packages are available since last check.We can create script check_slackware_update.sh to send a notification when there is an update:
Code:#!/bin/bash
/usr/bin/mkdir -p ~/.slackpkg
/usr/sbin/slackpkg check-updates | /usr/bin/sed -n '/available/ p' > ~/.slackpkg/updated-repo.txt
username=$(/usr/bin/whoami)
pid=$(pgrep -u $username kded5)
dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$pid/environ | sed 's/DBUS_SESSION_BUS_ADDRESS=//')
export DBUS_SESSION_BUS_ADDRESS=$dbus
[ -s ~/.slackpkg/updated-repo.txt ] && /usr/bin/notify-send -i dialog-warning "[ S L A C K P K G ]" "Available updates"The above script works only on Plasma 5 as I use process kded5 to retrieve environment variable DBUS_SESSION_BUS_ADDRESS in the cron context.
The script could then be added to the user crontab (not the root one):
Code:$ crontab -l
SHELL=/bin/bash
# Check update of Slackware packages
0 * * * * sh ~/check_slackware_update.shBash experts will no doubt clean up my script. You're welcome.
Also, to get DBUS_SESSION_BUS_ADDRESS in cron in any DE, I have only this:
Code:DBUS_SESSION_BUS_ADDRESS=$(ps -u chris e | grep -Eo 'dbus-daemon.*ADDRESS=unix:abstract=/tmp/dbus-[A-Za-z0-9]{10}' | tail -c35)What is the cleanest way to get DBUS_SESSION_BUS_ADDRESS in cron environment?


Quote:
Question (possibly a request) for `slackpkg check-updates`, the man page says: Quote:
|
For the avoidance of doubt, we'll discuss the stock slackpkg, not the slackpkg+ extension. Checking updates with slackpkg+ is covered in this post.
If there is no update, you'll get:
Code:$ slackpkg check-updates
No updated packages since last check.If there is an update:
Code:$ slackpkg check-updates
Updated packages are available since last check.We can create script check_slackware_update.sh to send a notification when there is an update:
Code:#!/bin/bash
/usr/bin/mkdir -p ~/.slackpkg
/usr/sbin/slackpkg check-updates | /usr/bin/sed -n '/available/ p' > ~/.slackpkg/updated-repo.txt
username=$(/usr/bin/whoami)
pid=$(pgrep -u $username kded5)
dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$pid/environ | sed 's/DBUS_SESSION_BUS_ADDRESS=//')
export DBUS_SESSION_BUS_ADDRESS=$dbus
[ -s ~/.slackpkg/updated-repo.txt ] && /usr/bin/notify-send -i dialog-warning "[ S L A C K P K G ]" "Available updates"The above script works only on Plasma 5 as I use process kded5 to retrieve environment variable DBUS_SESSION_BUS_ADDRESS in the cron context.
The script could then be added to the user crontab (not the root one):
Code:$ crontab -l
SHELL=/bin/bash
# Check update of Slackware packages
0 * * * * sh ~/check_slackware_update.shBash experts will no doubt clean up my script. You're welcome.
Also, to get DBUS_SESSION_BUS_ADDRESS in cron in any DE, I have only this:
Code:DBUS_SESSION_BUS_ADDRESS=$(ps -u chris e | grep -Eo 'dbus-daemon.*ADDRESS=unix:abstract=/tmp/dbus-[A-Za-z0-9]{10}' | tail -c35)What is the cleanest way to get DBUS_SESSION_BUS_ADDRESS in cron environment?