Slow start-up times for jetty and the lack of entropy

September 1st, 2015

The Google App Engine offers a maven project that uses jetty to launch a local test server. This is convenient and works quite well, but jetty suffers from one problem when running in a virtual machine: It needs a full entropy pool to start-up (probably to generate encryption keys?). The problem is that virtual machines (especially server-only machines) fill their entropy pool slowly (because they have no input from keystrokes etc.).
This means that jetty will start-up immediately after booting the VM and will subsequently take longer and longer to start (I had to wait up to 5 minutes to start the VM). This is of course horrible when you tweak your source code and just want to “quickly” test your changes.

A simple solution is to fake the entropy with rng-tools (as suggested there: [1] and [2]). Just apt-get install rng-tools, edit /etc/default/rng-tools by adding a line that says HRNGDEVICE=/dev/urandom and start rng-tools with /etc/init.d/rng-tools start.

This will make jetty start almost instantly.

Please note, that this hack fix compromises your system’s security. Do not generate any encryption keys on that machine. This should only be done on development virtual machines and never on production systems.

Compiling gstreamer from source

March 13th, 2014

I have to compile gstreamer on different computers and thus wrote this little script to fetch the sources and compile them. Note that you need to install dependencies first. gstreamer will usually compile when they are not present, but will then not work properly.

You can download it here: gstreamer_build.sh

#!/bin/bash
 
# you might need these additonal packages:
# apt-get install  bison flex  libusb-1.0-0-dev libgudev-1.0-dev libxv-dev
 
# from http://lists.freedesktop.org/archives/gstreamer-openmax/2013-March/000724.html
# apt-get install build-essential autotools-dev automake autoconf libtool autopoint libxml2-dev zlib1g-dev libglib2.0-dev pkg-config bison flex python
# apt-get install libasound2-dev libgudev-1.0-dev libxt-dev libvorbis-dev libcdparanoia-dev libpango1.0-dev libtheora-dev libvisual-0.4-dev iso-codes libgtk-3-dev libraw1394-dev libiec61883-dev libavc1394-dev libv4l-dev libcairo2-dev libcaca-dev libspeex-dev libpng-dev libshout3-dev libjpeg-dev libaa1-dev libflac-dev libdv4-dev libtag1-dev libwavpack-dev libpulse-dev libsoup2.4-dev libbz2-dev libcdaudio-dev libdc1394-22-dev ladspa-sdk libass-dev libcurl4-gnutls-dev libdca-dev libdirac-dev libdvdnav-dev libexempi-dev libexif-dev libfaad-dev libgme-dev libgsm1-dev libiptcdata0-dev libkate-dev libmimic-dev libmms-dev libmodplug-dev libmpcdec-dev libofa0-dev libopus-dev librsvg2-dev librtmp-dev libschroedinger-dev libslv2-dev libsndfile1-dev libsoundtouch-dev libspandsp-dev libx11-dev libxvidcore-dev libzbar-dev libzvbi-dev liba52-0.7.4-dev libcdio-dev libdvdread-dev libmad0-dev libmp3lame-dev libmpeg2-4-dev libopencore-amrnb-dev libopencore-amrwb-dev libsidplay1-dev libtwolame-dev libx264-dev
# source: http://gstreamer.freedesktop.org/wiki/HowToCompileForEmbedded
#
# to build with libav support
# apt-get install libavutil-dev
# apt-get install yasm
#
# and for our stream.sh script:
# apt-get install  inotify-tools
#
# For reference: there is also an ppa, but it currently seems to only offer gstreamer 1.0, 
# which does not include uvch264src
# add-apt-repository ppa:gstreamer-developers/ppa
# apt-get update
# apt-get install gstreamer1.0*
 
 
 
SOURCE=$HOME/gstreamer_sources
BUILD=$HOME/gstreamer_build
if [ ! -d "$SOURCE" ]; then
	mkdir $SOURCE
