2011-03-13 21:42

Here are some lines I’m using to backup my MySQL databases on my Debian server:

#!/bin/sh
# This will dump all your databases

DATE=$(date +%Y%m%d%H%M)

for DB in $(echo "show databases" | mysql --defaults-file=/etc/mysql/debian.cnf -N)
do
        mysqldump --defaults-file=/etc/mysql/debian.cnf $DB > /backup/mysql/${DB}_${DATE}.sql

        gzip /backup/mysql/${DB}_${DATE}.sql
done

# purge old dumps
find /backup/mysql/ -name "*.sql*" -mtime +8 -exec rm -vf {} \;

You can run it in a cron:

11 1 * * * /usr/local/bin/mysqldump.sh > /tmp/mysqldump.log

This way any error displayed by the script will be sent by mail to the root user (mail address in /etc/aliases).

If you are not under Debian and there is no password file in /etc/mysql, you should create such file.

2011-03-13 21:42 · Tags: , ,
2010-11-30 21:11

I discovered Clementine some time ago.

There is not any package for Ubuntu or Debian, but the official site gives you a .deb for your favorite Ubuntu version.
And you’ll also find Mac OS X and Windows versions…

A small click on the good .deb file for your Ubuntu distro and it should install.

I tested tons of players (Amarok, Rythmbox, old XMMS, Exaile, Listen, Totem…).

Clementine is based on Amarok, it’s far simpler and integrates very well in Gnome desktop using Qt4 librairies.

I’m happy to know this software and I recommend it to you.

2010-11-30 21:11 · Tags: , , , ,
2010-11-09 23:51

In a previous post, I explained how to setup a catchall with Exim. This to create multiple addresses all redirecting to the same destination:

catchall_pub:
  driver = redirect
  domains = ads.mydomain.com
  data = user@mydomain.com

Then, I wrote that on destination address we could setup a Sieve or Exim filter with a .forward file.

If you want to do that directly in Exim, to have all config in one place, or simply if your destination mail box doesn’t supports filters…

Just add a local_parts option:

catchall_pub:
  driver = redirect
  domains = ads.mydomain.com
  local_parts = !/etc/exim4/ads.mydomain.com.blacklist
  data = user@mydomain.com

In /etc/exim4/ads.mydomain.com.blacklist we put all rejected addresses, one per line:

foo1
bar2

This way foo1@ads.mydomain.com and bar2@ads.mydomain.com will be rejected.

Exim4 Doc:

2010-11-09 23:51 · Tags: , , ,
2010-10-11 00:45

Default in Debian: ProFTPD only uses the /etc/passwd system user base.

To add “virtual” users :

In /etc/proftpd/proftpd.conf:

DefaultRoot ~
AuthUserFile /etc/proftpd/ftpd.passwd
RequireValidShell off

Then restart proftpd: /etc/init.d/proftpd restart

Create users file:

vi /etc/proftpd/ftpd.passwd
username:HASH:1011:1011:MyUserName:/home/ftp/directory:/bin/true

You can also generate the user lines with the ftpasswd command, but I think it’s simpler to generate passwords with the command:

mkpasswd --hash=md5

Then paste the HASH in the passwd file.

Correct passwd file permissions:

chown proftpd /etc/proftpd/ftpd.passwd
chmod go-r /etc/proftpd/ftpd.passwd

And just test it to finish.

Links:

2010-10-11 00:45 · Tags: ,
2010-07-05 22:19

NetHack: one of the best games ever.

I find xnethack default tileset rather ugly. Under Debian/Ubuntu (nethack-x11 package), the tileset file must be in XPM format. It’s configuration is in the /etc/X11/app-defaults/NetHack file with the default xpm: /usr/share/pixmaps/nethack/x11tiles.

The file must be in XPM format, with a limited size and different color number, otherwise Nethack loading time explodes (several minutes).

Here is how to change it on Debian / Ubuntu:

  1. Example: on http://www.multifoliate.com/nh/, get the chozo32b.zip file (link: NetHack 3.4.2 (32×32) (modified by me)). Extract it to get chozo32b.bmp.
  2. Open it with Gimp, cut it to 1280×864 (to delete the black at the bottom). You can then convert it to 256 colors, then save it as XPM. It works but it’s ugly.
  3. To get a better result, save it to PNG.
  4. Install imagemagick package, then convert -depth 5 chozo32b.png chozo5.png
  5. Open chozo5.png with Gimp. Then save it to XPM format.
  6. Edit /etc/X11/app-defaults/NetHack and replace /usr/share/pixmaps/nethack/x11tiles with the path to chozo5.xpm.
  7. Then, reload X ressources: xrdb -merge /etc/X11/app-defaults/NetHack
  8. Start your favorite game: xnethack

The final gzipped file: chozo5.xpm.gz

Notes:

  • convert always saves xpms in 256 colors. I don’t know why.
  • head image.xpm gives you the first lines of the XPM file, with number of different colors.
  • Abigada tileset is by default in NetHack iPhone version.

