<?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>foscode</title>
	<atom:link href="http://www.foscode.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.foscode.com</link>
	<description>because code should be free</description>
	<lastBuildDate>Fri, 17 Feb 2012 22:04:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dynamic DNS with 1&amp;1</title>
		<link>http://www.foscode.com/dynamic-dns-11/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=dynamic-dns-11</link>
		<comments>http://www.foscode.com/dynamic-dns-11/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 16:32:15 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.foscode.com/?p=883</guid>
		<description><![CDATA[<p>I&#8217;ve been using afraid.org <a href="http://freedns.afraid.org/" target="_blank">FreeDNS</a> as my dynamic dns servers for my domains registered with <a href="http://1and1.com" target="_blank">1&#038;1</a> for the past few years. They offer great service and have a large variety of options when it comes down to configuration and so forth. With that being said, just recently I started noticing their servers weren&#8217;t responding and my site all of a sudden went down since the dns data wasn&#8217;t getting updated. I&#8217;ve started doing searches on alternatives and found a few, but none as straight forward as FreeDNS from afraid.org &#8230; until last night. </p>
<p><a href="http://www.foscode.com/dynamic-dns-11/" class="more-link">Read more on Dynamic DNS with 1&#038;1&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using afraid.org <a href="http://freedns.afraid.org/" target="_blank">FreeDNS</a> as my dynamic dns servers for my domains registered with <a href="http://1and1.com" target="_blank">1&#038;1</a> for the past few years. They offer great service and have a large variety of options when it comes down to configuration and so forth. With that being said, just recently I started noticing their servers weren&#8217;t responding and my site all of a sudden went down since the dns data wasn&#8217;t getting updated. I&#8217;ve started doing searches on alternatives and found a few, but none as straight forward as FreeDNS from afraid.org &#8230; until last night. </p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=890' title='oneandone'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2012/02/oneandone-150x150.png" class="attachment-thumbnail" alt="" title="oneandone" /></a>

</div>
<p><span id="more-883"></span><br />
I&#8217;ve finally come across this <a href="http://www.tsaiberspace.net/blog/2006/04/05/dynamic-dns-with-11" target="_blank">post</a> from Rob who has had the same service from afraid.org and was able to make his dynamic dns work with <a href="http://1and1.com" target="_blank">1&#038;1</a>. So I thought, wait, this is cool, I also have a domain with 1&#038;1, so let me give this a shot and see how it works. To my surprise, it worked indeed (after a few custom changes). So there, if you own a domain with 1&#038;1.com and have a dynamic ip address, you can now too, update your dns information whenever your ip changes! Here&#8217;s how:</p>
<p>1. Login to 1&#038;1 and change the dns settings for your domain. You now need to set it so it uses 1&#038;1 dns servers, and under advanced settings, enter the current ip address of your server.</p>
<p>2. If you would like to serve your own mail, you&#8217;ll also need to create a <a href="http://faq.oneandone.co.uk/domains/domain_admin/dns_settings/3.html" target="_blank">glue record</a> and a <a href="http://faq.1and1.co.uk/domains/domain_admin/dns_settings/9.html" target="_blank">mx record</a> and then update your settings. 1&#038;1 has the instructions for this (just click on the links I just mentioned.)</p>
<p>Now that you have the config part in 1&#038;1 done you can go ahead and setup the scripts that will update the dns information for you. I&#8217;ve downloaded and modified this script from <a href="http://www.tsaiberspace.net/blog/2006/04/05/dynamic-dns-with-11/" target="_blank">tsaiberspace</a>, which is an automated client that masquerades itself as a web browser to automatically update the IP address associated with a 1&#038;1 domain. For it all to work you&#8217;ll need to create a few scripts and install a few dependencies:</p>
<p>1. Install libwww-curl-perl<br />
2. config.cfg (Contains the domain information to be updated)<br />
3. checkdns (checks if the ip address has been changed, if so, runs the update1and1 script)<br />
4. update1and1 (updates 1and1 dns information)</p>
<p>1. config.cfg:</p>
<pre class="brush: bash">
# config file for 1and1 dns update
DOMAIN1=domain.com
LOGIN=www.domain.com
PASS=yourpassword
</pre>
<p>2. checkdns</p>
<pre class="brush: html">
#!/bin/bash

echo &quot;Reading config from /etc/dynamic1and1/config.cfg ....&quot; &gt;&amp;2
source /etc/dynamic1and1/config.cfg
## vars $DOMAIN1 $LOGIN $PASS come from config.cfg above

function update_dns() {
	$HOME/dynamic1and1/update1and1 $address $DOMAIN1 $LOGIN $PASS &gt;&amp;2
	echo &quot;1AND1 DNS Updated Successfuly&quot; &gt;&amp;2
}

function curr_ip() {
	currdev=$(/sbin/ip route| grep default |head -n 1 |awk &#039;{print $5}&#039;)
	currip=$(wget http://www.checkip.net/ -o /dev/null -O /dev/stdout | head -n 4 | tail -n 1 | cut -f2 -d:)
	echo $currip
}

function check_ip() {
	address=$(curr_ip)
	tmp_data=&quot;$HOME/.curr_ip&quot;
	# see if the address really changed
	if [ -f &quot;$tmp_data&quot; ]
	then
		if [ &quot;$address&quot; = &quot;$(cat $tmp_data)&quot; ]
		then
			echo &quot;IP Address hasn&#039;t changed, DNS records are uptodate&quot;
		else
			# update 1&amp;1.com
			update_dns
		fi
	else
		# update 1&amp;1.com
		update_dns
	fi
	echo $address &gt; $tmp_data
}

## This function runs now to check the ipaddress.
## If the ip has changed, the script will call the update1and1 script and update the dns data.
check_ip
</pre>
<p>3. update1and1</p>
<pre class="brush: html">
#!/usr/bin/perl -w

###############################################################################

package Update1and1;

use strict;
use WWW::Curl::Easy;
use URI::Escape;

sub __curldebug()
{
	my (@args) = @_;

	print map { &quot;[$_]\n&quot; } @args;
}

sub new($$)
{
	sub curlsink($$)
	{
		my ($data, $ref) = @_;

		push @$ref, $data;
		return length($data);
	}

	my ($class, $args) = @_;

	my $this = bless {
		curl =&gt; WWW::Curl::Easy-&gt;new(),
		root =&gt; &quot;https://admin.1and1.com&quot;,
		jsessionid =&gt; &quot;&quot;,
		headers =&gt; [],
		body =&gt; [],
		%{$args},
	};

	my $curl = $this-&gt;{curl};

	$curl-&gt;setopt(CURLOPT_VERBOSE, $args-&gt;{verbose} ? 1 : 0);
	$curl-&gt;setopt(CURLOPT_HEADERFUNCTION, \&amp;curlsink);
	$curl-&gt;setopt(CURLOPT_WRITEFUNCTION, \&amp;curlsink);

	$this;
}

sub httpOK($)
{
	my ($allheaders) = @_;

	my $finalheaders = &quot;&quot;;
	foreach (@$allheaders) {
		if (m@^HTTP/\d+\.\d+ \d+ @) {
			$finalheaders = &quot;&quot;;
		}
		$finalheaders .= $_;
	}

	return $finalheaders =~ m#^HTTP/1\.\d 200 OK#;
}

sub Login($)
{
	my ($this, $args) = @_;

	my $curl = $this-&gt;{curl};

	$curl-&gt;setopt(CURLOPT_URL, &quot;$this-&gt;{root}/&quot;);
	$curl-&gt;setopt(CURLOPT_FOLLOWLOCATION, 1);
	$curl-&gt;perform() and die &quot;$curl-&gt;errbuf\n&quot;;
	$curl-&gt;setopt(CURLOPT_FOLLOWLOCATION, 0);

	my $eurl = $curl-&gt;getinfo(CURLINFO_EFFECTIVE_URL);
	die &quot;Redirected to [$eurl] - looking for [^$this-&gt;{root}(:\\d+)?/]\n&quot;
		if $eurl !~ m#^$this-&gt;{root}(:\d+)?/#;

	($this-&gt;{jsessionid}) = $eurl =~ m@.*;jsessionid=(.*?)[&amp;\?].*?$@;

	$curl-&gt;setopt(CURLOPT_URL, $this-&gt;{root}
		. &quot;/xml/logpixel?jsessionid=$this-&gt;{jsessionid}&quot;);
	$curl-&gt;perform() and die &quot;$curl-&gt;errbuf\n&quot;;

	$curl-&gt;setopt(CURLOPT_URL, $this-&gt;{root}
		. &quot;/xml/config/TaOverview;&quot;
		. &quot;jsessionid=$this-&gt;{jsessionid}&quot;);
	$curl-&gt;setopt(CURLOPT_FOLLOWLOCATION, 1);
	$curl-&gt;setopt(CURLOPT_POST, 1);
	$curl-&gt;setopt(CURLOPT_POSTFIELDS, join(&quot;&amp;&quot;, (
		&quot;__lf=&quot; . uri_escape(&quot;HomeFlow&quot;),
		&quot;__sendingauthdata=&quot; . uri_escape(&quot;1&quot;),
		&quot;login.SelectContract=&quot; . uri_escape(&quot;&quot;),
		&quot;login.User=&quot; . uri_escape($args-&gt;{auth}-&gt;{customerid}),
		&quot;login.Pass=&quot; . uri_escape($args-&gt;{auth}-&gt;{password}),
	)));

	($this-&gt;{headers}, $this-&gt;{body}) = ([], []);
	$curl-&gt;setopt(CURLOPT_WRITEHEADER, \@{$this-&gt;{headers}});
	$curl-&gt;setopt(CURLOPT_FILE, \@{$this-&gt;{body}});
	$curl-&gt;perform() and die &quot;$curl-&gt;errbuf\n&quot;;
	$curl-&gt;setopt(CURLOPT_FOLLOWLOCATION, 0);
	$curl-&gt;setopt(CURLOPT_POST, 0);

	if ($this-&gt;{verbose}) {
		my $headers = join(&quot;&quot;, @{$this-&gt;{headers}});
		my $body = join(&quot;&quot;, @{$this-&gt;{body}});
		print &quot;[$headers]\n[$body]\n&quot;;
	}

	die &quot;HTTP failure in Login! [@{$this-&gt;{headers}}]\n&quot;
		if !httpOK($this-&gt;{headers});
}

sub GetDomain($$)
{
	# Return the index of the desired domain.
	my ($this, $args) = @_;

	my $curl = $this-&gt;{curl};

	$curl-&gt;setopt(CURLOPT_URL, $this-&gt;{root}
		. &quot;/xml/config/DomainOverview;&quot;
		. &quot;jsessionid=$this-&gt;{jsessionid}&quot;);
	$curl-&gt;setopt(CURLOPT_FOLLOWLOCATION, 1);
	($this-&gt;{headers}, $this-&gt;{body}) = ([], []);
	$curl-&gt;setopt(CURLOPT_WRITEHEADER, \@{$this-&gt;{headers}});
	$curl-&gt;setopt(CURLOPT_FILE, \@{$this-&gt;{body}});
	$curl-&gt;perform() and die &quot;$curl-&gt;errbuf\n&quot;;
	$curl-&gt;setopt(CURLOPT_FOLLOWLOCATION, 0);

	my $body = join(&quot;&quot;, @{$this-&gt;{body}});
	if ($this-&gt;{verbose}) {
		my $headers = join(&quot;&quot;, @{$this-&gt;{headers}});
		print &quot;[$headers]\n[$body]\n&quot;;
	}

	die &quot;HTTP failure in GetDomain! [@{$this-&gt;{headers}}]\n&quot;
		if !httpOK($this-&gt;{headers});

	$body =~ tr#\n##d;
	$body =~ s#^.*?&lt;tr nx=&quot;type:selectable;group:group_domainOverview;prop:editable##;
	$body =~ s#^.*?(&lt;a .*&lt;/a&gt;).*$#$1#;
	$body =~ s#&lt;/a&gt;.*?&lt;a#&lt;/a&gt;\n&lt;a#g;
	my @records = grep(
		m#/xml/config/DomainOverview;jsessionid=$this-&gt;{jsessionid}#,
		grep(/href\s*=\s*&quot;/, split(/\n/, $body)));

	my (%domainmap);
	my $ii = 0;
	foreach my $record (@records) {
		my ($url, $domain) =
			$record =~ m#&lt;a\s+.*href\s*=\s*&quot;(.*)&quot;.*&gt;(.*)&lt;/a&gt;#;
		$url =~ s#&amp;#&amp;#g;
		my ($domainIds) = $url =~ m#&amp;domainOverview.DomainIds=(\d+)#;
		$domainmap{$domain} = {
			index =&gt; $ii,
			domain =&gt; $domain,
			url =&gt; $url,
			domainIds =&gt; $domainIds,
		};
		$ii++;
	}

	return undef if !$domainmap{$args-&gt;{domain}};
	return $domainmap{$args-&gt;{domain}}-&gt;{domainIds};
}

sub EditDNSSettings($$)
{
	# Edit DNS settings for the indexed domain.
	my ($this, $args) = @_;

	my $curl = $this-&gt;{curl};

	$curl-&gt;setopt(CURLOPT_URL, $this-&gt;{root}
		. &quot;/xml/config/DomainOverview;&quot;
		. &quot;jsessionid=$this-&gt;{jsessionid}&quot;);
	$curl-&gt;setopt(CURLOPT_FOLLOWLOCATION, 1);
	$curl-&gt;setopt(CURLOPT_POST, 1);
	$curl-&gt;setopt(CURLOPT_POSTFIELDS, join(&quot;&amp;&quot;, (
		&quot;__lf=&quot; . uri_escape(&quot;MCPrivacyFlow&quot;),
		&quot;__sendingdata=&quot; . uri_escape(&quot;1&quot;),
		&quot;__currentindex%5BDomainOverview%5D=&quot; . uri_escape(&quot;0&quot;),
		&quot;__SYNT%3Ad1e502d0%3AdomainFilter.Set=&quot; . uri_escape(&quot;true&quot;),
		&quot;__SYNT%3Ad1e502d0%3AextendedDomainFilter.Set=&quot;
			. uri_escape(&quot;true&quot;),
		&quot;__SYNT%3Ad1e502d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;extendedDomainFilter&quot;),
		&quot;__SYNT%3Ad1e502d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;domainFilter&quot;),
		&quot;foo=&quot; . uri_escape(&quot;&quot;),
		&quot;__SYNT%3Ad1e1030d0%3A__pageflow=&quot;
			. uri_escape(&quot;settings_wizard_flow&quot;),
		&quot;__SYNT%3Ad1e1039d0%3A__pageflow=&quot;
			. uri_escape(&quot;MCFlow&quot;),
		&quot;__SYNT%3Ad1e1048d0%3A__pageflow=&quot;
			. uri_escape(&quot;dns_wizard_flow&quot;),
		&quot;__SYNT%3Ad1e1056d0%3A__pageflow=&quot;
			. uri_escape(&quot;lock_unlock_flow&quot;),
		&quot;__SYNT%3Ad1e1065d0%3A__pageflow=&quot;
			. uri_escape(&quot;subdomain_delete_flow&quot;),
		&quot;__SYNT%3Ad1e1073d0%3A__pageflow=&quot;
			. uri_escape(&quot;settings_info_flow&quot;),
		&quot;domainFilter.DomainnameSubstring=&quot;
			. uri_escape(&quot;&quot;),
		&quot;__SYNT%3Ad1e1106d0%3AdomainFilter.Set=&quot;
			. uri_escape(&quot;true&quot;),
		&quot;__SYNT%3Ad1e1106d0%3AextendedDomainFilter.Set=&quot;
			. uri_escape(&quot;true&quot;),
		&quot;__SYNT%3Ad1e1106d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;extendedDomainFilter&quot;),
		&quot;__SYNT%3Ad1e1106d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;domainFilter&quot;),
		&quot;domainFilter.DomainType=&quot;
			. uri_escape(&quot;all&quot;),
		&quot;extendedDomainFilter.TargetType=&quot;
			. uri_escape(&quot;all&quot;),
		&quot;extendedDomainFilter.FrontpageStatus=&quot;
			. uri_escape(&quot;all&quot;),
		&quot;__SYNT%3Ad1e1214d0%3AdomainFilter.Set=&quot;
			. uri_escape(&quot;true&quot;),
		&quot;__SYNT%3Ad1e1214d0%3AextendedDomainFilter.Set=&quot;
			. uri_escape(&quot;true&quot;),
		&quot;__SYNT%3Ad1e1214d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;extendedDomainFilter&quot;),
		&quot;__SYNT%3Ad1e1214d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;domainFilter&quot;),
		&quot;__SYNT%3Ad1e1312d0%3AselectDomain.Action=&quot;
			. uri_escape(&quot;reset&quot;),
		&quot;__SYNT%3Ad1e1312d0%3AdomainOrder.OrderBy=&quot;
			. uri_escape(&quot;domainname&quot;),
		&quot;__SYNT%3Ad1e1312d0%3AdomainOrder.OrderAscending=&quot;
			. uri_escape(&quot;true&quot;),
		&quot;__SYNT%3Ad1e1312d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;selectDomain&quot;),
		&quot;__SYNT%3Ad1e1312d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;domainOrder&quot;),
		&quot;__SYNT%3Ad1e1417d0%3AselectDomain.Action=&quot;
			. uri_escape(&quot;reset&quot;),
		&quot;__SYNT%3Ad1e1417d0%3AdomainOrder.OrderBy=&quot;
			. uri_escape(&quot;domaintype&quot;),
		&quot;__SYNT%3Ad1e1417d0%3AdomainOrder.OrderAscending=&quot;
			. uri_escape(&quot;false&quot;),
		&quot;__SYNT%3Ad1e1417d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;selectDomain&quot;),
		&quot;__SYNT%3Ad1e1417d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;domainOrder&quot;),
		&quot;__SYNT%3Ad1e1611d0%3AselectDomain.Action=&quot;
			. uri_escape(&quot;reset&quot;),
		&quot;__SYNT%3Ad1e1611d0%3AdomainOrder.OrderBy=&quot;
			. uri_escape(&quot;state&quot;),
		&quot;__SYNT%3Ad1e1611d0%3AdomainOrder.OrderAscending=&quot;
			. uri_escape(&quot;false&quot;),
		&quot;__SYNT%3Ad1e1611d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;selectDomain&quot;),
		&quot;__SYNT%3Ad1e1611d0%3A__CMD%5BDomainOverview%5D%3ASELWRP=&quot;
			. uri_escape(&quot;domainOrder&quot;),
		&quot;domainOverview.DomainIds=&quot; . uri_escape($args-&gt;{domainIds}),
		&quot;__pageflow=&quot; . uri_escape(&quot;dns_flow2&quot;),
	)));

	($this-&gt;{headers}, $this-&gt;{body}) = ([], []);
	$curl-&gt;setopt(CURLOPT_WRITEHEADER, \@{$this-&gt;{headers}});
	$curl-&gt;setopt(CURLOPT_FILE, \@{$this-&gt;{body}});
	$curl-&gt;perform() and die &quot;$curl-&gt;errbuf\n&quot;;
	$curl-&gt;setopt(CURLOPT_FOLLOWLOCATION, 0);
	$curl-&gt;setopt(CURLOPT_POST, 0);

	if ($this-&gt;{verbose}) {
		my $headers = join(&quot;&quot;, @{$this-&gt;{headers}});
		my $body = join(&quot;&quot;, @{$this-&gt;{body}});
		print &quot;[$headers]\n[$body]\n&quot;;
	}

	die &quot;HTTP failure in EditDNSSettings! [@{$this-&gt;{headers}}]\n&quot;
		if !httpOK($this-&gt;{headers});
}

