<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Matt&#039;s Blog</title>
	<atom:link href="http://blog.rueedlinger.ch/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rueedlinger.ch</link>
	<description>sw engineer and mountain / road bike evangelist</description>
	<lastBuildDate>Fri, 31 May 2013 23:09:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Raspberry Pi and Node.JS: Basic Setup</title>
		<link>http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/</link>
		<comments>http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/#comments</comments>
		<pubDate>Sun, 31 Mar 2013 12:12:36 +0000</pubDate>
		<dc:creator>Matthias Rüedlinger</dc:creator>
				<category><![CDATA[NodeJS]]></category>
		<category><![CDATA[Raspberry Pi]]></category>

		<guid isPermaLink="false">http://blog.rueedlinger.ch/?p=1015</guid>
		<description><![CDATA[I hade some time to play around with my Raspberry Pi. The primary goal was to have a basic setup for Node.JS 0.10.x with Raspbian &#8220;wheezy&#8221; (Hard-float) on a Raspberry Pi. I run in some troubles to install Node.JS on &#8230; <a href="http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I hade some time to play around with my <a href="http://www.raspberrypi.org/">Raspberry Pi</a>. The primary goal was to have a basic setup for <a href="http://nodejs.org/">Node.JS</a> 0.10.x with <a href="http://www.raspbian.org/">Raspbian</a> &#8220;wheezy&#8221; (Hard-float) on a Raspberry Pi.</p>
<p>I run in some troubles to install Node.JS on Raspbian soft-float image and also when you wanted to compile it for yourself you need some time. Luckily there is an ARM binary package for Raspberry Pi (<em>See &#8216;other release files&#8217; on Node.JS download section</em>).</p>
<p>For this tutorial you need:</p>
<ul>
<li><a href="http://www.raspberrypi.org/">Raspberry Pi</a></li>
<li><a href="http://elinux.org/RPi_SD_cards">SD card</a> at least 4GB</li>
<li>HDMI to DVI Converter &#8211; to plug the Raspberry Pi to your monitor</li>
<li>micro usb charger &#8211; for the power supply</li>
<li>Network cable and internet connection</li>
<li><a href="http://nodejs.org/">Node.JS</a> 0.10.x ARM binary package</li>
<li><a href="http://www.raspbian.org/">Raspbian</a> &#8216;wheezy&#8217; hard-float image (2013-02-09)</li>
</ul>
<p><em><strong>Note:</strong> We will use Node.JS 0.10.2 in this tutorial because the ARM binary package for 0.10.3 was not yet available. But I think when the new ARM package is available this tutorial should also work with the new minor release.</em>
</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2013/03/20130328_175044.jpg"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2013/03/20130328_175044.jpg" alt="20130328_175044" width="2560" height="1920" class="alignnone size-full wp-image-1024" /></a></p>
<h2>Install Raspbian on your SD Card</h2>
<p>Download <a href="http://www.raspberrypi.org/downloads">Raspian &#8220;wheezy&#8221; (hard-float, 2013-02-09-wheezy-raspbian)</a> and install it on your SD card. There are plenty of tutorials which shows you how to install Raspbian on your SD card. Have a look at the following tutorials how you can install Raspbian on your SD card.
</p>
<ul>
<li><a href="http://www.raspberrypi.org/quick-start-guide">Raspberry Pi Quick start guide</a></li>
<li><a href="http://lifehacker.com/5976912/a-beginners-guide-to-diying-with-the-raspberry-pi">A Beginner’s Guide to DIYing with the Raspberry Pi</a></li>
</ul>
<p>
<em><strong>Note</strong>: You have to use the Raspbian hard-float image. With the soft-float image the Node.JS ARM binary will not work.</em>
</p>
<h2>Configure your Raspberry Pi</h2>
<p>
Plug in your usb micro charger and Rasberry Pi will boot up and display the<br />
<a href="http://elinux.org/RPi_raspi-config">raspi-config</a> dialog.
</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2013/03/raspi-config.jpg"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2013/03/raspi-config.jpg" alt="raspi-config" width="709" height="512" class="alignnone size-full wp-image-1032" /></a></p>
<p>These are the configuration steps you should do with <em>&#8216;raspi-config&#8217;</em> after the first time you start your Raspberry Pi:</p>
<ul>
<li><strong>expand_rootfs</strong> &#8211; select expand_rootfs to expand the root partition to fill out the  whole SD card</li>
<li><strong>memory_split</strong> &#8211; we reduce the GPU to the minimum (16mb), because we will not start intensive graphical tasks.</li>
<li><strong>change_pass</strong> &#8211; change password for &#8216;pi&#8217; user. The user &#8216;pi&#8217; is the preconfigured user in Raspbian</li>
<li><strong>ssh</strong> &#8211; enable the ssh server, so that we can use ssh to log in from remote.</li>
<li>You should also adapt the keyboard, timezone and locale to your needs. When you are finished select <strong>finish</strong> to end the configuration.</li>
</ul>
<p>After the configuration you need to restart your system, so that the resizing of the root partition and memory split will work.</p>
<pre>
sudo reboot
</pre>
<p>You can always change your settings again with <em>&#8216;raspi-config&#8217;</em>.</p>
<pre>
sudo raspi-config
</pre>
<p>After the restart, login in with the user &#8216;pi&#8217; and the new password you have choosen. Now we need to update our system with <em>&#8216;apt-get&#8217;</em> our package manager.</p>
<pre>
sudo apt-get update
sudo apt-get upgrade
</pre>
<p>With no further network changes your Raspberry Pi will use DHCP to get a dynamic IP adress. So we are going to change this to a fixed IP adress. Because we will use our system as Node.JS server and this is quite simpler with a fixed IP adress. You can also work with a dynamic IP adress and just skip the following step.</p>
<p>To change the system to a fixed IP adress just open the interface configurartion file. For that we use the preinstalled editor <em>&#8216;nano&#8217;</em>.</p>
<pre>
sudo nano /etc/networks/interfaces
</pre>
<p>Replace the following lines for your network device <em>eth0</em> and just adapt the settings to your network (e.g. IP, gateway, dns, etc.) configuration.</p>
<pre>
iface eth0 inet static
address 10.0.0.40
netmask 255.255.255.0
gateway 10.0.0.1
nameserver 10.0.0.1
</pre>
<p>After the changes in the network configuration file just stop and start your network device with <em>&#8216;ifdown&#8217;</em> and <em>&#8216;ifup&#8217;</em>.</p>
<pre>
sudo ifdown eth0
sudo ifup eth0
</pre>
<p>Yo can try now from a remote system to connect with the user &#8216;pi&#8217; over SSH to our Raspberry Pi.
</p>
<pre>
ssh pi@10.0.0.40
</pre>
<h2>Installing Node.JS</h2>
<p>We will download the ARM binary package from Node.JS and create the directory <em>/opt/node</em> where we want Node.JS installed. We will not place Node.JS in <em>&#8216;/usr/local&#8217;</em>, instead we use a separate directory for Node.JS, this way it is much easier to update a manually installed package.</p>
<pre>
sudo mkdir /opt/node
</pre>
<p><p>The next step is to dowload the Node.JS ARM binary package, unpack it and copy the content to our node directory <em>/opt/node</em>.</p>
<pre>
&#119;&#103;et http://nodejs.org/dist/v0.10.2/node-v0.10.2-linux-arm-pi.tar.gz
tar xvzf node-v0.10.2-linux-arm-pi.tar.gz
sudo cp -r node-v0.10.2-linux-arm-pi/* /opt/node

</pre>
<p>Finally we have to add Node.JS to our path variable. For that you have to edit the <em>&#8216;/etc/profile&#8217;</em> configuration file.
</p>
<pre>
nano /etc/profile
</pre>
<p>Add the following lines to the configuration file before the <em>&#8216;export&#8217;</em> command.</p>
<pre>
...
NODE_JS_HOME="/opt/node"
PATH="$PATH:$NODE_JS_HOME/bin"
export PATH
...
</pre>
<p>Yo need now to logout and log in again, so that the changed path variable will work.</p>
<pre>
logout
</pre>
<h2>Configure Node.JS</h2>
<p>We need now a start script for Node.JS. Our script will start the Node.JS with the user <em>&#8216;pi&#8217;</em> and look for a <em>server.js</em> file in the <em>/home/app</em> directory. The output stream from Node.JS will be stored in the file <em>nodejs.log</em>. Just create the file <em>nodejs.sh</em> in your current directory with the following content:</p>
<pre>
#!/bin/bash

NODE=/opt/node/bin/node
SERVER_JS_FILE=/home/pi/app/server.js
USER=pi
OUT=/home/pi/nodejs.log

case "$1" in

start)
	echo "starting node: $NODE $SERVER_JS_FILE"
	sudo -u $USER $NODE $SERVER_JS_FILE > $OUT 2>$OUT &#038;
	;;

stop)
	killall $NODE
	;;

*)
	echo "usage: $0 (start|stop)"
esac

exit 0
</pre>
<p>
<em><strong>Note</strong>: When yo want to use a <a href="http://www.w3.org/Daemon/User/Installation/PrivilegedPorts.html">privileged port </a>(TCP/IP port numbers below 1024) you have to start the script as root. </em>
</p>
<p>Make the script executable with <em>&#8216;chmod&#8217;</em> and copy it to <em>&#8216;/etc.init.d&#8217;</em>. The last step is  to register the script as service with <em>&#8216;update-rc.d&#8217;</em>. Then our Node.JS server will automatically start up when the Raspberry Pi is powered on.</p>
<pre>
chmod 755 nodejs.sh
sudo cp nodejs.sh /etc/init.d
sudo update-rc.d nodejs.sh defaults
</pre>
<p>The last step is to create a Node.JS <em>server.js</em> file in our <em>/home/pi/app</em> directory. The directory <em>&#8216;/home/pi/app&#8217;</em> will be our Node.JS project directory.</p>
<pre>
mkdir /home/pi/app
</pre>
<p>The <em>&#8216;server.js&#8217;</em> file is just a simple Node.JS server which will listen on port 8080 and display &#8216;Hello World&#8217; and write some output to the console. Just place the following content as <em>&#8216;server.js&#8217;</em> file in directory <em>&#8216;/home/pi/app&#8217;</em>.</p>
<pre>
var http = require('http');

http.createServer(function(req,resp) {
	resp.writeHead(200, {"Content-Type": "text/plain"});
	resp.write("Hello World");
	resp.end();
	
	console.log("sample output to console");

}).listen(8080);
</pre>
<h2>Start Node.JS</h2>
<p>It&#8217;s time to start Node.JS with our start script and see if it all fits together.</p>
<pre>
sudo /etc/init.d/nodejs.sh start
</pre>
<p>Open a browser with the url <em>http://10.0.0.40:8080</em>. You should now see a page which displays <em>&#8216;Hello World&#8217;</em> and the output from the console.log() statement in the <em>/home/pi/node.log</em> file.</p>
<p>To stop Node.JS just enter</p>
<pre>
sudo /etc/init.d/nodejs.sh stop
</pre>
<p>When you want to use <em>&#8216;npm&#8217;</em> or <em>&#8216;node&#8217;</em> as root with sudo you have to add the <em>&#8216;-i&#8217;</em> option, so that the root user&#8217;s environment is acquired. For example when you want to install the package <em>&#8216;forever&#8217;</em> globally with <em>&#8216;npm&#8217;</em>.</p>
<pre>
sudo -i npm install forever -g
</pre>
<h2>Update Node.JS to a new version</h2>
<p>To update Node.JS to a new version just follow the next steps. Also check first if there is an ARM package available.</p>
<p>delete the old version</p>
<pre>
# sudo rm /opt/node -r
</pre>
<p>create new directory</p>
<pre>
# sudo mkdir /opt/node
</pre>
<p>unpack the new version and copy the content to our node.js directory. Replace &#8216;x&#8217; with the new minor version.</p>
<pre>
# tar xvzf node-v0.10.x-linux-arm-pi.tar.gz
# sudo cp -r node-v0.10.x-linux-arm-pi/* /opt/node
</pre>
<p>Check current version</p>
<pre>
# node -v
v0.10.2
</pre>
<p>I hope this tutorial was useful for you and will give you some quick start to play around with Node.JS and Raspberry Pi.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>First steps with responsive web design (RWD) and Twitter Bootstrap</title>
		<link>http://blog.rueedlinger.ch/2013/02/first-steps-with-responsive-web-design-rwd-and-twitter-bootstrap/</link>
		<comments>http://blog.rueedlinger.ch/2013/02/first-steps-with-responsive-web-design-rwd-and-twitter-bootstrap/#comments</comments>
		<pubDate>Tue, 05 Feb 2013 13:09:41 +0000</pubDate>
		<dc:creator>Matthias Rüedlinger</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.rueedlinger.ch/?p=943</guid>
		<description><![CDATA[With Twitter Bootstrap it is very easy to create a responsive web design (RWD). In this short post I show you how you can enable RWD for your web page with Twitter Bootstrap. Download Twitter Bootstrap and place the bootstrap.min.css &#8230; <a href="http://blog.rueedlinger.ch/2013/02/first-steps-with-responsive-web-design-rwd-and-twitter-bootstrap/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>With Twitter Bootstrap it is very easy to create a <a href="http://en.wikipedia.org/wiki/Responsive_web_design">responsive web design (RWD)</a>. In this short post I show you how you can enable <a href="http://en.wikipedia.org/wiki/Responsive_web_design">RWD </a>for your web page with Twitter Bootstrap.</p>
<p><a href="http://twitter.github.com/bootstrap">Download Twitter Bootstrap</a> and place the <b>bootstrap.min.css</b> and <b>bootstrap-responsive.min.css</b> in the css directory. Create an empty file with the name test.html. The content of your directory should look like this.</p>
<pre>
test.html
css --- bootstrap.min.css
     |- bootstrap-responsive.min.css   
</pre>
<p>To use RWD the following <strong>meta tag</strong> and the <strong>bootstrap-responsive.min.css</strong> css file are needed.</p>
<pre>
&lt;meta name="viewport" content="width=device-width, 
       initial-scale=1.0"&gt;
&lt;link href="css/bootstrap-responsive.min.css" 
       rel="stylesheet"&gt;
</pre>
<p>In the <strong>test.html</strong> page are three buttons. One button is shown only for mobile, one for tablets and the last one only for desktops environments. The following example shows the <strong>test.html</strong> file with responsive web design enabled and the three buttons.</p>
<pre>

&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Bootstrap 101 Template&lt;/title&gt;
    &lt;!-- Bootstrap --&gt;
    <b>
    &lt;meta name="viewport" content="width=device-width, 
       initial-scale=1.0"&gt;
    &lt;link href="css/bootstrap-responsive.min.css" 
       rel="stylesheet"&gt;
    &lt;link href="css/bootstrap.min.css" 
       rel="stylesheet" media="screen"&gt;
    </b>
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Hello, world!&lt;/h1&gt;
	
    &lt;button class="btn btn-large btn-primary <b>visible-desktop</b>" 
       type="button"&gt;Desktop&lt;/button&gt;
    &lt;button class="btn btn-large btn-danger <b>visible-tablet</b>" 
       type="button"&gt;Tablet&lt;/button&gt;
    &lt;button class="btn btn-large btn-success <b>visible-phone</b>" 
       type="button"&gt;Mobile&lt;/button&gt;
	
  &lt;/body&gt;
&lt;/html&gt;

</pre>
<p>There are css classes for showing an element for a specific environment (e.g. visible-phone) and to hide it (e.g. hidden-phone).  There are three environments <strong>phone</strong>, <strong>tablet </strong>and <strong>desktop</strong>.</p>
<p>To show the button only for a mobile environment just place the css class <strong>visible-phone</strong> to the button element.</p>
<pre>
&lt;button class="btn btn-large btn-success <b>visible-phone</b>" 
       type="button"&gt;Mobile&lt;/button&gt;
</pre>
<p>To test the page with a mobile or tablet device we can emulate this in chrome with the <a href="https://developers.google.com/chrome-developer-tools/">chrome developer tools</a>. Just open the <a href="http://www.howtogeek.com/113439/how-to-change-your-browsers-user-agent-without-installing-any-extensions/">settings in chrome developer tools</a> and pick the right user agent and device metrics (e.g. Android 4.0.2 &#8211; Galaxy Nexus).</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2013/02/chrome_developer_tools_ua.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2013/02/chrome_developer_tools_ua.png" alt="chrome_developer_tools_ua" width="733" height="339" class="alignnone size-full wp-image-959" /></a></p>
<p>When we visit our html page with a mobile device or emulate a mobile device with the chrome developer tools, then the right button should be displayed.
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2013/02/mobile.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2013/02/mobile.png" alt="rdw_view_mobile_Desktop" width="562" height="241" class="alignnone size-full wp-image-987" /></a></p>
<p>As you can see working with responsive design and Twitter Bootstrap is straightforward. For more details about responsive web design (RWD) and Twitter Bootstrap have a look at <a href="http://twitter.github.com/bootstrap/scaffolding.html#responsive">http://twitter.github.com/bootstrap/scaffolding.html#responsive</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rueedlinger.ch/2013/02/first-steps-with-responsive-web-design-rwd-and-twitter-bootstrap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build your own private cloud solution with Ubuntu Server and VirtualBox</title>
		<link>http://blog.rueedlinger.ch/2012/10/build-your-own-private-cloud-solution-with-ubuntu-server-and-virtualbox/</link>
		<comments>http://blog.rueedlinger.ch/2012/10/build-your-own-private-cloud-solution-with-ubuntu-server-and-virtualbox/#comments</comments>
		<pubDate>Mon, 01 Oct 2012 16:42:30 +0000</pubDate>
		<dc:creator>Matthias Rüedlinger</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://blog.rueedlinger.ch/?p=545</guid>
		<description><![CDATA[In this example we use VirtualBox 4.2 and Ubuntu Server 12.04 to host our own virtual servers. After playing with VirtualBox I thought it would be a good idea to host some virtual servers with VirtualBox in headless mode. After &#8230; <a href="http://blog.rueedlinger.ch/2012/10/build-your-own-private-cloud-solution-with-ubuntu-server-and-virtualbox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>
In this example we use VirtualBox 4.2 and Ubuntu Server 12.04 to host our own virtual servers. After playing with VirtualBox I thought it would be a good idea to host some virtual servers with VirtualBox in headless mode. After all this is quite the same as some sell you as Infrastructure as a Service (IaaS) or private cloud solution. To be honest to play with the big guys you have to find a solution how you can handle <a href="http://horicky.blogspot.com/2009/07/between-elasticity-and-scalability.html">elasticity, scalability</a> and automation.
</p>
<p>For our homegrown private cloud solution we will install an <a href="http://www.ubuntu.com/">Ubuntu Server</a> which hosts our <a href="https://www.virtualbox.org/">VirtualBox</a> virtual machines and a <a href="http://crossroads.e-tunity.com/">load balancer</a> which will distribute the work load to different virtual servers. The whole network setup should look like this:</p>
<ul>
<li>The VirtualBox server <strong>atlas</strong> with IP 10.0.0.50</li>
<li>virtual server <strong>zeus1</strong> with IP 10.0.0.71</li>
<li>virtual server <strong>zeus2</strong> with IP 10.0.0.72</li>
<li>A load balancer which distributes our workload for port 80 (http) to <strong>zeus1 </strong>and <strong>zeus2</strong></li>
</ul>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/Deployment_model_private_cloud.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/Deployment_model_private_cloud.png" alt="" title="Deployment_model_private_cloud" width="528" height="550" class="alignnone size-full wp-image-641" /></a></p>
<h2>Install Ubuntu server as VirtualBox server</h2>
<p>This server will be our VirtualBox server which hosts our virtual machines. Install Ubuntu Server with the following package.</p>
<ul>
<li>OpenSSH Server</li>
</ul>
<p>For this example our VirtualBox server has the following IP address and hostname.</p>
<ul>
<li>hostname: atlas</li>
<li>IP: 10.0.0.50</li>
</ul>
<p>Change the network settings in <em>/etc/network/interfaces</em>. You may also adapt the gateway and dns-nameserver settings.</p>
<pre>
auto eth0
iface eth0 inet static
        address 10.0.0.50
        netmask 255.255.255.0
        network 10.0.0.0
        broadcast 10.0.0.255
        gateway 10.0.0.1
        dns-nameservers 10.0.0.1
</pre>
<p>Also change the hostname in <em>/etc/hostname</em> and don&#8217;t forget to update the <em>/etc/hosts</em> file.</p>
<p>After a fresh installation we need to to upgrade Ubuntu.</p>
<pre>
sudo apt-get update
sudo apt-get upgrade
</pre>
<pe>Install the kernel headers  for the current kernel version. The command <em>&#8220;uname -r&#8221;</em> will give you your current kernel version. The kernel headers are needed for the VirtualBox kernel modules.</p>
<pre>
sudo apt-get install linux-headers-$(uname -r)
</pre>
<h2>Install VirtualBox</h2>
<p>Now we need to install VirtualBox. For more details see the official <a href="https://www.virtualbox.org/wiki/Linux_Downloads">instructions</a>. For Ubuntu 12.04 add the following lines to your <em>/etc/apt/sources.list</em>:</p>
<pre>
#
# VirtualBox for Ubuntu 12.04 (Precise Pangolin)
#
deb http://download.virtualbox.org/virtualbox/debian precise contrib

</pre>
<p>Next we need to add the public key, so that we can install the VirtualBox package from a third party package provider.</p>
<pre>
wget&#160;-q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
</pre>
<p>Now we can install the newest VirtualBox version from the VirtualBox package repository.</p>
<pre>
sudo apt-get update
sudo apt-get install virtualbox-4.2
</pre>
<p>Also install the <em>dkms</em> package to ensure that the VirtualBox host kernel modules (vboxdrv, vboxnetflt and vboxnetadp) are properly updated if the Linux kernel version changes.</p>
<pre>
sudo apt-get install dkms
</pre>
<p>We should also install the <a href="https://www.virtualbox.org/wiki/Downloads">VirtualBox extension pack</a>  which extends the functionality of the VirtualBox base package. Functionality like the VirtualBox Remote Desktop Protocol (VRDP). When you have problems with a virtual machine you can start the virtual machine with <a href="http://www.virtualbox.org/manual/ch07.html">VRDP support</a> and start a connection with <a href="http://manpages.ubuntu.com/manpages/lucid/man1/rdesktop.1.html">rdesktop</a>.</p>
<pre>
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack
</pre>
<p>Create the user <strong>vbox</strong> which will be used to start our virtual machines. The user must be in the follwing groups so that VirtualBox can access the cdrom and other devices.</p>
<pre>
sudo adduser vbox
sudo usermod -a -G vboxusers,cdrom,sudo,dip,plugdev,dialout,lpadmin,adm vbox
</pre>
<p>The group <a href="http://www.virtualbox.org/manual/ch02.html#idp5655936">vboxusers</a> should be automatically created during the installation of VirtualBox.</p>
<h2>Create a virtual machine</h2>
<p>Now its time to create a Virtual machine with VirtualBox and export the virtual machine as <a href="http://en.wikipedia.org/wiki/Open_Virtualization_Format">OVA</a> file. I created a Virtual machine from a Ubuntu server iso image. The easiest way is to create a virtual machine with VirtualBox on a computer with a graphical user interface.</p>
<p>Create a new virtual machine with the name zeus1, operation system type Linux and version ubuntu.</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_01.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_01-300x198.png" alt="" title="vbox_step_01" width="300" height="198" class="alignnone size-medium wp-image-603" /></a></p>
<p>Select the amount of base memeory for the virtual machine.</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_02.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_02-300x198.png" alt="" title="vbox_step_02" width="300" height="198" class="alignnone size-medium wp-image-605" /></a></p>
<p>Add a new virtual harddisk.</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_03.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_03-300x198.png" alt="" title="vbox_step_03" width="300" height="198" class="alignnone size-medium wp-image-606" /></a></p>
<p>Select VDI as virtual disk image.
<p>
<a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_04.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_04-300x217.png" alt="" title="vbox_step_04" width="300" height="217" class="alignnone size-medium wp-image-607" /></a></p>
<p>Select dynamically allocated disk space.</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_05.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_05-300x217.png" alt="" title="vbox_step_05" width="300" height="217" class="alignnone size-medium wp-image-609" /></a></p>
<p>Select the virtual disk space.</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_06.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_06-300x217.png" alt="" title="vbox_step_06" width="300" height="217" class="alignnone size-medium wp-image-610" /></a></p>
<p>Add the ubuntu server iso image as CD.</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_07.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_07-300x208.png" alt="" title="vbox_step_07" width="300" height="208" class="alignnone size-medium wp-image-611" /></a></p>
<p>Change network to bridged mode (bridged adapter).</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_08.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_08-300x208.png" alt="" title="vbox_step_08" width="300" height="208" class="alignnone size-medium wp-image-612" /></a></p>
<p>Boot up your virtual machine and start with the Ubuntu installation.</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_09.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_09-300x261.png" alt="" title="vbox_step_09" width="300" height="261" class="alignnone size-medium wp-image-613" /></a></p>
<p>When you did not select the Open SSH server during the installation, install it now with apt-get for our virtual machine.</p>
<pre>
sudo apt-get install openssh-server
</pre>
<p>An easy way to shutdown a virtual machine is with the VirtualBox command line tool which can send an ACPI shutdown event to the virtual machine. (e.g. <em>VBoxManage controlvm zeus1 acpipowerbutton</em>). To handle these events we have to install the acpid package.</p>
<pre>
sudo apt-get install acpid
</pre>
<p>For a working ACPI configuration which can handle the power button event you have to edit <strong>/etc/acpi/events/powerbtn</strong> config file.</p>
<pre>
event=button[ /]power
action=/etc/acpi/powerbtn.sh
</pre>
<p>To test the load balancing we also install the apache server.</p>
<pre>
sudo apt-get install apache2
</pre>
<p>We change now the network configuration to the following settings:</p>
<ul>
<li>hostname: zeus1</li>
<li>IP: 10.0.0.71</li>
</ul>
<p>Change the network settings in the file <em>/etc/network/interfaces</em></p>
<pre>
auto eth0
iface eth0 inet static
        address 10.0.0.71
        netmask 255.255.255.0
        network 10.0.0.0
        broadcast 10.0.0.255
        gateway 10.0.0.1
        dns-nameservers 10.0.0.1
</pre>
<p>After we have changed the network settings also change the hostname to zeus1 in <em>/etc/hostname</em> and don&#8217;t forget to update the <em>/etc/hosts</em> file too.</p>
<p><strong>Before we clone our image we have to remove some udev config files.</strong></p>
<ul>
<li>Remove all entries in <em>/etc/udev/rules.d/70-persistent-net.rules</em> because the interfaces (eth0, etc.) are bound to the MAC address and after import of a virtual machine with VirtualBox the MAC address is changed. So when you import virtual machine and start it up the configured interface eth0  is not configured.</li>
<li>Also remove all entries in in <em>/etc/udev/rules.d/70-persistent-cd.rules</em>. I had some problems to boot the virtual image. After I have removed this entries the virtual machine booted up without  problems.</li>
</ul>
<p>To test the acpi package, shutdown zeus1 with the poweroff command.</p>
<pre>
sudo poweroff
</pre>
<p>After the shutdown is complete, export the virtual machine zeus1 as OVA file.</p>
<p><a href="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_11.png"><img src="http://blog.rueedlinger.ch/wp-content/uploads/2012/02/vbox_step_11-300x224.png" alt="" title="vbox_step_11" width="300" height="224" class="alignnone size-medium wp-image-615" /></a></p>
<p>Copy the exported OVA file to your virtualbox server. As you know we have installed openssh on our VirtualBox server (atlas). So you can copy the virtual machine with <em>scp</em> over the newtork.</p>
<pre>
scp zeus1.ova vbox@10.0.0.50:/tmp
</pre>
<h2>Configure VirtualBox server</h2>
<p>Login to our virtualbox server (atlas) with ssh as user <strong>vbox</strong> and import the virtual machine</p>
<pre>
ssh vbox@10.0.0.50
VBoxManage import /tmp/zeus1.ova
</pre>
<p>Now we clone our virtual machine zeus1 and create a identically one with the name zeus2.</p>
<pre>
VBoxManage clonevm zeus1 --name zeus2 --register
</pre>
<p>To show all available vms run <em>&#8220;VBoxManage list vms&#8221;</em>. The output should now display zeus1 and zeus2.</p>
<pre>
"zeus1" {fa974e98-6411-4768-9cd9-017176e47e81}
"zeus2" {81953acc-59d0-4fa9-87f1-42e08bbbdb78}
</pre>
<p>To start up our virtual server automatically we create for both virtual machines the start script <em>vm_zeus1.sh</em> and <em>vm_zeus2.sh</em>. You have to change the <strong>vm_name</strong> variable to the name of the VirtualBox machine. The following example shows the start script <em>vm_zeus1.sh</em>. Copy this script and change the <em>vm_nam</em> variable to zeus2 for the script <em>vm_zeus2.sh</em>.</p>
<pre>
#!/bin/bash

# VirtualBox vm name
<strong>vm_name=zeus1</strong>

# VirtualBox username 
vbox_user=vbox

vbox_command="sudo -u $vbox_user -i VBoxManage"

case "$1" in

start)
        echo "starting vm vm_name"
        $vbox_command startvm --type headless $vm_name
        ;;

shutdown)
        echo "sending ACPI shutdown to vm $vm_name"
        $vbox_command controlvm $vm_name acpipowerbutton
        ;;
pause)
        echo "pause $vm_name"
        $vbox_command controlvm $vm_name pause
        ;;

resume)
        echo "resume $vm_name"
        $vbox_command controlvm $vm_name resume
        ;;

stop)
        echo "savestate $vm_name"
        $vbox_command controlvm $vm_name savestate
        ;;


*)
        echo "usage: $0 (start|stop|pause|resume|shutdown|help)"
        ;;
esac

exit 0
</pre>
<p>
The vm start script uses <strong>VBoxManage controlvm</strong> for operating with virtual machines. For more details what these commands do have a look in the <a href="http://www.virtualbox.org/manual/ch08.html#vboxmanage-controlvm">official manual</a>.
</p>
<p>Install both start script <em>vm_zeus1.sh</em> and <em>vm_zeus2.sh</em> with <em>update-rc.d</em>. The scripts must start after the VirtualBox service <em>vboxdrv</em> and stop before it. So we add the start sequence number 25 and kill sequence number 10. Adapts this settings when you have problems during the startup or shutdown of the atlas server.</p>
<pre>
chmod a+x vm_zeus1.sh 
sudo cp vm_zeus1.sh /etc/init.d/
sudo update-rc.d vm_zeus1.sh defaults 25 10
</pre>
<p>Now you can make the same configuration steps with the virtual machine zeus2.</p>
<h2>Configure virtual machine zeus2</h2>
<p>Start up the virtaul server zeus2. Be sure that zeus1 is not running, because zeus2 have still the same IP as zeus1.</p>
<pre>
sudo  /etc/init.d/vm_zeus2.sh start
</pre>
<p>Log into zeus2 with ssh and change the IP adresse and hostname.</p>
<ul>
<li>hostname: zeus2</li>
<li>IP: 10.0.0.72</li>
</ul>
<pre>
auto eth0
iface eth0 inet static
        address 10.0.0.72
        netmask 255.255.255.0
        network 10.0.0.0
        broadcast 10.0.0.255
        gateway 10.0.0.1
        dns-nameservers 10.0.0.1
</pre>
<p>Change the hostname in <em>/etc/hostname</em> to zeus2 and don&#8217;t forget to update the <em>/etc/hosts</em> file.</p>
<p>To test the acpi package, shutdown zeus2 with the poweroff command.</p>
<pre>
sudo poweroff
</pre>
<p>Now you can adjust some seetings with <a href="http://www.virtualbox.org/manual/ch08.html">VBoxManage modifyvm</a> when you need to allocate more memory or add an additional cpu.</p>
<h2>Configure the load balancer</h2>
<p>We use <a href="http://crossroads.e-tunity.com/">crossroads</a> as our load balancer. You should considering to install the load balancer on a different Linux box, which is connected to the Internet and redirects the request to your virtual servers. But in this example I have installed crossroad on our Ubuntu Server atlas.
</p>
<pre>
sudo apt-get install crossroads
</pre>
<p>Create a start sript <strong>/etc/init.d/crossroads.sh</strong>. This scripts redirects HTTP requests to 10.0.0.71 and 10.0.0.72. For configuration details look up the <a href="http://crossroads.e-tunity.com/">crossroads</a> documentation.</p>
<pre>
#!/bin/sh

XR=/usr/bin/xr
SERVER="-s http:0:80"
BACKENDS="-b 10.0.0.71:80 -b 10.0.0.72:80"
ALGORITHM="-dl"
HTTP_FLAGS="-x -X"
TIMEOUTS="-t 10"
CHECK_CALLS="-c 10"
DEBUGGING="-v"


case "$1" in

start)


	$XR $SERVER $BACKENDS $ALGORITHM $HTTP_FLAGS $TIMEOUTS $CHECK_CALLS $DEBUGGING 2>&#038;1 | logger -t crossroads &#038;
	;;
stop)
	killall $XR
	;;
*)
    echo "usage: $0 (start|stop|help)"
esac

exit 0
</pre>
<p>The last step is to install the load balancer start up script.</p>
<pre>
chmod a+x crossroads.sh
sudo cp crossroads.sh /etc/init.d
sudo update-rc.d crossroads.sh defaults
</pre>
<h2>Start up the whole infrastructure</h2>
<p>So now its time to startup the load balancer and the virtual servers.</p>
<pre>
sudo /etc/init.d/crossoads.sh start
sudo /etc/init.d/vm_zeus1.sh start
sudo /etc/init.d/vm_zeus2.sh start
</pre>
<h2>Test the load balancer</h2>
<p>Now when you connect to atlas (10.0.0.50) with a web browser you should be redirected to zeus1 (10.0.0.71) or zeus2 (10.0.0.72). To test the load balancer just shutdown one of the zeus vm&#8217;s and try to connect to http://10.0.0.50:80, now shutdown the other vm and start the previous stopped virtual machine. Refresh the browser and you should not notice any difference, expect that the loading time of the page is longer for the first time.</p>
<h2>Enable remote desktop for a virtual machine</h2>
<p>When a virtual machine behaves not as expected you can connect to the virtual machine over the remote desktop protocol. You have just to enable remote desktop for the specific virtual machine. First we have to shutdown the virtual machine an specify on which port the VirtualBox should listen for remote desktop connections.
</p>
<pre>
sudo /etc/init.d/vm_zeus1.sh shutdown
VBoxManage modifyvm zeus1 --vrde on --vrdeport 3389 --vrdeauthtype external
sudo /etc/init.d/vm_zeus1.sh start
</pre>
<p>When the virtual machine is started yo can connect from your client with rdesktop to the VirtualBox server over the previous specified port. Add the parameter <em>&#8220;-p -&#8221;</em> so that rdesktop ask for a password.</p>
<pre>
rdesktop 10.0.0.50:3389 -u vbox <strong>-p -</strong>
</pre>
<p>Or just add the password in the command line so that rdesktop don&#8217;t aks for it.</p>
<pre>
rdesktop 10.0.0.50:3389 -u vbox -p <strong>your_password</strong>
</pre>
<p>After you have no use for the remote desktop connection you should disable the remote desktop option for this virtual machine.</p>
<pre>
sudo /etc/init.d/vm_zeus1.sh shutdown
VBoxManage modifyvm zeus1 --vrde off
</pre>
<h2>And now?</h2>
<p>The next thing do would be to look how you can replace the human tasks with scripts. For example:</p>
<ul>
<li>You could write a script for cloning a virtual machine, change the IP address and add the new server to the load balancer.</li>
<li>Write a script which adds or remove dynamically new virtual machines to the load balancer when the load increase or decreases.</li>
</ul>
<p>I hope this post was useful and have fun by building your own homegrown private cloud.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rueedlinger.ch/2012/10/build-your-own-private-cloud-solution-with-ubuntu-server-and-virtualbox/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Use github as maven remote repository</title>
		<link>http://blog.rueedlinger.ch/2012/09/use-github-as-maven-remote-repository/</link>
		<comments>http://blog.rueedlinger.ch/2012/09/use-github-as-maven-remote-repository/#comments</comments>
		<pubDate>Tue, 25 Sep 2012 20:57:30 +0000</pubDate>
		<dc:creator>Matthias Rüedlinger</dc:creator>
				<category><![CDATA[maven]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.rueedlinger.ch/?p=759</guid>
		<description><![CDATA[For this example we create a github repository called mvn-repo which we will configure as our maven remote repository. First we create a directory for our internal maven repository. Later we will push the content of this directory to github &#8230; <a href="http://blog.rueedlinger.ch/2012/09/use-github-as-maven-remote-repository/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>
For this example we create a <a href="https://help.github.com/articles/creating-a-new-repository">github repository</a> called <b>mvn-repo</b> which we will configure as our maven remote repository.
</p>
<p>
First we create a directory for our internal maven repository. Later we will push the content of this directory to github as our maven remote repository.
</p>
<pre>
mkdir mvn-repo
</pre>
<p>
The next step is to create our project called <strong>code-base</strong> with maven. For simplicity this is just a normal maven project which is not configured with a <a href="http://maven.apache.org/pom.html#SCM">SCM</a> like git.
</p>
<pre>
mvn archetype:create -DgroupId=com.github.myproject
    -DartifactId=code-base -Dversion=1.0-SNAPSHOT
</pre>
<p>
There should now be a directory called <em>mvn-repo</em> for our internal repository and the directory <em>code-base</em> for our maven project.
</p>
<pre>
.
└──  code-base
└─── mvn-repo
 
</pre>
<p>
To deploy a maven artifact in the internal repository we have to modify the <em>pom.xml</em> file and add the following lines to our configuration. Adopt the file path here specified as maven property <strong>internal.repo.path</strong> to the location where you created the <em>mvn-repo</em> directory.
</p>
<pre>
&lt;properties&gt;
  &lt;!--maven variable which points to your local repository --&gt;
  &lt;internal.repo.path&gt;<strong>file:///home/mr/tmp/mvn-repo/</strong>&lt;/internal.repo.path&gt;
&lt;/properties&gt;
</pre>
<p>
Also add the following <strong>distributionManagement</strong> element for deploying a maven artifact in your internal repository. The location (url) to the repository is stored  as maven property <strong>${internal.repo.path}</strong> which points to our internal repository in the file system.
</p>
<pre>
&lt;distributionManagement&gt;
  &lt;repository&gt;
    &lt;id&gt;internal.repo&lt;/id&gt;
    &lt;name&gt;Internal Repository&lt;/name&gt;
    &lt;url&gt;<strong>${internal.repo.path}</strong>&lt;/url&gt;
  &lt;/repository&gt;
&lt;/distributionManagement&gt;
</pre>
<p>
Then we can deploy our artifact to the internal maven repository. With the maven <strong>deploy</strong> goal maven copies the maven artifacts to our internal repository.
</p>
<pre>
mvn deploy
</pre>
<p>After a maven deploy the content of our internal maven repository <em>mvn-repo</em> should look like this.</p>
<pre>
.
└── com
    └── github
        └── myproject
            └── code-base
                ├── 1.0-SNAPSHOT
                 \......
</pre>
<p>
To publish our artifacts we have to push our internal repository to github.  Next thing to do is to initialize the directory as local git repository and add the remote github repository. Then pull the files which github created for us (e.g. gitignore and README file) in the local git repository.  Also change <strong>{your_project}</strong> to your github username.
</p>
<pre>
git init
remote add origin https://github.com/<strong>{your_project}</strong>/mvn-repo.git
git pull origin master
</pre>
<p>
With git we add the new generated files from the execution of <em>maven deploy</em> to our git local repository. Then we push the changes to our remote git repository. The new artifacts should then be accessible to the rest of the world.
</p>
<pre>
git add .
git commit -m "first release"
git push origin master
</pre>
<p>
You can use your repository now in other maven projects. Change <strong>{your_project}</strong> to your github username and add the following lines to your <em>pom.xml</em> which want to use the code-base project.
</p>
<pre>
&lt;repository&gt;
  &lt;id&gt;my.mvn.repo&lt;/id&gt;
  &lt;url&gt;https://github.com/<strong>{your_project}</strong>/mvn-repo/raw/master&lt;/url&gt;
  &lt;!-- use snapshot version --&gt;
  &lt;snapshots&gt;
     &lt;enabled&gt;true&lt;/enabled&gt;
      &lt;updatePolicy&gt;always&lt;/updatePolicy&gt;
   &lt;/snapshots&gt;
&lt;/repository&gt;
</pre>
<p>
When you deploy <strong>SNAPSHOT</strong> versions be sure to enable them for your <em>pom.xml</em> with <em>snapshots/enabled = true</em>. See <a href="http://maven.apache.org/settings.html#Repositories">http://maven.apache.org/settings.html#Repositories</a> for more details on how to configure a remote repository.
</p>
<p>
Add the following dependencies in your <em>pom.xml</em> to use the code-base jar in your new maven project.
</p>
<pre>
&lt;dependency&gt;
  &lt;groupId&gt;com.github.myproject&lt;/groupId&gt;
  &lt;artifactId&gt;code-base&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>
When you don&#8217;t want to change the version manually in your code-base project before you deploy a new stable version. You could configure the maven <a href="http://maven.apache.org/plugins/maven-release-plugin/">release plugin</a>. I have not yet done this with git, perhaps when I have the time I will look for a solution how to configure git with maven and a working release plugin configuration. How to configure git with maven just read the following post <a href="http://www.sonatype.com/people/2009/09/maven-tips-and-tricks-using-github/">Maven Tips and Tricks: Using GitHub</a>.
</p>
<p>When you also want to deploy the source JAR and javadoc JAR to your remote repository you should have a look a the maven page <a href="http://maven.apache.org/plugin-developers/cookbook/attach-source-javadoc-artifacts.html">How to attach source and javadoc artifacts</a>.  Just configure the maven <em>javadoc</em> and <em>source</em> plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rueedlinger.ch/2012/09/use-github-as-maven-remote-repository/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
