Archief

Archief voor oktober 2007

Amsterdam 1/2 Marathon 2007

21 oktober 2007 Reacties uit

Amsterdam 1/2 Marathon 2007Vandaag de 1/2 marathon van Amsterdam gelopen. Ondank maar liefst 2 sanitaire stops (waarvan 1 serieuze!) toch nog een tijd waar ik tevreden over ben: 1:36:45.

Categorieën:Hardlopen Tags:

Kopenhagen

8 oktober 2007 Reacties uit

NyhavnDit weekend ben ik met collega’s Bert-Jan, Bob, Mark, Sander en Thijs naar Kopenhagen geweest, ik kan er helaas niet alles over vertellen wegens de standaard afspraak: “What happens in Kopenhagen, stays in Kopenhagen”. Tip voor reizigers (en voor Mark): plak een leuke sticker op je koffer, dan hoef je hem niet 5 x op de bagageband voorbij laten komen, voordat je hem herkent.

Sleep in HeavenWe kwamen vrijdagavond aan zijn naar de Vega geweest en sliepen in de hemel (mocht de hemel echt zo krap zijn, dan hoeft het voor mij niet zo).

Zaterdagavond zijn we naar eerst naar een authentieke Deense Pub geweest, nl. de Dubliner (zit ook in Stockholm, misschien iets voor het volgende uitje?) geweest, na overdag wat rondgelopen te hebben (o.a. in de vrijstaat Christiana). Na het sluiten (05:00 uur) gingen we terug, maar we onderweg hebben we nog even een party ge-crashed: erg gezellig verjaardagsfeestje in een vage woonkamer/bar, ergens hier. Als laatste bezoekers werden we op erg vriendelijke wijze gevraagd of we weg wilden gaan, toen was het 07:00 (o.i.d., hier de gevolgen van weinig slaap). Erg gastvrij die Denen! Bier is wel vrij duur, behalve op laatstgenoemde feestje. Foto’s en Films gemaakt door Bob en Thijs staan hier …

Categorieën:Diverse artikelen Tags:

Bash script to read XMail boxes with Mutt

1 oktober 2007 Reacties uit