sub DomainNGDnsUpdate($$)
{
	my ($this, $args) = @_;

	my $curl = $this-&gt;{curl};
	my @ipaddr = split(/\./, $args-&gt;{ipaddr});

	$curl-&gt;setopt(CURLOPT_URL, $this-&gt;{root}
		. &quot;/xml/config/DomainNGDnsUpdate;&quot;
		. &quot;jsessionid=$this-&gt;{jsessionid}&quot;);
	$curl-&gt;setopt(CURLOPT_FOLLOWLOCATION, 1);
	$curl-&gt;setopt(CURLOPT_POST, 1);
	$curl-&gt;setopt(CURLOPT_POSTFIELDS, join(&quot;&amp;&quot;, (
		&quot;__lf=&quot; . uri_escape(&quot;dns_flow2&quot;),
		&quot;__sendingdata=&quot; . uri_escape(&quot;1&quot;),
		&quot;__currentindex%5BDomainNGDnsUpdate%5D=&quot; . uri_escape(&quot;0&quot;),
		&quot;dnsUpdate.UseCname=&quot; . uri_escape(&quot;0&quot;),
		&quot;dnsUpdate.Cname=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.UseCompanyNameserver=&quot; . uri_escape(&quot;1&quot;),
		&quot;dnsUpdate.Nameserver0=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.UseCompanySecondaryNameserver=&quot; . uri_escape(&quot;0&quot;),
		&quot;dnsUpdate.Nameserver1=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.Nameserver2=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.Nameserver3=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.SelectIP=&quot; . uri_escape(&quot;2&quot;),
		&quot;dnsUpdate.IP0=&quot; . uri_escape($ipaddr[0]),
		&quot;dnsUpdate.IP1=&quot; . uri_escape($ipaddr[1]),
		&quot;dnsUpdate.IP2=&quot; . uri_escape($ipaddr[2]),
		&quot;dnsUpdate.IP3=&quot; . uri_escape($ipaddr[3]),
		&quot;dnsUpdate.UseCompanyMx=&quot; . uri_escape(&quot;1&quot;),
		&quot;dnsUpdate.Mx0=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.Mx0Prio=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.Mx1=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.Mx1Prio=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.UseBackupMx=&quot; . uri_escape(&quot;0&quot;),
		&quot;dnsUpdate.Mx2=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.Mx2Prio=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.Mx3=&quot; . uri_escape(&quot;&quot;),
		&quot;dnsUpdate.Mx3Prio=&quot; . uri_escape(&quot;&quot;),
		&quot;__SYNT%3Ad1e1858d0%3AdnsReset.Reset=&quot;
			. uri_escape(&quot;true&quot;),
		&quot;__SYNT%3Ad1e1858d0%3A__CMD%5BDomainNGDnsUpdate%5D%3ASELWRP=&quot;
			. uri_escape(&quot;dnsReset&quot;),
		&quot;__SBMT%3Ad1e1874d0%3A=&quot;
			. uri_escape(&quot;next&quot;),
	)));

	($this-&gt;{headers}, $this-&gt;{body}) = ([], []);
	$curl-&gt;setopt(CURLOPT_WRITEHEADER, \@{$this-&gt;{headers}});
	$curl-&gt;setopt(CURLOPT_FILE, \@{$this-&gt;{body}});
	$curl-&gt;perform() and die &quot;$curl-&gt;errbuf\n&quot;;
	$curl-&gt;setopt(CURLOPT_FOLLOWLOCATION, 0);
	$curl-&gt;setopt(CURLOPT_POST, 0);

	if ($this-&gt;{verbose}) {
		my $headers = join(&quot;&quot;, @{$this-&gt;{headers}});
		my $body = join(&quot;&quot;, @{$this-&gt;{body}});
		print &quot;[$headers]\n[$body]\n&quot;;
	}

	die &quot;HTTP failure in DomainNGDNSUpdate! [@{$this-&gt;{headers}}]\n&quot;
		if !httpOK($this-&gt;{headers});
}