Links:

2010-07-05 22:19 · Tags: , , ,
2010-05-24 23:52

The main idea is to have a set of anything@ads.mydomain.com addresses, all redirecting to a single mailbox. Then I can use any address @ads.mydomain.com as an alias to my primary mailbox.
This way, I give ebay@ads.mydomain.com to Ebay, amazon@ads.mydomain.com to Amazon and so on.

This solutions allows me to disable an alias if unsubscribing on the site doesn’t work. I can also use this to track sites selling my address to other sites.

First, Exim has to listen on the network, and accept mail to the ads.mydomain.com domain. Under Debian, put this in /etc/exim4/update-exim4.conf.conf:

dc_local_interfaces='0.0.0.0'
dc_relay_domains='ads.mydomain.com'

Note under Debian: each time Exim starts the /etc/exim4/exim4.conf.template file is filled with variables set in /etc/exim4/update-exim4.conf.conf, générating the /var/lib/exim4/config.autogenerated file. This is to ease Exim configuration in standard cases.

Then edit the /etc/exim4/exim4.conf.template file to add a new router, in first position just bellow begin routers:

catchall_pub:
  driver = redirect
  domains = ads.mydomain.com
  data = user@mydomain.com

The router will be called for any mail @ads.mydomain.com. It give all mails to the redirect transport sending them to the address set in data.

Finally, you can then use a /home/user/.forward file to disable aliases with a Sieve or Exim filter.

UPDATE 2010-11-10: another way of disabling aliases

References:

2010-05-24 23:52 · Tags: , , ,
2010-05-20 23:53

Audio CD copy is actually not possible with Brasero on Ubuntu Lucid. All details in the bug report.

As a workaround, you must install cdrdao version 1.2.3, which is not yet available as a package.

To install it, you can use CheckInstall which is a bit cleaner than the old make install:

tar -xjvf cdrdao-1.2.3.tar.bz2
cd cdrdao-1.2.3/
./configure
make
sudo checkinstall make install

Note: the make command can fail because of missing dev packages you’ll have to install.

CheckInstall builds and installs a nice Debian package.

You can also use cdrdao directly. ps axf shows us the command Brasero is using:

cdrdao read-cd --device /dev/sr0 --read-raw --datafile /home/dooblem/brasero.toc.bin -v 2 /home/dooblem/brasero.toc

Here we go!

Links :

2010-05-20 23:53 · Tags: , , , , , , ,
2010-03-09 22:11

Here is a small C program I wrote some years ago: Clictap. It’s very convenient and I’m still using it to watch my movies.

It makes use of Xlib and Xtest libraries to replace your mouse buttons by keyboard keys.

I made a small Debian package a few days ago:

clictap_0.6-1_i386.deb

soon included in the official repositories ?

Configuration file example including profiles for totem, xmms, rhythmbox and mplayer:

# ClicTap configuration file
# You can copy this example to ~/.clictap.conf

# When this key is pressed, Clictap will ungrab your mouse and quit
# Examples :
# quit_key q
# quit_key ctrl+q
quit_key q

# Profile used by default
default_profile mplayer

# List of profiles
# For each profile, a set of buttons to keys translations is given,
# each translation on a separate line.
# For a translation, the first field is the set of buttons,
# the second is the set of keys.
# Buttons are specified by their numbers.
# Keys are specified by their KeySym (Key Symbols).
# To know the button numbers and KeySyms, use the xev program to test X events.
# Example :
#
# profile foo
# 	1   a
# 	2   b+c
# 	3+1 space
# 	3+2 Control_L+d

profile totem
	1 b
	2 p
	3 n
	4 Up
	5 Down

profile xmms
	1 w
	2 c
	3 b
	4 Up
	5 Down

profile rhythmbox
	1 Alt_L+Left
	2 Control_L+space
	3 Alt_L+Right
	4 Control_L+Up
	5 Control_L+Down

profile mplayer
	1 Left
	2 space
	3 Right
	4 asterisk
	5 KP_Divide

profile mplayersub
	1 x
	2 space
	3 z
	4 asterisk
	5 KP_Divide

profile test
	1 XF86AudioLowerVolume
	2 space
	3 z
	4 asterisk
	5 KP_Divide
2010-03-09 22:11 · Tags: , , , ,
2010-02-10 19:38

The well known way to remove a service from system boot under Debian / Ubuntu, without removing the package:

update-rc.d -f mysql remove

This command removes all /etc/rc*/*mysql* symbolic links. At next boot, the service is not started.

Problem: when you update the mysql package (aptitude update), symlinks are created again.

Solution: in the last update-rc.d versions, there are disable / enable commands:

update-rc.d mysql disable

Useful if like me you only start apache or mysql some times for Web development. Also useful if you share files with Samba and only want to start the daemon occasionaly.

Note: update-rc.d --help tells us that The disable|enable API is not stable and might change in the future.

References:

2010-02-10 19:38 · Tags: ,