The Blog of Micah

A Slackers Development and Administration Playground

Posted by micah on August 30, 2010

Hyper-V Server 2008 R2 – Adding a SHELL

I installed Hyper-V Server 2008 R2 and of course there is no windows explorer… Being a free OS it was worth looking at but I’d like to be able to login and do things like surf the web, move files and such…

First we install Hyper-V Server and then…

I ran “net use G: \\remotepc\share” and then run the FireFox Installer. After that I downloaded CubicExplorer and SharpEnvironment… After installing those I just ran the installer…

Oops, no worky… SharpEnvironment fails to launch until I go and download oledlg.dll and put it in C:\Windows… Worky Worky…

One last thing:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell]
@=”cubic”
[HKEY_CLASSES_ROOT\Folder\shell\cubic]
@=”cubic”
[HKEY_CLASSES_ROOT\Folder\shell\cubic\command]
@=”\”C:\\Program Files\\CubicExplorer\\CubicExplorer.exe\” /idlist,%I,%L”
[HKEY_CLASSES_ROOT\Drive\shell]
@=”cubic”
[HKEY_CLASSES_ROOT\Drive\shell\cubic]
[HKEY_CLASSES_ROOT\Drive\shell\cubic\command]
@=”\”C:\\Program Files\\CubicExplorer\\CubicExplorer.exe\” /idlist,%I,%L”
[HKEY_CLASSES_ROOT\Directory\shell]
@=”cubic”
[HKEY_CLASSES_ROOT\Directory\shell\cubic]
[HKEY_CLASSES_ROOT\Directory\shell\cubic\command]
@=”\”C:\\Program Files\\CubicExplorer\\CubicExplorer.exe\” /idlist,%I,%L”

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell]@=”cubic”[HKEY_CLASSES_ROOT\Folder\shell\cubic]@=”cubic”[HKEY_CLASSES_ROOT\Folder\shell\cubic\command]@=”\”C:\\Program Files\\CubicExplorer\\CubicExplorer.exe\” /idlist,%I,%L”
[HKEY_CLASSES_ROOT\Drive\shell]@=”cubic”[HKEY_CLASSES_ROOT\Drive\shell\cubic][HKEY_CLASSES_ROOT\Drive\shell\cubic\command]@=”\”C:\\Program Files\\CubicExplorer\\CubicExplorer.exe\” /idlist,%I,%L”
[HKEY_CLASSES_ROOT\Directory\shell]@=”cubic”[HKEY_CLASSES_ROOT\Directory\shell\cubic][HKEY_CLASSES_ROOT\Directory\shell\cubic\command]@=”\”C:\\Program Files\\CubicExplorer\\CubicExplorer.exe\” /idlist,%I,%L”

Note: The path needed adjusted… Also, this reg file was found in the CubicExplorer Forums.

After putting this in a reg file and executing it, Cubic Explorer opens when I try and open folders…

Posted by micah on August 10, 2010

IceCast2, ices0, ices, darkice, JACK, PulseAudio

This started out as just testing IceCast2 with ices… I quickly found that this didn’t work for me…

My goals:

  1. Able to stream audio to Windows, Mac OS X, Linux using default applications
  2. Able to stream my 5 (five) MP3s (yes, I only have 5…)
  3. Able to stream audio from my sound card
  4. Able to stream audio from my tv card AND record it to file at the same time

Goal 1:

ices didn’t work like I wanted… I even have MPlayer on my Mac and couldn’t get ices + IceCast in a format I could use. (It uses OGG only from everything I’ve research…)  I know that iTune and Windows Media Player can can stream MP3 streams so I found ices0 which does send the audio stream as MP3

Goal 2:

This is how I tested goal one. I figured it’d be simpler to make it work with a playlist of MP3s instead of streaming the audio ports directly… It was slow to figure out why it didn’t work, but now I can stream MP3s with ease.

Goal 3:

Next I wanted to change from a playlist to an audio device… Wow… ices0 doesn’t do that… ices does but thats only in OGG… After a bit of research I found DarkIce. After a little tinkering I have DarkIce + IceCast2 streaming /dev/dsp1 which is my TV Card’s audio… Unfortunately the audio level is too low… (Still working on this problem.)

Goal 4:

The last important thing is that I’d like to be able to stream audio over the LAN or NET and also record it locally… It seams that once I use the audio device that it gets locked and I can’t attach another application to the same device… This fix is to use JACK to listen on the device and then let DarkIce and MPlayer (to record the stream locally) to use JACK as the audio source. (This requires recompiling DarkIce and MPlayer for full functionality.

Other:

In Goal 3 I noted that my sound is very low and that is with making the volume 100% on the source and clients. It looks as the fix is with PulseAudio in conjunction with JACK… I’m still testing this but it looks promising.

With any luck, I might be able to stream AM Radio, TV Audio (Weather), and MP3 collection (of 5 songs)!

Update – 8/12/2010 – Usage Notes

It appears MPlayer/mencoder can only output to JACK and PulseAudio. I haven’t seen anything in the docs or online that even suggests that it can record from JACK or PulseAudio…

Also, it appears that if something uses the same device that JACK is using then it quits working until you restart JACK…

My hope was that I could stream a Video and Audio feed as well as an Audio feed by itself… Maybe I can with ffmpeg or such…

Part 2…. I found a few things out…

  1. My TV Card doesn’t support ALSA nicely so OSS is required to use it
  2. JACK, after a while of running (10 min+) causes the sound to get corrupted and it gets worse over time… I tried several options with the same results…
  3. For whatever reason, I have /dev/audio1 and /dev/dsp1 – both are the same – but I can only use 1 at a time…
  4. I found oss2jack… It lets you take a JACK stream and pipe it to a device like /dev/dsp8. – It would be nice to be able to ‘clone’ or ‘fork’ 1 device to multiple devices; I just haven’t found any besides this one which also requires a modified version of fusd.

Update – 8/12/2010 – Usage Commands

# icecast -c /etc/icecast.xml -b
# jackd -R -d oss -r 11025 -C /dev/dsp1 -p 256 -b &
# darkice -c /etc/darkice.cfg &

Update -8/15/2010 – PulseAudio

Apparently, PulseAudio doesn’t work on my TV Card… My TV Card doesn’t support ALSA so I am forced to use OSS. Jack Audio Connection Kit works but PulseAudio breaks even with OSS support.

Next I’ll add another sound card and see if I can pipe to audio to it via ALSA.

Posted by micah on August 4, 2010

Video Streaming in Linux

Listed below are the different applications/projects for steaming video and audio.

  • MythTV – untested
  • FreeVo – untested
  • VLC – untested
  • ffserver (ffmpeg) – untested
  • Darwin Streaming Server – untested
  • mpeg4-ip – untested (does it still exist?)
  • IceCast – Audio Only
  • ShoutCast – probably won’t test, but may if I get bored… – Audio Only
  • fuppes – untested – to play videos on PS3 and such

As I test, I’ll do a review or something…

Posted by micah on June 6, 2010

VirtualBox – Create a VM Headless

The steps I take to create a new virtual machine; in this case, a windows server machine:

VBoxManage createvm --name "WINSRV08R2" --register
VBoxManage modifyvm "WINSRV08R2" --memory 1024 --acpi on
VBoxManage modifyvm "WINSRV08R2" --boot1 dvd --nic1 nat
VBoxManage storagectl "WINSRV08R2" --name "IDE Controller" --add ide \
   --controller PIIX4
VBoxManage createvdi --filename "WINSRV08R2.vdi" --size 10000 --register
VBoxManage registerimage dvd /home/image.iso

VBoxManage storageattach "WINSRV08R2" --storagectl "IDE Controller" \
   --port 0 --device 0 --type hdd --medium "WINSRV08R2.vdi"
VBoxManage storageattach "WINSRV08R2" --storagectl "IDE Controller" \
   --port 1 --device 0 --type dvddrive --medium /home/image.iso
# VBoxManage modifyvm "WINSRV08R2" --dvd none

Now that the machine is created, we need to start it and turn it off – here are the commands to do so:

VBoxHeadless --startvm "WINSRV08R2"
VBoxManage controlvm "WINSRV08R2" acpipoweroff

I post this as a reference to myself as I have to keep looking for this online.

Posted by micah on May 21, 2010

Notification via Email of IP Address Changes

Since I’ve moved I have a smaller DSL ISP that like to keep short dhcp leases. I found out quickly that on each router reset I get a new IP Address. Over the last few weeks it’s gotten even better… Now intermittently my PPPoE loses connection and is forced to reconnect. (My TV is on the same line and it’s been flaking out too so I know it’s not my router… It could be my modem so I’ll keep an eye on it.

Because I like to connect to my home PCs from anywhere, I need to know my IP address and when it changes. Last night, while watching to see if the tornados were coming to my house, I sat down and began to write a shell script that would detect my current IP and see if it has changed.

The script is pretty simple really… Here is what it does:

  1. Check to see if there is an IP address already recorded
  2. If yes – get and md5sum on the file and then move it to another file
  3. Get my current external IP address and save it to file
  4. Caclulate the md5 on that new file
  5. Check the two md5 sums and see if they match
  6. Do they match? Do nothing
  7. They don’t match? Lets send an e-mail to let me know

I also had a couple of bottlenecks. The first is that I couldn’t get sendmail to send an e-mail from my box… To get around this, I made a PHP script and put it on a web server. Now when I go to send the e-mail I call ‘wget -qO- “myurl?key=1&ip=${MYIP}” | grep cat.

The second concern is that I am calling an external page to find my external IP address. I’m afraid they might think I am spamming them so I created another php script to return my external IP address and posted it on my web server as well.

Now everything is working and I’ve setup an hourly cron job to run the script.

The shell script:

#!/bin/sh
cd ~
# curl -s checkip.dyndns.com | grep -Eo “[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+”
# curl -s www.whatismyip.com | grep -Eo “[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+”
# curl -s www.info66.net/whatsmyip.php | grep -Eo “[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+”
# MYIP=`curl -s www.ipchicken.com | grep -Eo “[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+”`
MYIP=`curl -s www.info66.net/whatsmyip.php | grep -Eo “[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+”`
MD5_LST=”"
OLD_IP=”"
if [ -f ExtIp.txt ]; then
    MD5_LST=`md5sum ./ExtIp.txt`
    OLD_IP=`cat ./ExtIp.txt`
    mv ./ExtIp.txt ./PrevExtIp.txt
fi
echo $MYIP > ./ExtIp.txt
MD5_NOW=`md5sum ./ExtIp.txt`
echo ” Ip: ${MYIP}”
echo ” Now: ${MD5_NOW}”
echo ” Lst: ${MD5_LST}”
if [ "${MD5_NOW}" != "${MD5_LST}" ]; then
    echo “IP Address Changed to ${MYIP} from ${OLD_IP}”
    wget -qO- “http://www.webserver.web/email.php?key=abcdef&ip=${MYIP}” | cat
fi

whatsmyip.php

<?php
	$ip = "";

	$ip = $_SERVER['REMOTE_ADDR'];

	echo "<h1>Your IP Address Is: " . $ip . " </h1>";
?>

email.php

<?php
    $key = "";
    $ip = "";
    $to = "";
    if ( !empty($_GET['ip']) ) {
      $ip = $_GET['ip'];
      $message = "My new IP is " . $_GET['ip'] . "...";
    } else {
      $message = "This is a test";
    }
    if ( !empty($_GET['to']) ) {
      $to = $_GET['to'];
    } else {
      $to = to@email.com;
    }

    if ( !empty($_GET['key']) ) {

           $key = $_GET['key'];

       } else {

           $key = “”;

       }

 

       $subject = “My New IP Address: “ . $ip;

       $headers .= “From: from@address.com\r\n”;

       $headers .= “Reply-To: from@address.com\r\n”;

       $headers .= “Return-Path: from@address.com\r\n”;

       $headers .= “X-Mailer: PHP/” . phpversion() . “\r\n”;

       $headers .= “MIME-Version: 1.0\r\n”;

       $headers .= “Content-Type: text/html; charset=\”iso-8859-1\”\n”;

       $headers .= “X-Priority: 1 (Higuest)\n”;

       $headers .= “X-MSMail-Priority: High\n”;

       $headers .= “Importance: High\n”;

 

       if ( $key == “abcdef” ) {

              // This $key is just a safety check so people can’t

              // use this as span so easily

              $status = mail($to, $subject, $message, $headers);

       } else {

              $status = 0;

       }

 

       if ($status) {

              echo “Success\r\n”;

       } else {

              echo “Failed\r\n”;

       }

?>

Posted by micah on May 16, 2010

My setup: Clock sync using NTP on Slackware

I’m setting up one server on my network as a time server and the other servers will synchronize against it. I’m using ntp servers from this URL: http://tycho.usno.navy.mil/ntp.html.

My Server Setup:

ntpd server: SlackNode10 with an IP of 192.168.1.210
ntpdate client: SlackNode00 thru SlackNode09

ntpd server setup

My /etc/ntp.conf

server  now.okstate.edu         # Stratum 1: Oklahoma State University, Stillwater, OK
server  tick.uh.edu             # Stratum 2: University of Houston, Houston, Texas
server  192.168.1.0             # local clock
fudge   192.168.1.0 stratum 10

driftfile /etc/ntp/drift
multicastclient                 # listen on default 224.0.1.1
broadcastdelay  0.008
restrict default noquery nomodify
restrict 192.168.1.0 mask 255.255.255.0
restrict 127.0.0.1

Start the ntpd service

# ntpdate -u now.okstate.edu
# chmod +x /etc/rc.d/rc.ntpd
# /etc/rc.d/rc.ntpd start

ntpdate clients setup

My /etc/cron.hourly/ntpdate.sh

#!/bin/sh
/usr/sbin/ntpdate -s -u 192.168.1.210
/sbin/hwclock --adjust
/sbin/hwclock --systohc
exit 0

.

Posted by micah on May 14, 2010

Compiling TrinityCore on Slackware 13

I was trying to compile trinity core on Slackware the other day and found that I needed to add linking flags for the ncurses library. This project uses “cmake” and I’m not that familiar with it so after a bit of research I found this is how you build it:

cmake ../trinitycore \
-DCMAKE_EXE_LINKER_FLAGS=-lncurses \
-DCMAKE_SHARED_LINKER_FLAGS=-lncurses

These two switches allow it to be built correctly on a Slackware 13 machine. (32bit and 64 bit)

This page has more details: How-to: Trinity Core on Slackware

Posted by micah on April 8, 2010

Slackware 13 – Install Virtual Box

This was pretty simple… Download the “All distributions” build. (My PC is 32 bit and I have not tested the 64 bit install – i’d imagine it being the same…)

# sh ./VirtualBox-3.1.6-59338-Linux_x86.run
# sh /etc/rc.d/rc.vboxdrv start

If the compile failed on setup (your linux src dir (/usr/src/linux) must be up to date with the running kernel so it can compile the drivers.) and after you setup you linux sources you just run this:

# sh /etc/rc.d/rc.vboxdrv setup
# sh /etc/rc.d/rc.vboxdrv start


Then you good to go… =D

Virtual Box is WAY easier to setup than VMWare AND you don’t need the pesky PAM gunk =D

Posted by micah on April 2, 2010

Install Windows from a USB Drive

Background:

I have several pcs and servers at my house. Most don’t have CD/DVD Rom drives because they don’t need them 98% of the time. This other 2% of the time isn’t worth the money when a DVD drive could be connected temporarily but why when you can install from USB drives? Here are the instructions on how to go about doing this.

How to:

  1. Insert your 4Gb+ USB drive
  2. run “diskpart” – you may need to download this tool from Microsoft
  3. type “list disk” and identify the USB drive (remember the Disk ###)
  4. type “select disk 3″ where 3 is the disk number from above
  5. type “clean” so that it removes everything from it (wipes the partition table on the USB drive)
  6. type “create partition primary” to create a new partition
  7. type “active” to make this partition bootable 
  8. type “format fs=ntfs quick” to perform a quick format of the drive
  9. type “assign” to mount the drive and allow access to it via explorer
  10. now you can exit diskpart
  11. See Extra if this doesn’t work
  12. copy over all files from the Windows DVD (I’ve tested with the free Windows Hyper-V Server R2 and with Windows 7 Enterprise x64)
  13. Now the USB drive can be used to install Windows (Your BIOS has to support and enable this)

Extra: (This allows it act like a “USB-ZIP” or “USB-SUPERFLOPPY” or “USB-FLOPPY” from Windows” as my BIOS doesn’t support USB-HDD directly – OK, I’m not sure how it works, but this allows me to boot it.)

  1. at a cmd prompt:
  2. type “<CDROM DRIVE LETTER>:” – ex. “D:”
  3. type “cd boot”
  4. type “bootsect.exe /nt60 <USB Drive>” – ex. “bootsect.exe /nt60 F:”
Posted by micah on March 17, 2010

DNN Clear Search Tables

SQL

delete SearchItemWordPosition where SearchItemWordId in (select SearchItemWordId from SearchItemWord where SearchItemID in (select SearchItemId from SearchItem))
delete SearchWord where SearchWordsId in (select SearchWordsId from SearchItemWord where SearchItemID in (select SearchItemId from SearchItem))
delete SearchItemWord where SearchItemId in (select SearchItemId from SearchItem) delete SearchItem 

DNN SQL

delete {objectQualifier}SearchItemWordPosition where SearchItemWordId in (select SearchItemWordId from {objectQualifier}SearchItemWord where SearchItemID in (select SearchItemId from {objectQualifier}SearchItem))
delete {objectQualifier}SearchWord where SearchWordsId in (select SearchWordsId from {objectQualifier}SearchItemWord where SearchItemID in (select SearchItemId from {objectQualifier}SearchItem))
delete {objectQualifier}SearchItemWord where SearchItemId in (select SearchItemId from {objectQualifier}SearchItem) delete {objectQualifier}SearchItem 

Copied from: DotNetNuke Developer Chris Hammon