Thursday, September 3, 2009

NewCS on a Sun VirtualBox

NEWCS on a Sun VirtualBox

Hardware/Software Configuration:

Hardware-
- Standard x86 PC (eg: P4 Springdale Chipset)
- Jaycar Serial Card Reader (in Phoenix modes). Mods: CardDetect Invert, Schottky Diode Mod
- N.D.S S.k.y NZ Card

Software-
- Host (the O/S that loads when you power up the PC): Win7
- Virtual PC Emulator: Sun VirtualBox
- Guest (the O/S running in Virtual Mode): ClarkConnect5 (CC5)
- NewCS V1.67RC1: Used for passing a legal card key
- ACamd V0610: Used for decrypting the DVB streams
- PuTTY (telnet/SSH client): Used for issuing terminal commands in CC5
- CoreFTPlite (FTP client): Used for uploading files to CC5


Why Use A Virtual Machine?

- Allows any O/S (within reason) to be used with NewCS
(important as NewCS is no longer supported in Windows)
- Allows separation to be maintained between the CS Server and the rest of the PC
(useful when 'experimenting')
- Allows the CS Server to simulate a separate PC
(useful if this is your ultimate goal)
- Its another interesting PC challenge to get under your belt.


Why Use Windows 7 at all?

- Many Geekzone (GZ) posts point to W7 Media Center (W7MC) panning out to be a MC that just works (with some NZ-centric tweaks). I'm sure all the other MC's also work well to varying degrees, however its fairly much acknowledged (by GZ posters) that W7MC is the easiest path to a HTPC that can record and playback all the NZ broadcast streams thrown at it.



Topology:



All hardware is connected to the W7 PC. The PC is running W7, however the NewCS box in above is running inside a Linux Virtual Machine (VM).


Setup:

Assumptions:
- all your hardware (cardreader, DVB-S cards, network, etc) is installed and working correctly on your W7 PC.

Downloads (all are donation or free):
- Virtual PC Emulator: Sun VirtualBox
- Guest (the O/S running in Virtual Mode): ClarkConnect5 (CC5)
- NewCS V1.67RC1: Used for passing a legal cards keys.
Extract: newcs.i686 & newcs.xml
Rename: newcs.i686 to newcs.x86
- ACamd V0610: Used for decrypting the DVB streams
- PuTTY (telnet/SSH client): Used for issuing terminal commands in CC5
- CoreFTPlite (FTP client): Used for uploading files to CC5

Methodology:

1) Virtual Box
Download and install Sun VirtualBox for windows (VirtualBox 3.0.4 for Windows hosts)
From memory there were no gotchas with this install on to W7. I downloaded the manual and printed parts of it as a reference.


2) Create a Virtual Machine
Using the VBox GUI create a new Virtual Machine (VM)
Tips: I used the following settings (a lot of these are default values) -

General
Name: ClarkConnectVM (can be anything)
O/S: Red Hat (Note: CC5 is based on the RedHat distro)

System
Base Memory: 512MB
Processors: 1
Boot Order: CD/DVD-ROM, Hard Disk
VT-x/AMD-V: Enabled
Nested Paging: Disabled

Display
Video Memory: 128MB
3D Acceleration: Enabled
Remote Display Server Port: 3389

Hard Disks
IDE Primary Master: ClarkConnectVM.vdi (Normal, 8.00GB)

CD/DVD-ROM
Host Drive: E: (but point this to your ClarkConnect iso when 'installing' CC5)

Floppy
Not Mounted

Audio
Host Driver: Windows DirectSound
Controller: ICH AC97

Network
Adapter 1: PCnet-Fast III (Bridged adapter, your PC's network card)
(I had some problems with networking. Default setting was NAT but that gave me problems so I went to a Bridged configuration)
Note: You can view the virtual MAC address as well.

Serial Ports
Port 1: COM1, Host Device (COM1)

USB
Device Filters: 0 (0 active)

Shared Folders
None


3) Install your Guest O/S (CC5)

