[SCM] Debian Live application startscripts branch, master, updated. 81ad272654f0899941ea0bf8a2c23c0ba725d95d

Richard Nelson unixabg at gmail.com
Fri Dec 19 16:02:26 UTC 2008


The following commit has been merged in the master branch:
commit 0fc4fcfe9bedcaa21e3fdb7352701457ce2bb075
Author: Richard Nelson <unixabg at gmail.com>
Date:   Fri Dec 19 09:52:09 2008 -0600

    Initial release of live-vmware-player. This file is designed to assist in the operations of deploying
    vmware image(s) to workstation(s) with the image snapshots stored locally, and the master images stored
    on the network and shared read only.

diff --git a/initscripts/live-vmware-player b/initscripts/live-vmware-player
new file mode 100644
index 0000000..d67719e
--- /dev/null
+++ b/initscripts/live-vmware-player
@@ -0,0 +1,183 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          live-vmware-player
+# Required-Start:    
+# Required-Stop:     
+# Default-Start:     
+# Default-Stop:
+# Short-Description: Setup miscellaneous things for VMWarePlayer.
+# Description:	The script tests for boot parameter of custom_options=ACTION:IMAGEPATH:VMXNAME
+# 		ACTION: The operation to perform on the workstation (none|scratch)
+#		IMAGEPATH: The folder path to the VMWare image you want to run.
+#		VMXNAME: The name of the VMWare image you want to run.
+# Notes:To use this file with WMWare images you will need to have a few things setup:
+#	1.) The VMWare Player needs to be installed in the image.
+#	2.) This script uses (s|h)da1 for writing image data, and is used as a scratch space. 
+#	    This scratch space should be a file system with linux permissions such as ext2.
+#	3.) VMWare image(s) should be in a mounted folder and setup as follows:
+#	    - Image(s) set to snapshot mode.
+#	    - For each image, the image folder needs to have a file called image-release with a 
+#	      variable CRELEASE. An example: CRELEASE="1.0.0"
+#             The image-release file is used by the image maintainer and this script to tell 
+#	      workstation(s) using a given image, to erase locally stored vmware image files
+#	      and setup with the newly configure image. The operation of erasing locally stored
+#	      vmare image files, is referred to as a scratch. 
+### END INIT INFO
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
+do_start () {
+        for x in $(cat /proc/cmdline); do
+		case $x in
+                	custom_options=*)
+				echo "Starting custom options of ${x#custom_options=} for VMPlayer setup." >>/var/log/live-vmware-player.log
+				# Source in some variables.
+				if [ -f /etc/live.conf ]; then
+					echo "Found /etc/live.conf!" >>/var/log/live-vmware-player.log
+					. /etc/live.conf
+				else
+					echo "No /etc/live.conf found!" >>/var/log/live-vmware-player.log
+					break
+				fi
+				# Ok here is where we need to determine info passed to do the magic.
+				ACTION=`echo ${x#custom_options=} | awk -F: '{print $1}'`
+				echo "ACTION of $ACTION " >>/var/log/live-vmware-player.log
+				IMAGEPATH=`echo ${x#custom_options=} | awk -F: '{print $2}'`
+				echo "IMAGEPATH of $IMAGEPATH " >>/var/log/live-vmware-player.log
+                                VMXNAME=`echo ${x#custom_options=} | awk -F: '{print $3}'`
+                                echo "VMXNAME of $VMXNAME " >>/var/log/live-vmware-player.log
+				echo "Setting up a symlink to the image we are going to use from the image pool." >>/var/log/live-vmware-player.log
+				ln -s $IMAGEPATH $IMAGEPATH/$VMXNAME
+				echo "Setting the session type with .dmrc for gdm." >>/var/log/live-vmware-player.log
+				cat > /home/$USERNAME/.dmrc <<EOF
+[Desktop]
+Session=vmware
+EOF
+				echo "Setting permissions on session type." >>/var/log/live-vmware-player.log
+				chown -R $USERNAME:$USERNAME /home/$USERNAME/.dmrc
+
+				echo "Setting the PostSession Default for the gdm to shutdown when we end the VMPlayer stops." >>/var/log/live-vmware-player.log
+				cat > /etc/gdm/PostSession/Default <<EOF
+#!/bin/sh
+/sbin/halt
+EOF
+				echo "Setting up the vmware.desktop option." >>/var/log/live-vmware-player.log
+				cat > /usr/share/xsessions/vmware.desktop <<EOF
+
+[Desktop Entry]
+Encoding=UTF-8
+Name=VMWare Player
+Comment=This session logs you into a VMWare session.
+Exec=/usr/bin/vmwrapper
+# no icon yet, only the top three are currently used
+Icon=
+Type=Application
+EOF
+				echo "Setup the vmwrapper which starts the vmplayer with a window manager." >>/var/log/live-vmware-player.log
+				cat > /usr/bin/vmwrapper <<EOF
+#!/bin/sh
+/usr/bin/metacity &
+/usr/bin/vmplayer -X "/vmware/$VMXNAME.vmx"
+EOF
+				echo "Setting chmod on the vmwrapper." >>/var/log/live-vmware-player.log
+				chmod 755 /usr/bin/vmwrapper
+
+				# Here is where once the player prompts are agreed it is injected.
+				echo "Copying over vmware settings for the user account $USERNAME." >>/var/log/live-vmware-player.log
+				cp -R /etc/vmware/.vmware /home/$USERNAME/
+
+				echo "Setting permissions on the users .vmware folder." >>/var/log/live-vmware-player.log
+				chown -R $USERNAME:$USERNAME /home/$USERNAME/.vmware
+
+				echo "Making the /vmware directory where we will compose the operations for the image." >>/var/log/live-vmware-player.log
+				mkdir /vmware
+
+				echo "Checking for a local scratch device." >>/var/log/live-vmware-player.log
+				MOUNTDEV=`fdisk -l | grep a1 | awk '{print $1}'`
+				echo "Potential scratch devices of: $MOUNTDEV" >>/var/log/live-vmware-player.log
+				
+				####################################################################################################
+				# Below is where I use a variable named CRELEASE which is sourced in from the image directory.
+				# This file is created by the person managing the images so he can modify an image and all 
+				# workstations using the image will know to auto scratch (erase local snapshot info) on next boot
+				# when the difference is detected between the image mainter variable in image-relase and the 
+				# file local-release (with variable RELEASE).
+				####################################################################################################
+				# This is the test for when we want to upgrade an image and deploy to all workstations. Workstations
+				# will scratch upon CRELEASE != RELEASE.
+				if [ -f $IMAGEPATH/image-release ]; then
+					. $IMAGEPATH/image-release
+					echo "Found image-release: $CRELEASE " >>/var/log/live-vmware-player.log
+				else
+					echo "******* No image-release found to set the CRELEASE variable! *******" >>/var/log/live-vmware-player.log
+					CRELEASE="NONE"
+				fi
+				
+				echo "Preparing VMWare image version $CRELEASE" >>/var/log/live-vmware-player.log
+				echo "Checking for clean scratch file system on $MOUNTDEV!" >>/var/log/live-vmware-player.log
+				fsck -C -a $MOUNTDEV
+
+				echo "Attempting to mount local scratch device." >>/var/log/live-vmware-player.log
+				mount -v $MOUNTDEV /vmware
+				
+				echo "Checking to see if scratch was requested at boot." >>/var/log/live-vmware-player.log
+				if [ "$ACTION" = "scratch" ]; then
+					echo "Scratching everything in scratch dir on the fly!" >>/var/log/live-vmware-player.log
+					rm -rf /vmware/*
+					echo "Scratching completed!" >>/var/log/live-vmware-player.log
+				fi
+
+
+				if [ -f /vmware/local-release ]; then
+					. /vmware/local-release
+					echo "Found local-release: $RELEASE " >>/var/log/live-vmware-player.log
+					if [ "$RELEASE" != "$CRELEASE" ]; then
+						echo "Upgrading release from version $RELEASE to $CRELEASE ." >>/var/log/live-vmware-player.log
+						echo "We will take scratch actions." >>/var/log/live-vmware-player.log
+						rm -rf /vmware/*
+						echo RELEASE=\"$CRELEASE\">/vmware/local-release
+						echo "Rsyncing in some stuff to /vmware." >>/var/log/live-vmware-player.log
+						rsync --exclude=$VMXNAME-f*.vmdk -r $IMAGEPATH/ /vmware/
+						# Link in the big chunks.
+						ln -s $IMAGEPATH/$VMXNAME-f*.vmdk /vmware
+					else
+						echo "Version match no scratch action taken!" >>/var/log/live-vmware-player.log
+						echo "Removing any temp old lock files!" >>/var/log/live-vmware-player.log
+						rm -f /vmware/*LOCK
+					fi
+				else
+					echo "Looks like an initial release setup for version $CRELEASE ." >>/var/log/live-vmware-player.log
+					echo RELEASE=\"$CRELEASE\">/vmware/local-release
+					echo "Rsyncing in some stuff to /vmware." >>/var/log/live-vmware-player.log
+					rsync --exclude=$VMXNAME-f*.vmdk -r $IMAGEPATH/ /vmware/
+					# Link in the big chunks.
+					ln -s $IMAGEPATH/$VMXNAME-f*.vmdk /vmware
+				fi
+
+				echo "Setting the permissions on the /vmware folder." >>/var/log/live-vmware-player.log
+				chown -R $USERNAME:$USERNAME /vmware
+
+				echo "Completed custom options! username = $USERNAME" >>/var/log/live-vmware-player.log
+				;;
+                esac
+	done
+}
+
+case "$1" in
+  start|"")
+	do_start
+	;;
+  restart|reload|force-reload)
+	echo "Error: argument '$1' not supported" >&2
+	exit 3
+	;;
+  stop)
+	# No-op
+	;;
+  *)
+	echo "Usage: live-vmware-player [start|stop]" >&2
+	exit 3
+	;;
+esac
+
+

-- 
Debian Live application startscripts



More information about the debian-live-changes mailing list