Chronophage.net Blog

Tag: Programming

IPv6 Day Silliness :)

by on Jun.03, 2011, under Administration, Frivolous, News

Well, in honor of IPv6 day, I decided to spurn people along. I created an IPv6 validation badge of my own, and a few other things to prod people to get their providers to switch.

I’ve also updated http://ipv6.chronophage.net with a new look. It also shows you a video that warns you of the real and present dangers of not switching to IPv6, or celebrates your IPv6 achievement with an INTERNET classic icon wink IPv6 Day Silliness :)

Making the pages was fun, especially using php to spit out the various dynamic graphics. In one spot I use a validator lifted from here On the main page i simply have this SetEnvIfNoCase REMOTE_ADDR "^[0-9a-f:]+$" IPV6_USER=1 in my apache config, and check for that variable in my shtml index. I use a php filter elsewhere. This is to test various ways of IPv6 validation. If you see an error, please comment.

Making dynamic graphics was straight out of the php documentation. That language has a function for everything!

No one will accuse me of being a website designer, I hope it’s ugly enough for you.

Anyways, have fun! Happy (pending) IPv6 day!

Leave a Comment :, , , , , , , , , more...

Ubuntu Apache2 Auto Config BASH script

by on Jan.12, 2011, under Administration, Software, UNIX 101

Man, I’ve been busy… I’ve recently been promoted to being a System’s Administrator! This has forced me to program a few BASH scripts. This one is for a customer that wants a managed system, but wants to be able to add websites at will. It’s pretty simple, and relies on an existing example.com template. Why example.com? Because I follow RFCs dammit! The template allows me to adjust the Apache specific settings, without recoding the script.  A little REGEX here, and a pipe to sed there, some error checking, formatting and a dash of some SUDO magic and voila! The customer doesn’t need to email/call me to add a website.  Sure beats paying for a crappy control panel icon wink Ubuntu Apache2 Auto Config BASH script

(continue reading…)

Leave a Comment :, , , more...

What happens when I program “On the Fly”

by on Jun.11, 2009, under News, Software

So I needed a quick script to query a billing database for DSL users. The user names, of course where horribly inconsistent. I had to use a program that executed a query of the database, as I didn’t have access to the actual database. Oh, and I didn’t know any Perl at the time.

Now, I have a bad habit when writing code for myself, to use ambiguous variable names, and strange loop structures, and no comments. See if you can figure out what’s going on.

Oh, I vow never to write code like this again. icon wink What happens when I program On the Fly

#!/bin/bash

echo Audit run on $( date )
echo Audit run on $( date ) > notinbilldb.txt
echo
echo

for i in $( cat radiusdump.txt | awk '{print $1}' ); do
 	t2=""
	t2=$( echo $i | sed -e 's/\@.*$//;' | cut -f1 -d . )
	t1=$( billdb -s $t2 | grep DSL | awk '{print $3}' | sed -e 's/\.dsl//; s/^dsl//;s/\@.*$//;' )
  	t3="0"
	t4="0"
	t5="0"
	t6=""

	if [ "$t1" = "" ]; then
		t1=$( billdb -s $i | grep Email | awk '{print $3}' | sed -e 's/\@.*$//;' )
		t5="1"
	fi

	if [ "$t1" = "" ]; then
		echo $i is not in billdb.
		echo $i is not in billdb. >> notinbilldb.txt
		t4="1"
	fi
	p=$( echo $i | sed -e 's/\.dsl//; s/^dsl//;s/\@.*$//;' )
	k=""

	for k in $( echo $t1 ); do
		if [ "$p" = "$k" ]; then
			if [ "$t5" = "1" ]; then
				t6=", but only in email"
			fi
			echo $i matched $k in billdb$t6.

			t3="1"
	 	fi
	done
	if [ "$t4" = "$t3" ]; then
		echo $i is really not in billdb but was close to $t1.
        	echo $i is really not in billdb but was close to $t1. >> notinbilldb.txt
	fi
	echo --------------------------------
	echo
done
echo
echo Audit completed $( date )
echo
Leave a Comment :, , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...