fi
if [ ! -d "$BUILD" ]; then
	mkdir $BUILD
fi
 
cd $SOURCE
wget http://gstreamer.freedesktop.org/src/gstreamer/gstreamer-1.2.0.tar.xz
tar -xJf gstreamer-1.2.0.tar.xz
wget http://gstreamer.freedesktop.org/src/orc/orc-0.4.18.tar.gz
tar -xzf orc-0.4.18.tar.gz
wget http://gstreamer.freedesktop.org/src/gst-plugins-base/gst-plugins-base-1.2.0.tar.xz
tar -xJf gst-plugins-base-1.2.0.tar.xz
wget http://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-1.2.0.tar.xz
tar -xJf gst-plugins-good-1.2.0.tar.xz
wget http://gstreamer.freedesktop.org/src/gst-plugins-ugly/gst-plugins-ugly-1.2.0.tar.xz
tar -xJf gst-plugins-ugly-1.2.0.tar.xz
wget http://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-1.2.0.tar.xz
tar -xJf gst-plugins-bad-1.2.0.tar.xz
wget http://gstreamer.freedesktop.org/src/gst-libav/gst-libav-1.2.0.tar.xz
tar -xJf gst-libav-1.2.0.tar.xz
 
cd gstreamer-1.2.0
./configure --prefix=$BUILD
make -j2
make install
 
cd ../orc-0.4.18
./configure --prefix=$BUILD 
make -j2
make install
 
cd ../gst-plugins-base-1.2.0
export PKG_CONFIG_PATH=$BUILD/lib/pkgconfig:$PKG_CONFIG_PATH; ./configure --prefix=$BUILD  --enable-orc --with-x 
make -j2
make install 
 
cd ../gst-plugins-good-1.2.0
export PKG_CONFIG_PATH=$BUILD/lib/pkgconfig:$PKG_CONFIG_PATH; ./configure  --prefix=$BUILD  --enable-orc --with-libv4l2 --with-x
make -j2
make install 
 
cd ../gst-plugins-ugly-1.2.0
export PKG_CONFIG_PATH=$BUILD/lib/pkgconfig:$PKG_CONFIG_PATH; ./configure  --prefix=$BUILD  --enable-orc 
make -j2
make install
 
cd ../gst-plugins-bad-1.2.0
export PKG_CONFIG_PATH=$BUILD/lib/pkgconfig:$PKG_CONFIG_PATH; ./configure  --prefix=$BUILD  --enable-orc
make -j2
make install
 
cd ../gst-libav-1.2.0
export PKG_CONFIG_PATH=$BUILD/lib/pkgconfig:$PKG_CONFIG_PATH; ./configure  --prefix=$BUILD  --enable-orc
make -j2
make install
 
 
echo
echo "GStreamer 1.2.0 installed sucessfully!"
echo
 
# to completly remove gstreamer, simpely delete the two directories:
# rm -rf $SOURCE
# rm -rf $BUILD
 
# to use this version of gstreamer, add it to your PATH:
# echo -e "\n\n#Path for a local version of gstreamer\nPATH=\"$BUILD/bin:\$PATH\"" >> $HOME/.profile

Quick overview over nearby wireless lan hotspots

March 6th, 2014

Here is a useful little command to get a quick overview over nearby hotspots:

 iw dev wlan0 scan  | grep 'SSID\|signal\|primary channel'
        SSID: 5g_station
                 * primary channel: 36
        signal: -42.00 dBm
        SSID: 2g_station
                 * primary channel: 6
        signal: -72.00 dBm

vimrc for latex

March 5th, 2014

Ah yes – finally – blog post time again :)

Since I am currently writing a lot of latex with vim I thought I backup share my ~/.gvimrc on my blog:

