hacks

You are currently browsing articles tagged hacks.

Debian: Integrating applications installed in /opt using Debian “alternatives”

Some Debian developer will probably see this and yell at me for doing something very evil, but I find this trick quite useful and thought I’d share it with the world. You might notice I also made use of it in my Debian Java mini-howto.

The Debian “alternatives” system is basically a set of utilities designed for manipulating what is no more than a complex collection of symlinks. However, the flexibility it affords users is wonderful. It allows the administrator to set up intelligent “default versions” for system utilities such as editors, pagers, and terminals.

And it also, if you abuse it slightly, gives you an easy way to manage applications installed into /opt.

Debian, as you might know, isn’t that great at always packaging applications that don’t agree with its “social contract”. So you’ll usually find yourself jumping through hoops to get anything that involves Java installed. I install apps like Eclipse, Azureus, and VMWare into directories in /opt (/opt/eclipse, /opt/azureus, etc). And then I use update-alternatives to add intelligent symlinks back into the main system:

update-alternatives --verbose --install [desired symlink] [name] [executable location in /opt/whatever] 500

For a specific example: update-alternatives --verbose --install /usr/bin/vmware vmware /opt/vmware/bin/vmware 500

If you also want to install a link for the manpage, you can also do that:

update-alternatives --verbose --install /usr/bin/vmware vmware /opt/vmware/bin/vmware 500 --slave /usr/share/man/man1/vmware.1 vmware.1 /opt/vmware/man/man1/vmware.1

(I know that actually points to the manpage of the vmware XF86 driver, but you get the idea…)

And since all the links are tracked by update-alternatives, I can easily remove them when I uninstall the application: update-alternatives --remove-all vmware

Tags: , ,

The Chris Metcalf Method

Apparently I’m a productivity guru now:

“I really need to spend a day sitting down doing the Chris Metcalf lifehacks thing, and organizing all my projects into folders and such…” - A friend of a friend in a forwarded email.

Whenever people take an interest in the nerdy little hacks I post, I’m quite surprised and flattered. So I’ve decided to start posting more Lifehacks. If this kind of stuff interests you, please leave me a comment and let me know how you feel.

So stay tuned for more fun hacks.

Update: By the way, I’m not the only desperate, productivity-challenged geek out there doing this stuff. By no means did I start this, I’m just another hipster with a stack of 3×5 cards. There are lots of other great resources for Lifehacks and Lifehacks-compatible ideas:

  • 43folders - Merlin didn’t start it all, but he sure has done a good job of bringing lots of good ideas together. The site is a bit Mac-bigoted, but then again everybody is these days. Also home to a great wiki where a lot of folks have posted great ideas.
  • Lifehacker - Way too many ads, but the RSS feed leaves those out. Lifehacker tends to aggregate ideas from a lot of other sites so its a good one to watch for ideas.
  • Working Smart - A great productivity blog for managers or wanna-be-managers.
  • Slacker Manager - Also with a management focus, but a little more easy-going.
  • Flickr - Surprisingly, there are a lot of good tags with some great Lifehacks and GTD-compatible ideas.

Oh, and pick up a copy of David Allen’s Getting Things Done. Right now.

Tags: , , ,

Automated PGP-encrypted MySQL backups

I’ve been bad. Until recently I haven’t been backing up my MySQL database. Bad things could have happened.

Today I finally hacked up a simple script to run from cron that will automatically dump, zip, and mail backups of my MySQL tables to an email address I specify. I set up a Gmail account to send the dumps to because they’re about 8 meg each. The dumps are also encrypted using my PGP 1024-bit public key to give me a bit of security.

Since I didn’t manage to find anything similar in my Googling, I decided to post it.

#!/bin/sh # Performs a backup of MySQL, encrypts it using PGP, and mails it to a particular user # The user to mail the backup to. Should have a public key in the above user's keyring... MAIL_TO="your-backup-account@gmail.com" MAIL_TO_KEY="Your PGP key ID" # Subject of the mail. A date stamp will be appended to it MAIL_SUBJECT="[mysqldump] MySQL Backup for ” ###################################### DATESTAMP=`date %Y-%m-%d` FILENAME=”/tmp/mysqldump-$DATESTAMP.gz” # Generate the dump mysqldump –all-databases | gzip > “$FILENAME” # Encrypt it gpg –encrypt –recipient “$MAIL_TO_KEY” “$FILENAME” # Mail it! mpack -s “$MAIL_SUBJECT $DATESTAMP” -c application/octet-stream $FILENAME.gpg” “$MAIL_TO” # Remove the backups rm -f $FILENAME $FILENAME.gpg

Tags: , , , , , ,

Newer entries »