Archive:Author Archive

Unity + vmware-unity-helper = Parallels for Ubuntu

August 25th, 2010
Technorati Tags: ,,

A friend of mine has parallels for OSX on his macbook. It is fairly cool – having a Windows-only program appear to be running natively in OSX. With parallels, there’s no need to dual boot – just use your favorite OS (OSX) and your favorite windows apps seamlessly. This enabled my co-worker to open up VMware’s vSphere Infrastructure Client from within OSX – something that normally takes a ton of configuration and hacking to accomplish.

I was a little jealous that my Ubuntu 10.04 LTS couldn’t do the same… or could it?

I recently passed my VMware Certified Professional 4 exam and as part of the congratulatory package from VMware, I received a copy of VMware Workstation 7 for free. I choose the Linux flavor because that’s what I prefer to use as my primary OS. I fired up a VM of XP, and started tinkering around when I came upon the Unity feature. For supported VMs with VMware tools installed, Unity will allow you to interact with the guest OS/programs as if they were native to the host. Behold!

Screenshot

(That’s the XP system information window sitting on top of a Linux console running top, on top of the Windows Live Writer program)

Unfortunately, to get to this point, I had to manually start the XP VM, then wait for VMware tools to start up before I was able to manually click the Unity button. It’s a boring, repetitive process – so like most things, I decided to see if I could script it somehow.

Enter vmware-unity-helper

I came upon the vmware-unity-helper tool somewhere in the VMware Communities. The question was asked, “How can I get a VM to automatically start with my OS” and the unity helper tool was mentioned in passing. A bit of Googling later and I had my answer.

vmware-unity-helper –run /path/to/vmx-file/vm.vmx "c://path//to//program.exe"

This command will attempt to run the specified program in the VM specified by the vmx configuration file. If the VM isn’t running, it will automatically start it, and when VMware tools starts up, the program is run.

To make my life a little easier, I created a very simple bash script that would run the vSphere client.

Screenshot1

After marking the script as executable, I can now run it and have the Infrastructure Client running “natively” in Ubuntu!

Screenshot-1

The only downside is that I can’t seem to fully maximize the windows… they seem to only maximize to the top portion of the screen. It may be related to guest resolution, but I’m not certain. For now, manually resizing is sufficient for my needs.

sudo for Powershell

May 25th, 2010

Today I discovered I had written a script that required admin rights (restarting a Windows service). I began looking into options for the Linux equivalent of sudo and came upon these two pages: Link 1, Link 2. Both describe simplified ways of trying to launch an app from an elevated account (notepad, powershell, etc). However, there were a few things missing. First, if I want to run an elevated powershell script I had to run

sudo powershell

, then once in the elevated prompt, cd to the directory and run the script

.\services.ps1

This obviously isn’t ideal – and the one source had a few mistakes with how the actual passed file was called (it didn’t deal well with the “.\” portion of a passed script.

I made some changes, added comments, and updated to allow for powershell scripts to be run with a simple flag “-ps”

Here’s the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
## sudo.ps1
#
# Authors: pezhore, mrigns, This guy: http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell,
#             other powershell peoples
#
# Sources:
#       http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell
#       http://www.ainotenshi.org/%E2%80%98sudo%E2%80%99-for-powershell-sorta
#
# Version:
#       1.0     Initial version
#       1.1     added -ps flag, cleaned up passed $file/$script full path
#       1.2     Comments
#       1.3     Fixed passing working directory to powershell/auto closing
 
param(
        [switch]$ps,               # Switch for running args as powershell script
        [string]$file,             # Script/Program to run
        [string]$arguments = $args # Arguments to program/script
     )
 
# Find our powershell full path
$powershell = (get-command powershell).definition
 
# Get current directory
$dir = get-location
 
#If we're running this as a elevated powershell script
if ($ps){
 
        # Script verification
        if([System.IO.File]::Exists("$(get-location)\$file")) {
 
                # Set the $script to full path of the ps script
                $script = (get-childitem $file).fullname
        }
 
        # Create a powershell process
        $psi = new-object System.Diagnostics.ProcessStartInfo $powershell
 
        $psi.WorkingDirectory = Get-Location
 
        # Combine the script and its arguments
        $sArgs = $script + " " + $arguments
 
        # Set the arguments to be the ps script and it's arguments
        $psi.Arguments = "-noexit -command set-location $dir; $sArgs"
 
        # Magic to run as elevated
        $psi.Verb = "runas";
}
 
# We're running something other than a powershells script
else {
 
        # File verification
        if([System.IO.File]::Exists("$(get-location)\$file")) {
 
                # Get full path
                $file = (get-childitem $file).fullname
        }
 
        # Same as above, create proccess/working directory/arguments/runas
        $psi = new-object System.Diagnostics.ProcessStartInfo $file
        $psi.Arguments = $arguments
        $psi.Verb = "runas"
}
 
# Start the process
[System.Diagnostics.Process]::Start($psi)

I added an alias in my profile and sudo was born:

1
New-Alias -name sudo 'd:\git-code\Powershell\ps_misc\sudo.ps1'

Fun thing of today: Powershell and VMware – Part 1

May 19th, 2010

Today’s fun thing: utilizing powershell to test stuff in VMware. There are a few cool things I have been able to piece together with Powershell and VMware -hopefully some of those will make it into a brief series.

I wrote two scripts to help with testing the various VLANs that were necessary for our VMs. (Really less scripts and more basic functions)

Function 1: PowerCLI

$vm = get-vm testVM
$VLANs = "3","5","08","09","11","18","22","35","59","106","112","201","202","222"
foreach ($vlan in $VLANs){
     $vm |Get-NetworkAdapter|Set-NetworkAdapter -networkname "VLAN $vlan" -Confirm:$false
     write-host "Press any key to continue..."
     $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}

Function 2: Testing VM

$VLANs = "3","5","08","09","11","18","22","35","59","106","112","201","202","222"
foreach ($vlan in $VLANS) {
     .\set-StaticIP.ps1 -ip 10.10.$vlan.254 -gtw 10.1.$vlan.254
     start-sleep 5
     $ping = new-object System.Net.NetworkInformation.Ping
     $rslt = $ping.send("10.10.3.3")
     if ($rslt.status.tostring() -eq "Success"){
          write-host "Vlan $vlan tested ok"
     }
     else {​
          write-host "Vlan $vlan ping test failed"
     }
     write-host "Press any key to continue..."
     $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}

Script 1: set-StaticIP.ps1

param(  [string]$ip,
     [string]$mask = "255.255.255.0",
     [string]$gtw = "192.168.1.254",
     [string]$dns1 = "192.168.1.1",
     [st​ring]$dns2
     )
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration | where{$_.IPEnabled -eq "TRUE"}
Foreach($NIC in $NICs) {
     if ($ip){
          $no = $NIC.EnableStatic($ip, $mask)
     }
     $no = $NIC.SetGateways($gtw)
     if($dns2){
          $dns ="$dns1,$dns2"
     }
     $no = $NIC.SetDNSServerSearchOrder($dns)
     $no = $NIC.SetDynamicDNSRegistration("FALSE")
}

Explanation

Function1 is started first using PowerCLI (after connecting to the appropriate ESX host). It configures the specified VM’s network adapter to be on the first VLAN, then pauses. After the vmnic is configured properly, Function2 is run on the testVM in powershell. This utilizes the set-StaticIP.ps1 script and configures the IP address to match the specified VLAN, then attempts a ping against MSIDI001 (This machine should be pingable from all the testing VLANS. If the ping is successful, it is indicated that the VLAN tested ok, if not, the failure is stated. After the result is noted, any key is pressed in PowerCLI to set the vmnic to the next VLAN. After it has been configured, any key is pressed in Fuction2 to set the new IP for testVM (the ping test then takes place on this new VLAN). This is repeated until all VLANs have been tested.
This is much quicker than manually assigning IPs or setting VLAN membership in VMware’s Infrastructure Client.

Mashups

July 21st, 2009

Sorry for the incredibly lack of updates lately. Between an extended 4th of July vacation and craziness at work/home, I’ve been a bit swamped.

Switching gears a bit from purely tech topics, I’d like to devote an entry to mashups. For those not in the know, mashups are the result of skillful merging of two or more distinct songs into a single musical piece. Sometimes the merger does little more than add a different beat, however skilled DJs can create songs that are virtually new creations of their own right.

There are several examples of excellent mashup collections, most notably the “Best of Bootie” (2008), a yearly collection of mashups from across the world. The music is often available for free to download. I myself haven’t had the pleasure of attending a Bootie mashup event, but the CDs and various mp3s are perhaps a decent substitute. Just today I came upon a few new sites that offer free mashup downloads. Mashuptown is a semiweekly blog that posts individual tracks as well as full albums from mashup artists. There’s a place for producers to submit their mashups. I found Dylan Mashed on Mashuptown recently and its been playing since.

Bootie USA is yet another blog that showcases mashups on a regular basis. Every month, Bootie USA releases their Top10 for the month – like DJ Lobsterdust’s “Hot Maus”(Van Halen vs. Deadmau5).

Mashups are an intriguing emerging trend in music and offer a unique listening experience.

I’m working on some more techie stuff for the future, but for now, head out to your nearest mashup site and snag some music.

Android VPN – VPNC

June 29th, 2009

I work in the IT department and we’re just rolling out Cisco VPN (with dongles) to replace our older ISA VPN. Seeing as my G1 is the first “smart” phone I’ve ever owned, I thought I’d get it setup to VPN in to work (So I could use the Android App Remote RDP). Unfortuantely it didn’t appear to be a simple app available to accomplish this feat. About two weeks ago, I stumbled upon this page which described how to configure vpn for Android. Using those directions (with help from the xda developer’s forum here) I was able to get VPN’ed into work, and RDP’ed to my workstation. Here’s what I did.

Requirements

  • A rooted G1 with the tun module available (I used JF 1.51)
  • JF’s Terminal Emulator (included with JF 1.51)
  • Remote RDP
  • Linux knowledge (optional)

Setup

  1. Download the Get-a-Robot VPNC bz2 file from google code
  2. Extract the archive (if on Linux you can use bunzip2, in Windows 7-zip works well) to a known folder. I extracted to c:\android-vpn\
    • Note: I did the bulk of this on Windows, but if you’re smart you can translate this to Linux
  3. Open vpnc.conf located in ./data/data/org.codeandroid.vpnc/etc/vpnc/
  4. Edit the file with information from your Cisco .pcf file. Below is the mapping of variables for vpnc.conf to YourFile.pcf.
    • IPSec gateway = Host
    • IPSec ID =GroupName
    • IPSec secret = GroupPwd (or if GroupPwd is blank, you’ll have to decrypt the enc_GroupPwd variable as shown below)
    • Xauth username = Your login username
    • Xauth password = Nothing. Leave this blank to have VPNC prompt you for your password every time.

    My vpnc.conf file (sanitized and with the wrong username):

    vpnc_config

  5. Edit the vpnc-script and change the first line from #!/system/bin/bash to #!/system/bin/sh
  6. Open a command prompt and push the files using adb push x:\path\to\data /, copying the edited script and config file to the root of your G1.vpnc_push
  7. Mount the microSDHC card and create a new folder in its root called vpnc.
  8. Create two files: go and prep
    go should contain this one line:
    /data/data/org.codeandroid.vpnc/bin/vpnc /data/data/org.codeandroid.vpnc/etc/vpnc/vpnc.conf --script /data/data/org.codeandroid.vpnc/etc/vpnc/vpnc-script --pid-file /data/data/org.codeandroid.vpnc/etc/vpnc/vpnc-pid --no-detach --debug 1

    prep contains a few lines:
    modprobe tun
    lsmod
    mkdir /dev/net
    ln -s /dev/tun /dev/net/tun

  9. Unmount the microSDHC card and then fire up terminal emulator – we need to chmod a few files to make things work.
    chmod 777 /data/data/org.codeandroid.vpnc/bin/vpnc
    chmod 777 /data/data/org.codeandroid.vpnc/etc/vpnc/vpnc-script

Starting the VPN

  1. In Terminal Emulator type su to get root access (Approve if it prompts you to grant permission)
  2. As root (designated by the “#” prompt) run cd /sdrom/vpnc
  3. Run sh prep (Note: this is only required once each time you reboot your phone)
  4. To start the VPN, run sh go. It will prompt your for your password, then attempt to connect:
  5. You can then click the back button to leave the vpn connection running and fire up Remote
    vpnc_remote
  6. To close the VPN, reopen Terminal Emulator, and if it’s still up and running, send the interrupt (ctrl-c) by clicking and holding the mouse ball, then pressing ‘c’
  7. If the vpn is not still running, you can find the process ID number by running ps and looking for /data/data/org/codeandroid.vpnc/bin/vpnc.
    vpnc_kill
  8. Kill the process by running kill -9 [pid], (in our example kill -9 1896)

Final Thoughts

Although this isn’t ideal for an extended VPN connection, if combinded with tethering (something I’m working on next), it could become quite powerful. For quick checks, this works quite well.

Sources:
xda-developer’s forum
Uber Geeky post
Get-A-Robot-VPNC Google Code Page

New theme

June 18th, 2009

After looking around for a while, I think I’ve settled on this theme: TarouMag. Clean, slightly techie-ish, and green – I like green. I had to do a tiny bit of work with the logo using Paint.NET, my all-time favorite image editor. I think I may do a brief write up on that program as part of my continuing series App of the [unit of time].

Migrating G1 Apps to SD

June 18th, 2009

After adding yet another app to my G1 I recieved my first “Low Disk Space” warning. I decided to see what options exist for moving the apps from internal storage to the SD card and found a few how-tos out there that describe the process. I ended up following the A2SD guide, with little problem.

The first step is to repartition your microSDHC card from one large Fat32 partition into two partitions: the first remains Fat32, the second is formated ext2. Since I don’t have a Linux box at work (and I was hoping to get this done over my lunch break), I fired up a VM and ran GParted, an open source Linux live CD that we use at work for resizing VM partitions. Using GParted, I was able to shrink the Fat32 partition from 4GB down to 3GB, and created the necessary ext2 partition from the remaining space. I should note that I used the phone as an microSDHC reader – it was on and functioning the entire time.

Since the Android SDK was already installed, the next step was relatively simple to complete. I fired up the command prompt on my Windows 7 box, and ran adb shell (this opens the shell on the phone).

To make sure the partition was correctly set, I ran busybox df -h and verified that the ext2 partition was showing up in the mount table.

App2SD_VerifyPartition

Since I only want to move the apps (not their cache) to the microSDHC card, I only had to run one command busybox cp -a /data/app /system/sd. This copies all the existing app data from the phone storage over to the microSDHC card.

The next step didn’t appear to work for me… but for completeness sake:

I then booted my phone into the JF Recovery mode by shutting down my phone, then starting it up holding the Power and Home buttons. I pressed Alt-X to get to the phone’s terminal and ran the following commands:

mount data
rm -rf /data/app
ln -s /system/sd/app /data/app
reboot

I’m not sure what the first command does (mounts whatever device is mapped to data in the mountd.conf file I’d assume). The second command removes all apps from the phone. The next command creates a symlink from the microSDHC partition to the directory Android is expecting the apps to be located. Lastly, the phone is rebooted.

When I did these steps, it didn’t take – the applications were still on my phone memory (as evidenced by the free space available). As I think back, I may have forgotten to mount data (but one would assume I would have gotten some errors while trying to delete the contents of /data/app. I verified the apps were still located in phone memory by once again plugging my phone in via USB and running adb shell. I reran the last three commands above (from rm -rf through to reboot) and everything had successfully moved off to the microSDHC card.

Now I’m running over 70 apps, and the phone actually appears to be responding faster.

PostBot: App of the [Unit of Time]

June 17th, 2009

Today’s app is PostBot for android phones. I’ll be reviewing it on my G1. Postbot is designed to allow remote updating of wordpress blogs.

Configuration
Pretty straight forward… from the phone configuration. I didn’t realize that remote posting had to be enabled on the wordpress blog itself (although it sort of makes sense). Unfortunately the only indication that something was amiss was a very brief pop up java exception that hinted at checking the admin page.

Once I enabled remote posting, everything went swimmingly.

Features
I haven’t fully utilized everything yet, but basic posting is fairly straight forward. You can add new categories – something that’s prettty cool (when it works). I had some timeout issues despite having 3 bars on the edge network.

In theory there’s also picture uploading, but I haven’t messed around with that too much.

Screen Shots

Vertict
This might change as I start to use PostBot more often, but for right now I’m giving it an arbitrary 3 nickels out of a possible goose (pretty devent app). We’ll see if the time outs extend to posting new messages, or if any issues arrise from media manipulation.

Also, it’s worth noting that this entire post was typed up on my G1 using PostBot.

Links
Developer’s blog
Cyrket Page

G1 InvisibleSHIELD Review

June 16th, 2009

I purchased the Developer’s G1 the second week in May 2009. I quickly installed Jesusfreke’s cupcake build and started playing around with it. I also began looking at the various protective coverings (skins, cases, etc) to keep my G1 in immaculate condition. I settled on the Zagg InvisibleSHIELD due in part to its claim to a “Military grade” scratch resistant cover. Price seemed a tiny bit steep ($26), but I figured if it managed to do the job and was as durable as other reviews claimed – it’d be worth it.

Judging from the reviews I found Zagg is one of three main types of skins currently available for the G1. The other two options are the RealCoolSkins and the BodyGuardz. Doing some preliminary research, the RCS and BG are made from a 3M product, whereas the Zagg is its own proprietary formula for its skin. The biggest complaint across the board is how difficult it is to properly install. As one reviewer put it, “You need the patience of a kindergarten teacher, and the hands of a surgeon.”

I have worked with tedious projects in the past, so I assumed I could handle it. It arrived roughly 4 days after I ordered it online. Install time clocked in at roughly an hour and a half. The corners were a pain to install, but I was able to hold them in place using plastic wrap.  Some small bubbles were present immediately following the install, but as other reviews said – the bubbles disappeared. slight “orange peel” was visible in the days since.

I’ve attempted to purposely scratch the back, and couldn’t. There are some left over pieces from the install and I attempted to use my exacto knife to cut the scraps… only with significant pressure could I cut through. If my phone goes up against something like an exacto knife – nothing will protect it.
Evaluation
Was it worth the money? Hells yes. I’m no longer worried about keeping my phone in a separate pocket from my keys. The touchscreen isn’t impaired by the skin, and the overall glossy look seems to actually add to the aesthetics.

New themes

June 16th, 2009

Trying out some new themes tonight, hoping to find the one that screams german technology with a minimum level of Hasselhoffness.