1
2
3
4
5
6
7
8
9
:setlocal spell spelllang=en_us " enable spell checking (Ctrl x + s for suggestions)
:set wrap			" wrap too long lines
:set guioptions-=m 		" disable menu bar
:set guioptions-=T		" disable toolbar
:set spellfile=/path/to/spellfile-en.utf-8.add
:set colorcolumn=80		" show a red bar in column 80
:set textwidth=80		" automatically break after column 80
:set encoding=utf-8  		" The encoding displayed.
:set fileencoding=utf-8  	" The encoding written to file. Use file -bi  <file> to verify

Puppet

August 7th, 2012

I started to roll out puppet to manage our servers at work and have to say I am impressed. It really changed the way I think about managing systems and is so much cleaner and easier to understand than the ‘traditional’ way.
Just being able to automate often repeated steps like enabling LDAP access or distributing config files makes puppet worthwhile. That the configuration is self documenting and versioned makes puppet priceless.
I will not post a tutorial here, just links to a few I found useful:

If you have to manage more than two or three servers, read up on puppet and consider using it (or any other configuration management tool).  It will be worth the time learning it.

First updates with unattended-upgrades

August 5th, 2012

Running it for the first time, it seams to work well. It upgraded the packages and send me an e-mail. Here are the config files I used:

/etc/apt/apt.conf.d/02periodic:

1
2
3
4
5
6
APT::Periodic::Enable "1";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "5";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::RandomSleep "3600";

/etc/apt/apt.conf.d/50unattended-upgrades:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Automatically upgrade packages from these (origin, archive) pairs
Unattended-Upgrade::Allowed-Origins {
    "${distro_id} stable";
    "${distro_id} ${distro_codename}-security";
//  "${distro_id} ${distro_codename}-updates";
//  "${distro_id} ${distro_codename}-proposed-updates";
};
 
// List of packages to not update
Unattended-Upgrade::Package-Blacklist {
//  "vim";
//  "libc6";
//  "libc6-dev";
//  "libc6-i686";
};
 
// Send email to this address for problems or packages upgrades
// If empty or unset then no email is sent, make sure that you
// have a working mail setup on your system. The package 'mailx'
// must be installed or anything that provides /usr/bin/mail.
Unattended-Upgrade::Mail "root@localhost";
 
// Do automatic removal of new unused dependencies after the upgrade
// (equivalent to apt-get autoremove)
//Unattended-Upgrade::Remove-Unused-Dependencies "false";
 
// Automatically reboot *WITHOUT CONFIRMATION* if a
// the file /var/run/reboot-required is found after the upgrade
Unattended-Upgrade::Automatic-Reboot "false";
 
// Use apt bandwidth limit feature, this example limits the download
// speed to 70kb/sec
//Acquire::http::Dl-Limit "70";

And here is the kind of report e-mail you get:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Unattended upgrade returned: True
 
Packages that are upgraded:
 bind9-host dnsutils isc-dhcp-client isc-dhcp-common libbind9-60 
 libdns69 libgssapi-krb5-2 libisc62 libisccc60 libisccfg62 
 libk5crypto3 libkrb5-3 libkrb5support0 liblwres60 libxml2 
 
