Browse files

initial commit for public dist

  • Loading branch information...
1 parent dd80f0f commit 62601df85440cf0e7d2fbbc6ee2fe1c1af8926cd @ryancnelson committed Jun 23, 2014
Showing with 178 additions and 0 deletions.
  1. +126 −0 coal-vmware-setup
  2. +52 −0 coal-vmware-setup.bat
126 coal-vmware-setup
@@ -0,0 +1,126 @@
+# coal-vmware-setup: sets up VMWare Fusion so you can use
+# CoaL (Cloud on a Laptop) with it.
+# Copyright (c) 2011 Joyent Inc., All rights reserved.
+function get_config_value() {
+ name=$1
+ script_dir=$(dirname $0)
+ if [[ -f "$script_dir/../config/config.coal" ]]; then
+ value=$(grep "^$name=" "$script_dir/../config/config.coal" | awk -F'=' '{print $2}')
+ fi
+ if [[ ! -z "$value" ]]; then
+ echo "$value"
+ else
+ return 1
+ fi
+if [ $UID -ne 0 ] ; then
+ echo This script must be run as root. Run again using the commandline:
+ echo sudo $0
+ exit 1
+BIN_DIR=/Library/Application\ Support/VMware\ Fusion
+SETTINGS_DIR=/Library/Application\ Support/VMware\ Fusion
+# Detect if Fusion 4 is installed
+if [ -e "/Applications/VMware" ]; then
+ BIN_DIR="/Applications/VMware"
+ SETTINGS_DIR="/Library/Preferences/VMware Fusion"
+ FUSION4=true
+## Networks ##
+# The admin "host-only" network - vmnet1 (only between the Mac and the headnode)
+ADMIN_NETWORK=$(get_config_value admin_network || echo
+ADMIN_NETMASK=$(get_config_value admin_netmask || echo
+ADMIN_MAC_IP=$(echo ${ADMIN_NETWORK} | sed 's/\.[0-9]*$/.254/')
+# The external NAT network - vmnet8 (can reach the internet)
+# Note: There isn't currently an "external_network" var in config.coal to use.
+echo "Admin network: network=\"${ADMIN_NETWORK}\", mac ip=\"${ADMIN_MAC_IP}\", netmask=\"${ADMIN_NETMASK}\""
+echo "External network: network=\"${EXTERNAL_NETWORK}\", mac ip=\"${EXTERNAL_MAC_IP}\", netmask=\"${EXTERNAL_NETMASK}\""
+VM_LIST=$("$BIN_DIR/vmrun" list)
+if [ "$VM_LIST" != "Total running VMs: 0" ] ; then
+ echo You have Virtual Machines running. Please shut them down before continuing.
+ exit 1
+echo "Setup VMWare networking: admin network $ADMIN_NETWORK, external network $EXTERNAL_NETWORK"
+cat networking | grep -ve 'VNET_[18]' > $NET_TMP
+cat locations | grep -ve 'VNET_[18]' > $LOCATIONS_TMP
+cat >> $NET_TMP <<__NETWORKING__
+answer VNET_1_DHCP no
+answer VNET_1_NAT no
+answer VNET_8_DHCP yes
+answer VNET_8_DHCP_CFG_HASH 889DD78A4E0F3E1F68AB5418242607E2B4A060B7
+answer VNET_8_NAT yes
+remove_answer VNET_1_HOSTONLY_NETMASK
+remove_answer VNET_1_DHCP
+answer VNET_1_DHCP no
+remove_answer VNET_8_HOSTONLY_NETMASK
+remove_answer VNET_8_NAT
+answer VNET_8_NAT yes
+remove_answer VNET_8_DHCP
+answer VNET_8_DHCP yes
+echo Changing VMware networking settings...
+cp networking networking.pre_coal
+cp locations locations.pre_coal
+echo Old settings backed up to the following files:
+echo $SETTINGS_DIR/networking.pre_coal
+echo $SETTINGS_DIR/locations.pre_coal
+mv $NET_TMP networking
+mv $LOCATIONS_TMP locations
+echo Restarting VMware services...
+if [ -n "$FUSION4" ]; then
+ "$BIN_DIR/" --stop
+ "$BIN_DIR/" --start
+ "$BIN_DIR/" --restart
+# If we're running before VMWare is run for the first time, the previous step
+# will have created a preference file as root, so fix it:
+chown -R $SUDO_UID:$SUDO_GID "/Users/$SUDO_USER/Library/Preferences/VMWare Fusion"
+echo Done!
52 coal-vmware-setup.bat
@@ -0,0 +1,52 @@
+@echo off
+rem coal-vmware-setup.bat: sets up VMWare Workstation / Player
+rem so you can use CoaL (Cloud on a Laptop) with it.
+rem Copyright (c) 2011 Joyent Inc., All rights reserved.
+reg query "HKU\S-1-5-19" >nul 2>nul
+if "%errorlevel%" NEQ "0" (
+ echo You must run this program as an Administrator. Please re-run by
+ echo right-clicking this file, and then clicking "Run as Administrator"
+ goto:EOF
+set vmdir="\Program Files (x86)\VMware\VMware Player"
+echo before: %vmdir%
+if exist "\Program Files (x86)\VMware\VMware Workstation" set vmdir="\Program Files (x86)\VMware\VMware Workstation"
+echo after: %vmdir%
+cd %vmdir%
+echo Stopping VMware networking services...
+start /wait vnetlib.exe -- stop dhcp
+start /wait vnetlib.exe -- stop nat
+echo Backing up VMware networking files...
+cd \ProgramData\VMware
+copy vmnetdhcp.conf vmnetdhcp.conf.pre_coal
+copy vmnetnat.conf vmnetnat.conf.pre_coal
+cd %vmdir%
+echo Changing VMware settings...
+start /wait vnetlib.exe -- set vnet vmnet8 mask
+start /wait vnetlib.exe -- set vnet vmnet8 addr
+start /wait vnetlib.exe -- add dhcp vmnet8
+start /wait vnetlib.exe -- add nat vmnet8
+start /wait vnetlib.exe -- update dhcp vmnet8
+start /wait vnetlib.exe -- update nat vmnet8
+start /wait vnetlib.exe -- update adapter vmnet8
+start /wait vnetlib.exe -- set vnet vmnet1 mask
+start /wait vnetlib.exe -- set vnet vmnet1 addr
+start /wait vnetlib.exe -- remove dhcp vmnet1
+start /wait vnetlib.exe -- remove nat vmnet1
+start /wait vnetlib.exe -- update dhcp vmnet1
+start /wait vnetlib.exe -- update nat vmnet1
+start /wait vnetlib.exe -- update adapter vmnet1
+echo Starting VMware networking services...
+start /wait vnetlib.exe -- start dhcp
+start /wait vnetlib.exe -- start nat
+echo Done

0 comments on commit 62601df

Please sign in to comment.