bash

Lovely Spam Music!

Submitted by rogueclown on Sun, 02/12/2012 - 22:40

say ohai to Lovely Spam Music!

a few weeks ago, niteshad told me about spamradio.com, a stream of synthesized spoken spam emails set over ambient electronic music. this amused me greatly and was strangely soothing to listen to, so it became my default background music.

however, it started to annoy me that the stream only played the same few spams over and over again. judging from the fact that any of the spams with dates in them referenced dates in 2006, i get the feeling that the content of the stream has not been updated since then. so, i decided to take matters into my own hands. i started collecting spam, tried my hand at a bit more algorithmic composition...

and, now, Lovely Spam Music is born!

i've also set up an email address, lovely.spam.music@gmail.com, for the specific purpose of collecting more spam. i've signed it up for all kinds of spammy newsletters that i'm pretty sure will sell this address far and wide; if you feel the urge to make Lovely Spam Music even more lovely, feel free to opt this email address into as many spam lists as you desire.

hopefully, you will find this as amusing as i do.

story tags 

code, music, bash, python

stupid splash screen!

Submitted by rogueclown on Fri, 10/21/2011 - 07:46

i've done a lot of netbooting-related stuff at work. a *lot*. i could probably talk your ear off about PXE, WDS, and a million other bits of netboot-related jargon in my sleep.

however, there was one quirk with Ubuntu that was driving me crazy. Ubuntu Server 10.10 and before worked flawlessly. however, starting with Natty Narwhal, i'd do a netboot install that would proceed as normal...until i booted into the system. at that point, i couldn't actually see anything on the screen. it was clear the computer was booting: it would go through the BIOS, and only stop displaying video when it went into the operating system. i was stumped.

this happened on any machine i tried the netboot install on: Dell, Supermicro, HP, no-name, you name it. it happened on new machines and old machines. it always happened. i googled and googled with no luck, and finally just forsook netboot installs of Natty in favour of burning discs.

Oneiric Ocelot came out earlier this month, and i was hoping this problem would be fixed. i put it up on the PXE server, and no dice. i was annoyed, but i was determined. i cast a wider net in my search for a solution, looking at more general forum threads about Ubuntu video issues, since limiting it to just netboot install advice was getting me nowhere.

finally, i figured out the problem, and how to get around it. the problem was that trying to display the splash screen was completely borking the virtual terminal. (i figured this out because, when i hit Ctrl-Alt-F2 on one of the "hosed" installs, that virtual terminal came up just fine.) the problem can be avoided by preseeding the Ubuntu install to call a post-install script that removes the splash screen instruction from the default boot line generated by GRUB2.

to implement this, put the following lines at the end your preseed file. (or, create a preseed file with these lines, if you're not using preseeding with your Ubuntu install):


# this is just a post-install script.
#
# update Grub to get rid of that splash screen that borks the
# video on netboot installs of 11.04 and later
d-i preseed/late_command string \
cd /target; \
wget http://bigtruck.minazo.net/unbork_splash.sh; \
chmod +x ./unbork_splash.sh; \
chroot ./ ./unbork_splash.sh; \
rm -f ./unbork_splash.sh

this pulls a script down that fixes the GRUB issue, executes it in a chroot of the new install, and then deletes the script.

for the sake of openness, here's the script it pulls:


#!/bin/bash
# by rogueclown, 2011
# WTFPL (Do What The Fuck You Want To Public License)
cd /etc/default
sed "s/quiet splash/quiet/g" grub > grub.new
mv grub grub.orig
mv grub.new grub
update-grub
exit 0

voila: the box reboots, and you've got video.

why a server, much less a Linux server needs a splash screen, i'll never know. i love Ubuntu Server, but i'm quite angry that such a useless feature as a splash screen causes such an annoying problem as borking the virtual terminal on which it tries to display.

story tags 

linux, code, bash

whoprompt

Submitted by rogueclown on Sat, 12/25/2010 - 05:45

i've been batting around in my head just blogging about the random bits of tech knowledge i learn along the way, or computer-related things i do. that way, it'll be a way to commit that stuff to memory for my future reference, as well as document the trajectory of things i'm doing and learning.

in the spirit of that last entry, i'll start with a little bit of code i wrote earlier tonight. i work in a data center, and my duties are as varied as the calamities and successes that befall our customers. however, one of the fairly common tasks i have to perform is preliminary investigation of abuse complaints: figuring out which customer sent the complained-about spam (much less, if it was a customer at all...), notifying the customer of the complaint, and escalating it if it's particularly messy. basically, this involves a lot of whois queries (or dig queries followed by whois queries, for those spam complaints that only provide domain names and not IP addresses).

it was a particularly long night of spam complaint lookups tonight, and i started to get very annoyed about having to type "whois" or "whodig" (a little one-liner i wrote a few months ago to automate the dig-then-whois process) before every single IP or domain i cut and pasted from the spam headers. i wished i could just paste the IP or domain at the command prompt, hit enter, and have the shell read my mind that i wanted a whois lookup.

so, as any self respecting lazy IT geek would do, i wrote a script that does just that.

#!/bin/bash

# whoprompt.sh
#
# an interactive whois command line
#
# this will run whois if an IP is typed at the prompt
# and whodig (a dig-and-then-whois script) in response to a domain name
#
# nicolle neulist
# December 25, 2010
#
# * ----------------------------------------------------------------------------
# * "THE BEER-WARE LICENSE" (Revision 42):
# *  wrote this file. As long as you retain this 
# * notice you can do whatever you want with this stuff. If we meet some day
# * and you think this stuff is worth it, you can buy me a beer in return.
# * ----------------------------------------------------------------------------

# define constants
SHELLPROMPT="whois> "

# define function to test for a valid IP address

function valid_ip()
{
	local  ip=$1
	local  stat=1

	if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
		OIFS=$IFS
		IFS='.'
		ip=($ip)
		IFS=$OIFS
		[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
		stat=$?
		fi
	return $stat
}

# define function to run a dig query on a domain name and then a 
# whois lookup on the corresponding IP

function whodig()
{
	whois $(dig $1 | grep -A1 "ANSWER SECTION" | grep "IN" | awk '{print $5}')
}

# main loop
printf "type \"help\" for help.\n"
printf "type \"exit\" to exit.\n"
while [ 1==1 ]; do
	read -p "$SHELLPROMPT" -e address
	if [ $address == "help" ] ; then	# print help text
		printf "\ntype an IP address to run a whois lookup.\n"
		printf "for any other text, it will attempt to run a\n"
		printf "dig query, and then a whois lookup on that.\n\n"
		printf "it will return the same success or error text\n"
		printf "as a normal whois or dig lookup on linux.\n\n"
		printf "to end the program, type \"exit\".\n\n"
	elif [ $address == "exit" ] ; then 	# "exit" quits the program.
		exit 0
	else							# whois/whodig routine
		if valid_ip $address; then	# test IP
			whois $address		# whois on valid IP
			printf "\n"
		else
			whodig $address		# assume domain if not IP
			printf "\n"
		fi
	fi
done
Hopefully you'll get some use out of this little bit of code, especially if you're also in a position that requires lots of abuse complaint investigation, or anything else that requires a lot of whois lookups.

story tags 

code, bash
Subscribe to RSS - bash