For Postmasters: easy way to read a mailbox from your XMail spool. If you have a CDB file (see this post), it is also capable of looking up aliases.

  1.  
  2. readmail real.user@domain.org
  3. #or:
  4. readmail an.alias@domain.org
  5. #or if your RootDomain is domain.org:
  6. readmail an.alias

 

  1.  
  2. #!/bin/bash
  3. XMAILROOT="/var/lib/xmail"
  4. CDB="/var/lib/qpsmtpd/rcptto/validrcptto.cdb"
  5.  
  6. RootDomain=$(grep RootDomain $XMAILROOT/server.tab | awk ‘{print $2}’|sed ‘s/"//g’)
  7. aliaslookup=1
  8. [ -f "$CDB" ] || {
  9.   echo "warning: CDB file not found, alias lookup disabled"
  10.   aliaslookup=0
  11. }
  12. spool="$XMAILROOT/domains/"
  13. if [ -z "$1" ]; then echo usage: $0 user@domain; exit; fi
  14. user=$(echo $1|cut -d@ -f1);
  15. domain=$(echo $1|cut -d@ -f2)
  16. [ "$domain" == "$user" ] && domain=$RootDomain
  17.  
  18. if [ ! -d "$spool/$domain" ]; then
  19.   echo "$domain: no such domain in $spool"
  20.   exit 8
  21. fi
  22.  
  23. if [ ! -d "$spool/$domain/$user" ]; then
  24.   if [ $aliaslookup -eq 1 ]; then
  25.     echo -n "$user@$domain not found, looking for alias: "
  26.     real=$(cdb -qm $CDB $user@$domain)
  27.     if [ $real == "" ];then
  28.       echo "not found"
  29.       exit 8
  30.     else
  31.       echo "using $real"
  32.       user=$(echo $real|cut -d@ -f1)
  33.     fi
  34.   else
  35.     echo "$user: no such user in domain $domain"
  36.     exit 9
  37.   fi
  38. fi
  39.  
  40. mutt -f $spool/$domain/$user/Maildir
Categorieën:Linux Tips & Trics Tags:,

XMail to CDB-database for use with qpsmtpd

1 oktober 2007 Reacties uit

This scripts creates a Constant DataBase file. We use this to interact with the qpsmtpd plugin check_validrcptto_cdb.

  1.  
  2. #!/bin/bash
  3.  
  4. #this script creates a cdb file from xmail users and their aliases
  5.  
  6. OUTPUTFILE=/var/lib/qpsmtpd/rcptto/validrcptto.cdb
  7. XMAILROOT=/etc/xmail
  8.  
  9. #no more settings beyond this point
  10.  
  11. TMPFILE=$(mktemp /tmp/email2cdb.XXXXXXXXXX)
  12.  
  13. [ -d "$(dirname $OUTPUTFILE)" ] || {
  14.     echo "directory for OUTPUTFILE $OUTPUTFILE does not exists"
  15.     exit 3
  16. }
  17.  
  18. [ -f "$TMPFILE" ] && rm $TMPFILE
  19. touch $TMPFILE || {
  20.     echo "can not create $TMPFILE"
  21.     exit 9
  22. }
  23.  
  24. #paranoia strikes again:
  25. #chmod og-r $TMPFILE
  26.  
  27. #list all email boxes:
  28. cat $XMAILROOT/mailusers.tab \
  29.     | sed ‘s/"//g’ \
  30.     | awk ‘{print $2 "@" $1 "\t" $2 "@" $1}’ \
  31.     | sed ‘s/^*//’ \
  32.     | sed ‘s/*//’ >> $TMPFILE
  33.  
  34. #list aliases
  35. cat $XMAILROOT/aliases.tab \
  36.     | sed ‘s/"//g’ \
  37.     | awk ‘{print $2 "@" $1 "\t" $3 "@" $1}’ \
  38.     | sed ‘s/^*//’ \
  39.     | sed ‘s/*//’ >> $TMPFILE
  40.  
  41. #create cdb file
  42. cdb -cm $CDBOPTIONS  $OUTPUTFILE $TMPFILE || {
  43.     echo "can not create cdb file $OUTPUTFILE FROM $TMPFILE"
  44.     echo "WARNING: I did not remove $TMPFILE for debug purposes"
  45.     exit 9
  46. }
  47.  
  48. #cleanup:
  49. rm $TMPFILE
  50. exit 0
Categorieën:Linux Tips & Trics Tags:

KDE dialog for crypysetup

1 oktober 2007 Reacties uit

Here is a bash script that uses kdialog to present a password prompt and tries to mount a crypt device. It interacts with the (k)ubuntu “cryptsetup” package.

  1.  
  2. #!/bin/bash
  3. if [ -r /lib/cryptsetup/cryptdisks.functions ]; then
  4.   . /lib/cryptsetup/cryptdisks.functions
  5. else
  6.   kdialog –title $(basename $0) –error "/lib/cryptsetup/cryptdisks.functions not found"
  7.   exit 1
  8. fi
  9.  
  10. crypt_create (){
  11.   DLG_TITLE="Cryptsetup Dialog"
  12.   mountpoint=$(grep $MAPPER/$1 /etc/fstab | awk ‘{FS=" "}{print $2}’)
  13.   sudo cryptsetup status $1 > /dev/null
  14.   if [ $? -ne 0 ]; then
  15.     pwd=$(kdialog –title "$DLG_TITLE" –password "mapping $1 to device <$2>
  16.  
  17. Enter passphrase:")
  18.     if [ $? -ne 0 ]; then return 3; fi
  19.     if [ "$pwd" == "" ]; then
  20.       kdialog –title "$DLG_TITLE" –warningyesno "empty password, try again?" && {
  21.         crypt_create $1 $2
  22.         return 2
  23.       }
  24.     fi
  25.     echo "$pwd" | sudo cryptsetup create $1 $2
  26.     mount $mountpoint 2&>/dev/null|| {
  27.       sudo cryptsetup remove $1
  28.       kdialog –title "$DLG_TITLE" –warningyesno "cryptsetup create <$1> <$2> failed, try again?" && {
  29.         crypt_create $1 $2
  30.         return 2
  31.       }
  32.       return 0
  33.     }
  34.   else
  35.     if [ -z $3 ]; then
  36.       kdialog –yesno "$MAPPER/$CRYPT_NAME is active, do you want to deactivate?" && {
  37.         umount $mountpoint
  38.         sudo cryptsetup remove $1
  39.       }
  40.     fi
  41.   fi
  42.   return 1 #cryptdevice already setup
  43. }
  44.  
  45. if [ -r $TABFILE ]; then
  46.   grep -Ev "^#" $TABFILE | while read line; do
  47.     cryptname=$(echo $line | awk ‘{print $1}’)
  48.     cryptdevice=$(echo $line | awk ‘{print $2}’)
  49.     crypt_create $cryptname $cryptdevice $1
  50.   done
  51.   exit 0
  52. else
  53.   kdialog –title $(basename $0) –error "$TABFILE not readable"
  54.   exit 2
  55. fi
  56.