a) Download the ClarkConnect Community Edition ISO image
(note: no need to burn to CD, VM has some magic for iso's)

b) Set the VBox VM CD/DVD-ROM to 'see' the CC5 iso as a CD

c) Start your new VM Guest (ie: this is the same as powering up the VM 'PC')
You will see a SUN 'BIOS' come up, the VM will boot from virtual CD and you will be asked to select as follows:
- Select: Language
- Select: Keyboard (US)
- Select: Install Method (Local CDrom)
- Select: Install Type (Install)
- To proceed: Type - "ClarkConnect"
- System Mode: Standalone Mode - No Firewall
- Specify LAN IP: Manual Config or Dynamic if your Router supports leased IP by MAC address.
(My router does so I set dynamic and then leased IP:10.1.1.50 using the VM assigned MAC)

- Nameserver IP: Your router gateway IP (eg: 10.1.1.1)
- Set the System Root Password > write it down!!
- Partitioning: Use Default
- Select Software Modules: Definitely need FTP, I selected most of them.

d) When the install is complete, you will be presented with a login screen. Login with your new root password created above. There are a number of options in here but you should be done for now. Use the Shutdown option and shutdown. Then start up again and your new CC5 should boot all the way up. If you have set a manual IP you are done for now. If dynamic you have two options:
i) My favourite - login to your router and look at your DHCP clients, one of them should be CC5.
Note the IP of this DHCP client

ii) Also good - Alt+F2 will drop you into a CC5 terminal, login as root and issue the command: "ifconfig". This is like the Win "ipconfig" - it will show your IP.

e) Now minimise the CC5 window, minimise the VirtualBox window.


4i) Guest O/S (CC5) Setup - User Account

a) Open a browser (eg: IE8) and browse to https://the.IP.of.Guest:81
(in my example: https://10.1.1.50:81)

b) Click through the warnings of doom ('Connection Not Trusted' etc)
c) Login, Username: Root, Password: you wrote it down above
d) Language: default English
e) Network: Standalone Mode No Firewall
f) Register: As you like
g) Time Zone: Godz Own ;-)
h) Domain: Can just leave as is ("clarkconnect.lan") or change if you like
i) Organisation: Real Data or space-fillers
j) Finish: Again you will probably get dire messages, just click-through.



4ii) Guest O/S (CC5) Setup - Dashboard

a) Continuing to use the browser window, Open the Tab "Account Manager"
b) Click to add users "+Add"

c)
Username: "bob" (make one up),
First Name: "Bob" (make one up),
Last Name: "Bobber" (make one up),
Password: "bobword" (make one up)
Verify: "password" (repeat password just entered)
Write down the Username and Password. These will be used for FTP file uploading.
d) Click on the tab "+Add"
e) Open tab "Software" and "FTP"
f) FTP configuration set to "1" not to "30" and click "Update" tab
g) Set these two to:
Status -Running ('Start')
On boot - Automatic ('To Auto')
h) That's the Dashboard done. You can logout now.


5) Transfer NewCS files to Guest using FTP Client

a) For this we will use CoreFTPLite (or your fav).
Open CoreFTPLite and enter:
- Host:
the.IP.of.Guest (eg: 10.1.1.50)
- User Name: The Name you created under Dashboard (bob)
- Password: The Password you entered above (bobword)
Now connect to the CC5 server
b) Transfer the newcs files extracted earlier to your newly created user account
(TIP: location will be: /home/'username' (bob in my case))


6) Setting newcs files for use in CC5 using PuTTY

a) For this we will use PuTTY.

Open/Login PuTTY with:
-
Host: IP.of.Guest (eg: 10.1.1.50)
- User: root
- Password: (the password you set in 3c (you wrote it down))


b) Create directory's and copy files to these directorys:

cd /var
mkdir /var/bin
ls
(you should now see bin)
cd /home/Username (4ii c eg: bob)
ls
(should see the FTP'd files: newcs.xml, newcs.x86)
cp newcs.x86 /var/bin
cp newcs.xml /etc
cd /var/bin
ls
(should see newcs.x86)
chmod 755 newcs.x86
ls
(should now go from the colours white to green)


c) Edit the newcs.xml file to your card reader (newcs.xml config is a project by itself!):