Package installation log:
(Reading database ... 23943 files and directories currently installed.)
Preparing to replace isc-dhcp-client 4.1.1-P1-15+squeeze3 (using .../isc-dhcp-client_4.1.1-P1-15+squeeze6_amd64.deb) ...
Unpacking replacement isc-dhcp-client ...
Preparing to replace isc-dhcp-common 4.1.1-P1-15+squeeze3 (using .../isc-dhcp-common_4.1.1-P1-15+squeeze6_amd64.deb) ...
Unpacking replacement isc-dhcp-common ...
Preparing to replace libk5crypto3 1.8.3+dfsg-4squeeze5 (using .../libk5crypto3_1.8.3+dfsg-4squeeze6_amd64.deb) ...
Unpacking replacement libk5crypto3 ...
Preparing to replace libgssapi-krb5-2 1.8.3+dfsg-4squeeze5 (using .../libgssapi-krb5-2_1.8.3+dfsg-4squeeze6_amd64.deb) ...
Unpacking replacement libgssapi-krb5-2 ...
Preparing to replace libkrb5-3 1.8.3+dfsg-4squeeze5 (using .../libkrb5-3_1.8.3+dfsg-4squeeze6_amd64.deb) ...
Unpacking replacement libkrb5-3 ...
Preparing to replace libkrb5support0 1.8.3+dfsg-4squeeze5 (using .../libkrb5support0_1.8.3+dfsg-4squeeze6_amd64.deb) ...
Unpacking replacement libkrb5support0 ...
Preparing to replace libxml2 2.7.8.dfsg-2+squeeze4 (using .../libxml2_2.7.8.dfsg-2+squeeze5_amd64.deb) ...
Unpacking replacement libxml2 ...
Preparing to replace bind9-host 1:9.7.3.dfsg-1~squeeze5 (using .../bind9-host_1%3a9.7.3.dfsg-1~squeeze6_amd64.deb) ...
Unpacking replacement bind9-host ...
Preparing to replace dnsutils 1:9.7.3.dfsg-1~squeeze5 (using .../dnsutils_1%3a9.7.3.dfsg-1~squeeze6_amd64.deb) ...
Unpacking replacement dnsutils ...
Preparing to replace libisc62 1:9.7.3.dfsg-1~squeeze5 (using .../libisc62_1%3a9.7.3.dfsg-1~squeeze6_amd64.deb) ...
Unpacking replacement libisc62 ...
Preparing to replace libdns69 1:9.7.3.dfsg-1~squeeze5 (using .../libdns69_1%3a9.7.3.dfsg-1~squeeze6_amd64.deb) ...
Unpacking replacement libdns69 ...
Preparing to replace libisccc60 1:9.7.3.dfsg-1~squeeze5 (using .../libisccc60_1%3a9.7.3.dfsg-1~squeeze6_amd64.deb) ...
Unpacking replacement libisccc60 ...
Preparing to replace libisccfg62 1:9.7.3.dfsg-1~squeeze5 (using .../libisccfg62_1%3a9.7.3.dfsg-1~squeeze6_amd64.deb) ...
Unpacking replacement libisccfg62 ...
Preparing to replace liblwres60 1:9.7.3.dfsg-1~squeeze5 (using .../liblwres60_1%3a9.7.3.dfsg-1~squeeze6_amd64.deb) ...
Unpacking replacement liblwres60 ...
Preparing to replace libbind9-60 1:9.7.3.dfsg-1~squeeze5 (using .../libbind9-60_1%3a9.7.3.dfsg-1~squeeze6_amd64.deb) ...
Unpacking replacement libbind9-60 ...
Processing triggers for man-db ...
Setting up isc-dhcp-common (4.1.1-P1-15+squeeze6) ...
Setting up isc-dhcp-client (4.1.1-P1-15+squeeze6) ...
Setting up libkrb5support0 (1.8.3+dfsg-4squeeze6) ...
Setting up libk5crypto3 (1.8.3+dfsg-4squeeze6) ...
Setting up libkrb5-3 (1.8.3+dfsg-4squeeze6) ...
Setting up libgssapi-krb5-2 (1.8.3+dfsg-4squeeze6) ...
Setting up libxml2 (2.7.8.dfsg-2+squeeze5) ...
Setting up libisc62 (1:9.7.3.dfsg-1~squeeze6) ...
Setting up libdns69 (1:9.7.3.dfsg-1~squeeze6) ...
Setting up libisccc60 (1:9.7.3.dfsg-1~squeeze6) ...
Setting up libisccfg62 (1:9.7.3.dfsg-1~squeeze6) ...
Setting up libbind9-60 (1:9.7.3.dfsg-1~squeeze6) ...
Setting up liblwres60 (1:9.7.3.dfsg-1~squeeze6) ...
Setting up bind9-host (1:9.7.3.dfsg-1~squeeze6) ...
Setting up dnsutils (1:9.7.3.dfsg-1~squeeze6) ...
 
 
Unattended-upgrades log:
Initial blacklisted packages: 
Starting unattended upgrades script
Allowed origins are: ["('Debian', 'stable')", "('Debian', 'squeeze-security')"]
Packages that are upgraded: bind9-host dnsutils isc-dhcp-client isc-dhcp-common libbind9-60 libdns69 libgssapi-krb5-2 libisc62 libisccc60 libisccfg62 libk5crypto3 libkrb5-3 libkrb5support0 liblwres60 libxml2
Writing dpkg log to '/var/log/unattended-upgrades/unattended-upgrades-dpkg_2012-08-05_06:33:13.547920.log'
All upgrades installed

