Email a list of updates from a Debian server.

Do you run remote servers? Me too.

It’s a good ideea to keep them up to date. On the other hand I don’t like automatic updates, something might break when you least want or expect it. So I prefer to be notified of updates and choose myself the moment when to apply them. Following is a nice script that sends an email of available updates on a Debian system.

# Only download updates.
# Nothing is installed.
apt-get -dqq update
apt-get -dyqq upgrade

upgrades=$(apt-get -s upgrade | grep ^Inst)
if [ “$upgrades” ] ; then
echo “$upgrades” | mail -s “Updates for $(hostname) on $(date +%Y-%m-%d)” $EMAIL
Set the above script to run from cron as often as you’d like to get these notifications.

Tentakel on CentOS 6 / Python 2.6

You probably already know this old, unmaintained but incredibly useful software:  tentakel. If not check it out, you might like it.

There are two issues we need to tackle:

1. Tentakel uses tpg but the bundled version is not compatible with python 2.6

Error thrown:
[cc_bash]return self.lexer[start:stop]
TypeError: object cannot be interpreted as an index[/cc_bash]
The fix is to download this version of tpg from it’s developer: From this archive extract and copy it to py/lekatnet/plugins in tentakel’s source tree.

Don’t try the latest TPG version as it will not work probably it’s parameters changed and tentakel doesn’t work. Basically we take a version low enough to work with tentakel (the built in is from 2003) and new enough to work with Python 2.6

2. Hide the md5 deprecation warning. This is not essential but seeing the warning everytime is annoying. Edit py/lekatnet/ and add around line 49 (after “””)
Error shown:
[cc_bash]/usr/lib/python2.6/site-packages/lekatnet/plugins/ DeprecationWarning: the md5 module is deprecated; use hashlib instead
import md5[/cc_bash]
It’s just a warning but it might interfere with automated tasks:
[cc_python]import warnings
warnings.simplefilter(“ignore”, DeprecationWarning)[/cc_python]
After that build and install accordingly to INSTALL

3. The site-packages are not copied in the right place (at least for CentOS 6) so move /usr/lib/python2.6/site-packages/lekatnet to /usr/lib/python2.6/site-packages/lekatnet


After that build and install accordingly to INSTALL

Remove duplicates from the current folder

I needed today to remove duplicate files from a big folder (8Gb+, 10000+ files). I use the nice fdupes program written by Adrian Lopez
[cci_bash]fdupes -rdN .[/cci_bash]
Note the point after the parameters. That means to search inside the current folder. A path could be provided instead of it. The options are:

  • -r means search recursively
  • -d means delete. use carefully and read the man page to understand what could go wrong!
  • -N means “no prompt”, i.e. the program will not ask which file to keep when multiple are found (I didn’t care, you might)