###############################################################################

package main;

use strict;
use Getopt::Std;

use vars qw($opt_v);
die if !getopts(&quot;v&quot;);
my $verbose = $opt_v ? 1 : 0;

## Changed the line below. Added new parameters $uname and $upass. Added $ARGV[2] and $ARGV[3]
my ($ip, $domain, $uname, $upass) = ($ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]);
## Changed line below to also check for !$uname and !$upass
if (!$ip || $ip !~ m#^\d+\.\d+\.\d+\.\d+$# || !$domain || !$uname || !$upass) {
## Changed the usage instructions below to include login and password info
	die &lt;&lt;EOM;
Usage: $0 [-v(erbose)] &lt;ipaddr&gt; &lt;domain&gt; &lt;loginname&gt; &lt;password&gt;
Example: $0 111.222.333.444 domainname.net 1and1loginname somepassword
EOM
}

$| = 1;

my $a1 = Update1and1-&gt;new({
	verbose =&gt; $verbose,
});

## Changed auth array to use the vars assigned above ($uname and $upass) instead of hardcoding them in here
$a1-&gt;Login({
	auth =&gt; {
#		&quot;customerid&quot; =&gt; &quot;someloginname&quot;,
#		&quot;password&quot; =&gt; &quot;somepassword&quot;,
		&quot;customerid&quot; =&gt; $uname,
		&quot;password&quot; =&gt; $upass,
	},
});
my $domainIds = $a1-&gt;GetDomain({
	domain =&gt; $domain,
});
die &quot;Couldn&#039;t find \&quot;$domain\&quot;!\n&quot; if !defined($domainIds);

$a1-&gt;EditDNSSettings({
	domainIds =&gt; $domainIds,
});

