From 57bed0e2242eeb9359ddc97009af4e9c2364d442 Mon Sep 17 00:00:00 2001
From: thaibault
Date: Thu, 8 Aug 2013 16:24:35 +0200
Subject: Add persistent bootable virtual machine features.
---
.../data/opt/openslx/scripts/vmchooser-clc | 459 +++++++++++++++++++++
.../data/opt/openslx/scripts/vmchooser-run_virt | 55 ++-
.../data/opt/openslx/scripts/vmchooser-xml_filter | 13 +-
.../data/opt/openslx/etc/vmware/run-virt.include | 28 +-
4 files changed, 528 insertions(+), 27 deletions(-)
create mode 100755 remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc
mode change 100644 => 100755 remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include
(limited to 'remote/modules')
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc
new file mode 100755
index 00000000..a8cfbcf3
--- /dev/null
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc
@@ -0,0 +1,459 @@
+#!/bin/bash
+
+# region header
+
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+
+# Dependencies:
+
+# VMware Player - Runs a virtual machine.
+# VMware Workstation - Runs, edits, creates virtual machines for business
+# usage.
+# VirtualBox till version 4 - Plays, creates, edits virtual machines.
+# bash till version 4 - A sh-compatible command line interpreter.
+# cat - Concatenate and prints file contents.
+# echo - Prints chars.
+# grep - Prints lines which matches a given regular expression pattern.
+# sed - Stream-editor for filtering and transformation text.
+# mktemp - Creates temporary files and folders.
+# dirname - Extracts the last element from a given file path.
+# mv - moves and renames file objects.
+# rm - Removes files and folders.
+# cp - Copies files and folders.
+# sleep - Delays program calls.
+# readlink - Print resolved symbolic links or canonical file names.
+
+# Notes:
+
+# USE "sudo bin/vmware-vmx --new-sn JJ237-G52E2-08X0C-C3306-0WCQ1"
+# To activate wmware workstation!
+
+# Abbreviation for "createLinkedClone".
+__NAME__='vmchooser-clc'
+
+# endregion
+
+# Provides the main module scope.
+function vmchooser-clc() {
+
+# region configuration
+
+ # region private properties
+
+ # region command line arguments
+
+ local _VERBOSE='no'
+ # NOTE: You should write upper case first letters to support valid
+ # camel case method names to handle given hypervisor.
+ local _SUPPORTED_HYPERVISOR=('VMware' 'VirtualBox')
+ # NOTE: This value will be determined automatically. If no hypervisor
+ # could be detected this value will be used as default.
+ # The first value from supported Machines is taken as default.
+ local _HYPERVISOR="$_SUPPORTED_HYPERVISOR"
+ local _PERSISTENT_SHORT_DESCRIPTION_SUFFIX=' --persistent--'
+ local _PERSISTENT_CONFIG_TARGET=''
+ local _BASIC_IMAGE_CONFIGURATION_FILE_PATH=''
+ local _TARGET_PATH=''
+ local _VIRTUAL_BOX_SNAPSHOT_NAME='persistentUserSnapshot'
+
+ # endregion
+
+ local _STANDARD_OUTPUT=/dev/null
+ local _ERROR_OUTPUT=/dev/null
+ local _VIRTUAL_BOX_SNAPSHOT_UUID_FILE_PATH='/tmp/clcVirtualBoxSnapshotUUID'
+
+ # endregion
+
+# endregion
+
+# region functions
+
+ # region command line interface
+
+ # Prints a description about how to use this program.
+ function clcPrintUsageMessage() {
+ cat << EOF
+ $__NAME__ Generates a linked clone from given machine description file in
+ given target location.
+EOF
+ return $?
+ }
+
+ # Prints a description about how to use this program by providing examples.
+ function clcPrintUsageExamples() {
+ cat << EOF
+ # Getting a help message.
+ >>> $0 --help
+
+ # Creating a linked clone.
+ >>> $0 /path/to/config.xml ~/.persistentLinkedClones/
+
+ # Creating a linked clone configuration file.
+ >>> $0 /path/to/config.xml ~/.persistentLinkedClones/ -c
+
+ # Creating a linked clone in verbose mode.
+ >>> $0 /path/to/config.xml ~/.persistentLinkedClones/ --verbose
+
+ # Creating a linked clone in verbose mode with debugging output.
+ >>> $0 /path/to/config.xml ~/.persistentLinkedClones/ --verbose --debug
+
+ # Creating a linked clone in verbose mode with debugging output.
+ >>> $0 /path/to/config.xml ~/.persistentLinkedClones/ -v -d
+EOF
+ return $?
+ }
+
+ # Prints descriptions about each available command line option.
+ function clcPrintCommandLineOptionDescriptions() {
+ # NOTE; All letters are used for short options.
+ cat << EOF
+ -h --help Shows this help message.
+
+ -v --verbose Tells you what is going on (default: "$_VERBOSE").
+
+ -d --debug Gives you any output from all tools which are used
+ (default: "$_DEBUG").
+
+ -c --create-persistent-config PERSISTENT_IMAGE_FILE_PATH If set an xml file
+ for persistent openslx boot will be created referencing to given
+ persistent image path (default: "$_PERSISTENT_CONFIG_TARGET").
+
+ -v --virtualbox-snapshot-name NAME Provide a name for newly created
+ snapshots. (default: "$_VIRTUAL_BOX_SNAPSHOT_NAME").
+
+ -u --virtualbox-snapshot-uuid-file-path PATH Provide a file path where to
+ save the newly generated snapshot uuid (default: \
+ "$_VIRTUAL_BOX_SNAPSHOT_UUID_FILE_PATH").
+EOF
+ return $?
+ }
+
+ # Provides a help message for this module.
+ function clcPrintHelpMessage() {
+ echo -e \
+ "\nUsage: $0 BASIC_IMAGE_CONFIGURATION_FILE_PATH TARGET_PATH [options]\n" && \
+ clcPrintUsageMessage "$@" && \
+ echo -e '\nExamples:\n' && \
+ clcPrintUsageExamples "$@" && \
+ echo -e '\nOption descriptions:\n' && \
+ clcPrintCommandLineOptionDescriptions "$@" && \
+ echo && \
+ return $?
+ }
+
+ # Provides the command line interface and interactive questions.
+ function clcCommandLineInterface() {
+ while true; do
+ case "$1" in
+ -h|--help)
+ shift
+ clcPrintHelpMessage "$0"
+ exit 0
+ ;;
+ -v|--verbose)
+ shift
+ _VERBOSE='yes'
+ ;;
+ -d|--debug)
+ shift
+ _DEBUG='yes'
+ _STANDARD_OUTPUT=/dev/stdout
+ _ERROR_OUTPUT=/dev/stderr
+ ;;
+ -c|--create-persistent-config)
+ shift
+ _PERSISTENT_CONFIG_TARGET="$1"
+ shift
+ ;;
+ -v|--virtualbox-snapshot-name)
+ shift
+ _VIRTUAL_BOX_SNAPSHOT_NAME="$1"
+ shift
+ ;;
+ -u|--virtualbox-snapshot-uuid-file-path)
+ shift
+ _VIRTUAL_BOX_SNAPSHOT_UUID_FILE_PATH="$1"
+ shift
+ ;;
+
+ '')
+ shift
+ break 2
+ ;;
+ *)
+ if [[ ! "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH" ]]; then
+ _BASIC_IMAGE_CONFIGURATION_FILE_PATH="$1"
+ elif [[ ! "$_TARGET_PATH" ]]; then
+ _TARGET_PATH="$1"
+ else
+ clcLog 'critical' \
+ "Given argument: \"$1\" is not available." '\n'
+ clcPrintHelpMessage "$0"
+ return 1
+ fi
+ shift
+ ;;
+ esac
+ done
+ if [[ ! "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH" ]] || \
+ [[ ! "$_TARGET_PATH" ]]; then
+ clcLog 'critical' \
+ "You have to provide a basic image configuration file and a destination path."
+ clcPrintHelpMessage "$0"
+ return 1
+ fi
+ local supportedVirtualMachine
+ for supportedVirtualMachine in ${_SUPPORTED_HYPERVISOR[*]}; do
+ if [[ "$(clcGetXMLValue 'virtualMachine' | \
+ grep --ignore-case "$supportedVirtualMachine")" ]]; then
+ _HYPERVISOR="$supportedVirtualMachine"
+ clcLog 'debug' "Detected \"$_HYPERVISOR\" as hypervisor."
+ break
+ fi
+ done
+ clcLog 'info' "Using \"$_HYPERVISOR\" as hypervisor." && \
+ return $?
+ }
+
+ # Grabs a value from currently loaded xml file.
+ function clcGetXMLValue() {
+ grep --ignore-case --only-matching "<$1 param=.*" \
+ "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH" | awk -F '"' '{ print $2 }'
+ return $?
+ }
+
+ # Handles logging messages. Returns non zero and exit on log level error to
+ # support chaining the message into toolchain.
+ function clcLog() {
+ local loggingType='info'
+ local message="$1"
+ if [ "$2" ]; then
+ loggingType="$1"
+ message="$2"
+ fi
+ if [ "$_VERBOSE" == 'yes' ] || [ "$loggingType" == 'error' ] || \
+ [ "$loggingType" == 'critical' ]; then
+ if [ "$3" ]; then
+ echo -e -n "$3"
+ fi
+ echo -e "${loggingType}: $message"
+ fi
+ if [ "$loggingType" == 'error' ]; then
+ exit 1
+ fi
+ }
+
+ # endregion
+
+ # region tools
+
+ # Returns the minimal vmx vmware configuration file content to create a
+ # snapshot.
+ function clcGetTemporaryVMXContent() {
+ cat << EOF
+.encoding = "UTF-8"
+config.version = "8"
+virtualHW.version = "7"
+ide0:0.present = "TRUE"
+ide0:0.fileName = "$1"
+displayName = ""
+EOF
+ return $?
+ }
+
+ # This functions escapes every special meaning character for a sed replacement.
+ #
+ # Examples:
+ #
+ # >>> sed "s/myInputString/$(clcValidateSEDReplacement '\hans/peter&klaus')/g"
+ function clcValidateSEDReplacement() {
+## unixBase
+## sed --expression 's/\\/\\\\/g' --expression 's/\//\\\//g' \
+## --expression 's/&/\\\&/g' <<< "$1"
+ sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g' <<< "$1"
+##
+ return $?
+ }
+
+ # endregion
+
+ # region main tasks
+
+ # Creates a snapshot from VMware generated virtual machine.
+ function clcCreateVMwareSnapshot() {
+ local temporaryConfigurationPath="$(mktemp --directory)/" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ local temporaryConfigurationFilePath="$(mktemp --suffix '.vmx')" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ clcLog "Generate a temporary virtual machine configuration file \"$temporaryConfigurationFilePath\"." && \
+ clcGetTemporaryVMXContent "$(dirname \
+ "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH")/$(clcGetXMLValue \
+ 'image_name')" 1>"$temporaryConfigurationFilePath" \
+ 2>"$_ERROR_OUTPUT" && \
+ mv "$temporaryConfigurationFilePath" "$temporaryConfigurationPath" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ clcLog "Needed temporary files generated in \"$temporaryConfigurationPath\" generated." && \
+ vmrun snapshot "$temporaryConfigurationPath"*.vmx \
+ persistentUserSnapshot 1>"$_STANDARD_OUTPUT" \
+ 2>"$_ERROR_OUTPUT" && \
+ mv "$temporaryConfigurationPath"*.vmdk "$_TARGET_PATH" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
+ local result=$?
+ if [[ "$_DEBUG" == 'no' ]]; then
+## unixBase rm --recursive "$temporaryConfigurationPath" \
+ rm -r "$temporaryConfigurationPath" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
+ fi
+ return $result
+ }
+
+ # Creates a snapshot from virtualBox generated virtual machine.
+ function clcCreateVirtualBoxSnapshot() {
+ local temporaryConfigurationPath="$(mktemp --directory)/" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+## unixBase (cp --recursive ~/.VirtualBox/ \
+ (cp -r ~/.VirtualBox/ \
+ "${temporaryConfigurationPath}virtualBoxBackup" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" || \
+## unixBase
+## mkdir --parents "${temporaryConfigurationPath}virtualBoxBackup") && \
+ mkdir -p "${temporaryConfigurationPath}virtualBoxBackup") && \
+##
+ # VBoxManage version to create snaphots.
+ clcLog 'Create a temporary virtual machine.' && \
+ # NOTE: Virtualbox needs 5 at leas 5 seconds to register that it has
+ # a new configuration directory.
+ sleep 5 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ VBoxManage createvm --name tmp --basefolder \
+ "$temporaryConfigurationPath" --register 1>"$_STANDARD_OUTPUT" \
+ 2>"$_ERROR_OUTPUT" && \
+ clcLog 'Create a temporary virtual ide controller.' && \
+ VBoxManage storagectl tmp --name tmp --add ide 1>"$_STANDARD_OUTPUT" \
+ 2>"$_ERROR_OUTPUT" && \
+ clcLog 'Attach given virtual disk image to temporary virtual machine.' && \
+ VBoxManage storageattach tmp --storagectl tmp --port 0 --device 0 \
+ --type hdd --medium "$(dirname \
+ "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH")/$(clcGetXMLValue \
+ 'image_name')" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ clcLog "Needed temporary files generated in \"$temporaryConfigurationPath\" generated." && \
+ clcLog "Take a snapshot with name or uuid \"$_VIRTUAL_BOX_SNAPSHOT_NAME\"." && \
+ VBoxManage snapshot tmp take "$_VIRTUAL_BOX_SNAPSHOT_NAME" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ local virtualBoxSnapshotUUID="$(basename \
+ "${temporaryConfigurationPath}tmp/Snapshots/"*.vdi | sed \
+ --regexp-extended 's/\{(.+)\}\..+/\1/g')" 1>"$_STANDARD_OUTPUT" \
+ 2>"$_ERROR_OUTPUT" && \
+ echo "$virtualBoxSnapshotUUID" \
+ 1>"$_VIRTUAL_BOX_SNAPSHOT_UUID_FILE_PATH" 2>"$_ERROR_OUTPUT" && \
+ clcLog "Created snapshot uuid is \"$virtualBoxSnapshotUUID\" (uuid saved to \"$_VIRTUAL_BOX_SNAPSHOT_UUID_FILE_PATH\")." && \
+ clcLog "Copy result to given target path \"$_TARGET_PATH\"." && \
+ cp "${temporaryConfigurationPath}tmp/Snapshots/"*.vdi "$_TARGET_PATH" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ # NOTE: Isn't possible because virtualbox tries to consolidate with
+ # readonly basic image.
+ #VBoxManage snapshot tmp delete "$_VIRTUAL_BOX_SNAPSHOT_NAME" \
+ # 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ # NOTE: Isn't possible because virtual box has child images registered.
+ #VBoxManage closemedium disk "$(dirname \
+ # "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH")/$(clcGetXMLValue \
+ # 'image_name')" 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ clcLog 'Detach given virtual disk image from temporary created virtual machine.' && \
+ VBoxManage storageattach tmp --storagectl tmp --port 0 --device 0 \
+ --medium none 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ clcLog 'Remove virtual dummy harddisk.' && \
+ VBoxManage storagectl tmp --name tmp --remove \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ clcLog 'Unregister temporary created virtual machine.' && \
+ VBoxManage unregistervm tmp 1>"$_STANDARD_OUTPUT" \
+ 2>"$_ERROR_OUTPUT" && \
+ clcLog 'Restore virtualbox home directory.' && \
+## unixBase
+## rm --recursive --force ~/.VirtualBox/ 1>"$_STANDARD_OUTPUT" \
+ rm -rf ~/.VirtualBox/ 1>"$_STANDARD_OUTPUT" \
+##
+ 2>"$_ERROR_OUTPUT" && \
+## unixBase
+## cp --recursive "${temporaryConfigurationPath}virtualBoxBackup/" \
+ cp -r "${temporaryConfigurationPath}virtualBoxBackup/" \
+##
+ ~/.VirtualBox/ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+## unixBase
+## rm --recursive --force "$temporaryConfigurationPath" && \
+ rm -rf "$temporaryConfigurationPath" && \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+##
+ # NOTE: Virtualbox needs at least 5 seconds to register that it has
+ # a new configuration directory.
+ sleep 5 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
+ local result=$?
+ if [[ "$_DEBUG" == 'no' ]]; then
+## unixBase rm --recursive "$temporaryConfigurationPath" \
+ rm -r "$temporaryConfigurationPath" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" || \
+ return $?
+ fi
+ return $result
+ }
+
+ # Creates a persistent version of given config file.
+ function clcCreatePersistentConfig() {
+ clcLog "Create a persistent configuration file version from \"$_BASIC_IMAGE_CONFIGURATION_FILE_PATH\" in \"$_TARGET_PATH\"." && \
+ cp "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH" "$_TARGET_PATH" && \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ clcLog 'Edit short description.' && \
+## unixBase sed --in-place --regexp-extended \
+ sed -ir \
+ "s/(< *short_description[^>]*param=\"[^\"]*)(\")/\\1$_PERSISTENT_SHORT_DESCRIPTION_SUFFIX\\2/g" \
+ "$_TARGET_PATH" 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ clcLog 'Append "original_xml_file_path" tag.' && \
+## unixBase
+## sed --in-place --regexp-extended \
+## "s/^([ \\t]*)(< *persistent[^>]+param=\"[^\"]+\"[^>]*>)/\\1\\2\\n\\1/g" \
+## "$_TARGET_PATH" 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ sed -ir \
+ "s/^([ \\t]*)(< *persistent[^>]+param=\"[^\"]+\"[^>]*>)/\\1\\2\\n\\1/g" \
+ "$_TARGET_PATH" 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+##
+ clcLog 'Edit image file path.' && \
+## unixBase sed --in-place --regexp-extended \
+ sed -ir \
+ "s/(< *image_name[^>]*param=\")[^\"]*(\")/\\1$(clcValidateSEDReplacement \
+ "$_PERSISTENT_CONFIG_TARGET")\\2/g" "$_TARGET_PATH" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
+ return $?
+ }
+
+ # endregion
+
+# endregion
+
+# region controller
+
+ clcCommandLineInterface "$@" || return $?
+ if [[ "$_PERSISTENT_CONFIG_TARGET" ]]; then
+ clcCreatePersistentConfig || \
+ clcLog 'error' 'Creating persistent configuration file failed.'
+ else
+ "clcCreate${_HYPERVISOR}Snapshot" || \
+ clcLog 'error' 'Creating Linked Clone failed.'
+ fi
+ clcLog 'Program has successfully finished.' && \
+ return $?
+
+# endregion
+
+}
+
+# region footer
+
+if [[ "$0" == *"${__NAME__}" ]]; then
+ "$__NAME__" "$@"
+fi
+
+# endregion
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
index 874669dd..81498227 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
@@ -109,26 +109,41 @@ filecheck ()
################################################################################
## Added for persistent support.
-diskmode='nonpersistent'
-xmlfile="$1"
-if [[ "$(grep --extended-regexp '< *persistent *param=".+"' "$xmlfile")" ]]; then
- imageFilePath="$(grep -io '"${LOGFILE}"
+ fi
fi
##
# absolute or relative path?
+xmlfile=$1
if ls "${xmlfile}" 2>/dev/null | grep '/' >/dev/null 2>&1; then
xmlpath=$(dirname "${xmlfile}")
xmlfile=$(basename "${xmlfile}")
@@ -201,13 +216,13 @@ if echo "${imgname}" 2>/dev/null | grep -q '^/' >/dev/null 2>&1; then
vmpath="${imgpath}/${imgname}"
# If old vmchooser binary stuff
# We do not need folder name as it is already included by vmchooser
- elif echo "${xmlfile}" 2>/dev/null | grep -q '^/tmp/' >/dev/null 2>&1; then
+elif echo "${xmlfile}" 2>/dev/null | grep -q '^/tmp/' >/dev/null 2>&1; then
vmpath="$imgname"
imgname="$(basename "${imgname}")"
- ## Added for persistent support.
- elif [[ "$userBranchFilePath" ]]; then
+## Added for persistent support.
+elif [[ "$userBranchFilePath" ]]; then
vmpath="$userBranchFilePath"
- ##
+##
# Else use same path as xml
else
imgpath="${xmlpath}"
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
index 67e49d3e..f327b5d9 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
@@ -38,9 +38,16 @@ function handlePersistentVM() {
"/dev/null && \
+ local imagePath="$(pwd)/.persistentMachineSnapshots/$imageName"
+ cd - >/dev/null && \
+ local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename \
+ "$1")" && \
+ "$(dirname "$0")/vmchooser-clc" -d -v "$1" \
+ "$persistentConfigVersionFilePath" --create-persistent-config \
+ "$imagePath" && \
echo "$persistentConfigVersionFilePath"
fi
}
diff --git a/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include
old mode 100644
new mode 100755
index 675835a9..9a817d65
--- a/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include
+++ b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include
@@ -230,7 +230,9 @@ MemTrimRate = "-1"
# ide-disks
ide0:0.present = "$ide"
ide0:0.fileName = "$diskfile"
-ide0:0.mode = "independent-nonpersistent"
+## Edited for persistent mode.
+ide0:0.mode = "independent-${diskmode}"
+##
ide1:0.present = "$cdrom0"
ide1:0.autodetect = "TRUE"
ide1:0.fileName = "auto detect"
@@ -245,7 +247,9 @@ scsi0.present = "$scsi"
scsi0:0.present = "$scsi"
scsi0:0.fileName = "$diskfile"
scsi0.virtualDev = "$hddrv"
-scsi0:0.mode = "independent-nonpersistent"
+## Edited for persistent mode.
+scsi0:0.mode = "independent-${diskmode}"$stateFileConfiguration
+##
# floppies
floppy0.present = "$floppy0"
@@ -459,7 +463,7 @@ esac
# check for whitelisted HW-3D
. /opt/openslx/config
-local FORCE3D=""
+FORCE3D=""
if [ -n "$SLX_VMWARE_3D" ]; then
FORCE3D='mks.gl.allowBlacklistedDrivers = "TRUE"'
fi
@@ -512,6 +516,20 @@ esac
# check if ide/scsi and hwver of image
# read only the first 30 lines to be sure
imghead=$(head -n 30 "${diskfile}")
+## Added to handle persistent snapshots.
+if [[ "$originalVMDKFilePath" ]]; then
+ echo "Select \"${originalVMDKFilePath}\" as information base for \"${diskfile}\"."
+ imghead=$(head -n 30 "$originalVMDKFilePath") && \
+ # Support suspend mode.
+ stateFilePath="$(readlink -f "$(dirname "$diskfile")/"*.vmss)" && \
+ if [ -f "$stateFilePath" ]; then
+ echo "Found state file \"$stateFilePath\"." && \
+ stateFileConfiguration="
+checkpoint.vmState = \"$stateFilePath\""
+ fi
+ POSTRUN="stateFilePath=\"\$(readlink --canonicalize \"${confdir}/\"*.vmss)\" && memoryFilePath=\"\$(readlink --canonicalize \"${confdir}/\"*.vmem)\" && [ -f \"\$stateFilePath\" ] && echo \"Saving state and memory file \\\"\$stateFilePath\\\" and \\\"\$memoryFilePath\\\".\" && mv --force \"\$stateFilePath\" \"$(dirname "$diskfile")/\" && mv --force \"\$memoryFilePath\" \"$(dirname "$diskfile")/\""
+fi
+##
hddrv=$(echo "${imghead}" | grep -m1 -ia "ddb.adapterType" | awk -F '"' '{print $2}')
hwver=$(echo "${imghead}" | grep -m1 -ia "ddb.virtualHWVersion" | awk -F '"' '{print $2}')
case "${hddrv}" in
@@ -557,7 +575,9 @@ cp "/opt/openslx/etc/vmware/nvram" "$confdir/nvram" 2>/dev/null
# log script information
writelog "# File created by $0 (VMversion ${vmversion})\n# on $(date)\n"
-writelog "Starting with non-persistent mode ...\n"
+## Edited for persistent mode.
+writelog "Starting with ${diskmode} mode ...\n"
+##
# write all results to logfile
# log disksetup
--
cgit v1.2.3-55-g7522
From 44b0d6e7d211ac1b5148a68024977133fe1061d4 Mon Sep 17 00:00:00 2001
From: Christian Rößler
Date: Thu, 8 Aug 2013 16:34:43 +0200
Subject: [systemd] New TODO-file for, well, systemd-module specific TODOs.
---
remote/modules/systemd/TODO | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 remote/modules/systemd/TODO
(limited to 'remote/modules')
diff --git a/remote/modules/systemd/TODO b/remote/modules/systemd/TODO
new file mode 100644
index 00000000..4b17eb88
--- /dev/null
+++ b/remote/modules/systemd/TODO
@@ -0,0 +1,2 @@
+libkmod: libkmod gets installed systemwide at present. This should not
+ be the case.
--
cgit v1.2.3-55-g7522
From 72683a974b0d97c96edc393ad8f0dfff9de4ef5c Mon Sep 17 00:00:00 2001
From: thaibault
Date: Thu, 8 Aug 2013 18:46:12 +0200
Subject: Increase compatibility with different busybox versions.
---
.../vmchooser/data/opt/openslx/scripts/vmchooser-clc | 14 ++++++++++----
.../data/opt/openslx/scripts/vmchooser-xml_filter | 6 +++---
2 files changed, 13 insertions(+), 7 deletions(-)
(limited to 'remote/modules')
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc
index a8cfbcf3..a70d46d8 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc
@@ -341,10 +341,16 @@ EOF
clcLog "Take a snapshot with name or uuid \"$_VIRTUAL_BOX_SNAPSHOT_NAME\"." && \
VBoxManage snapshot tmp take "$_VIRTUAL_BOX_SNAPSHOT_NAME" \
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+## unixBase
+## local virtualBoxSnapshotUUID="$(basename \
+## "${temporaryConfigurationPath}tmp/Snapshots/"*.vdi | sed \
+## --regexp-extended 's/\{(.+)\}\..+/\1/g')" 1>"$_STANDARD_OUTPUT" \
+## 2>"$_ERROR_OUTPUT" && \
local virtualBoxSnapshotUUID="$(basename \
"${temporaryConfigurationPath}tmp/Snapshots/"*.vdi | sed \
- --regexp-extended 's/\{(.+)\}\..+/\1/g')" 1>"$_STANDARD_OUTPUT" \
+ -r 's/\{(.+)\}\..+/\1/g')" 1>"$_STANDARD_OUTPUT" \
2>"$_ERROR_OUTPUT" && \
+##
echo "$virtualBoxSnapshotUUID" \
1>"$_VIRTUAL_BOX_SNAPSHOT_UUID_FILE_PATH" 2>"$_ERROR_OUTPUT" && \
clcLog "Created snapshot uuid is \"$virtualBoxSnapshotUUID\" (uuid saved to \"$_VIRTUAL_BOX_SNAPSHOT_UUID_FILE_PATH\")." && \
@@ -404,7 +410,7 @@ EOF
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
clcLog 'Edit short description.' && \
## unixBase sed --in-place --regexp-extended \
- sed -ir \
+ sed -i -r \
"s/(< *short_description[^>]*param=\"[^\"]*)(\")/\\1$_PERSISTENT_SHORT_DESCRIPTION_SUFFIX\\2/g" \
"$_TARGET_PATH" 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
clcLog 'Append "original_xml_file_path" tag.' && \
@@ -414,7 +420,7 @@ EOF
## "$(readlink --canonicalize \
## "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH")")\"\/>/g" \
## "$_TARGET_PATH" 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
- sed -ir \
+ sed -i -r \
"s/^([ \\t]*)(< *persistent[^>]+param=\"[^\"]+\"[^>]*>)/\\1\\2\\n\\1/g" \
@@ -422,7 +428,7 @@ EOF
##
clcLog 'Edit image file path.' && \
## unixBase sed --in-place --regexp-extended \
- sed -ir \
+ sed -i -r \
"s/(< *image_name[^>]*param=\")[^\"]*(\")/\\1$(clcValidateSEDReplacement \
"$_PERSISTENT_CONFIG_TARGET")\\2/g" "$_TARGET_PATH" \
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
index f327b5d9..1f6c5985 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
@@ -27,7 +27,7 @@
#
# include default directories
-. /etc/opt/openslx/openslx.conf
+. /opt/openslx/config
if [ -f ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf ]; then
. ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf
@@ -40,8 +40,8 @@ function handlePersistentVM() {
# user we provide an additional persistent version.
local imageName=$(basename "$(grep -io '/dev/null && \
- local imagePath="$(pwd)/.persistentMachineSnapshots/$imageName"
+ cd "$SLX_VM_PERSISTENT_PATH" >/dev/null && \
+ local imagePath="$(pwd)/$imageName"
cd - >/dev/null && \
local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename \
"$1")" && \
--
cgit v1.2.3-55-g7522
From c2f82bfd7db133040070bb17c8f0a8ea0cff2ca3 Mon Sep 17 00:00:00 2001
From: thaibault
Date: Thu, 8 Aug 2013 18:57:29 +0200
Subject: Fix bug in xml filter.
---
.../vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
(limited to 'remote/modules')
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
index 1f6c5985..697c2fe2 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
@@ -40,12 +40,11 @@ function handlePersistentVM() {
# user we provide an additional persistent version.
local imageName=$(basename "$(grep -io '/dev/null && \
- local imagePath="$(pwd)/$imageName"
- cd - >/dev/null && \
+ eval export SLX_VM_PERSISTENT_PATH="${SLX_VM_PERSISTENT_PATH}" && \
+ local imagePath="${SLX_VM_PERSISTENT_PATH}${imageName}"
local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename \
"$1")" && \
- "$(dirname "$0")/vmchooser-clc" -d -v "$1" \
+ "$(dirname "$0")/vmchooser-clc" "$1" \
"$persistentConfigVersionFilePath" --create-persistent-config \
"$imagePath" && \
echo "$persistentConfigVersionFilePath"
--
cgit v1.2.3-55-g7522
From 90cdae646b68c93bc3c7d17c0dc4672659df6f3f Mon Sep 17 00:00:00 2001
From: thaibault
Date: Thu, 8 Aug 2013 19:53:25 +0200
Subject: Fix statefile moving.
---
remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt | 2 +-
remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'remote/modules')
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
index 81498227..8dea615b 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
@@ -472,7 +472,7 @@ fi
# Postrun for commands after virtualization finishes
if [ -n "${POSTRUN}" ]; then
- eval ${POSTRUN} >/dev/null 2>&1
+ eval ${POSTRUN} >/dev/null 2>&1
fi
cleanexit 0
diff --git a/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include
index 9a817d65..084828ff 100755
--- a/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include
+++ b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include
@@ -527,7 +527,7 @@ if [[ "$originalVMDKFilePath" ]]; then
stateFileConfiguration="
checkpoint.vmState = \"$stateFilePath\""
fi
- POSTRUN="stateFilePath=\"\$(readlink --canonicalize \"${confdir}/\"*.vmss)\" && memoryFilePath=\"\$(readlink --canonicalize \"${confdir}/\"*.vmem)\" && [ -f \"\$stateFilePath\" ] && echo \"Saving state and memory file \\\"\$stateFilePath\\\" and \\\"\$memoryFilePath\\\".\" && mv --force \"\$stateFilePath\" \"$(dirname "$diskfile")/\" && mv --force \"\$memoryFilePath\" \"$(dirname "$diskfile")/\""
+ POSTRUN="stateFilePath=\"\$(readlink -f \"${confdir}/\"*.vmss)\" && memoryFilePath=\"\$(readlink -f \"${confdir}/\"*.vmem)\" && [ -f \"\$stateFilePath\" ] && echo \"Saving state and memory file \\\"\$stateFilePath\\\" and \\\"\$memoryFilePath\\\".\" && mv -f \"\$stateFilePath\" \"$(dirname "$diskfile")/\" && mv -f \"\$memoryFilePath\" \"$(dirname "$diskfile")/\""
fi
##
hddrv=$(echo "${imghead}" | grep -m1 -ia "ddb.adapterType" | awk -F '"' '{print $2}')
--
cgit v1.2.3-55-g7522
From 02f09e26a6f9a670571aa4fa8612e3d19e599811 Mon Sep 17 00:00:00 2001
From: thaibault
Date: Fri, 9 Aug 2013 15:08:40 +0200
Subject: Fix some issues with race conditions. Code refactoring. Improve
documentation.
---
.../data/opt/openslx/scripts/vmchooser-clc | 102 +++++++++++----------
.../data/opt/openslx/scripts/vmchooser-run_virt | 4 +-
.../data/opt/openslx/scripts/vmchooser-xml_filter | 2 +-
3 files changed, 59 insertions(+), 49 deletions(-)
(limited to 'remote/modules')
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc
index a70d46d8..455d3707 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc
@@ -1,33 +1,31 @@
-#!/bin/bash
+#!/usr/bin/env busybox
# region header
# vim: set tabstop=4 shiftwidth=4 expandtab:
# vim: foldmethod=marker foldmarker=region,endregion:
-# Dependencies:
+ # region dependencies:
-# VMware Player - Runs a virtual machine.
+# VMware Player - Runs a virtual machine.
# VMware Workstation - Runs, edits, creates virtual machines for business
# usage.
-# VirtualBox till version 4 - Plays, creates, edits virtual machines.
-# bash till version 4 - A sh-compatible command line interpreter.
-# cat - Concatenate and prints file contents.
-# echo - Prints chars.
-# grep - Prints lines which matches a given regular expression pattern.
-# sed - Stream-editor for filtering and transformation text.
-# mktemp - Creates temporary files and folders.
-# dirname - Extracts the last element from a given file path.
-# mv - moves and renames file objects.
-# rm - Removes files and folders.
-# cp - Copies files and folders.
-# sleep - Delays program calls.
-# readlink - Print resolved symbolic links or canonical file names.
-
-# Notes:
-
-# USE "sudo bin/vmware-vmx --new-sn JJ237-G52E2-08X0C-C3306-0WCQ1"
-# To activate wmware workstation!
+# VirtualBox ver. 4+ - Plays, creates, edits virtual machines.
+# bash ver. 4+ - A sh-compatible command line interpreter.
+# cat - Concatenate and prints file contents.
+# echo - Prints chars.
+# grep - Prints lines which matches a given regular expression
+# pattern.
+# sed - Stream-editor for filtering and transformation text.
+# mktemp - Creates temporary files and folders.
+# dirname - Extracts the last element from a given file path.
+# mv - moves and renames file objects.
+# rm - Removes files and folders.
+# cp - Copies files and folders.
+# sleep - Delays program calls.
+# readlink - Print resolved symbolic links or canonical file names.
+
+ # endregion
# Abbreviation for "createLinkedClone".
__NAME__='vmchooser-clc'
@@ -37,7 +35,7 @@ __NAME__='vmchooser-clc'
# Provides the main module scope.
function vmchooser-clc() {
-# region configuration
+# region configuration
# region private properties
@@ -262,13 +260,14 @@ EOF
return $?
}
- # This functions escapes every special meaning character for a sed replacement.
+ # This functions escapes every special meaning character for a sed
+ # replacement.
#
# Examples:
#
# >>> sed "s/myInputString/$(clcValidateSEDReplacement '\hans/peter&klaus')/g"
function clcValidateSEDReplacement() {
-## unixBase
+## bash
## sed --expression 's/\\/\\\\/g' --expression 's/\//\\\//g' \
## --expression 's/&/\\\&/g' <<< "$1"
sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g' <<< "$1"
@@ -301,7 +300,7 @@ EOF
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
local result=$?
if [[ "$_DEBUG" == 'no' ]]; then
-## unixBase rm --recursive "$temporaryConfigurationPath" \
+## bash rm --recursive "$temporaryConfigurationPath" \
rm -r "$temporaryConfigurationPath" \
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
fi
@@ -312,15 +311,20 @@ EOF
function clcCreateVirtualBoxSnapshot() {
local temporaryConfigurationPath="$(mktemp --directory)/" \
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
-## unixBase (cp --recursive ~/.VirtualBox/ \
+## bash
+## (cp --recursive ~/.VirtualBox/ \
+## "${temporaryConfigurationPath}virtualBoxBackup" \
+## 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" || \
+## mkdir --parents \
+## "${temporaryConfigurationPath}virtualBoxBackup" \
+## 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT") && \
(cp -r ~/.VirtualBox/ \
"${temporaryConfigurationPath}virtualBoxBackup" \
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" || \
-## unixBase
-## mkdir --parents "${temporaryConfigurationPath}virtualBoxBackup") && \
- mkdir -p "${temporaryConfigurationPath}virtualBoxBackup") && \
+ mkdir -p "${temporaryConfigurationPath}virtualBoxBackup" \
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT") && \
##
- # VBoxManage version to create snaphots.
+ # VBoxManage version to create snapshots.
clcLog 'Create a temporary virtual machine.' && \
# NOTE: Virtualbox needs 5 at leas 5 seconds to register that it has
# a new configuration directory.
@@ -341,11 +345,11 @@ EOF
clcLog "Take a snapshot with name or uuid \"$_VIRTUAL_BOX_SNAPSHOT_NAME\"." && \
VBoxManage snapshot tmp take "$_VIRTUAL_BOX_SNAPSHOT_NAME" \
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
-## unixBase
+## bash
## local virtualBoxSnapshotUUID="$(basename \
## "${temporaryConfigurationPath}tmp/Snapshots/"*.vdi | sed \
-## --regexp-extended 's/\{(.+)\}\..+/\1/g')" 1>"$_STANDARD_OUTPUT" \
-## 2>"$_ERROR_OUTPUT" && \
+## --regexp-extended 's/\{(.+)\}\..+/\1/g')" \
+## 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
local virtualBoxSnapshotUUID="$(basename \
"${temporaryConfigurationPath}tmp/Snapshots/"*.vdi | sed \
-r 's/\{(.+)\}\..+/\1/g')" 1>"$_STANDARD_OUTPUT" \
@@ -375,18 +379,17 @@ EOF
VBoxManage unregistervm tmp 1>"$_STANDARD_OUTPUT" \
2>"$_ERROR_OUTPUT" && \
clcLog 'Restore virtualbox home directory.' && \
-## unixBase
+## bash
## rm --recursive --force ~/.VirtualBox/ 1>"$_STANDARD_OUTPUT" \
+## 2>"$_ERROR_OUTPUT" && \
+## cp --recursive "${temporaryConfigurationPath}virtualBoxBackup/" \
+## ~/.VirtualBox/ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+## rm --recursive --force "$temporaryConfigurationPath" && \
+## 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
rm -rf ~/.VirtualBox/ 1>"$_STANDARD_OUTPUT" \
-##
2>"$_ERROR_OUTPUT" && \
-## unixBase
-## cp --recursive "${temporaryConfigurationPath}virtualBoxBackup/" \
cp -r "${temporaryConfigurationPath}virtualBoxBackup/" \
-##
~/.VirtualBox/ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
-## unixBase
-## rm --recursive --force "$temporaryConfigurationPath" && \
rm -rf "$temporaryConfigurationPath" && \
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
##
@@ -395,7 +398,7 @@ EOF
sleep 5 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
local result=$?
if [[ "$_DEBUG" == 'no' ]]; then
-## unixBase rm --recursive "$temporaryConfigurationPath" \
+## bash rm --recursive "$temporaryConfigurationPath" \
rm -r "$temporaryConfigurationPath" \
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" || \
return $?
@@ -403,18 +406,18 @@ EOF
return $result
}
- # Creates a persistent version of given config file.
+ # Creates a persistent version of given configuration file.
function clcCreatePersistentConfig() {
clcLog "Create a persistent configuration file version from \"$_BASIC_IMAGE_CONFIGURATION_FILE_PATH\" in \"$_TARGET_PATH\"." && \
cp "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH" "$_TARGET_PATH" && \
1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
clcLog 'Edit short description.' && \
-## unixBase sed --in-place --regexp-extended \
+## bash sed --in-place --regexp-extended \
sed -i -r \
"s/(< *short_description[^>]*param=\"[^\"]*)(\")/\\1$_PERSISTENT_SHORT_DESCRIPTION_SUFFIX\\2/g" \
"$_TARGET_PATH" 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
clcLog 'Append "original_xml_file_path" tag.' && \
-## unixBase
+## bash
## sed --in-place --regexp-extended \
## "s/^([ \\t]*)(< *persistent[^>]+param=\"[^\"]+\"[^>]*>)/\\1\\2\\n\\1"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
##
clcLog 'Edit image file path.' && \
-## unixBase sed --in-place --regexp-extended \
+## bash sed --in-place --regexp-extended \
sed -i -r \
"s/(< *image_name[^>]*param=\")[^\"]*(\")/\\1$(clcValidateSEDReplacement \
"$_PERSISTENT_CONFIG_TARGET")\\2/g" "$_TARGET_PATH" \
- 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
+ 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ clcLog 'Convert configuration file from windows style line endings to unix line endings.' && \
+## bash
+## sed --in-place --regexp-extended 's/\r//g' "$_TARGET_PATH" \
+## 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ sed -i -r 's/\r//g' "$_TARGET_PATH" 1>"$_STANDARD_OUTPUT" \
+ 2>"$_ERROR_OUTPUT" && \
+##
return $?
}
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
index 8dea615b..979db35a 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt
@@ -136,8 +136,8 @@ if [[ "$(grep --extended-regexp \
# Create linked clone if not exists.
if [ ! -f "$imageFilePath" ]; then
mkdir -p "$(dirname "$imageFilePath")" && \
- "$(dirname "$0")/vmchooser-clc" "$originalXMLFilePath" \
- "$imageFilePath" --debug --verbose #&>"${LOGFILE}"
+ bash "$(dirname "$0")/vmchooser-clc" "$originalXMLFilePath" \
+ "$imageFilePath" --debug --verbose &>"${LOGFILE}"
fi
fi
##
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
index 697c2fe2..a9a57ec9 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
@@ -44,7 +44,7 @@ function handlePersistentVM() {
local imagePath="${SLX_VM_PERSISTENT_PATH}${imageName}"
local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename \
"$1")" && \
- "$(dirname "$0")/vmchooser-clc" "$1" \
+ bash "$(dirname "$0")/vmchooser-clc" "$1" \
"$persistentConfigVersionFilePath" --create-persistent-config \
"$imagePath" && \
echo "$persistentConfigVersionFilePath"
--
cgit v1.2.3-55-g7522
From da1e96c047c46909bd1a1d3d938c86727e6052b8 Mon Sep 17 00:00:00 2001
From: thaibault
Date: Fri, 9 Aug 2013 15:46:45 +0200
Subject: Make script more compatible to different shell versions.
---
.../vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
(limited to 'remote/modules')
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
index a9a57ec9..3e0ee42d 100755
--- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
+++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter
@@ -44,9 +44,12 @@ function handlePersistentVM() {
local imagePath="${SLX_VM_PERSISTENT_PATH}${imageName}"
local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename \
"$1")" && \
- bash "$(dirname "$0")/vmchooser-clc" "$1" \
- "$persistentConfigVersionFilePath" --create-persistent-config \
- "$imagePath" && \
+ local vmchooserFilePath="$(dirname "$0")/vmchooser-clc" && \
+ if [ ! -f "$vmchooserFilePath" ]; then
+ vmchooserFilePath='/opt/openslx/plugin-repo/vmchooser/vmchooser-clc'
+ fi
+ bash "$vmchooserFilePath" "$1" "$persistentConfigVersionFilePath" \
+ --create-persistent-config "$imagePath" && \
echo "$persistentConfigVersionFilePath"
fi
}
--
cgit v1.2.3-55-g7522