<?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>mathz.nu</title>
	<atom:link href="http://mathz.nu/feed/" rel="self" type="application/rss+xml" />
	<link>http://mathz.nu</link>
	<description>Asterisk Blacklist Hobby webbhotell</description>
	<lastBuildDate>Fri, 18 May 2012 19:15:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Regexp</title>
		<link>http://mathz.nu/regexp/</link>
		<comments>http://mathz.nu/regexp/#comments</comments>
		<pubDate>Fri, 18 May 2012 19:15:58 +0000</pubDate>
		<dc:creator>Mathz</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mathz.nu/?p=249</guid>
		<description><![CDATA[Simple regex Regex quick reference [abc]     A single character: a, b or c [^abc]     Any single character but a, b, or c [a-z]     Any single character in the range a-z [a-zA-Z]     Any single character in the range a-z or A-Z ^     Start of line $     End of line \A  [...]]]></description>
			<content:encoded><![CDATA[<p><code>Simple regex</p>
<p>Regex quick reference<br />
[abc]     A single character: a, b or c<br />
[^abc]     Any single character but a, b, or c<br />
[a-z]     Any single character in the range a-z<br />
[a-zA-Z]     Any single character in the range a-z or A-Z<br />
^     Start of line<br />
$     End of line<br />
\A     Start of string<br />
\z     End of string<br />
.     Any single character<br />
\s     Any whitespace character<br />
\S     Any non-whitespace character<br />
\d     Any digit<br />
\D     Any non-digit<br />
\w     Any word character (letter, number, underscore)<br />
\W     Any non-word character<br />
\b     Any word boundary character<br />
(...)     Capture everything enclosed<br />
(a|b)     a or b<br />
a?     Zero or one of a<br />
a*     Zero or more of a<br />
a+     One or more of a<br />
a{3}     Exactly 3 of a<br />
a{3,}     3 or more of a<br />
a{3,6}     Between 3 and 6 of a</p>
<p>options: i case insensitive m make dot match newlines x ignore whitespace in regex o perform #{...} substitutions only once</code></p>
]]></content:encoded>
			<wfw:commentRss>http://mathz.nu/regexp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenVPN</title>
		<link>http://mathz.nu/openvpn/</link>
		<comments>http://mathz.nu/openvpn/#comments</comments>
		<pubDate>Sat, 12 May 2012 18:48:27 +0000</pubDate>
		<dc:creator>Mathz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mathz.nu/?p=246</guid>
		<description><![CDATA[Innehåll Overview What is a bridged VPN? Setting up a Bridged VPN using OpenVPN Installing the Server Setting up the Bridge Generating Certificates Configuring the Server Getting Clients Connected Generating Client Certificate and Key Configuring the Client Firestarter configuration for OpenVPN Other Resources &#160; Overview &#160; OpenVPN is a Virtual Private Networking (VPN) solution provided [...]]]></description>
			<content:encoded><![CDATA[<p class="table-of-contents-heading">Innehåll</p>
<ol>
<li><a href="#Overview">Overview</a></li>
<li><a href="#What_is_a_bridged_VPN.3F">What is a bridged VPN?</a></li>
<li><a href="#Setting_up_a_Bridged_VPN_using_OpenVPN">Setting up a Bridged VPN using OpenVPN</a>
<ol>
<li><a href="#Installing_the_Server">Installing the Server</a>
<ol>
<li><a href="#Setting_up_the_Bridge">Setting up the Bridge</a></li>
<li><a href="#Generating_Certificates">Generating Certificates</a></li>
<li><a href="#Configuring_the_Server">Configuring the Server</a></li>
</ol>
</li>
<li><a href="#Getting_Clients_Connected">Getting Clients Connected</a>
<ol>
<li><a href="#Generating_Client_Certificate_and_Key">Generating Client Certificate and Key</a></li>
<li><a href="#Configuring_the_Client">Configuring the Client</a></li>
</ol>
</li>
<li><a href="#Firestarter_configuration_for_OpenVPN">Firestarter configuration for OpenVPN</a></li>
</ol>
</li>
<li><a href="#Other_Resources">Other Resources</a></li>
</ol>
<p>&nbsp;</p>
<h1 id="Overview">Overview</h1>
<p>&nbsp;</p>
<p class="line874">OpenVPN is a Virtual Private Networking (VPN) solution provided in the Ubuntu Repositories. It is flexible, reliable and secure. It belongs to the family of SSL/TLS VPN stacks (different from IPSec VPNs).</p>
<p class="line862">This page refers to the <strong>community version</strong> of the OpenVPN server. Setup examples are also provided on the <a class="http" href="http://www.openvpn.net/index.php/open-source.html">OpenVPN community website</a>. There is also a <a class="http" href="http://openvpn.net">commercial Web GUI</a> which might be easier to set up and maintain, especially for non-experts, and which allows clients to download VPN configurations themselves using the web browser.</p>
<h1 id="What_is_a_bridged_VPN.3F">What is a bridged VPN?</h1>
<p>&nbsp;</p>
<p class="line874">A bridged VPN allows the clients to appear as though they are on the same local area network (LAN) as the server system. The VPN accomplishes this by using a combination of virtual devices &#8212; one called a &#8220;bridge&#8221; and the other called a &#8220;tap device&#8221;. A tap device acts as a virtual Ethernet adapter and the bridge device acts as a virtual hub. When you bridge a physical Ethernet device and a tap device, you are essentially creating a hub between the physical network and the remote clients. Therefore, all LAN services are visible to the remote clients.</p>
<h1 id="Setting_up_a_Bridged_VPN_using_OpenVPN">Setting up a Bridged VPN using OpenVPN</h1>
<p>&nbsp;</p>
<p class="line874">Note that good networking knowledge and enough time is required to follow this manual setup guide. These instructions are for setting up a Bridged VPN on Ubuntu 8.04 using x509 certs and some general administration tasks.</p>
<p class="line862">Newer instructions are found at <a class="https" href="https://help.ubuntu.com/11.10/serverguide/C/openvpn.html">the Ubuntu 11.10 Server guide &#8212; OpenVPN</a>.</p>
<p class="line874">This example installation was performed using Ubuntu Jeos 8.04 in a KVM virtual machine (but could just have easily been performed on a standalone Ubuntu Server). In my configuration eth0 is connected to the Internet and eth1 is connected to the LAN network that will be bridged. Comments in configuration files are preceeded by two pound signs (##).</p>
<h2 id="Installing_the_Server">Installing the Server</h2>
<p>&nbsp;</p>
<p class="line874">Install OpenVPN:</p>
<pre>sudo apt-get install openvpn bridge-utils</pre>
<p>&nbsp;</p>
<h3 id="Setting_up_the_Bridge">Setting up the Bridge</h3>
<ul>
<li>Edit /etc/network/interfaces</li>
</ul>
<p class="line874">When a Linux server is behind a NAT firewall, the /etc/network/interfaces file commonly looks like</p>
<pre># This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo eth0
iface lo inet loopback

# The primary network interface
## This device provides internet access.
iface eth0 inet static
  address 192.168.1.10
  netmask 255.255.255.0
  gateway 192.168.1.1</pre>
<p>&nbsp;</p>
<p class="line874">Edit this and add a bridge interface:</p>
<pre>sudo nano /etc/network/interfaces</pre>
<p>&nbsp;</p>
<p class="line874">so that it look similar to:</p>
<pre>## This is the network bridge declaration

## Start these interfaces on boot
auto lo br0

iface lo inet loopback

iface br0 inet static
  address 192.168.1.10
  netmask 255.255.255.0
  gateway 192.168.1.1
  bridge_ports eth0

iface eth0 inet manual
  up ip link set $IFACE up promisc on
  down ip link set $IFACE down promisc off</pre>
<ul>
<li>If you are running Linux inside a virtual machine, you may want to add the following parameters to the bridge connection:</li>
</ul>
<pre>  bridge_fd 9      ## from the libvirt docs (forward delay time)
  bridge_hello 2   ## from the libvirt docs (hello time)
  bridge_maxage 12 ## from the libvirt docs (maximum message age)
  bridge_stp off   ## from the libvirt docs (spanning tree protocol)</pre>
<ul>
<li>Restart networking:</li>
</ul>
<pre>sudo /etc/init.d/networking restart</pre>
<p>&nbsp;</p>
<p class="line874">The bridging declarations come from the libvirt documentation. (I really only understand the bridge_ports directive and the bridge_stp directive. Please add more instructions here.)</p>
<h3 id="Generating_Certificates">Generating Certificates</h3>
<ul>
<li>Generate certificates for the server. In order to do this I will setup my own Certificate Authority using the provided easy-rsa scripts in the /usr/share/doc/openvpn/examples/easy-rsa/ directory. Another alternative is using the graphical program tinyca to create your CA.</li>
</ul>
<p class="line874">Step 1:</p>
<ul>
<li style="list-style-type: none;">Copy files to the /etc/openvpn/easy-rsa/ directory
<pre>sudo mkdir /etc/openvpn/easy-rsa/
sudo cp -R /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa/</pre>
<p>&nbsp;</li>
</ul>
<p class="line874">Step 2:</p>
<ul>
<li style="list-style-type: none;">Edit /etc/openvpn/easy-rsa/vars
<pre>sudo vi /etc/openvpn/easy-rsa/vars</pre>
<p>Change these lines at the bottom so that they reflect your new CA.</p>
<pre>export KEY_COUNTRY="US"
export KEY_PROVINCE="CA"
export KEY_CITY="SanFrancisco"
export KEY_ORG="Fort-Funston"
export KEY_EMAIL="me@myhost.mydomain"</pre>
</li>
</ul>
<p class="line874">Step 3:</p>
<ul>
<li style="list-style-type: none;">Setup the CA and create the first server certificate
<pre>cd /etc/openvpn/easy-rsa/ ## move to the easy-rsa directory
sudo chown -R root:admin .  ## make this directory writable by the system administrators
sudo chmod g+w . ## make this directory writable by the system administrators
source ./vars ## execute your new vars file
./clean-all  ## Setup the easy-rsa directory (Deletes all keys)
./build-dh  ## takes a while consider backgrounding
./pkitool --initca ## creates ca cert and key
./pkitool --server server ## creates a server cert and key
cd keys
openvpn --genkey --secret ta.key  ## Build a TLS key
sudo cp server.crt server.key ca.crt dh1024.pem ta.key ../../</pre>
<p>&nbsp;</li>
</ul>
<p class="line874">The Certificate Authority is now setup and the needed keys are in /etc/openvpn/</p>
<h3 id="Configuring_the_Server">Configuring the Server</h3>
<p>&nbsp;</p>
<p class="line874">By default all servers specified in *.conf files in the /etc/openvpn/ directory are started on boot. Therefore, all we have to do is creating a new file named server.conf in the /etc/openvpn/ directory.</p>
<p class="line874">First, we&#8217;re going to create a couple of new scripts to be used by the openvpn server.</p>
<pre>sudo vi /etc/openvpn/up.sh</pre>
<p>&nbsp;</p>
<p class="line874">This script should contain the following</p>
<pre>#!/bin/sh

BR=$1
DEV=$2
MTU=$3
/sbin/ip link set "$DEV" up promisc on mtu "$MTU"
/usr/sbin/brctl addif $BR $DEV</pre>
<p>&nbsp;</p>
<p class="line874">Now, we&#8217;ll create a &#8220;down&#8221; script.</p>
<pre>sudo vi /etc/openvpn/down.sh</pre>
<p>&nbsp;</p>
<p class="line874">It should contain the following.</p>
<pre>#!/bin/sh

BR=$1
DEV=$2

/usr/sbin/brctl delif $BR $DEV
/sbin/ip link set "$DEV" down</pre>
<p>&nbsp;</p>
<p class="line874">Now, make both scripts executable.</p>
<pre>sudo chmod +x /etc/openvpn/up.sh /etc/openvpn/down.sh</pre>
<p>&nbsp;</p>
<p class="line874">And now on to configuring openvpn itself.</p>
<pre>sudo vi /etc/openvpn/server.conf</pre>
<p>&nbsp;</p>
<pre>mode server
tls-server

local &lt;your ip address&gt; ## ip/hostname of server
port 1194 ## default openvpn port
proto udp

#bridging directive
dev tap0 ## If you need multiple tap devices, add them here
up "/etc/openvpn/up.sh br0 tap0 1500"
down "/etc/openvpn/down.sh br0 tap0"

persist-key
persist-tun

#certificates and encryption
ca ca.crt
cert server.crt
key server.key  # This file should be kept secret
dh dh1024.pem
tls-auth ta.key 0 # This file is secret

cipher BF-CBC        # Blowfish (default)
comp-lzo

#DHCP Information
ifconfig-pool-persist ipp.txt
server-bridge 192.168.1.10 255.255.255.0 192.168.1.100 192.168.1.110
push "dhcp-option DNS your.dns.ip.here"
push "dhcp-option DOMAIN yourdomain.com"
max-clients 10 ## set this to the max number of clients that should be connected at a time

#log and security
user nobody
group nogroup
keepalive 10 120
status openvpn-status.log
verb 3</pre>
<p>&nbsp;</p>
<p class="line862">The server initialization script will complain about <strong>WARN: could not open database for 4096 bits. Skipped</strong>and you can work around it by running this command:</p>
<pre>touch /usr/share/openssl-blacklist/blacklist.RSA-4096</pre>
<p>&nbsp;</p>
<p class="line874">Don&#8217;t forget to either reboot or run the command below. This will restart openvpn and load the new config.</p>
<pre>sudo /etc/init.d/openvpn restart</pre>
<p>&nbsp;</p>
<p class="line874">In case you run a firewall like ufw, please consider enabling ip forwarding, otherwise the clients will only be able to connect to the server, but not to other LAN servers.</p>
<h2 id="Getting_Clients_Connected">Getting Clients Connected</h2>
<p>&nbsp;</p>
<p class="line862">This section concerns creating client certificate and key files and setting up a client configuration file. The files can then be used with OpenVPN on a client platform. The described configuration will work with OpenVPN installations of <a class="http" href="http://openvpn.se/">OpenVPN GUI</a> for Windows and <a class="http" href="http://code.google.com/p/tunnelblick/">Tunnelblick</a> for Mac OS X clients. For a detailed discussion of each, refer to their respective home pages. It should also be compatible with Linux OpenVPN clients.</p>
<h3 id="Generating_Client_Certificate_and_Key">Generating Client Certificate and Key</h3>
<p>&nbsp;</p>
<p class="line862">Generating certificates and keys for a client is very similar to the process used for generating server certificates. It is assumed that you have already set up the <tt>/etc/openvpn/easy-rsa/</tt> directory and updated the <tt>/etc/openvpn/easy-rsa/vars</tt> file as described above. You should have already setup your Certificate Authority and created a server certificate and keys.</p>
<pre>cd /etc/openvpn/easy-rsa/ ## move to the easy-rsa directory
source ./vars             ## execute the vars file
./pkitool client          ## create a cert and key named "client"</pre>
<p>&nbsp;</p>
<h3 id="Configuring_the_Client">Configuring the Client</h3>
<p>&nbsp;</p>
<p class="line874">The client configuration has been adapted from the OpenVPN 2.0 sample configuration file. For Windows, the file should be named client.ovpn and for other operating systems, the file should be named client.conf. The file can be created using vi or other editor that can create plain text files.</p>
<p class="line874">The configuration file assumes that there is only one TUN/TAP device configured on the client.</p>
<pre>### Client configuration file for OpenVPN

# Specify that this is a client
client

# Bridge device setting
dev tap

# Host name and port for the server (default port is 1194)
# note: replace with the correct values your server set up
remote your.server.example.com 1194

# Client does not need to bind to a specific local port
nobind

# Keep trying to resolve the host name of OpenVPN server.
## The windows GUI seems to dislike the following rule.
##You may need to comment it out.
resolv-retry infinite

# Preserve state across restarts
persist-key
persist-tun

# SSL/TLS parameters - files created previously
ca ca.crt
cert client.crt
key client.key

# Since we specified the tls-auth for server, we need it for the client
# note: 0 = server, 1 = client
tls-auth ta.key 1

# Specify same cipher as server
cipher BF-CBC

# Use compression
comp-lzo

# Log verbosity (to help if there are problems)
verb 3</pre>
<p>&nbsp;</p>
<p class="line874">Place the client.ovpn (or client.conf) configuration file along with the certificate and key files in the openvpn configuration directory on the client. With the above setup, the following files should be in the configuration directory.</p>
<pre>client.ovpn
ca.crt
client.crt
client.key
ta.key</pre>
<p>&nbsp;</p>
<p class="line862">(For the <a class="http" href="http://openvpn.se/">OpenVPN GUI</a> for Windows, the default location for the files is <tt>C:\Program Files\OpenVPN\config</tt>.)</p>
<p class="line862">(For <a class="http" href="http://code.google.com/p/tunnelblick/">Tunnelblick</a> for Mac OS X, the default location for the files is <em><tt>~username</tt></em><tt>/Library/openvpn</tt>.</p>
<p class="line867">
<h2 id="Firestarter_configuration_for_OpenVPN">Firestarter configuration for OpenVPN</h2>
<p>&nbsp;</p>
<p class="line874">Firestarter requires some configuration on both client and server machines to allow services like SAMBA over a VPN tunnel. In addition the creation of rules within the GUI, it was also necessary to edit the /etc/firestarter/user-pre file. I used the instructions found here:</p>
<p class="line867"><a class="http" href="http://www.howtoadvice.com/FirestarterVPN/">http://www.howtoadvice.com/FirestarterVPN/</a></p>
<p class="line874">Also, though the tutorial didn&#8217;t discuss it, I found it necessary to save the original user-pre file as a copy, then rename the original and rename the copy to user-pre due to permissions issues.</p>
<h1 id="Other_Resources">Other Resources</h1>
<ul>
<li>
<p class="line862">Consult the official <a class="http" href="http://openvpn.net/howto.html">OpenVPN Howto</a>.</p>
</li>
<li class="gap">
<p class="line862">Consult <a class="http" href="http://www.juanpablo.netne.net/index.php/en/manuales-linux/red-privada-virtual-openvpn/item/58">this tutorial</a>.</p>
</li>
<li class="gap">
<p class="line862">Consult <a class="http" href="http://ubuntuguide.org/wiki/OpenVPN_server">(K)Ubuntuguide &#8212; OpenVPN server installation</a></p>
</li>
</ul>
<hr />
<p class="line874">CategoryVPN <a href="/community/CategoryVPN">CategoryVPN</a></p>
<div id="pagebottom"></div>
<p id="pageinfo" class="info" lang="sv" dir="ltr">OpenVPN (senast redigerad 2012-04-27 05:53:03 av <span title="beijersb @ 85.159.97.70[85.159.97.70]"><a class="interwiki" title="beijersb @ 85.159.97.70[85.159.97.70]" href="https://launchpad.net/~beijersb">beijersb</a></span>)</p>
<div id="footer">
<p>The material on this wiki is available under a free license, see <a href="https://help.ubuntu.com/community/ 		License">Copyright / License</a> for details<br />
<strong>You</strong> can contribute to this wiki, see<br />
<a href="https://help.ubuntu.com/community/WikiGuide">Wiki Guide</a> for details</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://mathz.nu/openvpn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TVheadend DVB drivers kernel 3.0</title>
		<link>http://mathz.nu/tvheadend-dvb-drivers-kernel-3-0/</link>
		<comments>http://mathz.nu/tvheadend-dvb-drivers-kernel-3-0/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 22:16:06 +0000</pubDate>
		<dc:creator>Mathz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mathz.nu/?p=244</guid>
		<description><![CDATA[http://linuxtv.org/wiki/index.php/How_to_Obtain,_Build_and_Install_V4L-DVB_Device_Drivers]]></description>
			<content:encoded><![CDATA[<p>http://linuxtv.org/wiki/index.php/How_to_Obtain,_Build_and_Install_V4L-DVB_Device_Drivers</p>
]]></content:encoded>
			<wfw:commentRss>http://mathz.nu/tvheadend-dvb-drivers-kernel-3-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>newcs install</title>
		<link>http://mathz.nu/newcs-install/</link>
		<comments>http://mathz.nu/newcs-install/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 10:10:33 +0000</pubDate>
		<dc:creator>Mathz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mathz.nu/?p=239</guid>
		<description><![CDATA[In Ubuntu you need sudo apt-get install libssl-dev libssl0.9.8]]></description>
			<content:encoded><![CDATA[<p>In Ubuntu you need</p>
<p>sudo apt-get install libssl-dev libssl0.9.8</p>
]]></content:encoded>
			<wfw:commentRss>http://mathz.nu/newcs-install/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DVB drivers for USB</title>
		<link>http://mathz.nu/dvb-drivers-for-usb/</link>
		<comments>http://mathz.nu/dvb-drivers-for-usb/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 22:26:37 +0000</pubDate>
		<dc:creator>Mathz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mathz.nu/?p=236</guid>
		<description><![CDATA[git clone git://linuxtv.org/media_build.git cd media_build ./build make make install]]></description>
			<content:encoded><![CDATA[<pre>git clone git://linuxtv.org/media_build.git
cd media_build
./build
make
make install</pre>
]]></content:encoded>
			<wfw:commentRss>http://mathz.nu/dvb-drivers-for-usb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TapeWare in Ububtu</title>
		<link>http://mathz.nu/tapeware-in-ububtu/</link>
		<comments>http://mathz.nu/tapeware-in-ububtu/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 10:55:11 +0000</pubDate>
		<dc:creator>Mathz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mathz.nu/?p=228</guid>
		<description><![CDATA[To install TapeWare v7.0 Master and Server Enterprise (SP5C) you need to install xterm sudo apt-get install xterm sudo apt-get install ncurses-term start xming server on Windows start sudo xterm start the install of TapeWare &#160; SUN DLT7000 drive in TapeWare in file twtapdev.ini add &#8220;SUN     DLT7000=DLT 7000&#8243; in my case there was 5 spaces. [...]]]></description>
			<content:encoded><![CDATA[<p>To install TapeWare v7.0 Master and Server Enterprise (SP5C) you need to install xterm</p>
<p>sudo apt-get install xterm</p>
<p>sudo apt-get install ncurses-term</p>
<p>start xming server on Windows</p>
<p>start sudo xterm</p>
<p>start the install of TapeWare</p>
<p>&nbsp;</p>
<p>SUN DLT7000 drive in TapeWare<br />
in file twtapdev.ini add &#8220;SUN     DLT7000=DLT 7000&#8243; in my case there was 5 spaces.<br />
restartservice:<br />
sudo ./twunxsvc -x<br />
sudo ./twunxsvc -s</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://mathz.nu/tapeware-in-ububtu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Diff directories in Linux</title>
		<link>http://mathz.nu/diff-directories-in-linux/</link>
		<comments>http://mathz.nu/diff-directories-in-linux/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 16:37:02 +0000</pubDate>
		<dc:creator>Mathz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mathz.nu/?p=226</guid>
		<description><![CDATA[diff --recursive --brief /tmp/dir1 /tmp/dir2 &#124;grep Only]]></description>
			<content:encoded><![CDATA[<pre><strong>diff --recursive --brief /tmp/dir1 /tmp/dir2</strong> |grep Only</pre>
]]></content:encoded>
			<wfw:commentRss>http://mathz.nu/diff-directories-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert an Addon Domain to its Own cPanel and Vice Versa</title>
		<link>http://mathz.nu/convert-an-addon-domain-to-its-own-cpanel-and-vice-versa/</link>
		<comments>http://mathz.nu/convert-an-addon-domain-to-its-own-cpanel-and-vice-versa/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 17:59:14 +0000</pubDate>
		<dc:creator>Mathz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mathz.nu/?p=223</guid>
		<description><![CDATA[These steps assume that the domain will remain on the same server. Addon domain turned into a separate cPanel Download the content of your addon domain to your local PC. Backup any associated database(s). Go into the original cPanel and remove the addon domain from under the Addon Domains icon. (You do not need to [...]]]></description>
			<content:encoded><![CDATA[<p>These steps assume that the domain will remain on the same server.</p>
<h2>Addon domain turned into a separate cPanel</h2>
<ol>
<li>Download the content of your addon domain to your local PC.</li>
<li>Backup any associated database(s).</li>
<li>Go into the original cPanel and remove the addon domain from under the Addon Domains icon. (You do not need to delete the original content or original databases.)</li>
<li>Create a New Account inside your WHM. Fill out the form, using the old addon domain name as the Domain. Click the Create button.</li>
<li>Once the new cPanel is ready, upload the content of your old addon domain to this new cPanel, in the public_html folder. (When using FTP to upload, connect to the cPanel&#8217;s IP address and login with the new cPanel&#8217;s username and password.)</li>
<li>Login to the new cPanel and restore the database backup(s).</li>
<li>Reconfigure any database connections. (The database name and username have likely changed.)</li>
</ol>
<p>Your site will only be down as long as it takes to complete these steps. No need to change your name servers.</p>
]]></content:encoded>
			<wfw:commentRss>http://mathz.nu/convert-an-addon-domain-to-its-own-cpanel-and-vice-versa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>xml2array</title>
		<link>http://mathz.nu/xml2array/</link>
		<comments>http://mathz.nu/xml2array/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 21:51:10 +0000</pubDate>
		<dc:creator>Mathz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mathz.nu/?p=217</guid>
		<description><![CDATA[This code is not written by me! /** * xml2array() will convert the given XML text to an array in the XML structure. * Link: http://www.bin-co.com/php/scripts/xml2array/ * Arguments : $contents - The XML text * $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag [...]]]></description>
			<content:encoded><![CDATA[<p>This code is not written by me!</p>
<p><code><br />
/**<br />
* xml2array() will convert the given XML text to an array in the XML structure.<br />
* Link: http://www.bin-co.com/php/scripts/xml2array/<br />
* Arguments : $contents - The XML text<br />
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag values - this results in a different array structure in the return value.<br />
* $priority - Can be 'tag' or 'attribute'. This will change the way the resulting array sturcture. For 'tag', the tags are given more importance.<br />
* Return: The parsed XML in an array form. Use print_r() to see the resulting array structure.<br />
* Examples: $array = xml2array(file_get_contents('feed.xml'));<br />
* $array = xml2array(file_get_contents('feed.xml', 1, 'attribute'));<br />
*/<br />
function xml2array($contents, $get_attributes=1, $priority = 'tag') {<br />
if(!$contents) return array();</code></p>
<p>if(!function_exists(&#8216;xml_parser_create&#8217;)) {<br />
//print &#8220;&#8216;xml_parser_create()&#8217; function not found!&#8221;;<br />
return array();<br />
}</p>
<p>//Get the XML parser of PHP &#8211; PHP must have this module for the parser to work<br />
$parser = xml_parser_create(&#8221;);<br />
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, &#8220;UTF-8&#8243;); # http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss<br />
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);<br />
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);<br />
xml_parse_into_struct($parser, trim($contents), $xml_values);<br />
xml_parser_free($parser);</p>
<p>if(!$xml_values) return;//Hmm&#8230;</p>
<p>//Initializations<br />
$xml_array = array();<br />
$parents = array();<br />
$opened_tags = array();<br />
$arr = array();</p>
<p>$current = &amp;$xml_array; //Refference</p>
<p>//Go through the tags.<br />
$repeated_tag_index = array();//Multiple tags with same name will be turned into an array<br />
foreach($xml_values as $data) {<br />
unset($attributes,$value);//Remove existing values, or there will be trouble</p>
<p>//This command will extract these variables into the foreach scope<br />
// tag(string), type(string), level(int), attributes(array).<br />
extract($data);//We could use the array by itself, but this cooler.</p>
<p>$result = array();<br />
$attributes_data = array();</p>
<p>if(isset($value)) {<br />
if($priority == &#8216;tag&#8217;) $result = $value;<br />
else $result['value'] = $value; //Put the value in a assoc array if we are in the &#8216;Attribute&#8217; mode<br />
}</p>
<p>//Set the attributes too.<br />
if(isset($attributes) and $get_attributes) {<br />
foreach($attributes as $attr =&gt; $val) {<br />
if($priority == &#8216;tag&#8217;) $attributes_data[$attr] = $val;<br />
else $result['attr'][$attr] = $val; //Set all the attributes in a array called &#8216;attr&#8217;<br />
}<br />
}</p>
<p>//See tag status and do the needed.<br />
if($type == &#8220;open&#8221;) {//The starting of the tag &#8221;<br />
$parent[$level-1] = &amp;$current;<br />
if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag<br />
$current[$tag] = $result;<br />
if($attributes_data) $current[$tag. '_attr'] = $attributes_data;<br />
$repeated_tag_index[$tag.'_'.$level] = 1;</p>
<p>$current = &amp;$current[$tag];</p>
<p>} else { //There was another element with the same tag name</p>
<p>if(isset($current[$tag][0])) {//If there is a 0th element it is already an array<br />
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;<br />
$repeated_tag_index[$tag.'_'.$level]++;<br />
} else {//This section will make the value an array if multiple tags with the same name appear together<br />
$current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array<br />
$repeated_tag_index[$tag.'_'.$level] = 2;</p>
<p>if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well<br />
$current[$tag]['0_attr'] = $current[$tag.'_attr'];<br />
unset($current[$tag.'_attr']);<br />
}</p>
<p>}<br />
$last_item_index = $repeated_tag_index[$tag.'_'.$level]-1;<br />
$current = &amp;$current[$tag][$last_item_index];<br />
}</p>
<p>} elseif($type == &#8220;complete&#8221;) { //Tags that ends in 1 line &#8221;<br />
//See if the key is already taken.<br />
if(!isset($current[$tag])) { //New Key<br />
$current[$tag] = $result;<br />
$repeated_tag_index[$tag.'_'.$level] = 1;<br />
if($priority == &#8216;tag&#8217; and $attributes_data) $current[$tag. '_attr'] = $attributes_data;</p>
<p>} else { //If taken, put all things inside a list(array)<br />
if(isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array&#8230;</p>
<p>// &#8230;push the new element into that array.<br />
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;</p>
<p>if($priority == &#8216;tag&#8217; and $get_attributes and $attributes_data) {<br />
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . &#8216;_attr&#8217;] = $attributes_data;<br />
}<br />
$repeated_tag_index[$tag.'_'.$level]++;</p>
<p>} else { //If it is not an array&#8230;<br />
$current[$tag] = array($current[$tag],$result); //&#8230;Make it an array using using the existing value and the new value<br />
$repeated_tag_index[$tag.'_'.$level] = 1;<br />
if($priority == &#8216;tag&#8217; and $get_attributes) {<br />
if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well</p>
<p>$current[$tag]['0_attr'] = $current[$tag.'_attr'];<br />
unset($current[$tag.'_attr']);<br />
}</p>
<p>if($attributes_data) {<br />
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . &#8216;_attr&#8217;] = $attributes_data;<br />
}<br />
}<br />
$repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken<br />
}<br />
}</p>
<p>} elseif($type == &#8216;close&#8217;) { //End of tag &#8221;<br />
$current = &amp;$parent[$level-1];<br />
}<br />
}</p>
<p>return($xml_array);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://mathz.nu/xml2array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dump mysql tables with mysqldump</title>
		<link>http://mathz.nu/dump-mysql-tables-with-mysqldump/</link>
		<comments>http://mathz.nu/dump-mysql-tables-with-mysqldump/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 08:10:08 +0000</pubDate>
		<dc:creator>Mathz</dc:creator>
				<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://mathz.nu/?p=210</guid>
		<description><![CDATA[Here is a script for dumping tables from all databases in MySql. #!/bin/bash # ************************************************************* # file: mysqldump.sh # date: 2011-12-22 00:22 # author: (c) by Mats Ahlbom - mats@ahlbom.nu # description: Get a mysqldump-file for eath table in all databases # ************************************************************* # name of database user ( must have LOCK_TABLES rights )&#8230; dbUsername=&#8221;mythtv&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a script for dumping tables from all databases in MySql.</p>
<p><code><br />
#!/bin/bash<br />
# *************************************************************<br />
# file: mysqldump.sh<br />
# date: 2011-12-22 00:22<br />
# author: (c) by Mats Ahlbom - mats@ahlbom.nu<br />
# description: Get a mysqldump-file for eath table in all databases<br />
# *************************************************************</code></p>
<p># name of database user ( must have LOCK_TABLES rights )&#8230;<br />
dbUsername=&#8221;mythtv&#8221;</p>
<p># password of database user&#8230;<br />
dbPassword=&#8221;mythtv&#8221;</p>
<p># path to backup directory&#8230;<br />
dbBackup=&#8221;/home/mathz/mysqldump&#8221;</p>
<p># Delete old dumped tables true/false<br />
delete_old=&#8221;flase&#8221;</p>
<p># *************************************************************<br />
# Do not edit below this line!<br />
# get current date ( YYYY-MM-DD )&#8230;<br />
date=$( date +%Y-%m-%d )</p>
<p># create backup directory if not exists&#8230;<br />
[ ! -d "$dbBackup" ] &amp;&amp; mkdir -p $dbBackup</p>
<p>if [ $delete_old = "true" ]; then<br />
find $dbBackup/ -type f -name &#8216;*.sql.gz&#8217; -exec rm -rf {} &#8216;;&#8217; &gt;/dev/null 2&gt;&amp;1<br />
fi</p>
<p># loop all databases&#8230;</p>
<p>for db in $( mysql -u $dbUsername &#8211;password=$dbPassword -Bse &#8220;show databases&#8221; ); do<br />
# loop all tables in database<br />
for tables in $( mysql -u $dbUsername &#8211;password=$dbPassword -Bse &#8220;show tables&#8221; ${db} ); do<br />
# get mysqldump of current tavble&#8230;<br />
mysqldump -u $dbUsername &#8211;password=$dbPassword &#8211;opt &#8211;databases $db &#8211;tables $tables | gzip -9 &gt;${dbBackup}/${db}-${tables}-${dat<br />
e}.sql.gz<br />
done<br />
done</p>
<p># *************************************************************<br />
# EOF</p>
]]></content:encoded>
			<wfw:commentRss>http://mathz.nu/dump-mysql-tables-with-mysqldump/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