If I could just shake off the feeling that one day a broken update will get pushed into the repositories and take down all the servers at once ;)

wordpress facebook test post

August 4th, 2012

This is a simple test post to check if I can directly post from my blog to facebook…

Connecting facebook and wordpress

August 4th, 2012

I finally got around to connect my blog to my facebook account and run into trouble enabling a developer account. To use the wordpress facebook plugin you need to create a facebook app that can post to your facebook account.  To create the app you need a facebook developer account. So far so simple. The tricky part is, that you need to link your facebook account to a mobile phone. In my case the confirmation code was simply wrong and I could not get it to work. Different solutions are reported here: http://main.alincristianjoita.com/archives/248

In my case replying with “F” to the number that send me the wrong code performed some magic to send me a new (correct) code. The SMS with the correct code was in German while the SMS with the wrong code were in English.

So I assume facebook has some problems when people do not use facebook with their native language).

 

Automatic Updates on debian stable

August 4th, 2012

To automate the installations of updates on our servers I am experimenting with the package unattended-updates. Good introductions can be found here:

I have to admit that I am a bit uneasy, but in the past year of applying updates by hand nothing ever broke. So I assume that this should not cause any problems. At least it will cut down the spam flood of nagios notices when updates become available :)

 

A simple wxPython image viewer

December 11th, 2011

For a project I needed to display an image in a GUI. As I have used wxPython in the past, I choose to use it again. Although the toolkit is extremely simple and easy to use, I still needed some time to write this simple image viewer. The problem was, that I expected to be able to attach a wx.Image to a Sizer. It took me sometime to figure out, that I needed to turn it into a wx.StaticBitmap first.

Here is a very small and simple image viewer with wxPython, may it be of help to the internet ;)

#!/usr/bin/env python
import wx
 
class FooApp(wx.App):
 
	# called when the 'change' button is pressed
	def changeImage(self,event):
		img = wx.Image("foo.jpg")
		self.image = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(img))
 
	def __init__(self):
		# setup code for the window
		wx.App.__init__(self)
		self.frame = wx.Frame(None, title='Demo')
		self.panel = wx.Panel(self.frame)
 
		# load an image
		img = wx.Image("bla.jpg")
		self.image = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(img))
 
		# create a Sizer to hold one (or more) button
		self.buttons = wx.BoxSizer(wx.VERTICAL)
		self.changeButton = wx.Button(self.panel, -1, "Change")
		self.changeButton.Bind(wx.EVT_BUTTON,self.changeImage)
		self.buttons.Add(self.changeButton)
 
		self.mainSizer = wx.BoxSizer(wx.VERTICAL)
		self.mainSizer.Add(self.image)
		self.mainSizer.Add(self.buttons)
 
		# more generic setupcode
		self.panel.SetSizer(self.mainSizer)
		self.mainSizer.Fit(self.frame)
		self.panel.Layout()
		self.frame.Show(True)
 
if __name__ == '__main__':
    app = FooApp()
    app.MainLoop()

Just for the record: here are the websites that helped me write this code: