vCloud Director CentOS Guest OS Customization Script

I needed to customize a custom Linux VM image with a static IP address in vCloud Director. Here’s the script I came up with. It doesn’t work unless VMWare tools is installed and running in the VM (kernel upgrades tend to break it). The VM should be stopped, then paste the script into the “Guest OS Customization” script area. Boot the VM with the “Power On and Force Recustomization” option.

 

#!/bin/bash
HOSTNAME=YourHostNameHere
IPADDR=StaticIpAddressGoesHere
NETMASK=255.255.255.0
(
echo "------------------------------------------------------------------------------"
date
if [ x$1 == x"precustomization" ]; then
  set -e
  echo "Running Pre-Customization tasks..."
  if [ x$HOSTNAME != x ]; then
    echo "Configuring hostname as $HOSTNAME"
    sed -i "/HOSTNAME/d" /etc/sysconfig/network
    echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network 
    hostname $HOSTNAME
    hostname
  else
    # Set it so it can be used below
    HOSTNAME=hostname
  fi
  if [ x$IPADDR != x ]; then
    echo "Configuring network IP=$IPADDR NETMASK=$NETMASK"
    rm /etc/udev/rule.d/70-persistent-net.rules
    sed -i "/IPADDR/d" /etc/sysconfig/network-scripts/ifcfg-eth0
    sed -i "/NETMASK/d" /etc/sysconfig/network-scripts/ifcfg-eth0
    sed -i "/HWADDR/d" /etc/sysconfig/network-scripts/ifcfg-eth0
    sed -i "/BOOTPROTO/d" /etc/sysconfig/network-scripts/ifcfg-eth0
    sed -i "/DHCPHOSTNAME/d" /etc/sysconfig/network-scripts/ifcfg-eth0
    cat >> /etc/sysconfig/network-scripts/ifcfg-eth0 <<ENDCFG
BOOTPROTO=static
IPADDR=$IPADDR
NETMASK=$NETMASK
DHCPHOSTNAME=$HOSTNAME
ENDCFG
  fi
  echo "Done with Pre-Customization"
elif [ x$1 == x"postcustomization" ]; then
  echo "Running Post-Customization tasks..."
fi
) | tee -a /root/customize.log
 

Update: It turns out that having VMWare Tools functioning properly is enough for vCloud Director to configure the network settings all by itself, without the help of a script.

Is Android open?

Ars Technica has an interesting article about how “Android is open—except for all the good parts”, which they’ve been making proprietary.

It’s a warning to developers who integrate with proprietary Google APIs — maps APIs, cloud messaging, location APIs, in-app purchasing, “Play Games” API. When they embrace Google’s great APIs, it makes it more difficult to port to Kindle Fire and other Android derivatives.

My overall feeling is that Google gives users more freedom with Android than Apple gives users with iPhone/iOS. (Sidenote: In spite of that, I like iOS slightly better).

Closing the good parts doesn’t mean there’s no competition — there’s still iPhone and Windows Phone.

Fidelity App: Not responsible for accuracy of financial information

Do you ever read the fine print when you install an application, and it presents you with an end-user-license-agreement?

I do.

Recently, I installed the Fidelity iPhone app, and here’s a few surprising parts of their service agreement:

By using the Services, I consent to the transmission by electronic means…. I acknowledge that Fidelity cannot assure the security or privacy of electronic transmission of such information. Any transmission may also be subject to other agreements that you have with your mobile service or access device provider. Accordingly, I must assess whether my use of the Services is adequately secure to meet my particular needs. While all information accessible through the Services has been obtained from sources believed to be reliable, I understand that Fidelity will not be responsible whatsoever for the accuracy, timeliness, completeness, or use of any information received by it or received by me from Fidelity or any Provider through the Services and that Fidelity does not make any warranty concerning such information.

I don’t think most of us are capable of assessing whether our use of a third-party service is adequately secure — it’s difficult for security professionals to decide such things.

Tools and trade-offs

Ten or more years ago, I purchased a Gerber multi-tool. It was less expensive than a Leatherman, and it was painted in my favorite color. Since then, I saw my brother’s Leatherman Wave, and wanted one. For Father’s Day this year, Janice gave me a Wave. I like it — it’s a sleek piece of engineering in every way. The screwdriver fits more of the screws that I encounter compared to the bulky phillips head on the Gerber. The saw works far better. It’s easier to access the Leatherman’s knives, saw and file.

Leatherman Wave vs Gerber multi-tools

However, I’ve found that when I’m out and about in the yard, the Gerber is easier to work with. It’s belt-holster is secured with velcro — easy not only to open, but to close. And opening the pliers is an easy one-handed flick-of-the wrist, which means I don’t have to put the tool in my left hand down in order to open the pliers like I do with the Leatherman.

The Gerber’s pliers can be used to pry things apart. The Leatherman folds up when I try the same thing. The Leatherman is a more dangerous tool to open and use — more likely to pinch or draw blood (as it has done on a few occasions).

The tools definitely have trade-offs. I admire the Leatherman most, but for regular use, the Gerber wins.

The same thing is true of operating systems. I’ve used Linux and Windows for years, and have wanted to try out Mac OS X and a MacBook Pro.

My wish came true. For the past two months, I’ve been using a MacBook Pro 17″ with Retina display. Not only is the engineering and design gorgeous, the screen is eye-poppingly clear and crisp. The battery lasts and lasts, and the laptop doesn’t get too warm. The track-pad is the best I’ve ever used, and I love the gesture support to go forward and back in the web browser, and the gestures to switch desktop workspaces, activate Mission Control and Launch Pad.

Yet the keyboard shortcuts have taken some getting used to compared to the ones I know from both Gnome (Linux) and Windows 7. I find that it’s easy to accidentally hit Command-Q when I meant to hit Command-W. Control-Left and Control-Right don’t work — it’s Option-Left and Option-Right to jump forward and backward by a word. Home and End go to the beginning and end of a document instead of the beginning and end of a line. There’s no built-in window-snapping like Windows 7 or Gnome-Shell.

When I switch back and forth between Mac, Linux, and Windows, I hit the wrong keyboard shortcuts. Is it Command-C or Control-C for copy? On-and-on it goes — sharp edges. But I’m getting used to context switching. I love the MacBook Pro.

Last week, a Gallego UltraPro arrived from System76. It’s a compact powerhouse, and best of all, the keyboard shortcuts work like I expect, and I can get work done faster because I’m used to the underlying OS and tools. When programs break, I know where to look and what utilities to use to solve the problems (I love having /proc available). But the UltraPro with Ubuntu has sharp edges as well. The screen is a bit small, and it’s not as beautiful as the Retina display. It doesn’t have a backlit keyboard, and so far, I haven’t been able to get Evolution to talk to our Exchange server (which isn’t a problem on Mac because it has Outlook).

I admire the refinement, the visual beauty of OS X and the design of the MacBook Pro. For regular use in getting my work done, the UltraPro and Ubuntu currently win.

Book: Mac OS X and iOS Internals

I’ve been reading Mac OS X and iOS Internals by Jonathan Levin. For me, who’s daily bread and butter has been working with Linux, it’s a fascinating and an excellent read that plunges into how OS X and iOS function, from Mach-O binaries to DTrace to bundles and file systems and so much more.

I highly recommend the book.

Debugging shell scripts, User Interfaces and compiled programs on Linux

When I want to debug a shell/bash shell script, I add the following to the script:

set -x export PS4='+(${BASH_SOURCE}:${LINENO}): '

Other times, I export PS4 in my interactive shell, and run the script with “bash -x /path/to/script”. More bash script debugging tips are here: http://wiki.bash-hackers.org/scripting/debuggingtips

When I want to see what commands are being run on a Linux machine by a higher-level user interface, I turn to startmon. It shows me every process created, along with its arguments. This can be useful for figuring out how a CD/DVD-creation program calls wodim/cdrecord, or how it mounts a drive.

When I don’t have source code to a compiled program, and I want to see what system calls it is making, and check into why it might be failing to run, I use strace.

When I want to find out which programs are preventing me from unmounting a DVD or a USB flash drive, I use ‘lsof‘, which is available for nearly every UNIX-like operating system.

When I want to know what programs are consuming the most disk I/O and making things go slow, I use ‘top’ to see the top-memory consumers, and whether they have a high number of page faults. I use ‘iotop’ as well.

OpenWest notes: Do more with LESSCSS

I attended Jake Smith‘s presentation, “Do more with LESSCSS” at the OpenWest conference. Here are my rough notes.

Why use LESSCSS? Be organized in your CSS code — DRY principle (Do Not Repeat yourself)

What is LESSCSS not?

  • doesn’t solve IE or other browser bugs
  • doesn’t save you from yourself.
Gives you:
  1. variables, which are especially useful to help you reference paths or colors or fonts using String interpolation: ‘@{imgPath}divider.png’
  2. nesting. But don’t nest unless you really need to. Never go more than three levels deep on your nesting because it will bloat out your CSS.
  3. Normally, @import slows down page load times, but LESSCSS combines all your imports so that it’s a single HTTP GET.
  4. Hex math to make colors lighter or darker (as for visited links, etc.)
  5. Mixins — the heart of LESS.
  6. if/else — called guards. It looks like a media query.
  7. scope — inherit the closest variable
  8. namespacing
You can have less.js load and compile your less css. But don’t do it. Use CodeKit (a paid tool) instead to compile it before your browser sees it. It will minify it for you as well. There’s also the “Less App”, which is free. SimpleLESS works on Windows and Mac. And there’s LiveReload, which is a paid app for Linux, Windows and Mac. Or use the command line using Node.js’s nvm, then “lessc myfile.less output.min.css -x”

There’s a LESS compiler for PHP, Ruby, etc., but do not use them – they’re not being kept up-to-date.

LESS vs SASS

SASS has a built-in sprite generator. But Jake generates his own sprites. LESS is gaining features of SASS, like @extend.

LESS 1.4 will have (will be delivered by the end of the month):

  1. :extend() functionality
  2. math must be wrapped in parenthesis
  3. variables as default variables
  4. new math functions
  5. convert function: convert(5em, px)

Posted in CSS

Fun and enjoyment when projects involve others

I believe we’re social beings, and that we succeed or fail based on the quality of our interactions with others. Such interactions introduce accountability and are educational and motivating.

Jake Edge reports that when Linus Torvalds was asked what motivated him to write Linux, the answer was that

If Linux hadn’t attracted other people right away, the project probably would have died within six months. But the involvement of others was a “huge motivating factor” for [Linus] to continue, because it “made it much more fun“.

 

 

OpenWest: Embrace your inner designer

During the first weekend in May, I attended the outstanding OpenWest conference, and enjoyed learning from experts. Among the most interesting sessions was one by Josh Broton titled, “Embrace your Inner Designer“.

Is design important? Yes. It changes how users see your application, how they use your application, and how they spread/recommend your application.

Think in flows, not in screens. Make a list of steps users take to use your application, and then do it yourself, and have your staff do it too.

  1. Users navigate to our site
  2. Users click login button
  3. User enters email address
  4. Enter password
  5. Click login button
  6. System validates credentials
The best marketing is FREE marketing. When your users recommend the app to others.

Design tips for developers:

  1. Use a consistent layout — use a grid system to ensure proper spacing.
    1. e.g. http://5by5.tv, http://panoetic.com
  2. Use white space! It helps users differentiate between objects. Less space creates groupings. It improves your readability and user retention.
  3. Use Color, Size and Positioning to convey importance.
  4. Be Consistent. Use one sans-serif font for the body on the screen. On paper, use serif fonts. On Retina displays, either is okay. Use one other font for accent. Use h1, h2 tags, etc. If you change the font you’re using part way through, it takes the brain a while to switch so that it starts comprehending again.
  5. Icons should only be used to add emphasis. This drives him crazy about mobile apps. If you must use icons, then be consistent, and adhere to UI standards.
  6. Color. Every color should consistently match an action. Remember that 10% of the world is colorblind. Use “Adobe Kuler” to help you pick good color palettes. There’s a CSS plugin to desaturate your website.
  7. Use typical casing. All UPPERCASE is extremely difficult to read. Use a non-monospace font. People use width to help them differentiate words.
  8. Left-align type and objects. Don’t center text or right-align.
  9. Steal/mimic ideas. “99% of creating is forgetting where you stole an idea from”
  10. Navigation MUST be easy. Proper nesting, breadcrumb navigation, and consider touch devices (which have no hover capability).
  11. Keep it Simple. Don’t make your users think. Ever. Buy the book — it’s great. by Steve Krug.
    • But you can let them access additional features or enable them.
    • Search engines may penalize you.
  12. Make action items obvious.
  13. Make important items stand out.
  14. Minimize noise
  15. Omit needless items. “The reduction to the essential has never led to catastrophe.” — Dieter Rams
  16. When in doubt, leave it out!
  17. Keep your instructions simple
  18. Test, test, test
Ask your users if they can do what they need to with your app. Don’t ask them whether your app does what it should.

Twitter bootstrap is awesome for non-designers. You can tell websites that use it because of their look, but that might be okay. (Wikipedia info here)

Audience question: Does Windows 8 suck?

Answer: For my mom, it’s perfect. The use of whitespace is great. However, people don’t like switching to a new design paradigm. He despises the complete and total waste of space in Metro.

Check out Font-Awesome — it helps you know standard icons to use in your application.