Postfix Satellite configuration: Remote SMTP with auth

November 1st, 2010

If you have ever run into the problem that your computer will not send e-mails directly, then this might help.

Install Postfix and configure it as a satellite server. This was done on a Ubuntu desktop installation, so I don’t know what Fedora and co. will say.

In the /etc/postfix/main.cf file add or modify the following lines:

relayhost = smtp.gateway.ch
smtp_sasl_auth_enable = yes
smtpd_tls_auth_only = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

This configures postfix to relay all e-mails over the defined host. Now the sasl_passwd file must be created with the credentials for the SMTP gateway:

smtp.gateway.ch user@gateway.ch:password

Now create the map of the password file and reload postfix:

sudo postmap /etc/postfix/sasl_passwd
sudo /etc/init.d/postfix reload

Test the configuration by sending a test e-mail:

echo -e "From: someone@somewhere.ch\nTo: some@otherplace.com\nSubject: Hello World\n\Body: \nHello beautiful world" | sendmail -t

And see what postfix said:

tail /var/log/mail.info

Have fun!

Makefile to compile C code

October 2nd, 2010

During my phases where I learn to write in C, I don’t want to keep creating new Makefiles. Thus after searching all over the net I managed to put together this simple Makefile. It expects your source code to be in ./src and it will put the compiled executables in ./bin

#
# Makefile to compile arbitrary C sources to an executable with the same name
# The source files are in the src/ sub directory
# The compiled executables are in the bin/ sub directory
#

# $@ is automatic variable that holds name of target
# $< is automatic variable that holds the name of the prerequisite

# defines the sub directory in which the sources are found
SRC_PATH=./src/
# defines the sub directory in which the executables are compiled to
BIN_PATH=./bin/

# tells make to search in $(SRC_PATH) for the .c files
VPATH = src:$(SRC_PATH)

# defines the name of the executables which are to be compiled
EXECUTABLES= $(patsubst $(SRC_PATH)%.c,%,$(shell ls $(SRC_PATH)*.c))

# default target which prepares the bin/ sub directory, and initiates the compilation
all: prepare $(EXECUTABLES)

# the target which is expanded to compile each found C source file
$(EXECUTABLES): %: %.c
	gcc $< -lm -o $(BIN_PATH)$@

# declare phony targets
.PHONY: prepare clean

# create the $(BIN_PATH) sub directory
prepare:
	mkdir -p $(BIN_PATH)
# remote the $(BIN_PATH) subdirectory
clean:
	rm -rf $(BIN_PATH)

Adding new LaTeX packages and styles

September 22nd, 2010

This is a quick explanation on how to install new LaTeX styles so that you can use them, but without having to change your system.

  • First download a style from CTAN
  • Then unpack the zip somewhere in your home folder
  • Copy the styles/packages to ~/texmf/tex
  • Run the command mktexlsr or texhash
  • Use the package and it should work

This helped me: StackOverflow

Ubuntu Netboot

August 27th, 2010

Notes on getting Ubuntu netboot to work so that I don’t have to burn any CD’s

This document expects a DHCP server to be available in the network

Install tftp

sudo aptitude install tftpd-hpa tftp-hpa

Get netboot files:

cd /var/lib/tftpboot
sudo wget -r -nH -np --cut-dirs=8 http://archive.ubuntu.com/\
ubuntu/dists/maverick/main/installer-amd64/\
current/images/netboot
find ./ -name "index.*" | sudo xargs rm

Add the following to the DHCP subnet configuration:

next-server 10.0.0.68;
filename "pxelinux.0";

Now normal netboot should work.

If one wants to have liveCD, then carry on by installing NFS-Server:

sudo aptitude install nfs-kernel-server

Add export for the livecd in /etc/exports:

/var/lib/tftpboot/maverick 10.0.0.0/255.255.255.0(async,no_root_squash,no_subtree_check,ro)

Mount and copy liveCD contents to exported NFS share:

sudo mount -o loop /tmp/maverick-desktop-amd64.iso /mnt
sudo cp -ar /mnt/* /var/lib/tftpboot/maverick/

Add a new menu entry in ubuntu-installer/amd64/boot-screens/rqtxt.cfg

label maverickLiveCD
menu label ^Live CD
kernel maverick/casper/vmlinuz
append vga=788 boot=casper netboot=nfs \
nfsroot=10.0.0.68/var/lib/tftpboot/maverick initrd=maverick/casper/initrd.lz --

Restart NFS:

sudo /etc/init.d/nfs-kernel-server reload

If problems arise, try using the following boot append line:

append file=/var/lib/tftpboot/maverick/preseed/ubuntu.seed vga=788 \
boot=casper root=/dev/nfs netboot=nfs \
nfsroot=10.0.0.68:/var/lib/tftpboot/maverick initrd=maverick/casper/initrd.lz --

VirtualBox resolution problems in a headless environment

August 16th, 2010

In certain cases running a VirtualBox VM in a headless linux environment can lead to a Windows XP having an undesired resolution.

I fixed this using the following two commands:

Global command:
VBoxManage setextradata global GUI/MaxGuestResolution 1920,1200

For a running VM:
VBoxManage controlvm "remote" setvideomodehint 1920 1200 24

I found the resolution in this forum:
VirtualBox Forums

aptitude search vs apt-cache search

July 7th, 2010

Over the years I have grown used to the fact that when I search for a package on a debian based distro, then I use:
apt-cache search foo bar
The result was a list of all the packages which had the text ‘foo’ and ‘bar’ in the description.

Lately it has been discouraged to use apt-get and apt-cache, but one should rather use aptitude as this tool is more powerful.

It is more powerful, but it does not behave the same. So the following command:
aptitude search foo bar
would return any result where either ‘foo’ or ‘bar’ was in the package name, not the description.

Since I have gotten used to apt-cache way this is how I do it with aptitude:
aptitude search "~dfoo bar"

But! This command does not check package names. Package names are with ~n. Maybe someone out there can explain how I can combine the two correctly?

Debugging And Logging Java RMI Calls

June 15th, 2010

If you ever need to debug Java RMI, then add these properties to the VM configuration:

-Djava.rmi.server.logCalls=true
-Dsun.rmi.server.logLevel=VERBOSE
-Dsun.rmi.client.logCalls=true
-Dsun.rmi.transport.tcp.logLevel=VERBOSE

Determining the base directory of a bash script

May 9th, 2010

While writing bash scripts, I find it a good idea to put reusable functions into their own scripts and then source them into other scripts.

This means that one must use the source /file/to/source call to load these files. To be able to do this, the bash script must know where the scripts to source are. To not have to hardwire this into the script, I just have the requirement, that the script must be in the same directory as the script itself.

The following code shows how one can find the base directory, with out using any external commands and it should work with out regards to how the script is called:

SCRIPT_NAME="${0##*/}"
SCRIPT_DIR="${0%/*}"

# if the script was started from the base directory, then the
# expansion returns a period
if test "$SCRIPT_DIR" == "." ; then
  SCRIPT_DIR="$PWD"
# if the script was not called with an absolute path, then we need to add the
# current working directory to the relative path of the script
elif test "${SCRIPT_DIR:0:1}" != "/" ; then
  SCRIPT_DIR="$PWD/$SCRIPT_DIR"
fi

# now we can source our other scripts
source $SCRIPT_DIR/logger.sh

Ubuntu 10.04 and Lucid Lynx: No icons in menu or buttons

May 6th, 2010

For the Ubuntu 10.04 Lucid Lynx, the developers decided to remove the Interface tab in System -> Preferences -> Appearance.

What made them do that I can not fathom. Yet there is (still) an option to put the icons back.

You can put it back for all new users by adding the following two lines to /usr/share/gconf/defaults/10_libgnome2-common:

/desktop/gnome/interface/menus_have_icons       true
/desktop/gnome/interface/buttons_have_icons      true

And you can activate it again for your current user by using these two commands:

gconftool-2 --type bool --set /desktop/gnome/interface/menus_have_icons        true
gconftool-2 --type bool --set /desktop/gnome/interface/buttons_have_icons       true

I just really hope support for this isn’t removed altogether in new Gnome versions

Courtesy of the following two ubuntu forum threads:
No icons in context menu for 9.10
GTK menus missing icons

Nerd Test

April 20th, 2010

I just had to do it:


I am nerdier than 89% of all people. Are you a nerd? Click here to take the Nerd Test, get geeky images and jokes, and write on the nerd forum!

Update 10 January 2011:
Well, I took the test again and this is now my result:

I am nerdier than 93% of all people. Are you a nerd? Click here to take the Nerd Test, get geeky images and jokes, and talk on the nerd forum!