summaryrefslogtreecommitdiffstats
path: root/remote
diff options
context:
space:
mode:
Diffstat (limited to 'remote')
-rwxr-xr-xremote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-clc102
-rwxr-xr-xremote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt4
-rwxr-xr-xremote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-xml_filter2
3 files changed, 59 insertions, 49 deletions
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<original_xml_file_path param=\"$(clcValidateSEDReplacement \
## "$(readlink --canonicalize \
@@ -427,11 +430,18 @@ EOF
"$_TARGET_PATH" 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"