nano /etc/newcs.xml
(CC5 editor starts, note the ctrl characters at the bottom)
(remember to save your changes)


d) Linking the "libcrypto" file newcs expects to the actual
"libcrypto" CC5 file:

cd /lib
ln -sf libcrypto.so.0.9.8e libcrypto.so.0.9.8


e) Start NewCS

cd /var/bin
ls
./newcs.x86
(depending on your newcs.xml settings you should see NewCS startup)


f) Optional: NewCS auto-start

nano /etc/rc.d/rc.local
(
You will see a line like: "touch" and so on. Under that line is a lot of empty space. Write next line exactly under that "touch" line)

/var/bin/newcs.x86
(Save the changes)


7) Methods for logging/viewing NewCS from your Host

Depending on your newcs.xml file settings here are some ways to see what's going on:

a) PuTTY
- Start your CC5 VM
- Login with PuTTY just as you did in 6a)
- Start NewCS with this command (assumes NewCS is not auto-started):
cd /var/bin
ls
./newcs.x86

- On your PuTTY terminal/console you will see the debug script

b) Browser (assumes NewCS is already running either manually or auto-start)
- Using IE or other browser enter:
http: the.IP.of.Guest:httpd_port_set_in_newcsxml (eg: http://10.1.1.50:8080)
- User: httpd_user_set_in_newcsxml (eg: admin)
- Password:
httpd_password_set_in_newcsxml (eg: password)
This is kinda cool as you can actually make changes to your newcs.xml file thru your browser, plus see keys and all sorts of cool stuff.

c) Telnet (simple logger)
- Host: IP.of.Guest, port: tcp_port_set_in_newcsxml (eg: 10.1.1.50, port 1001)
You will see any activity related to NewCS, eg: browser logins

d) Logfile
If you set your newcs.xml file to log 'debug' to a logfile then you can pull this down with CoreFTPlite.
Tip: In your newcs.xml file set your logfile to your user directory.
Ie:/home/usename_4ii_c ("bob" in 4ii C above).
This makes it easy to get access to the logfile.


8) Method for starting CC5 as a non-GUI on your Host

a) Create a desktop shortcut of the command prompt
(copy the Start>All Programs>Accessories "C:\" icon
command prompt shortcut and drag this copy to the desktop)

b) Right click your new shortcut and go to 'properties'

c) Set the target directory ("Start in:") to: "C:\Program Files\Sun\xVM VirtualBox\"
Set the target ("Target:") to:
C:\Windows\System32\cmd.exe /k VBoxHeadless.exe --startvm name_of_your_cc5_guest
eg:
C:\Windows\System32\cmd.exe /k VBoxHeadless.exe --startvm ClarkConnectVM

d) Apply/OK

Now when you double-click this shortcut it will start VirtualBox and also start CC5. You won't be able to tell when it is ready (other than CPU usage), however its ready when you can login with PuTTY as root.

Tip: To stop NewCS Process:
- If in the terminal that you used to start NewCS - Scroll up to see the Process Number created.
Use this number in the following command: kill xxxx (where 'xxxx' is the process number)
- If you cannot see the Process Number, or have just logged in then run:
ps ax_grep newcs (please replace _ with: "shift+\" - I can't post the vertical bar character)
kill xxxx (xxxx is the process found above)

Tip: To do an orderly shut down of CC5 do this:

- Login as root (with PuTTY)
- Issue the command: shutdown -h now


VirtualBox and CC5 will now sit in the background acting as a NewCS Server. In headless mode it boots up into CC5 in less than a minute (on my old PC) and doesn't use many CPU cycles.

Hope this helps others. It looks complicated (and it kinda is!) but follow through the steps and you should be good to go.

BIG THANKS to kapzas over on Eurocardsharing forum for allowing me to use his/her ClarkConnect How-To!!!

Please let me know if I made any typos or other mistakes.

No comments:

Post a Comment