$a1-&gt;DomainNGDnsUpdate({
	ipaddr =&gt; $ip,
});
</pre>
<p>Now you can just copy and paste these and save them to your home folder in the server where you host your site, or just download the zip below and follow the instrcutions in the readme file.<br />
<a href='http://www.foscode.com/wp-content/uploads/2012/02/dynamic1and1.tar'>dynamic1and1</a></p>
<p>****  DON&#8217;T FORGET TO CHANGE THE SETTINGS TO MATCH YOUR SITE,LOGIN AND PASSWORD INFORMATION ******</p>
<p>You&#8217;ll pretty much have to:</p>
<p>1. Unzip the files to your home folder<br />
2. Copy the config.cfg file to /etc/dynamic1and1/config.cfg and edit the settings accordingly<br />
3. (optional) &#8211;> If you unzipped the app into a folder other then your home folder, edit line 8 in checkdns accordingly &#8211;> function update_dns()<br />
4. (optional) &#8211;> If you decided to place the config.cfg someplace else, edit line 4 in checkdns accordingly &#8211;> source /etc/dynamic1and1/config.cfg<br />
4. Create a cron job to execute checkdns as often as you see fit</p>
<p>*****  KNOWN ISSUES ******<br />
You should not get any errors when you run the script, however, if you get an error like:</p>
<p>WWW::Curl::Easy=SCALAR(0&#215;7855f0)->errbuf</p>
<p>It means you either have an outdated version of cacert or do not have it installed. Just go ahead and install it and you should be good to go. If you are running ubuntu, just do:</p>
<p>sudo apt-get install ca-certificates </p>
<p>If you running a different flavor, head over to to your distro repository and search for ca-certificate and install it from there.</p>
<p>That&#8217;s it, you should now have your dynamic address updated on 1&#038;1 DNS servers whenever it changes. Thank you for stopping by and please share with others, after all, code should be free.<a href="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" rel="wp-prettyPhoto[g883]"><img src="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" alt="foscode.com | because code should be free" title="FOSCODE" width="227" height="18" class="alignright size-full wp-image-221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.foscode.com/dynamic-dns-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ExtJS Treepanel with MySQL data</title>
		<link>http://www.foscode.com/extjs-treepanel-mysql-data/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=extjs-treepanel-mysql-data</link>
		<comments>http://www.foscode.com/extjs-treepanel-mysql-data/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 18:04:20 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[treepanel]]></category>

		<guid isPermaLink="false">http://www.foscode.com/?p=876</guid>
		<description><![CDATA[In this tutorial I'll show you how to build an ExtJS treepanel using data coming from MySQL, while using PHP to create the json array sent to the treepanel.]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I&#8217;ll show you how to build an ExtJS treepanel using data coming from MySQL, while using PHP to create the json array sent to the treepanel. Here&#8217;s how:</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=875' title='treepanel'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/12/treepanel-150x150.png" class="attachment-thumbnail" alt="" title="treepanel" /></a>

</div>
<p><span id="more-876"></span></p>
<p>1. Create ourapp.js, this will contain all our js files in steps 2 and 3:</p>
<p>ourapp.js</p>
<pre class="brush: javascript">
Ext.onReady(function(){
        // Items from step 2 and 3 will go in here
});
</pre>
<p>2. Create the treepanel:</p>
<pre class="brush: javascript">
var tpanel = new Ext.tree.TreePanel({

    	id: &#039;tree-panel&#039;,

    	height: 477,

        useArrows: true,                    

	    animate: true,

	    border: false,

	    root: {

	        nodeType: &#039;async&#039;,

	        text: &#039;Items&#039;,

	        draggable: false, 

	        id: &#039;0&#039;                       

	    },        

        loader: new Ext.tree.TreeLoader({

            dataUrl:&#039;itemlist.php&#039;, // This is where our treepanel items come from

            requestMethod: &#039;GET&#039;

        })

    });
</pre>
<p>3. Create the panel that&#8217;ll house the treepanel:</p>
<pre class="brush: javascript">
var homepanel = new Ext.Panel({

			      id: &#039;mainpanel_id&#039;,

			      renderTo: &#039;maindiv&#039;,

			      width : 1218,

			      height: 545,

			      frame: true,

			      layout: &#039;border&#039;,

			      items: [{

				        region:&#039;west&#039;, 

				        margins: &#039;0 0 0 0 &#039;, 

				        id: &#039;westregion_id&#039;,

				        width: 300,

				        autoHeight: true,

				        layout: &#039;fit&#039;,

				        frame: true,

				        items:[tpanel] // treepanel goes here

				    },{

				        region: &#039;east&#039;,     

				        margins: &#039;0 0 0 0&#039;,

				        id: &#039;eastregion_id&#039;,

				        width: 900, 

				        autoHeight: true,

				        layout: &#039;fit&#039;,

				        frame: true,	        

				        items: [] // Add whatever other items you&#039;d like here

				    },{

				        title: &#039;Center Region&#039;,

				        region: &#039;center&#039;,     // center region is required, no width/height specified

				        xtype: &#039;container&#039;,

				        layout: &#039;fit&#039;,

				        margins: &#039;1 1 1 1&#039; // top, right, bottom, left

				    }]

});
</pre>
<p>4. Now create the php file that&#8217;ll load the data from MySQL and create the json array for us:<br />
itemlist.php</p>
<pre class="brush: php">
&lt;?php
include(&#039;../Connections/yourconnectiondata.php&#039;);

//connection String
$_con = mysql_connect($hostname, $username, $password) or die(&#039;Could not connect: &#039; . mysql_error());
//select database
$bool = mysql_select_db($database, $_con);
if ($bool === False){
	print &quot;can&#039;t find $database&quot;;
}

$query = &quot;SELECT item_id as id, item_name as text, &#039;true&#039; as leaf FROM items&quot;;
$res = mysql_query($query, $_con);

if (mysql_num_rows($res) &gt; 0) {
	while($obj = mysql_fetch_object($res)){
		$arr[] = $obj;		

	    }

		$myData = $arr;

		} else {     

		$myData = &#039;&#039;;

		}			

echo json_encode($myData);
?&gt;
</pre>
<p>5. Create the index file that&#8217;ll put it all together (remember to change the paths to where you have your extjs files):<br />
index.php</p>
<pre class="brush: html">
&lt;html&gt;

	&lt;body&gt;

		&lt;table align=&quot;center&quot; class=&quot;contenttable&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot;&gt;

    &lt;/br&gt;

        &lt;tr&gt;

            &lt;td id=&quot;maindiv&quot;&gt;&lt;/td&gt;

        &lt;/tr&gt;

	&lt;/table&gt;

	&lt;/body&gt;

                &lt;!-- include ext-all.css --&gt;

		&lt;link rel=&quot;stylesheet&quot; href=&quot;ext/resources/css/ext-all.css&quot; /&gt;

		&lt;!-- include ext-base.js --&gt;

		&lt;script type=&quot;text/javascript&quot; src=&quot;ext/adapter/ext/ext-base.js&quot;&gt;&lt;/script&gt;

		&lt;!-- include ext-all.js --&gt;

		&lt;script type=&quot;text/javascript&quot; src=&quot;ext/ext-all.js&quot;&gt;&lt;/script&gt;    

		&lt;!-- include our app js files --&gt;

		&lt;script type=&quot;text/javascript&quot; src=&quot;ourapp.js&quot;&gt;&lt;/script&gt;

&lt;/html&gt;
</pre>
<p>6. Our entire ourapp.js should look like this:<br />
ourapp.js</p>
<pre class="brush: javascript">
Ext.onReady(function(){

var tpanel = new Ext.tree.TreePanel({

    	id: &#039;tree-panel&#039;,

    	height: 477,

        useArrows: true,                    

	    animate: true,

	    border: false,

	    root: {

	        nodeType: &#039;async&#039;,

	        text: &#039;Items&#039;,

	        draggable: false, 

	        id: &#039;0&#039;                       

	    },        

        loader: new Ext.tree.TreeLoader({

            dataUrl:&#039;itemlist.php&#039;, // This is where our treepanel items come from

            requestMethod: &#039;GET&#039;

        })

    });	

var homepanel = new Ext.Panel({

			      id: &#039;mainpanel_id&#039;,

			      renderTo: &#039;maindiv&#039;,

			      width : 1218,

			      height: 545,

			      frame: true,

			      layout: &#039;border&#039;,

			      items: [{

				        region:&#039;west&#039;, 

				        margins: &#039;0 0 0 0 &#039;, 

				        id: &#039;westregion_id&#039;,

				        width: 300,

				        autoHeight: true,

				        layout: &#039;fit&#039;,

				        frame: true,

				        items:[tpanel] // treepanel goes here

				    },{

				        region: &#039;east&#039;,     

				        margins: &#039;0 0 0 0&#039;,

				        id: &#039;eastregion_id&#039;,

				        width: 900, 

				        autoHeight: true,

				        layout: &#039;fit&#039;,

				        frame: true,	        

				        items: [] // Add whatever other items you&#039;d like here

				    },{

				        title: &#039;Center Region&#039;,

				        region: &#039;center&#039;,     // center region is required, no width/height specified

				        xtype: &#039;container&#039;,

				        layout: &#039;fit&#039;,

				        margins: &#039;1 1 1 1&#039; // top, right, bottom, left

				    }]

});   

});
</pre>
<p>7. You&#8217;re welcome and enjoy. Thank you for stopping by and please share with others, after all, code should be free.<a href="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" rel="wp-prettyPhoto[g876]"><img src="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" alt="foscode.com | because code should be free" title="FOSCODE" width="227" height="18" class="alignright size-full wp-image-221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.foscode.com/extjs-treepanel-mysql-data/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to connect to Microsoft SQL server from Linux via command line</title>
		<link>http://www.foscode.com/connect-microsoftsql-server-from-linux/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=connect-microsoftsql-server-from-linux</link>
		<comments>http://www.foscode.com/connect-microsoftsql-server-from-linux/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 14:40:34 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[freetds]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.foscode.com/?p=850</guid>
		<description><![CDATA[<p>Although 95% of my work is done in Linux and MySQL, there are those unfortunate times I need to manipulate some data on a Microsoft SQL server. I didn&#8217;t want to install any apps on my computer that weren&#8217;t open source and I didn&#8217;t want to use a Micro$uck app through wine either. So after a few searches I came across an open source project called Sqsh.  In this tutorial I&#8217;ll show you how to install sqsh and access a Microsoft SQL server from the Linux command line.</p>
<p><a href="http://www.foscode.com/connect-microsoftsql-server-from-linux/" class="more-link">Read more on How to connect to Microsoft SQL server from Linux via command line&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Although 95% of my work is done in Linux and MySQL, there are those unfortunate times I need to manipulate some data on a Microsoft SQL server. I didn&#8217;t want to install any apps on my computer that weren&#8217;t open source and I didn&#8217;t want to use a Micro$uck app through wine either. So after a few searches I came across an open source project called Sqsh.  In this tutorial I&#8217;ll show you how to install sqsh and access a Microsoft SQL server from the Linux command line.</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=868' title='sqsh'><img width="150" height="93" src="http://www.foscode.com/wp-content/uploads/2011/09/sqsh-150x93.gif" class="attachment-thumbnail" alt="" title="sqsh" /></a>

</div>
<p><span id="more-850"></span><br />
Sqsh (pronounced skwish) is short for SQshelL (pronounced s-q-shell), it is intended as a replacement for &#8216;isql&#8217;, supplied by Sybase. Sqsh is intended to provide much of the functionality provided by a good shell, such as variables, redirection, pipes, back-grounding, job control, history, command completion, and dynamic configuration. Sqsh has quite a few features, this is just a short list, for detailed explanation and examples please <a href="http://www.sqsh.org/sqsh_features.html"  target="_blank">visit their site here.</a></p>
<p>. Provides all commands provided by isql<br />
. Variables are provided in sqsh, much in the same way they are used within a standard shell<br />
. Redirection &#038; Pipes<br />
. As of release 1.2, sqsh supports full csh-style command aliasing<br />
. Command substitution<br />
. Backgrounding &#038; Job Control<br />
. SQL Batch History<br />
. Configurable Exit Status<br />
. Ability to transfer the result set from any command batch to another server (or even the same server) via the Sybase bcp protocol<br />
. Remote Procedure Calls<br />
. Simple Scripting</p>
<p>Now that you know what sqsh does, let&#8217;s go ahead and install and start using it. If you are running Ubuntu, it is very easy, just do:</p>
<pre class="brush: bash">
sudo apt-get install freetds
sudo apt-get install sqsh
</pre>
<p>You might also need a couple of other libraries installed depending on your setup, but the 2 apps above should contain everything you need.<br />
If not running Ubuntu, get <a href="http://sourceforge.net/projects/sqsh/files/" target="_blank">sqsh&#8217;s latest source from sourceforge</a> and follow the install steps in the Install document inside the tar file you will be downloading.</p>
<p>Now that both freetds and sqsh have been installed, go ahead and create an entry at the end of the file /etc/freetds/freetds.conf that includes the M$Sql server you&#8217;ll be accessing:</p>
<p>/etc/freetds/freetds.conf</p>
<pre class="brush: bash">
[MSuck]
        host = msuckserver
        port = 1433
        tds version = 8.0
</pre>
<p>Now create the sqsh configuration file containing your credentials and any other setting you&#8217;d like to have predefined. This file must reside in your home directory, otherwise you&#8217;ll have to start sqsh with the -r flag, which specifies the path and file to be used instead:</p>
<p>-r [sqshrc[:sqshrc ...]]</p>
<p>Specifies an alternate .sqshrc file to be processed, rather than the default. If no sqshrc is<br />
supplied following -r, then no initialization files are processed. This flag must be the<br />
first argument supplied on the command line, all other instances will be ignored.</p>
<p>So, let&#8217;s do it, create the new file .sqshrc and add your settings (obviously change each of the settings to match your own):</p>
<p>~/.sqshrc</p>
<pre class="brush: html">
user@laptop:~$ vim ~/.sqshrc

\set username=msqlloginname
\set password=msqlloginpassword
\set database=msqldbname
\set style=vert
</pre>
<p>Now you have both freetds and sqsh installed and configured, just go ahead and run it. For more information, options and in depth usage <a href="http://www.sqsh.org/sqsh_man.html" target="_blank">see the manual</a>, or as one of my bosses used to say RTFM (read the fine manual) <img src='http://www.foscode.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />        </p>
<pre class="brush: html">
user@laptop:~$ sqsh -SMSuck

sqsh-2.1 Copyright (C) 1995-2001 Scott C. Gray
This is free software with ABSOLUTELY NO WARRANTY
For more information type &#039;\warranty&#039;
1&gt; select field1, field2, field3 from table where field1 = &#039;test&#039;;
2&gt; go
field1: test
field2: other data
field3: 

(1 row affected)
1&gt; exit
user@laptop:~$
</pre>
<p>That&#8217;s it, you are now able to connect to a Microsoft SQL server from the command line in Linux and manipulate your data as you wish. Hopefully this tutorial helped you. Thank you for stopping by and please share with others, after all, code should be free.<a href="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" rel="wp-prettyPhoto[g850]"><img src="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" alt="foscode.com | because code should be free" title="FOSCODE" width="227" height="18" class="alignright size-full wp-image-221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.foscode.com/connect-microsoftsql-server-from-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache Virtual Hosts in Ubuntu in 5 easy steps</title>
		<link>http://www.foscode.com/apache-virtual-host-ubuntu/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=apache-virtual-host-ubuntu</link>
		<comments>http://www.foscode.com/apache-virtual-host-ubuntu/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 16:41:35 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[Virtual Host]]></category>

		<guid isPermaLink="false">http://www.foscode.com/?p=844</guid>
		<description><![CDATA[Creating Virtual Hosts in Apache and Ubuntu in 5 easy steps]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I&#8217;ll walk you through setting up 3 Apache virtual hosts running on a single Ubuntu server. An Apache virtual host, as explained by Apache, refers to the practice of running more than one web site (such as www.company1.com and www.company2.com) on a single machine. Virtual hosts can be &#8220;IP-based&#8221; or &#8220;name-based&#8221;. By default, Ubuntu already has this capability enabled, so things are much easier to configure these days. Enough with the intro, this is how you do it:</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=843' title='httpd_logo_wide'><img width="150" height="72" src="http://www.foscode.com/wp-content/uploads/2011/08/httpd_logo_wide-150x72.gif" class="attachment-thumbnail" alt="" title="httpd_logo_wide" /></a>

</div>
<p><span id="more-844"></span></p>
<p>We are going to create 3 sites, site1.com, site2.com and site3.com</p>
<p>1. Create the folders that will host your new sites. By default, Apache in Ubuntu serves from /var/www. So create these:</p>
<pre class="brush: bash">
mkdir /var/www/site1
mkdir /var/www/site2
mkdir /var/www/site3
</pre>
<p>2. Copy the current default setting found in /etc/apache2/sites-available/default and name it the same as your new site.</p>
<pre class="brush: bash">
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/site1
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/site2
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/site3
</pre>
<p>3. Edit the new config files for each site using your preferred text editor. Add the line ServerName server1 right below the ServerAdmin line and change both DocumentRoot and Directory to point to your new sites.<br />
This is what it should look like (you&#8217;ll do exactly the same for each of your 3 new sites, repeat this step for as many new sites as you&#8217;ll be creating):</p>
<p>/etc/apache2/sites-available/site1</p>
<pre class="brush: html">
&lt;VirtualHost *:80&gt;
	ServerAdmin webmaster@localhost
	ServerName site1

	DocumentRoot /var/www/site1
	&lt;Directory /&gt;
		Options FollowSymLinks
		AllowOverride All
	&lt;/Directory&gt;
	&lt;Directory /var/www/site1/&gt;
		Options -Indexes FollowSymLinks MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
	&lt;/Directory&gt;

	ErrorLog ${APACHE_LOG_DIR}/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog ${APACHE_LOG_DIR}/access.log combined

&lt;/VirtualHost&gt;
</pre>
<p>4. After you have edited the config files for each of the 3 or how many virtual hosts you are creating, just tell Apache to start serving the new domains and stop serving the default:</p>
<pre class="brush: bash">
sudo a2ensite site1
sudo a2ensite site2
sudo a2ensite site3
sudo a2dissite default
</pre>
<p>5. Now reload apache and you should be able to get to each of your new domains:</p>
<pre class="brush: bash">
sudo /etc/init.d/apache2 reload
</pre>
<p>Congratulations, you have done it, 3 sites running off of the same Apache server. Hopefully this tutorial helped you. Thank you for stopping by and please share with others, after all, code should be free.<a href="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" rel="wp-prettyPhoto[g844]"><img src="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" alt="foscode.com | because code should be free" title="FOSCODE" width="227" height="18" class="alignright size-full wp-image-221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.foscode.com/apache-virtual-host-ubuntu/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Installing jasperserver 4.0 with mysql 5.5</title>
		<link>http://www.foscode.com/installing-jasperserver40-mysql55/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=installing-jasperserver40-mysql55</link>
		<comments>http://www.foscode.com/installing-jasperserver40-mysql55/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 15:22:17 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[mysql jasperserver code tomcat]]></category>

		<guid isPermaLink="false">http://www.foscode.com/?p=830</guid>
		<description><![CDATA[<p>Installing jasperserver on tomcat with mysql5.5 it isn&#8217;t as straight forward as one might think (or as their manual implies). I was trying to install the latest version of jasperserver using the war method and found the script fails.<br />
Reason: there are two files with the wrong syntax that need to be edited (this might also affect other versions of mysql and jasperserver). The files mentioned are located in this folder:<br />
jasperreports-server-cp-4.0.0-bin/buildomatic/install_resources/sql/mysql/ and they are called:</p>
<p><a href="http://www.foscode.com/installing-jasperserver40-mysql55/" class="more-link">Read more on Installing jasperserver 4.0 with mysql 5.5&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Installing jasperserver on tomcat with mysql5.5 it isn&#8217;t as straight forward as one might think (or as their manual implies). I was trying to install the latest version of jasperserver using the war method and found the script fails.<br />
Reason: there are two files with the wrong syntax that need to be edited (this might also affect other versions of mysql and jasperserver). The files mentioned are located in this folder:<br />
jasperreports-server-cp-4.0.0-bin/buildomatic/install_resources/sql/mysql/ and they are called:</p>
<p>js-create.ddl<br />
quartz.ddl</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=829' title='jasperserver'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/08/jasperserver-150x150.png" class="attachment-thumbnail" alt="" title="jasperserver" /></a>

</div>
<p><span id="more-830"></span></p>
<p>Both of these files have the wrong syntax for creating the tables and setting its default type. This is how you fix it and successfully install jasperserver:<br />
Download dependencies and jasperserver:</p>
<pre class="brush: bash">
sudo apt-get install openjdk-6-jdk
</pre>
<p>You can grab the latest <a href=" http://sourceforge.net/projects/jasperserver/files/JasperServer/JasperServer%204.0.0/jasperreports-server-cp-4.0.0-bin.zip/download"  target="_blank">jasperserver from here</a>. This will download a file called jasperreports-server-cp-4.0.0-bin.zip, if not, just rename it, then unzip it. Now lets start configuring things:</p>
<p>1. Change all occurrences of type=InnoDB to ENGINE=InnoDB (the files affected are listed below) and also<br />
2. Change the following create table statement (notice the single back ticks around  `maxValue`) maxValue is a reserved word in mysql5.5 and the compile fails if you try to create a table with a field name maxValue.<br />
So open a text editor and edit the following 2 files:</p>
<p>js-create.ddl<br />
quartz.ddl</p>
<pre class="brush: bash">
jasperreports-server-cp-4.0.0-bin/buildomatic/install_resources/sql/mysql/js-create.ddl
jasperreports-server-cp-4.0.0-bin/buildomatic/install_resources/sql/mysql/quartz.ddl
</pre>
<p>These are the changes, they apply to both files above (obviously, don&#8217;t add the comment &#8212; CORRECT!!! &#8212;- when editing the file:</p>
<pre class="brush: bash">
WRONG:

create table JIDataType (
        id bigint not null,
        type tinyint,
        maxLength integer,
        decimals integer,
        regularExpr varchar(255),
        minValue tinyblob,
        maxValue tinyblob,       --- WRONG !!!  ---
        strictMin bit,
        strictMax bit,
        primary key (id)
    ) ENGINE=InnoDB;

CORRECT:

       create table JIDataType (
        id bigint not null,
        type tinyint,
        maxLength integer,
        decimals integer,
        regularExpr varchar(255),
        minValue tinyblob,
        `maxValue` tinyblob,       --- CORRECT !!!  -----
        strictMin bit,
        strictMax bit,
        primary key (id)
    ) ENGINE=InnoDB;
</pre>
<p>3. You should now be able to compile and install jasperserver, first start by copying and editing the config file. Assuming you have downloaded and unzipped the jasperserver file into your home directory, do the following:</p>
<pre class="brush: bash">
cd ~/jasperreports-server-cp-4.0.0-bin/buildomatic/
cp sample_conf/mysql_master.properties default_master.properties
</pre>
<p>4. Now edit the config file default_master.properties with your correct mysql settings, it should look similar to this:</p>
<pre class="brush: bash">
appServerType = tomcat6
appServerDir = /var/lib/tomcat6
dbType=mysql
dbHost=localhost
dbUsername=yourmysqlusername
dbPassword=yourmysqlpassword
js.dbName=jasperserver
</pre>
<p>5. After the config file above has been copied and edited, run these: </p>
<pre class="brush: bash">
./js-ant gen-config
./js-ant create-js-db
./js-ant init-js-db-ce
./js-ant import-minimal-ce
sudo ./js-ant deploy-webapp-ce
</pre>
<p>6. Restart tomcat</p>
<pre class="brush: bash">
sudo service tomcat6 restart
</pre>
<p>7. After jasperserver has been installed and it is up and running, we need to edit the file below in jasperserver and reload the jar because jasperserver still fails with mysql 5.5 when handling numeric fields:</p>
<pre class="brush: bash">
cp /var/lib/tomcat6/webapps/jasperserver/WEB-INF/lib/jasperserver-repository-hibernate-4.0.0.jar ~/tmp/
cd ~/tmp/
unzip jasperserver-repository-hibernate-4.0.0.jar
</pre>
<p>8. Use your preferred text editor to edit the line for maxValue  (line #19) notice the addition of column=&#8221;[maxValue]&#8221;  in the file com/jaspersoft/jasperserver/api/metadata/common/service/impl/hibernate/persistent/RepoDataType.hbm.xml:</p>
<pre class="brush: bash">
vim com/jaspersoft/jasperserver/api/metadata/common/service/impl/hibernate/persistent/RepoDataType.hbm.xml
</pre>
<p>The entries look like the following, replace the one that says WRONG with the CORRECT one:</p>
<pre class="brush: html">
&lt;property name=&quot;maxValue&quot; type=&quot;serializable&quot;/&gt;  ---&gt; WRONG

&lt;property name=&quot;maxValue&quot; column=&quot;[maxValue]&quot; type=&quot;serializable&quot;/&gt;  ---&gt; CORRECT
</pre>
<p>9. rename the original jar to something else or just delete it and rebuild the jar with your changes:</p>
<pre class="brush: bash">
jar cvf jasperserver-repository-hibernate-4.0.0.jar com META-INF
</pre>
<p>10. Login to Tomcat Web Application Manager and stop jasperserver<br />
11. Replace the old jar with the new one: </p>
<pre class="brush: bash">
cd ~/tmp/
sudo cp -r jasperserver-repository-hibernate-4.0.0.jar /var/lib/tomcat6/webapps/jasperserver/WEB-INF/lib/
</pre>
<p>12. Restart jasperserver via Tomcat Web Application Manager </p>
<p>13. You&#8217;re done, you should now be able to have your own jasperserver running on mysql5.5 without any errors. Hopefully this tutorial helped you. Thank you for stopping by and please share with others, after all, code should be free.<a href="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" rel="wp-prettyPhoto[g830]"><img src="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" alt="foscode.com | because code should be free" title="FOSCODE" width="227" height="18" class="alignright size-full wp-image-221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.foscode.com/installing-jasperserver40-mysql55/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>php ajax/jquery countdown</title>
		<link>http://www.foscode.com/php-ajaxjquery-countdown/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-ajaxjquery-countdown</link>
		<comments>http://www.foscode.com/php-ajaxjquery-countdown/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 17:27:51 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.foscode.com/?p=806</guid>
		<description><![CDATA[I recently came across the need to have a countdown displayed in one of our applications. After a few searches I found  a jquery plugin called jquery countdown.]]></description>
			<content:encoded><![CDATA[<p>I recently came across the need to have a countdown displayed in one of our applications. I was going to be releasing a new version of our app and wanted the users to have an idea of how long it was going to take until the application was up and running. After a few searches I found a plugin that does just what I needed, it is a jquery plugin, very simple to use and to add to any php application in just a matter of minutes.</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=823' title='countdown'><img width="150" height="118" src="http://www.foscode.com/wp-content/uploads/2011/08/countdown-150x118.png" class="attachment-thumbnail" alt="" title="countdown" /></a>

</div>
<p><span id="more-806"></span><br />
The plugin is called jQuery Countdown, and it can be <a href="http://keith-wood.name/countdown.html " target="_blank">found here</a>. This is a simple plugin and as their site states, it sets a div or span to show a countdown to/from a given time.</p>
<p>Enough said, this is how you do it:</p>
<p>1. Download jquery and load it to your app server, all you need is the bare minimum, so just get jquery.min.js. Assuming your application is located in /var/www/, create a folder for jquery and place the file there:</p>
<pre class="brush: bash">
cd /var/www/
mkdir jquery
cd jquery
wget http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js
</pre>
<p>2. Download the<a href="http://keith-wood.name/countdown.html" target="_blank"> jQuery Countdown package</a> to your computer. The package is a zip file, all you need are 2 files from it.<br />
Open it and extract only the 2 files called jquery.countdown.css and jquery.countdown.js to the jquery folder you created on your server (same place where you placed jquery.min.js in the step above).</p>
<p>3. Now create the php page that will display the countdown. jquery.countdown has many different options you can use, these are just a few I have used to create my countdown,<a href="http://keith-wood.name/countdownRef.html" target="_blank"> please visit their site</a> to see the entire list of options and all different settings you can use:</p>
<p>comingsoon.php</p>
<pre class="brush: php">
&lt;html&gt;

&lt;head&gt;

    &lt;title&gt;&#039;Coming Soon&#039;&lt;/title&gt;

    &lt;script type=&quot;text/javascript&quot; src=&quot;jquery/jquery.min.js&quot;&gt;&lt;/script&gt;

    &lt;style type=&quot;text/css&quot;&gt; 

	@import &quot;jquery/jquery.countdown.css&quot;;

	#defaultCountdown { width: 240px; height: 45px; -moz-border-radius: 5px; border-radius: 5px; margin-left: 80px;} 

    &lt;/style&gt; 

    &lt;script type=&quot;text/javascript&quot; src=&quot;jquery/jquery.countdown.js&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;

$(function () {

// new Date(year, mth - 1, day, hr, min, sec)

// year --&gt; year the event will occur

// mth --&gt; month the event will occur

// day --&gt; day the event will occur

// hr --&gt; hour the event will occur

// min --&gt; min the event will occur

// sec --&gt; sec the event will occur

var newserver = new Date(2012, 8 - 1, 13, 19); 

$(&#039;#defaultCountdown&#039;).countdown({until: newserver}); 

$(&#039;#removeCountdown&#039;).toggle(function() { 

        $(this).text(&#039;Re-attach&#039;); 

        $(&#039;#defaultCountdown&#039;).countdown(&#039;destroy&#039;); 

    }, 

    function() { 

        $(this).text(&#039;Remove&#039;); 

        $(&#039;#defaultCountdown&#039;).countdown({until: newserver}); 

    } 

);

});

&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;div id=&quot;mx&quot;&gt;	

	&lt;?php echo _(&#039;&lt;p&gt; Site coming soon.&#039;) .&#039;&lt;br&gt;&#039;;?&gt;

	&lt;?php echo &#039;&lt;/p&gt;&#039;; ?&gt;

	&lt;div id=&quot;defaultCountdown&quot;&gt;&lt;/div&gt;

	&lt;?php echo &#039;&lt;br&gt;&#039;; ?&gt;

&lt;/div&gt;

&lt;/body&gt;

&lt;/html&gt;
</pre>
<p>That&#8217;s it, now browse to your page and you&#8217;ll see the countdown. Hopefully this tutorial helped you. Thank you for stopping by and please share with others, after all, code should be free.<a href="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" rel="wp-prettyPhoto[g806]"><img src="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" alt="foscode.com | because code should be free" title="FOSCODE" width="227" height="18" class="alignright size-full wp-image-221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.foscode.com/php-ajaxjquery-countdown/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Connect to Cisco Nortel Contivity VPN from Ubuntu</title>
		<link>http://www.foscode.com/connect-nortel-contivity-vpn-ubuntu/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=connect-nortel-contivity-vpn-ubuntu</link>
		<comments>http://www.foscode.com/connect-nortel-contivity-vpn-ubuntu/#comments</comments>
		<pubDate>Sun, 07 Aug 2011 18:19:19 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://www.foscode.com/?p=792</guid>
		<description><![CDATA[Cisco VPN, Ubuntu, Linux]]></description>
			<content:encoded><![CDATA[<p>I finally figured out how to get Ubuntu to connect to a Nortel Contivity VPN. It took quite a while to find the right app and configuration, but after a lot of search, I&#8217;ve found a package called vpnc (vpn client for cisco3000 VPN Concentrator). The <a href="http://www.unix-ag.uni-kl.de/~massar/vpnc/" target="_blank">project homepage is found here</a> and it is supposed to work with:</p>
<p>    * Cisco VPN concentrator 3000 Series<br />
    * Cisco IOS routers<br />
    * Cisco PIX / ASA Zecurity Appliances<br />
    * Juniper/Netscreen </p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=803' title='vpn'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/08/vpn1-150x150.png" class="attachment-thumbnail" alt="" title="vpn" /></a>

</div>
<p><span id="more-792"></span><br />
and it supports the following:</p>
<p> Authentications: Hybrid, Pre-Shared-Key + XAUTH, Pre-Shared-Key<br />
 IKE DH-Groups: dh1 dh2 dh5<br />
 Hash Algo (IKE/IPSEC): md5 sha1<br />
 Encryptions (IKE/IPSEC): (null) (1des) 3des aes128 aes192 aes256<br />
 Perfect Forward Secrecy: nopfs dh1 dh2 dh5</p>
<p>However, the version we need to work with the Nortel Contivity group authentication is found in the svn repos.<br />
Before we get there, we need to install some dependencies:</p>
<p>1. Install dependencies</p>
<pre class="brush: bash">
sudo apt-get install libcrypt*
sudo apt-get install gnutls-bin
sudo apt-get install libgnutls-devsudo
sudo apt-get install resolvconf
</pre>
<p>*** VERY IMPORTANT ***<br />
You will find there are different branches of vpnc client, you need the one from the vpnc-nortel branch as I mentioned above. The branches you&#8217;ll find are:<br />
 vpnc-0.3.2-hybrid/<br />
 vpnc-0.4.0-hybrid/<br />
 vpnc-nortel/<br />
 vpnc-sonicwall/<br />
There is also a package called vpnc-0.5.3.tar.gz, DON&#8217;T get this one either.</p>
<p>The reason you need the vpnc-nortel branch is because it supports these 2 options, which are crucial for this to work:<br />
&#8211;auth-mode gpassword &#8211;vendor nortel</p>
<p>2. Go to a directory where you&#8217;d like to download the app and download the latest vpnc-nortel <a href="http://svn.unix-ag.uni-kl.de/vpnc/branches/vpnc-nortel/" target="_blank">client from here</a> via svn. The version I currently installed is revision 457. Once the command below is ran, a new folder is created called vpnc-nortel</p>
<pre class="brush: bash">
svn checkout http://svn.unix-ag.uni-kl.de/vpnc/branches/vpnc-nortel/
</pre>
<p>3. Install the vpn client:</p>
<pre class="brush: bash">
cd vpnc-nortel
make
sudo make install
</pre>
<p>4. Run the app. There are 2 ways you can start the vpn:<br />
4.1 Method 1 (Command line):</p>
<pre class="brush: bash">
sudo vpnc --gateway vpn.server.name --id yourgroupid --username yourusername --natt-mode nortel-udp --pfs dh5 --dh dh5 --debug 1 --auth-mode gpassword --vendor nortel

sudo route add default gw 192.168.69.2
sudo route del -net 10.36.0.0 netmask 255.255.248.0 dev tun0
sudo route del -net default netmask 0.0.0.0 dev tun0
sudo route add -net 10.0.0.0 netmask 255.0.0.0 dev tun0
</pre>
<p>4.2 Method 2 (Config file):</p>
<p>Create the vpn config file called whatevername.conf (obviously you can name the conf file whatever you&#8217;d like) in /etc/vpnc/ so you don&#8217;t have to type all the above. Also create the file contivity-ip-split-script (also can be called anything you&#8217;d like) to configure the network and route, in the same folder /etc/vpnc/.<br />
whatevername.conf</p>
<pre class="brush: bash">
#### whatevername.conf begins here

IPSec gateway vpn.server.name
IPSec ID yourgroupid
IPSec secret yourgrouppassword
Xauth username yourusername
Xauth password yourpassword
#### This is specific to  Nortel Contivity Server Config
NAT Traversal Mode nortel-udp
Vendor nortel
Perfect Forward Secrecy dh5
IKE DH Group dh5
IKE Authmode gpassword
Debug 1 

Script /etc/vpnc/contivity-ip-split-script

#### end whatevername.conf
</pre>
<p>Now we create the script that&#8217;ll handle the route. Script is called<br />
/etc/vpnc/contivity-ip-split-script. Remember to change the settings in this file to match your needs.</p>
<p>contivity-ip-split-script</p>
<pre class="brush: bash">
#!/bin/sh
# ===== /etc/vpnc/contivity-ip-split-script

add_ip ()
{
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_ADDR=$1
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_MASK=255.255.255.255
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_MASKLEN=32
        export CISCO_SPLIT_INC=$(($CISCO_SPLIT_INC + 1))
}
add_Csubnet ()
{
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_ADDR=$1
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_MASK=255.255.255.0
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_MASKLEN=24
        export CISCO_SPLIT_INC=$(($CISCO_SPLIT_INC + 1))
}
add_Bsubnet ()
{
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_ADDR=$1
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_MASK=255.255.0.0
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_MASKLEN=16
        export CISCO_SPLIT_INC=$(($CISCO_SPLIT_INC + 1))
}
add_Asubnet ()
{
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_ADDR=$1
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_MASK=255.0.0.0
        export CISCO_SPLIT_INC_${CISCO_SPLIT_INC}_MASKLEN=8
        export CISCO_SPLIT_INC=$(($CISCO_SPLIT_INC + 1))
}

# Initialize empty split tunnel list
export CISCO_SPLIT_INC=0

# Delete DNS info provided by VPN server to use internet DNS
# Comment following line to use DNS beyond VPN tunnel
unset INTERNAL_IP4_DNS

# List of IPs beyond VPN tunnel
# These should be listed in /etc/hosts also...

### Substitute YYY, AAA, BBB ... for meaningful values i.e 10.11.1.48
add_ip 10.11.1.48  #someserver name
#add_ip 10.YYY.YYY.YYY # www server
#add_ip 10.AAA.BBB.CCC # your workstation
#add_ip 10.ZZZ.ZZZ.ZZZ # some other server
# add_Asubnet 10.0.0.0     # full 10.0.0.0 private class A subnet
# add_Bsubnet 10.10.0.0   # eg class B subnet
# add_Csubnet 10.10.10.0 # eg class C subnet

# Execute default script
. /etc/vpnc/vpnc-script

# End of script
</pre>
<p>5. Now chmod both scripts:</p>
<pre class="brush: bash">
sudo chmod 600 /etc/vpnc/whatevername.conf
sudo chmod 700 /etc/vpnc/contivity-ip-split-script
</pre>
<p>6. Start up the vpn (obviously only run this if using the config file method, otherwise you&#8217;d already have started the vpn in step 4.1. Since we named the config file whatevername.conf, we start the vpn as such:</p>
<pre class="brush: bash">
sudo vpnc whatevername
</pre>
<p>6. You should be connected now, to disconect the vpn just do:</p>
<pre class="brush: bash">
sudo vpnc-disconnect
</pre>
<p>7. If you can&#8217;t reach hosts inside the vpn it might be because you haven&#8217;t added them to /etc/hosts, so go ahead and do that and you should be good to go. Congratulations, you&#8217;re done.</p>
<p>Without the posts below I would not have been able to get this working:<br />
<a href="http://www.gossamer-threads.com/lists/vpnc/devel/2807" target="_blank">Nortel Group Authentication</a><br />
<a href="http://www.gossamer-threads.com/lists/vpnc/devel/2732" target="_blank">vpnc-nortel with group password authentication</a><br />
<a href="http://ubuntuforums.org/showthread.php?t=1202896" target="_blank">vpnc with Nortel Contivity VPN using group auth</a></p>
<p>Hopefully this tutorial helped you. Thank you for stopping by and please share with others, after all, code should be free.<a href="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" rel="wp-prettyPhoto[g792]"><img src="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" alt="foscode.com | because code should be free" title="FOSCODE" width="227" height="18" class="alignright size-full wp-image-221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.foscode.com/connect-nortel-contivity-vpn-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a robotic voice using audacity</title>
		<link>http://www.foscode.com/create-robotic-voice/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=create-robotic-voice</link>
		<comments>http://www.foscode.com/create-robotic-voice/#comments</comments>
		<pubDate>Sat, 02 Jul 2011 21:38:33 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[audacity]]></category>
		<category><![CDATA[robotic]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.foscode.com/?p=773</guid>
		<description><![CDATA[<p>In this tutorial I&#8217;ll guide you through creating your very own robotic voice. You&#8221;ll need to have 1 tool installed, <a href="http://audacity.sourceforge.net/" target="_blank">audacity</a> audio editor. If you are running ubuntu, just run from the command line sudo apt-get install audacity, otherwise,<a href="http://audacity.sourceforge.net/" target="_blank"> head on over to their site </a>and download the latest version and follow the install steps. Once audacity has been installed we can get started.</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=777' title='audacity'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/07/audacity-150x150.png" class="attachment-thumbnail" alt="" title="audacity" /></a>

</div>
<p><span id="more-773"></span></p>
<pre class="brush: bash">
yourname@yourcomputer:$ sudo apt-get install audacity
</pre>
<p>Now you have the software you need, go to <a href="http://www2.research.att.com/~ttsweb/tts/demo.php"  target="_blank">AT&#038;T Labs Natural Voices® Text-to-Speech Demo</a>.<br />
Choose the voice and language you like best and enter a simple text message, in this tutorial I used the word &#8220;Welcome&#8221;.<br />
Scroll down and click on the button called &#8220;Speak&#8221; so you hear the message you just created. If you like it, just click on &#8220;Download&#8221; and follow the instructions provided to save the wav file.<br />
Once you have saved the file to your computer, open audacity and load the newly downloaded wav.</p>
<div align="center">
(Video: Watch this video on the post page)
</div>
<p><br \/><br />
Highlight the entire speech either by highlighting it with your mouse or just using Ctrl+A.<br />
Go to Effect -> Echo and then enter 0.009 for Delay time and 0.5 for Decay factor. Click preview to check the result and if you like it click OK to apply the effect.<br />
Now we need to re-apply the same effect so the voice will become the &#8220;robotic&#8221; voice, so just use the shortcut Ctrl+r. I&#8217;ve hit Ctrl+r 4 to 6 times, it really just depends on how it sounds to you, so just play with it and see what sounds best to you.<br />
To undo any of the steps just hit Ctrl+z. We are almost done. Now just click File -> export and choose a location along with the file type from the available options and click save (I prefer ogg). That&#8217;s it, you just created your own robotic voice. </p>
<p><a href="http://www.foscode.com/create-robotic-voice/" class="more-link">Read more on How to create a robotic voice using audacity&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I&#8217;ll guide you through creating your very own robotic voice. You&#8221;ll need to have 1 tool installed, <a href="http://audacity.sourceforge.net/" target="_blank">audacity</a> audio editor. If you are running ubuntu, just run from the command line sudo apt-get install audacity, otherwise,<a href="http://audacity.sourceforge.net/" target="_blank"> head on over to their site </a>and download the latest version and follow the install steps. Once audacity has been installed we can get started.</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=777' title='audacity'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/07/audacity-150x150.png" class="attachment-thumbnail" alt="" title="audacity" /></a>

</div>
<p><span id="more-773"></span></p>
<pre class="brush: bash">
yourname@yourcomputer:$ sudo apt-get install audacity
</pre>
<p>Now you have the software you need, go to <a href="http://www2.research.att.com/~ttsweb/tts/demo.php"  target="_blank">AT&#038;T Labs Natural Voices® Text-to-Speech Demo</a>.<br />
Choose the voice and language you like best and enter a simple text message, in this tutorial I used the word &#8220;Welcome&#8221;.<br />
Scroll down and click on the button called &#8220;Speak&#8221; so you hear the message you just created. If you like it, just click on &#8220;Download&#8221; and follow the instructions provided to save the wav file.<br />
Once you have saved the file to your computer, open audacity and load the newly downloaded wav.</p>
<div align="center">
(Video: Watch this video on the post page)
</div>
<p><br\><br />
Highlight the entire speech either by highlighting it with your mouse or just using Ctrl+A.<br />
Go to Effect -> Echo and then enter 0.009 for Delay time and 0.5 for Decay factor. Click preview to check the result and if you like it click OK to apply the effect.<br />
Now we need to re-apply the same effect so the voice will become the &#8220;robotic&#8221; voice, so just use the shortcut Ctrl+r. I&#8217;ve hit Ctrl+r 4 to 6 times, it really just depends on how it sounds to you, so just play with it and see what sounds best to you.<br />
To undo any of the steps just hit Ctrl+z. We are almost done. Now just click File -> export and choose a location along with the file type from the available options and click save (I prefer ogg). That&#8217;s it, you just created your own robotic voice. </p>
<p>Hopefully this tutorial helped you. Thank you for stopping by and please share with others, after all, code should be free.<a href="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" rel="wp-prettyPhoto[g773]"><img src="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" alt="foscode.com | because code should be free" title="FOSCODE" width="227" height="18" class="alignright size-full wp-image-221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.foscode.com/create-robotic-voice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup Guest OS on a virtual disc image (virtual machine) on Linux</title>
		<link>http://www.foscode.com/guest-os-virtual-disc-image-linux/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=guest-os-virtual-disc-image-linux</link>
		<comments>http://www.foscode.com/guest-os-virtual-disc-image-linux/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 15:00:38 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[emulator]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[virtual machine]]></category>

		<guid isPermaLink="false">http://www.foscode.com/?p=746</guid>
		<description><![CDATA[<div align="center">

<a href='http://www.foscode.com/?attachment_id=740' title='logo3'><img width="150" height="98" src="http://www.foscode.com/wp-content/uploads/2011/06/logo3-150x98.png" class="attachment-thumbnail" alt="" title="logo3" /></a>
<a href='http://www.foscode.com/?attachment_id=745' title='qemu12'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu12-150x150.png" class="attachment-thumbnail" alt="" title="qemu12" /></a>

</div>
<p>(This tutorial assumes you own a legal copy of the OS you&#8217;ll be using to install as the &#8220;guest&#8221; OS, be it Unix, Winblows or any other Operating System not mentioned here)</p>
<p><a href="http://www.foscode.com/guest-os-virtual-disc-image-linux/" class="more-link">Read more on Setup Guest OS on a virtual disc image (virtual machine) on Linux&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<div align="center">

<a href='http://www.foscode.com/?attachment_id=740' title='logo3'><img width="150" height="98" src="http://www.foscode.com/wp-content/uploads/2011/06/logo3-150x98.png" class="attachment-thumbnail" alt="" title="logo3" /></a>
<a href='http://www.foscode.com/?attachment_id=745' title='qemu12'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu12-150x150.png" class="attachment-thumbnail" alt="" title="qemu12" /></a>

</div>
<p>(This tutorial assumes you own a legal copy of the OS you&#8217;ll be using to install as the &#8220;guest&#8221; OS, be it Unix, Winblows or any other Operating System not mentioned here)</p>
<p>In this tutorial I&#8217;ll walk you through setting up a virtual machine in Linux using QEMU. According to QEMU site, QEMU is a generic and open source machine emulator and virtualizer. When used as a machine emulator, QEMU can run OSes and programs made for one machine (e.g. an ARM board) on a different machine (e.g. your own PC). By using dynamic translation, it achieves very good performance. </p>
<p><span id="more-746"></span></p>
<p>With all that being said, lets start. First you&#8217;ll need to install QEMU, if you are running Ubuntu, that&#8217;s pretty straight forward, from the command line just do sudo apt-get install qemu. </p>
<pre class="brush: bash">
sudo apt-get install qemu
</pre>
<p>If you are not running Ubuntu or your version doesn&#8217;t find QEMU in its repository, just go on to <a href="http://wiki.qemu.org/Download" target="_blank">QEMU site and download</a> their latest version.</p>
<p>Once QEMU is installed we can go ahead and begin setting up our first virtual machine. To set up your own guest OS image, you first need to choose the format that matches your preferences and then create a blank disc image.</p>
<p>According to QEMU&#8217;s site, there are 6 different image types (formats) you can choose from, I decided to go with qcow2, but you can change this to match your own preferences. The image types (formats) are:</p>
<p>raw<br />
    (default) the raw format is a plain binary image of the disc image, and is very portable. On filesystems that support sparse files, images in this format only use the space actually used by the data recorded in them.<br />
cloop<br />
    Compressed Loop format, mainly used for reading Knoppix and similar live CD image formats<br />
cow<br />
    copy-on-write format, supported for historical reasons only and not available to QEMU on Windows<br />
qcow<br />
    the old QEMU copy-on-write format, supported for historical reasons and superseded by qcow2<br />
qcow2<br />
    QEMU copy-on-write format with a range of special features, including the ability to take multiple snapshots, smaller images on filesystems that don&#8217;t support sparse files, optional AES encryption, and optional zlib compression. This is the &#8220;native&#8221; and most flexible type is qcow2, which supports copy on write, encryption, compression, and VM snapshots.<br />
vmdk<br />
    VMware 3 &#038; 4, or 6 image format, for exchanging images with that product </p>
<p>Step 1:</p>
<p>Let&#8217;s go ahead and create a folder to store the new image and create it by issuing the following commands (this will create an image with a 20G size limit):</p>
<pre class="brush: bash">
cd ~
mkdir qemu_images
cd qemu_images
qemu-img create -f qcow2 winblows.img 20G
</pre>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=733' title='qemu0'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu0-150x150.png" class="attachment-thumbnail" alt="" title="qemu0" /></a>

</div>
<p>Step 2:<br />
Start QEMU. You can start it from the command line (qemulator) or by clicking on its icon under Applications -> Accessories -> Qemulator</p>
<p>Step 3:<br />
Click on the &#8220;+&#8221; symbol to setup a new machine</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=734' title='qemu1'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu1-150x150.png" class="attachment-thumbnail" alt="" title="qemu1" /></a>

</div>
<p>Step 4:<br />
Give it any name you&#8217;d like and choose the icon of your preference.</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=735' title='qemu2'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu2-150x150.png" class="attachment-thumbnail" alt="" title="qemu2" /></a>

</div>
<p>Step 5:<br />
Click on the folder for the &#8220;Boot from image&#8221; and browse to the location where you have saved the blank image we created above in step 1 (winblows.img). Once the image has been selected you should be able to click the OK button and you&#8217;ll be taken back to the main Qemulator screen.</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=737' title='qemu4'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu4-150x150.png" class="attachment-thumbnail" alt="" title="qemu4" /></a>
<a href='http://www.foscode.com/?attachment_id=741' title='qemu8'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu8-150x150.png" class="attachment-thumbnail" alt="" title="qemu8" /></a>

</div>
<p>Step 6:<br />
Select the new virtual machine you created and click on the &#8220;show settings&#8221; button at the bottom of the window, this will show you the selected image (machine) preferences.</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=738' title='qemu5'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu5-150x150.png" class="attachment-thumbnail" alt="" title="qemu5" /></a>

</div>
<p>Step 7:<br />
Insert the cd rom/dvd of the guest os you&#8217;ll be adding, wait until it is automounted by your system.<br />
Go to the tab called &#8220;Main&#8221;, and under filesystem (left hand side) make sure hda says the name of your image (in this example, winblows.img), and choose &#8220;Mount real cdrom&#8221; and make sure right below it says &#8220;cdrom&#8221;.<br />
Next go under &#8220;boot options&#8221; on the right hand side and choose cdrom (hdc).<br />
Click the &#8220;Save&#8221; button at the bottom of the screen and then click the green arrow (top right hand side of the window) to begin installing the guest os. </p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=738' title='qemu5'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu5-150x150.png" class="attachment-thumbnail" alt="" title="qemu5" /></a>

</div>
<p>From this point on just follow the screen prompts to continue installing the guest os.</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=739' title='qemu7'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu7-150x150.png" class="attachment-thumbnail" alt="" title="qemu7" /></a>

</div>
<p>Step 8: Once the guest os install has completed you can go ahead and eject the cd/dvd rom.</p>
<p>Step 9: Go back into qemulator, click on the virtual machine/ guest os/ virtual disk image we created and change the settings for the<br />
filesystem and boot options. Under &#8220;Filesystem&#8221; on the left hand side, make sure volume still says the name of your image, make sure cdrom says &#8220;(None)&#8221;<br />
and also &#8220;Mount real cdrom&#8221; says &#8220;cdrom&#8221;. Go on the right hand side and change the &#8220;boot options&#8221; (this is very important, if you<br />
don&#8217;t do this the image will not boot since it will be looking for the cdrom/dvd instead), so change it from &#8220;cdrom (hdc)&#8221; to &#8220;hda&#8221;.</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=742' title='qemu9'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu9-150x150.png" class="attachment-thumbnail" alt="" title="qemu9" /></a>

</div>
<p>Step 10: Go into the &#8220;Default bootimage folder&#8221;, select the image listed, click on &#8220;show settings&#8221; at the bottom so the settings are displayed and make sure  it also points to the correct location and the &#8220;boot options&#8221; also have hda checked instead of cdrom.</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=743' title='qemu10'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu10-150x150.png" class="attachment-thumbnail" alt="" title="qemu10" /></a>
<a href='http://www.foscode.com/?attachment_id=744' title='qemu11'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu11-150x150.png" class="attachment-thumbnail" alt="" title="qemu11" /></a>

</div>
<p>Step 11: Once everything has been updated accordingly, select the image you&#8217;d like to boot and click on the green arrow again and watch your virtual machine boot. You&#8217;re done. </p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=745' title='qemu12'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/06/qemu12-150x150.png" class="attachment-thumbnail" alt="" title="qemu12" /></a>

</div>
<p>*** The speed up instructions below were taken from <a href="http://alien.slackbook.org/dokuwiki/doku.php?id=slackware:qemu" target="_blank">Alien Bob&#8217;s Wiki Pages</a>, all credit goes to him, I just added it here since I found it helpful.</p>
<p>If you want to speed up your virtual machine some more, you can follow the following steps which help qemu offer best results if qemu can map the Virtual Machine&#8217;s memory pages to your computer&#8217;s physical RAM. If qemu finds a mounted RAM filesystem at /dev/shm it will create a hidden file there which will hold the RAM of the virtual machine. If it does not find a RAM filesystem, the VM&#8217;s memory will be mapped to a disk file in your /tmp directory, which will not nearly be as fast as working entirely in RAM.<br />
So, add this line to /etc/fstab (adjust the size as you see fit, the example below makes 750MB of your RAM available to qemu. )</p>
<pre class="brush: bash">
none        /dev/shm        tmpfs   size=750M         0 0
</pre>
<p>By default, adding this line in /etc/fstab will allow a maximum of 50% of your physical RAM to be used up by the RAM filesystem. If you want your QEMU to emulate a computer with an X MB amount of memory, then this amount of memory “X” must be available to qemu in /dev/shm, or else qemu will refuse to start. This means for instance, that if your computer has 1GB of RAM, and the above line is present in /etc/fstab, qemu will be able to emulate a computer with a maximum of 500MB RAM (actually, a little less than 50% is effectively available to the VM, so try to give QEMU a couple of percents less than 50% of your physical RAM).</p>
<p>Hopefully this has helped you, and as always thank you for stopping by and please share with others, after all, code should be free.<a href="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" rel="wp-prettyPhoto[g746]"><img src="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" alt="foscode.com | because code should be free" title="FOSCODE" width="227" height="18" class="alignright size-full wp-image-221" /></a>   </p>
]]></content:encoded>
			<wfw:commentRss>http://www.foscode.com/guest-os-virtual-disc-image-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install pianobar on Ubuntu</title>
		<link>http://www.foscode.com/install-pianobar-ubuntu/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=install-pianobar-ubuntu</link>
		<comments>http://www.foscode.com/install-pianobar-ubuntu/#comments</comments>
		<pubDate>Fri, 20 May 2011 20:55:08 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.foscode.com/?p=719</guid>
		<description><![CDATA[<p>In this quick tutorial I&#8217;ll show you how to install pianobar on ubuntu. Pianobar is a free/open-source, command line client for pandora. With pianobar you can:</p>
<p>- play and manage (create, add more music, delete, rename, &#8230;) your stations<br />
- rate played songs and let pandora explain why they have been selected<br />
- show upcoming songs/song history<br />
- configure keybindings<br />
- last.fm scrobbling support (external application)<br />
- proxy support for listeners outside the USA</p>
<p><a href="http://www.foscode.com/install-pianobar-ubuntu/" class="more-link">Read more on How to install pianobar on Ubuntu&#8230;</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In this quick tutorial I&#8217;ll show you how to install pianobar on ubuntu. Pianobar is a free/open-source, command line client for pandora. With pianobar you can:</p>
<p>- play and manage (create, add more music, delete, rename, &#8230;) your stations<br />
- rate played songs and let pandora explain why they have been selected<br />
- show upcoming songs/song history<br />
- configure keybindings<br />
- last.fm scrobbling support (external application)<br />
- proxy support for listeners outside the USA</p>
<div align="center">

<a href='http://www.foscode.com/?attachment_id=724' title='pianobar'><img width="150" height="150" src="http://www.foscode.com/wp-content/uploads/2011/05/Screenshot-150x150.png" class="attachment-thumbnail" alt="" title="pianobar" /></a>

</div>
<p><span id="more-719"></span></p>
<p>Here&#8217;s how to install it:</p>
<p>1. Install all dependencies:</p>
<pre class="brush: bash">
sudo apt-get install git-core
sudo apt-get install libao-dev
sudo apt-get install libmad0-dev
sudo apt-get install libfaac-dev
sudo apt-get install libfaad-dev
</pre>
<p>2. Download the latest copy from the git repository:</p>
<pre class="brush: bash">
git clone git://github.com/PromyLOPh/pianobar.git
</pre>
<p>3. Go into the newly created folder (git automatically creates the folder calder pianobar) and install it.</p>
<pre class="brush: bash">
make clean
make
sudo make install
</pre>
<p>4. After you have installed pianobar, you can create a config file where you&#8217;d have your username and password. (Beats having to type those everytime you start the app). </p>
<pre class="brush: bash">
cd ~
mkdir .config/pianobar
vim .config/pianobar/config
</pre>
<p>5. add the following 2 lines and save the file</p>
<pre class="brush: text">
user = pandoraUserName
password = pandoraPassword
</pre>
<p>6. That&#8217;s it, just run pianobar from the command line and enjoy.</p>
<p>Hopefully this has helped you, and as always thank you for stopping by and please share with others, after all, code should be free.<a href="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" rel="wp-prettyPhoto[g719]"><img src="http://www.foscode.com/wp-content/uploads/2010/04/foscode_logo_sm.png" alt="foscode.com | because code should be free" title="FOSCODE" width="227" height="18" class="alignright size-full wp-image-221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.foscode.com/install-pianobar-ubuntu/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

