├── .bash_aliases ├── .dockerignore ├── .gitignore ├── Dependency ├── Dockerfile ├── README.md ├── ReleaseProcess.md ├── dlwRun.sh ├── script ├── ArgumentsDockerVerifyInclude.sh ├── ArgumentsGetInclude.sh ├── ArgumentsGetTest.sh ├── ArgumentsMainInclude.sh ├── ArrayMapTest.sh ├── ArrayMapTestInclude.sh ├── ComponentListVerifyInclude.sh ├── ImageGUIDlist.sh ├── ImageGUIDlistTest.sh ├── MessageInclude.sh ├── PacketInclude.sh ├── PacketIncludeMakefile.sh ├── PacketIncludeTest.sh ├── VirtCmmdInterface.sh ├── VirtDockerCmmdSingle.sh ├── VirtDockerContainerInterface.sh ├── VirtDockerImageInterface.sh ├── VirtDockerInterface.sh ├── VirtDockerReportingCmmdMultiInterface.sh ├── VirtDockerReportingCmmdSingleInterface.sh ├── VirtDockerReportingInterface.sh ├── command │ ├── attach.sh │ ├── build.sh │ ├── create.sh │ ├── diff.orig.sh │ ├── diff.sh │ ├── dlw.sh │ ├── help.sh │ ├── helpDoc.sh │ ├── images.sh │ ├── itest.sh │ ├── kill.sh │ ├── logs.sh │ ├── pause.sh │ ├── port.sh │ ├── ps.sh │ ├── restart.sh │ ├── rm.sh │ ├── rmi.sh │ ├── run.sh │ ├── screen.sh │ ├── start.sh │ ├── stop.sh │ ├── tmux.sh │ ├── top.sh │ ├── unpause.sh │ ├── version.sh │ └── watch.sh ├── makefile └── makefileFunExtend.sh └── scriptInstall ├── dlwLogin.sh ├── install.sh ├── installPackages.sh ├── installPrep_docker-engine.sh ├── installPrep_tmux.sh ├── installUser_dlw.sh ├── installUsers.sh ├── userUID_GID_Reassign.sh └── versionSpecifiers.sh /.bash_aliases: -------------------------------------------------------------------------------- 1 | alias dlw='`if [ -f "./script/command/dlw.sh" ]; then echo "./script/command/dlw.sh"; else echo "/usr/bin/dlw/command/dlw.sh"; fi`'; 2 | 3 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | *.sh~ 2 | Dockerfile~ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.sh~ 2 | *.md~ 3 | makefile~ 4 | .gitignore~ 5 | .dockerignore~ 6 | -------------------------------------------------------------------------------- /Dependency: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # 3 | # The content of this file expresses the dependencies between a Component and 4 | # others based on the type of the Docker command being executed. For example, 5 | # one would encode a makefile dependency rule that associates a Component's 6 | # ancestor (parent, See Docker FROM statement) as a prerequisite for the 7 | # targeted child Component when processing a Docker build command. 8 | # 9 | # A Project that defines interdependent components, must encode this 'Dependency' 10 | # file in the Project's Compnent directory. Ex: '.../sample/component/Dependency' 11 | # where 'sample' reflects the name assigned to the Project. 12 | # 13 | # Although distinct dependency graphs can be specified for each Docker command, 14 | # so far, the makefile rules categorized a Docker command as a member of either 15 | # 'build' or 'run' types. These dependency types are encoded as makefile rules 16 | # with a suffix of either '.build' or '.run'. For example, given a Component 17 | # named "Child" with a static build dependency on another Component named 18 | # "Parent" and assuming that "Parent" is a root Component, it doesn't depend 19 | # on other (parent) Components then the dependency graph for the Docker 20 | # 'build' command for these components would be expressed as: 21 | # 22 | # Child.build : Parent.build 23 | # 24 | # In an analogous way, run-time dependencies, for example, the requirement to 25 | # start one container before another would be encoded as: 26 | # 27 | # RequiresServices.run : OffersService_1.run OffersService_2.run 28 | # 29 | # Where containers derived from Components OffersService_1 and OffersService_2 30 | # must be started before initiating a container derived from RequiresServices. 31 | # 32 | # Note, only rules that define dependencies should be specified. Root (independent) 33 | # Components are automatically deduced by examining the Component Catalog. 34 | # 35 | ############################################################################### 36 | 37 | 38 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # 3 | # Purpose: Construct an image containing the Docker Local Workbench (dlw) 4 | # and its dependent tools. 5 | # 6 | ############################################################################## 7 | FROM ubuntu:12.04 8 | MAINTAINER Richard Moyse 9 | # Install helper scripts to improve declarative benefit of package installs. 10 | ADD ./scriptInstall/* /usr/bin/scriptInstall/ 11 | # Incorporate dlw command alias to avoid typing '.sh' file suffix and altering 12 | # PATH variable. 13 | ADD .bash_aliases /usr/bin/scriptInstall/ 14 | # Install desired packages. 15 | RUN /usr/bin/scriptInstall/installPackages.sh 'docker-engine' 'make' 'tmux' \ 16 | # Create the dlw non-root user to provide another level of isolation 17 | # within the containers spawned from this image. 18 | && /usr/bin/scriptInstall/installUsers.sh 'dlw' \ 19 | # Patch login process so dlw account can assume an external 20 | # account's UID and GID list. 21 | && mv /usr/bin/scriptInstall/dlwLogin.sh /usr/sbin/ \ 22 | && mv /usr/bin/scriptInstall/userUID_GID_Reassign.sh /usr/sbin/ \ 23 | # Create a project directory, isolated from dlw's home directory 24 | # tree, for the dlw user to group projects and add 25 | # the 'sample' Project Catalog structure to provide testbed. 26 | && mkdir -p '/project/sample/component' \ 27 | # Create a symbolic link to the /project directory to facilitate 28 | # access by the dlw account and prevent cascading file ownership, 29 | # primary group permission changes by 'usermod' 30 | && ln -s '/project' '/home/dlw/project' \ 31 | # Create a link spot for the tmux.conf file. The file is empty so it 32 | # assumes the tmux defaults. This empty file can be overridden using 33 | # volume option (-v) to incorporate desired tmux.conf from host. 34 | && mkdir -p '/tmux/.tmuxconfdir' \ 35 | && touch '/tmux/.tmuxconfdir/.tmux.conf' \ 36 | && ln -s '/tmux/.tmuxconfdir/.tmux.conf' '/home/dlw/.tmux.conf' \ 37 | && mv /usr/bin/scriptInstall/.bash_aliases /home/dlw/ \ 38 | # Establish dlw account as owner if its own files. This avoids creating 39 | # additional layers in order to set USER. 40 | && chown -R dlw:dlw /home/dlw \ 41 | && chown -R dlw:dlw /project/sample \ 42 | # make install helper scripts invisible from this layer forward 43 | && rm -f -r "/usr/bin/scriptInstall" 44 | # Create an entry point to automatically login dlw user. 45 | # 'dlwLogin.sh' configures dlw user permissions, properly establishes 46 | # device (/dev) permissions, and sets home directory as shell's current directory. 47 | # Also, must use root level priviledges when establishing login process 48 | # via the ENTRYPOINT command. 'dlwlogin.sh' below will fail if the container 49 | # is started by a non-root account. 50 | ENTRYPOINT dlwLogin.sh 51 | # Install the dlw scripts into user level bin. Located here, at the end, 52 | # as these frequently change during development. 53 | ADD ./script /usr/bin/dlw/ 54 | # Provide a means to debug socket assignments if necessary 55 | # RUN apt-get install -y lsof 56 | -------------------------------------------------------------------------------- /ReleaseProcess.md: -------------------------------------------------------------------------------- 1 | New release process: 2 | 3 | + merge latest_lastest branch into master. 4 | + Ensure merged master builds properly with new version: 5 | + Download master to 'release-test environment': 6 | + Release-test environment must have git and the desired version of the Docker Daemon running 7 | + ```apt-cache show lxc-docker-?.?.?``` 8 | + ```git clone https://github.com/WhisperingChaos/DeveloperLocalWorkbenchForDocker``` 9 | + ```git remote set-url origin git@github.com:WhisperingChaos/DeveloperLocalWorkbenchForDocker.git``` 10 | + Change existing files in Release-test environment: 11 | + [versionSpecifiers.sh](https://github.com/WhisperingChaos/DeveloperLocalWorkbenchForDocker/blob/master/scriptInstall/versionSpecifiers.sh) must reflect the desired build time component versions. 12 | + [version.sh](https://github.com/WhisperingChaos/DeveloperLocalWorkbenchForDocker/blob/master/script/command/version.sh) must reflect the newly determined ```dlw``` version. 13 | + ```docker build -t dlw .``` the workbench locally. 14 | + Test the new branch. 15 | + ```dlwRun.sh -l dlw``` creates a new container reflecting the newly introduced component versions. 16 | + Verify that selected versions are reflected by: 17 | + ```dlw version``` 18 | + Run the integration tests within the container: 19 | + ```cd ~/project/sample``` 20 | + ```dlw itest``` 21 | + Iterate building & testing till happy. 22 | + Create a new [dlw](https://github.com/WhisperingChaos/DeveloperLocalWorkbenchForDocker) git tag: 23 | + Determine ```dlw version```. 24 | + Determine ```docker version```. 25 | + Generate git tag name: ```dlw version```_```docker version``` 26 | + Create annotated tag: 27 | + ```git tag -a _ -m "dlw: , Docker Daemon: "``` 28 | + Push tag to github: 29 | + ```git push origin --tag # new tag``` 30 | + Add new [Docker Hub Tag](https://registry.hub.docker.com/u/whisperingchaos/dlw/tags/manage/) to reference the newly created tag. 31 | + tag name=github tag name 32 | + Test Docker Hub image: 33 | + Download and run ```dlw``` Hub image: 34 | + ```dlwRun.sh _``` 35 | + ```cd ~/project/sample``` 36 | + ```dlw itest``` 37 | 38 | -------------------------------------------------------------------------------- /dlwRun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # 4 | # Purpose: 5 | # Download and install the desired 'dlw' image to the Docker Daemon's 6 | # local repository and bind host project and tmux configuration directories 7 | # to container when desired. 8 | # 9 | # Assumes: 10 | # 1. Local Docker Daemon accessible via its usual socket. 11 | # 2. Created container tty will attach to current CLI terminal. 12 | # 13 | ############################################################################### 14 | function helpText () { 15 | cat <_. 25 | If omitted, tag name assigned 'latest_latest' 26 | see: https://registry.hub.docker.com/u/whisperingchaos/dlw/tags/manage/ 27 | 28 | OPTIONS: 29 | 30 | -p Existing host directory containing one or more dlw Projects as 31 | subdirectories. If omitted, Projects are stored in container. 32 | 33 | -t Existing host directory containing the '.tmux.conf' file. If omitted 34 | tmux provides its own default settings. 35 | 36 | -u {'ASSUME'||'CONTAIN'} 37 | External account UID that will replace the container's 'dlw' 38 | account's UID. This permits processes within the container 39 | to access host directories/files mounted using 'docker run|create' 40 | volume (-v) option, using rudementary Linux DAC. 41 | 'ASSUME' - Use the UID that started this script. (default) 42 | - Numeric linux User Identifer. 43 | 'CONTAIN' - Don't alter 'dlw' container UID. 44 | 45 | -g {'ASSUME'|' ...'|'CONTAIN'} 46 | GID list that will augment the container's 'dlw' account's GID list. 47 | This permits processes within the container to access host 48 | directories/files mounted using 'docker run|create' 49 | volume (-v) option, using rudementary Linux DAC. The first GID becomes 50 | the 'dlw' account's primary GID. 51 | 'ASSUME' - Use the GID list associated to the UID that started this script. (default) 52 | - Numeric linux Group Identifer. 53 | 'CONTAIN' - Don't alter 'dlw' container account GID list. 54 | 55 | -l Treat HUB_TAG_NAME as complete local repository image name. 56 | 57 | For more help: https://github.com/WhisperingChaos/DeveloperLocalWorkbenchForDocker#ToC 58 | 59 | COMMAND_HELP 60 | } 61 | ############################################################################### 62 | function hostDirWarningText () { 63 | cat <&2 127 | exit 1 128 | fi 129 | HOST_PROJECT_DIR="-v '$HOST_PROJECT_DIR:/home/dlw/project'" 130 | ;; 131 | t) declare HOST_TMUX_DIR="$OPTARG" 132 | if ! [ -d "$HOST_TMUX_DIR" ]; then 133 | echo "Abort: -t option doesn't resolve to an existing host directory: '$HOST_TMUX_DIR'.">&2 134 | exit 1 135 | fi 136 | if ! [ -e "$HOST_TMUX_DIR/.tmux.conf" ]; then 137 | echo "Abort: -t option host directory: '$HOST_TMUX_DIR', doesn't contain: '.tmux.conf'.">&2 138 | exit 1 139 | fi 140 | HOST_TMUX_DIR="-v '$HOST_TMUX_DIR:/home/dlw/.tmuxconfdir'" 141 | ;; 142 | u) ASSUME_UID="$OPTARG" 143 | ;; 144 | g) ASSUME_GID_LIST="$OPTARG" 145 | ;; 146 | l) TREAT_LOCAL_REPOSITORY_NAME='true' 147 | ;; 148 | esac 149 | done 150 | 151 | if ! ID_verify "$ASSUME_UID"; then 152 | echo "Abort: Specified -u option value invalid: '$ASSUME_UID'.">&2 153 | exit 1 154 | fi 155 | 156 | if [ "$ASSUME_UID" == 'ASSUME' ]; then 157 | ASSUME_UID="--env \"ASSUME_UID=`id -u`\"" 158 | elif [ "$ASSUME_UID" == 'CONTAIN' ]; then 159 | unset ASSUME_UID 160 | else 161 | ASSUME_UID="-e \"ASSUME_UID=$ASSUME_UID\"" 162 | fi 163 | 164 | if ! ID_verify "$ASSUME_GID_LIST"; then 165 | echo "Abort: Specified -g option value invalid: '$ASSUME_GID_LIST'.">&2 166 | exit 1 167 | fi 168 | 169 | if [ "$ASSUME_GID_LIST" == 'ASSUME' ]; then 170 | ASSUME_GID_LIST="--env \"ASSUME_GID_LIST=`GID_list_gen`\"" 171 | elif [ "$ASSUME_GID_LIST" == 'CONTAIN' ]; then 172 | unset ASSUME_GID_LIST 173 | else 174 | ASSUME_GID_LIST="-e \"ASSUME_GID_LIST=$ASSUME_GID_LIST\"" 175 | fi 176 | 177 | shift $((OPTIND-1)) 178 | declare DLW_TAG='latest_latest' 179 | if [ -n "$1" ]; then 180 | DLW_TAG="$1" 181 | fi 182 | if ! $TREAT_LOCAL_REPOSITORY_NAME; then 183 | DLW_TAG="whisperingchaos/dlw:$DLW_TAG" 184 | fi 185 | 186 | if [ -z "$HOST_PROJECT_DIR" ]; then 187 | hostDirWarningText 188 | read -p "Confirm: Project files are local to the started container (Y/n):" -N 1 -- Yn 189 | if [ "$Yn" != 'Y' ]; then 190 | echo 191 | echo "Abort: Please specify an existing host directory as second argument.">&2 192 | exit 1; 193 | fi 194 | echo 195 | fi 196 | # create a container to run dlw. Container will attach to current terminal 197 | eval docker run \-\i \-\t \-\v \'/var/run/docker.sock:/var/run/docker.sock\' $HOST_PROJECT_DIR $HOST_TMUX_DIR $ASSUME_UID $ASSUME_GID_LIST -- $DLW_TAG 198 | ############################################################################### 199 | # 200 | # The MIT License (MIT) 201 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 202 | # 203 | # Permission is hereby granted, free of charge, to any person obtaining a copy 204 | # of this software and associated documentation files (the "Software"), to deal 205 | # in the Software without restriction, including without limitation the rights 206 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 207 | # copies of the Software, and to permit persons to whom the Software is 208 | # furnished to do so, subject to the following conditions: 209 | # The above copyright notice and this permission notice shall be included in 210 | # all copies or substantial portions of the Software. 211 | # 212 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 213 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 214 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 215 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 216 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 217 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 218 | # THE SOFTWARE. 219 | # 220 | ############################################################################### 221 | # 222 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 223 | # in the United States and/or other countries. Docker, Inc. and other parties 224 | # may also have trademark rights in other terms used herein. 225 | # 226 | ############################################################################### 227 | -------------------------------------------------------------------------------- /script/ArgumentsMainInclude.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################## 3 | ## 4 | ## Purpose: 5 | ## Package up all the command line arguments into an array. Must be done 6 | ## at initial calling level within script to properly preserve 7 | ## quotes within option/argument values. 8 | ## 9 | ## Inputs: 10 | ## $1-$N arguments passed to the body of the main function. 11 | ## 12 | ############################################################################### 13 | declare a mainArgumentList 14 | while [ $# -ne 0 ]; do 15 | mainArgumentList+=("$1") 16 | shift 17 | done 18 | # call the main function that should be defined in every command script file 19 | main 'mainArgumentList' 20 | ############################################################################### 21 | # 22 | # The MIT License (MIT) 23 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 24 | # 25 | # Permission is hereby granted, free of charge, to any person obtaining a copy 26 | # of this software and associated documentation files (the "Software"), to deal 27 | # in the Software without restriction, including without limitation the rights 28 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 29 | # copies of the Software, and to permit persons to whom the Software is 30 | # furnished to do so, subject to the following conditions: 31 | # The above copyright notice and this permission notice shall be included in 32 | # all copies or substantial portions of the Software. 33 | # 34 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 36 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 40 | # THE SOFTWARE. 41 | # 42 | ############################################################################### 43 | -------------------------------------------------------------------------------- /script/ArrayMapTest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArrayMapTestInclude.sh"; 4 | 5 | function AssociativeMapFromBufferTest () { 6 | 7 | echo "$FUNCNAME Test 1: Simple one element packet." 8 | local packet='3/Key5/value' 9 | unset fieldNameMap 10 | declare -A fieldNameMap 11 | AssociativeMapFromBuffer "$packet" 'fieldNameMap' 12 | AssociativeMapAssertKeyValue $LINENO 'fieldNameMap' 'Key' 'value' 13 | echo "$FUNCNAME Test 1: Successful" 14 | 15 | echo "$FUNCNAME Test 2: Two element packet." 16 | local packet='3/Key5/value4/Key26/value2' 17 | unset fieldNameMap 18 | declare -A fieldNameMap 19 | AssociativeMapFromBuffer "$packet" 'fieldNameMap' 20 | AssociativeMapAssertKeyValue $LINENO 'fieldNameMap' 'Key' 'value' 'Key2' 'value2' 21 | echo "$FUNCNAME Test 2: Successful" 22 | 23 | echo "$FUNCNAME Test 3: Three element packet. Third element encapsulates another packet." 24 | local packet='3/Key5/value4/Key26/value24/Key314/4/Key46/value4' 25 | unset fieldNameMap 26 | declare -A fieldNameMap 27 | AssociativeMapFromBuffer "$packet" 'fieldNameMap' 28 | AssociativeMapAssertKeyValue $LINENO 'fieldNameMap' 'Key' 'value' 'Key2' 'value2' 'Key3' '4/Key46/value4' 29 | echo "$FUNCNAME Test 3: Successful" 30 | 31 | local packet='12/PacketHeader12/PacketHeader20/ComponentContextPath57//home/dlw/project/sample/component/dlw_apache/context/run13/ComponentName10/dlw_apache17/ImageGUIDFileName50//home/dlw/project/sample/image/dlw_apache.GUIDlist20/ComponentDescription0/9/ImageGUID12/a59c9799043c13/DockerCommand72/docker run -d -i --name dlw_apache --link dlw_mysql:mysql a59c9799043c ' 32 | echo "$FUNCNAME Test 4: Real generated packet that failed." 33 | unset fieldNameMap 34 | declare -A fieldNameMap 35 | AssociativeMapFromBuffer "$packet" 'fieldNameMap' 36 | AssociativeMapAssertKeyValue $LINENO 'fieldNameMap' 'PacketHeader' 'PacketHeader' 'DockerCommand' 'docker run -d -i --name dlw_apache --link dlw_mysql:mysql a59c9799043c ' 37 | echo "$FUNCNAME Test 4: Successful" 38 | } 39 | 40 | function AssociativeMapToBufferTest () { 41 | 42 | echo "$FUNCNAME Test 1: Simple one element map." 43 | unset fieldNameMap 44 | declare -A fieldNameMap 45 | fieldNameMap['Key']='value' 46 | if [ '3/Key5/value' != "`AssociativeMapToBuffer 'fieldNameMap'`" ]; then echo problem; exit 1; fi 47 | AssociativeMapAssertKeyValue $LINENO 'fieldNameMap' 'Key' 'value' 48 | echo "$FUNCNAME Test 1: Successful" 49 | 50 | echo "$FUNCNAME Test 2: Two element map." 51 | unset fieldNameMap 52 | declare -A fieldNameMap 53 | fieldNameMap['Key2']='value2' 54 | fieldNameMap['Key']='value' 55 | if [ '4/Key26/value23/Key5/value' != "`AssociativeMapToBuffer 'fieldNameMap'`" ]; then echo problem; exit 1; fi 56 | AssociativeMapAssertKeyValue $LINENO 'fieldNameMap' 'Key' 'value' 'Key2' 'value2' 57 | echo "$FUNCNAME Test 2: Successful" 58 | 59 | echo "$FUNCNAME Test 3: Three element packet. Third element encapsulates another packet." 60 | unset fieldNameMap 61 | declare -A fieldNameMap 62 | fieldNameMap['Key3']='4/Key46/value4' 63 | fieldNameMap['Key2']='value2' 64 | fieldNameMap['Key']='value' 65 | if [ '4/Key314/4/Key46/value44/Key26/value23/Key5/value' != "`AssociativeMapToBuffer 'fieldNameMap'`" ]; then echo problem; exit 1; fi 66 | AssociativeMapAssertKeyValue $LINENO 'fieldNameMap' 'Key' 'value' 'Key2' 'value2' 'Key3' '4/Key46/value4' 67 | echo "$FUNCNAME Test 3: Successful" 68 | 69 | echo "$FUNCNAME Test 4: One element packet with trailing spaces." 70 | unset fieldNameMap 71 | declare -A fieldNameMap 72 | fieldNameMap['Key']='value ' 73 | if [ '3/Key11/value ' != "`AssociativeMapToBuffer 'fieldNameMap'`" ]; then echo problem; exit 1; fi 74 | AssociativeMapAssertKeyValue $LINENO 'fieldNameMap' 'Key' 'value ' 75 | echo "$FUNCNAME Test 4: Successful" 76 | } 77 | 78 | function main () { 79 | AssociativeMapFromBufferTest 80 | AssociativeMapToBufferTest 81 | } 82 | 83 | main 84 | ############################################################################### 85 | # 86 | # The MIT License (MIT) 87 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 88 | # 89 | # Permission is hereby granted, free of charge, to any person obtaining a copy 90 | # of this software and associated documentation files (the "Software"), to deal 91 | # in the Software without restriction, including without limitation the rights 92 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 93 | # copies of the Software, and to permit persons to whom the Software is 94 | # furnished to do so, subject to the following conditions: 95 | # The above copyright notice and this permission notice shall be included in 96 | # all copies or substantial portions of the Software. 97 | # 98 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 99 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 100 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 101 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 102 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 103 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 104 | # THE SOFTWARE. 105 | # 106 | ############################################################################### 107 | -------------------------------------------------------------------------------- /script/ComponentListVerifyInclude.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | ## 4 | ## Purpose: 5 | ## Ensure entire list of component names provided as arguments are actual 6 | ## components of the provided command's context. 7 | ## 8 | ## Inputs: 9 | ## $1 - Command name. 10 | ## $2-$n - A list, of one or more component names. 11 | ## 12 | ## Outputs: 13 | ## When Failure: 14 | ## SYSERR - A message indentifying the provided component names that don't 15 | ## exist in the list of all component names that are valid for 16 | ## the specified command. 17 | ## 18 | ############################################################################### 19 | function ComponentNmListVerify (){ 20 | local -r commandName="$1" 21 | declare -A componentSetAll 22 | # A component name of 'all' is always valid representing the entire list of 23 | # component names for the given project 24 | if [ "$2" == "all" ]; then return 0; fi 25 | local componentName 26 | for componentName in `ComponentNmListGetAll "$commandName" '-B'` 27 | do 28 | componentSetAll["$componentName"]="$componentName" 29 | done 30 | shift 31 | local componentMissingList="" 32 | local errorTripped=false 33 | while [ $# -ne 0 ]; do 34 | if [ "${componentSetAll["$1"]}" != "$1" ]; then 35 | errorTripped=true 36 | componentMissingList="$componentMissingList '$1'" 37 | fi 38 | shift 39 | done 40 | if $errorTripped; then 41 | echo "These component(s): $componentMissingList are absent from the following command context: '$commandName'." >&2 42 | return 1; 43 | fi 44 | return 0; 45 | } 46 | ############################################################################### 47 | ## 48 | ## Purpose: 49 | ## Retrieve the entire list of components of Image GUID List names. 50 | ## 51 | ## Inputs: 52 | ## $1 - Command name 53 | ## $2 - optional GNU make options 54 | ## 55 | ## Outputs: 56 | ## When Successful: 57 | ## SYSOUT - Displays a single row which enumberates the list Image 58 | ## GUID List names as columns in this row separated by 59 | ## whitespace. 60 | ## 61 | ############################################################################### 62 | function ComponentNmListGetAll () { 63 | local imageGUIDListName="" 64 | local imageGUIDListNameList="" 65 | while read imageGUIDListName; do 66 | imageGUIDListNameList="$imageGUIDListNameList $imageGUIDListName" 67 | done < <( make --no-print-directory --always-make --directory=$MAKEFILE_DIR COMMAND_CURRENT=$1 COMP_NAME_ONLY=true $1 ) 68 | # echo absent of enclosing quotes cleans leading/trailing whitespace and generates only a single whitespace character between tokens. 69 | echo $imageGUIDListNameList | grep '^make: ' >/dev/null 2>/dev/null && imageGUIDListNameList="" 70 | echo $imageGUIDListNameList 71 | return 0; 72 | } 73 | FunctionOverrideIncludeGet 74 | ############################################################################### 75 | # 76 | # The MIT License (MIT) 77 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 78 | # 79 | # Permission is hereby granted, free of charge, to any person obtaining a copy 80 | # of this software and associated documentation files (the "Software"), to deal 81 | # in the Software without restriction, including without limitation the rights 82 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 83 | # copies of the Software, and to permit persons to whom the Software is 84 | # furnished to do so, subject to the following conditions: 85 | # The above copyright notice and this permission notice shall be included in 86 | # all copies or substantial portions of the Software. 87 | # 88 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 89 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 90 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 91 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 92 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 93 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 94 | # THE SOFTWARE. 95 | # 96 | ############################################################################### 97 | -------------------------------------------------------------------------------- /script/MessageInclude.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | ## 4 | ## Purpose: 5 | ## Issue an error message to SYSERR prefixed by "Error: Module: '$0' 6 | ## followed by provided message text and return to the caller. 7 | ## 8 | ## Input: 9 | ## $1 - Message text. 10 | ## 11 | ## Ouptut: 12 | ## Writes a message to SYSERR. 13 | ## 14 | ############################################################################### 15 | function ScriptError (){ 16 | local messageText="$1" 17 | if [ -z "$messageText" ]; then messageText="Message not provided"; fi 18 | local moduleName 19 | if [ -n "$VERBOSE_OUTPUT" ] && [ "$VERBOSE_OUTPUT" == 'true' ]; then 20 | moduleName="Module: '$0', " 21 | fi 22 | echo "Error: ${moduleName}$messageText" >&2 23 | return 1 24 | } 25 | ############################################################################### 26 | ## 27 | ## Purpose: 28 | ## Provide debugging message output. 29 | ## 30 | ## Input: 31 | ## $1 - LINENO. 32 | ## $2 - Message text. 33 | ## 34 | ## Ouptut: 35 | ## Writes a debug message to SYSERR. 36 | ## 37 | ############################################################################### 38 | function ScriptDebug () { 39 | local messText="$2" 40 | if [ -z "$messText" ]; then messText="Debug message not supplied."; fi 41 | ScriptMessageBasic "$1" "$0" 'Debug' "$messText" 42 | return 0 43 | } 44 | ############################################################################### 45 | ## 46 | ## Purpose: 47 | ## Issue an error message to SYSERR prefixed by "Error: Module: '$0' 48 | ## followed by provided message text and return to the caller. 49 | ## 50 | ## Input: 51 | ## $1 - Message text. 52 | ## 53 | ## Ouptut: 54 | ## Writes a message to SYSERR. 55 | ## 56 | ############################################################################### 57 | function ScriptInform (){ 58 | local messageText="$1" 59 | if [ -z "$messageText" ]; then messageText="Message not provided"; fi 60 | local moduleName 61 | if [ -n "$VERBOSE_OUTPUT" ] && [ "$VERBOSE_OUTPUT" == 'true' ]; then 62 | moduleName="Module: '$0', " 63 | fi 64 | echo "Inform: ${moduleName}$messageText" >&2 65 | return 1 66 | } 67 | ############################################################################### 68 | ## 69 | ## Purpose: 70 | ## Terminates the execution of the script while providing minimal 71 | ## debugging information that includes: the script line 72 | ## number of the offending command, its module name, and optional 73 | ## message text. 74 | ## 75 | ## Call this function for unrecoverable errors. 76 | ## 77 | ## Note: 78 | ## This does not generate a complete function call stack. 79 | ## 80 | ## Input: 81 | ## $1 - LINENO of calling location: 82 | ## $2 - Optional message text. 83 | ## 84 | ## Ouptut: 85 | ## Writes a message, prefixed by "Abort: ' to SYSERR. 86 | ## 87 | ############################################################################### 88 | function ScriptUnwind (){ 89 | ScriptMessageBasic "$1" "$0" 'Abort' "$2" 90 | exit 1 91 | } 92 | ############################################################################### 93 | ## 94 | ## Purpose: 95 | ## Issue a message message indicating a fault in a standard format. 96 | ## 97 | ## Input: 98 | ## $1 - LINENO of calling location: 99 | ## $2 - Module nameOptional message text. 100 | ## $3 - Fault type: {'Abort'|'Error'} 101 | ## $4 - Optional message text. 102 | ## 103 | ## Ouptut: 104 | ## Writes a message, prefixed by fault type: to SYSERR. 105 | ## 106 | ############################################################################### 107 | function ScriptMessageBasic (){ 108 | local lineInfo="$1" 109 | local moduleName="$2" 110 | local -r faultType="$3" 111 | local messageText="$4" 112 | 113 | if [ -z "$messageText" ]; then messageText="Unwinding script stack."; fi 114 | if [ -n "$VERBOSE_OUTPUT" ] && [ "$VERBOSE_OUTPUT" == 'true' ]; then 115 | lineInfo=" LINENO: '$lineInfo'" 116 | else 117 | moduleName="`basename "$moduleName"`" 118 | unset lineInfo 119 | fi 120 | echo "${faultType}: Module: '$moduleName'$lineInfo, $messageText" >&2 121 | } 122 | ############################################################################### 123 | ## 124 | ## Purpose: 125 | ## Determine if a global environment variable has already been defined and 126 | ## if so, terminate this shell. 127 | ## 128 | ## Note - It's a flimsy mechanism but it's better than nothing. This global 129 | ## variable is being created to improve performance by eliminating 130 | ## subshell spawning. 131 | ## 132 | ############################################################################### 133 | if [ -n "$PIPE_ERROR_ENCOUNTERED" ] && [ "$PIPE_ERROR_ENCOUNTERED" != 'PipeErrorEncountered' ]; then 134 | ScriptUnwind $LINENO "Global variable already defined: PIPE_ERROR_ENCOUNTERED: '$PIPE_ERROR_ENCOUNTERED'" 135 | else 136 | export PIPE_ERROR_ENCOUNTERED='PipeErrorEncountered' 137 | fi 138 | ############################################################################### 139 | ## 140 | ## Purpose: 141 | ## Issue an unwind request and communicate to the next process listening 142 | ## on the pipe. 143 | ## 144 | ## This function should never be called directly. Instead, it replaces 145 | ## 'ScriptUnwind' implementation by encoding: 146 | ## 147 | ## function ScriptUnwind (){ 148 | ## ScriptUnwindImplPipe "$1" "$2" 149 | ## } 150 | ## Executing the above code at the point you wish this implementation 151 | ## to override the current implementation of 'ScriptUnwind'. 152 | ## 153 | ## Input: 154 | ## $1 - LINENO of calling location: 155 | ## $2 - Optional message text. 156 | ## 157 | ## Ouptut: 158 | ## SYSERR - An abort message. 159 | ## SYSOUT - The token/signal: PIPE_ERROR_ENCOUNTERED 160 | ## 161 | ############################################################################### 162 | function ScriptUnwindImplPipe () { 163 | ScriptMessageBasic "$1" "$0" 'Abort' "$2" 164 | echo "$PIPE_ERROR_ENCOUNTERED" 165 | exit 1 166 | } 167 | ############################################################################### 168 | ## 169 | ## Purpose: 170 | ## Test for an upstream pipe error. If an error is encountered, this 171 | ## routine immediately terminates the current process and forwards the 172 | ## notification token to a possible next process in the chain. 173 | ## 174 | ## Assume: 175 | ## * PIPE_ERROR_ENCOUNTERED is properly defined. 176 | ## * The token is the ony value for a given line of input. 177 | ## * A cleanup process at the chain's end that removes the token 178 | ## from SYSOUT. 179 | ## 180 | ## Input: 181 | ## $1 - A line read from the pipe. 182 | ## 183 | ## Ouptut: 184 | ## SYSOUT - When upstream failure detected: PIPE_ERROR_ENCOUNTERED 185 | ## 186 | ############################################################################### 187 | function PipeScriptNotifyAbort (){ 188 | if [ "$1" == "$PIPE_ERROR_ENCOUNTERED" ]; then 189 | echo "$PIPE_ERROR_ENCOUNTERED" 190 | exit 1 191 | fi 192 | return 0 193 | } 194 | ############################################################################### 195 | ## 196 | ## Purpose: 197 | ## Implement a function override mechanism so others can repair and 198 | ## extend the behavior of all bash source inculded in this product without 199 | ## having to apply changes directly to the files that contain the code. 200 | ## 201 | ## Note: 202 | ## 1. This function must be used for bash scripts that are directly 203 | ## invoked by their name, creating their own command shell - 204 | ## 'mainline' programs. 205 | ## 206 | ## 207 | ## Input: 208 | ## None 209 | ## 210 | ############################################################################### 211 | function FunctionOverrideCommandGet (){ 212 | FunctionOverrideIncludeSource "$0" 213 | } 214 | ############################################################################### 215 | ## 216 | ## Purpose: 217 | ## Implement a function override mechanism so others can repair and 218 | ## extend the behavior of all bash source inculded in this product without 219 | ## having to apply changes directly to the files that contain the code. 220 | ## 221 | ## Note: 222 | ## > This function must be used for bash scripts that are included, 223 | ## using the 'source' keyword into the same command shell that serves 224 | ## as a 'mainline' program/shell. 225 | ## 226 | ## Assume: 227 | ## > At the time the source is included, that there is only a single 228 | ## layer of source between the invocation of this function and its 229 | ## definition in this file, as more than one level will cause 230 | ## the reference of ${BASH_SOURCE[1]} to incorrectly resolve 231 | ## to one of these intermediate layers. 232 | ## 233 | ## Input: 234 | ## None. 235 | ## 236 | ############################################################################### 237 | function FunctionOverrideIncludeGet (){ 238 | FunctionOverrideIncludeSource "${BASH_SOURCE[1]}" 239 | } 240 | ############################################################################### 241 | ## 242 | ## Purpose: 243 | ## Implement a function override mechanism so others can repair and 244 | ## extend the behavior of all bash source inculded in this product without 245 | ## having to apply changes directly to the files that contain the code. 246 | ## 247 | ## Permits others to have their own local customizations without concern 248 | ## that they will be overwritten by a new release of the project code. 249 | ## 250 | ## Note: 251 | ## > This function should not be directly called, instead, one of the 252 | ## functions above, that call this routine should be called. 253 | ## > The files containing the source need not exist as their non-existence 254 | ## will be suppressed. 255 | ## 256 | ## Assume: 257 | ## > All source module names in the project are unique. 258 | ## > All extension modules must be placed in their appropriate directories. 259 | ## Otherwise, overriding mechanism may fail. 260 | ## > The PATH variable has been properly established to include all 261 | ## extension directories in appropriate search order. 262 | ## 263 | ## Input: 264 | ## $1 - file name of bash module to extend. 265 | ## 266 | ## Ouptut: 267 | ## SYSERR - All messages generated while including the source should 268 | ## appear in SYSERR except for "not exist" 269 | ## SYSOUT - All messages generated while including the source 270 | ## that are written SYSOUT. 271 | ## 272 | ############################################################################### 273 | function FunctionOverrideIncludeSource (){ 274 | local -r functionOverrideName="`basename "$1" .sh`" 275 | source "${functionOverrideName}Override.sh" 2> >( grep -v '.*MessageInclude.sh:.*: No such file or directory'>&2) 276 | } 277 | FunctionOverrideIncludeGet 278 | ############################################################################### 279 | # 280 | # The MIT License (MIT) 281 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 282 | # 283 | # Permission is hereby granted, free of charge, to any person obtaining a copy 284 | # of this software and associated documentation files (the "Software"), to deal 285 | # in the Software without restriction, including without limitation the rights 286 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 287 | # copies of the Software, and to permit persons to whom the Software is 288 | # furnished to do so, subject to the following conditions: 289 | # The above copyright notice and this permission notice shall be included in 290 | # all copies or substantial portions of the Software. 291 | # 292 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 293 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 294 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 295 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 296 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 297 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 298 | # THE SOFTWARE. 299 | # 300 | ############################################################################### 301 | -------------------------------------------------------------------------------- /script/PacketIncludeMakefile.sh: -------------------------------------------------------------------------------- 1 | source "MessageInclude.sh"; 2 | source "ArrayMapTestInclude.sh"; 3 | source "PacketInclude.sh"; 4 | 5 | -------------------------------------------------------------------------------- /script/PacketIncludeTest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArrayMapTestInclude.sh"; 4 | source "PacketInclude.sh"; 5 | 6 | function PacketCreateFromStringsTest () { 7 | 8 | echo "$FUNCNAME Test 1: Create a single field packet." 9 | local packet 10 | PacketCreateFromStrings 'FieldName' 'FieldValue' 'packet' 11 | if ! [ '12/PacketHeader12/PacketHeader9/FieldName10/FieldValue9/PacketEnd9/PacketEnd' == "$packet" ]; then 12 | ScriptUnwind $LINENO "Test should have successfully completed."; 13 | fi 14 | echo "$FUNCNAME Test 1: Successful" 15 | 16 | echo "$FUNCNAME Test 2: Create a two field packet using strings" 17 | local packet 18 | PacketCreateFromStrings 'FieldName' 'FieldValue' 'FieldName2' 'FieldValue2' 'packet' 19 | if ! [ '12/PacketHeader12/PacketHeader9/FieldName10/FieldValue10/FieldName211/FieldValue29/PacketEnd9/PacketEnd' == "$packet" ]; then 20 | ScriptUnwind $LINENO "Test should have successfully completed."; 21 | fi 22 | echo "$FUNCNAME Test 2: Successful" 23 | 24 | echo "$FUNCNAME Test 3: Attempt to create a packet that consists of an entry of only a field name - should fail" 25 | local packet 26 | if `PacketCreateFromStrings 'FieldName' 'FieldValue' 'FieldName2' 'packet'`; then 27 | ScriptUnwind $LINENO "Test should have failed."; 28 | fi 29 | echo "$FUNCNAME Test 3: Successful" 30 | 31 | echo "$FUNCNAME Test 4: Attempt to create a packet that consists a field name that's associated to a null string" 32 | local packet 33 | PacketCreateFromStrings 'FieldName' 'FieldValue' 'FieldNa"me2' '' 'packet' 34 | if ! [ '12/PacketHeader12/PacketHeader9/FieldName10/FieldValue11/FieldNa"me20/9/PacketEnd9/PacketEnd' == "$packet" ]; then 35 | ScriptUnwind $LINENO "Test should have successfully completed."; 36 | fi 37 | echo "$FUNCNAME Test 4: Successful" 38 | 39 | echo "$FUNCNAME Test 5: forget to put the receiving buffer at the end of the create" 40 | local packet 41 | if `PacketCreateFromStrings 'FieldName' 'FieldValue' 'FieldNa"me2' ''`; then 42 | ScriptUnwind $LINENO "Test should have failed with appropiate message."; 43 | fi 44 | echo "$FUNCNAME Test 5: Successful" 45 | } 46 | 47 | function PacketAddFromStringsTest () { 48 | # Since PacketCreateFromStrings is simply a wrapper for the PacketAddFromStrings only basic argument positioning testing performed. 49 | echo "$FUNCNAME Test 1: Create a single field packet by adding a single field to a empty packet." 50 | local packet 51 | PacketAddFromStrings '' 'FieldName' 'FieldValue' 'packet' 52 | if ! [ '12/PacketHeader12/PacketHeader9/FieldName10/FieldValue9/PacketEnd9/PacketEnd' == "$packet" ]; then 53 | ScriptUnwind $LINENO "Test should have successfully completed."; 54 | fi 55 | echo "$FUNCNAME Test 1: Successful" 56 | 57 | echo "$FUNCNAME Test 2: Add a second set of fileds to an existing packet." 58 | local packet 59 | PacketAddFromStrings '12/PacketHeader12/PacketHeader9/FieldName10/FieldValue9/PacketEnd9/PacketEnd' 'FieldName2' 'FieldValue2' 'packet' 60 | if ! [ '12/PacketHeader12/PacketHeader9/FieldName10/FieldValue10/FieldName211/FieldValue29/PacketEnd9/PacketEnd' == "$packet" ]; then 61 | ScriptUnwind $LINENO "Test should have successfully completed."; 62 | fi 63 | echo "$FUNCNAME Test 2: Successful" 64 | } 65 | 66 | PacketCreateFromAssociativeMapTest () { 67 | # Since PacketCreateFromAssociativeMap is nearly a wrapper for AssociativeMapToBuffer only basic argument positioning testing performed. 68 | echo "$FUNCNAME Test 1: Two element map." 69 | unset fieldNameMap 70 | declare -A fieldNameMap 71 | fieldNameMap['Key2']='value2' 72 | fieldNameMap['Key']='value' 73 | AssociativeMapAssertKeyValue $LINENO 'fieldNameMap' 'Key' 'value' 'Key2' 'value2' 74 | local packet 75 | PacketCreateFromAssociativeMap 'fieldNameMap' 'packet' 76 | if [ '12/PacketHeader12/PacketHeader4/Key26/value23/Key5/value9/PacketEnd9/PacketEnd' != "$packet" ]; then 77 | ScriptUnwind $LINENO "Test should have successfully completed." 78 | fi 79 | echo "$FUNCNAME Test 1: Successful" 80 | } 81 | 82 | function PacketConvertToAssociativeMapTest () { 83 | # Since PacketCreateFromAssociativeMap is nearly a wrapper for AssociativeMapToBuffer only basic argument positioning testing performed. 84 | echo "$FUNCNAME Test 1: Two element packet to map." 85 | unset fieldNameMap 86 | declare -A fieldNameMap 87 | if ! PacketConvertToAssociativeMap '12/PacketHeader12/PacketHeader4/Key26/value23/Key5/value9/PacketEnd9/PacketEnd' 'fieldNameMap'; then 88 | ScriptUnwind $LINENO "Test should have successfully completed."; 89 | fi 90 | AssociativeMapAssertKeyValue $LINENO 'fieldNameMap' 'Key' 'value' 'Key2' 'value2' 91 | echo "$FUNCNAME Test 1: Successful" 92 | } 93 | 94 | function PacketPreambleMatchTest () { 95 | 96 | echo "$FUNCNAME Test 1: Test preamble detection." 97 | local packet 98 | PacketCreateFromStrings 'FieldName' 'FieldValue' 'packet' 99 | if ! PacketPreambleMatch "$packet"; then ScriptUnwind $LINENO "Test should have successfully completed."; fi 100 | echo "$FUNCNAME Test 1: Successful" 101 | 102 | echo "$FUNCNAME Test 2: Test failure of preamble detection." 103 | if PacketPreambleMatch "gabarage"; then ScriptUnwind $LINENO "Test should have failed."; fi 104 | echo "$FUNCNAME Test 2: Successful" 105 | } 106 | 107 | function PacketTerminatorMatchTest () { 108 | 109 | echo "$FUNCNAME Test 1: Test termination detection." 110 | local packet 111 | PacketCreateFromStrings 'FieldName' 'FieldValue' 'packet' 112 | if ! PacketTerminatorMatch "$packet"; then ScriptUnwind $LINENO "Test should have successfully completed."; fi 113 | echo "$FUNCNAME Test 1: Successful" 114 | 115 | echo "$FUNCNAME Test 2: Test failure of packet termination detection." 116 | if PacketTerminatorMatch "gabarage"; then ScriptUnwind $LINENO "Test should have failed."; fi 117 | echo "$FUNCNAME Test 2: Successful" 118 | } 119 | 120 | function PacketCatTest () { 121 | 122 | echo "$FUNCNAME Test 1: Test termination detection." 123 | local packet1 124 | PacketCreateFromStrings 'FieldName' 'FieldValue' 'packet1' 125 | local packet2 126 | PacketCreateFromStrings 'FieldName' 'FieldValue' 'packet2' 127 | local packetResult 128 | PacketCat "$packet1" "$packet2" 'packetResult' 129 | if [ '12/PacketHeader12/PacketHeader9/FieldName10/FieldValue9/FieldName10/FieldValue9/PacketEnd9/PacketEnd' != "$packetResult" ]; then 130 | ScriptUnwind $LINENO "Test should have successfully completed." 131 | fi 132 | echo "$FUNCNAME Test 1: Successful" 133 | 134 | echo "$FUNCNAME Test 2: Test failure mode where expected packet isn't one." 135 | local packet1 136 | PacketCreateFromStrings 'FieldName' 'FieldValue' 'packet1' 137 | local packetResult 138 | if `PacketCat "$packet1" "garbarage" 'packetResult'`; then 139 | ScriptUnwind $LINENO "Test should have failed." 140 | fi 141 | echo "$FUNCNAME Test 2: Successful" 142 | 143 | echo "$FUNCNAME Test 3: Test failure mode when missing return variable." 144 | local packet1 145 | PacketCreateFromStrings 'FieldName' 'FieldValue' 'packet1' 146 | local packet2 147 | PacketCreateFromStrings 'FieldName' 'FieldValue' 'packet2' 148 | local packetResult 149 | if `PacketCat "$packet1" "$packet2" "$packet1" "$packet2"`; then 150 | ScriptUnwind $LINENO "Test should have failed." 151 | fi 152 | echo "$FUNCNAME Test 3: Successful" 153 | } 154 | 155 | function main () { 156 | if ! PacketCreateFromStringsTest; then ScriptUnwind $LINENO "Unexpected return code: '$?', should be '0'"; fi 157 | if ! PacketAddFromStringsTest; then ScriptUnwind $LINENO "Unexpected return code: '$?', should be '0'"; fi 158 | if ! PacketCreateFromAssociativeMapTest; then ScriptUnwind $LINENO "Unexpected return code: '$?', should be '0'"; fi 159 | if ! PacketConvertToAssociativeMapTest; then ScriptUnwind $LINENO "Unexpected return code: '$?', should be '0'"; fi 160 | if ! PacketPreambleMatchTest; then ScriptUnwind $LINENO "Unexpected return code: '$?', should be '0'"; fi 161 | if ! PacketCatTest; then ScriptUnwind $LINENO "Unexpected return code: '$?', should be '0'"; fi 162 | } 163 | 164 | main 165 | ############################################################################### 166 | # 167 | # The MIT License (MIT) 168 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 169 | # 170 | # Permission is hereby granted, free of charge, to any person obtaining a copy 171 | # of this software and associated documentation files (the "Software"), to deal 172 | # in the Software without restriction, including without limitation the rights 173 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 174 | # copies of the Software, and to permit persons to whom the Software is 175 | # furnished to do so, subject to the following conditions: 176 | # The above copyright notice and this permission notice shall be included in 177 | # all copies or substantial portions of the Software. 178 | # 179 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 180 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 181 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 182 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 183 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 184 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 185 | # THE SOFTWARE. 186 | # 187 | ############################################################################### 188 | -------------------------------------------------------------------------------- /script/VirtDockerCmmdSingle.sh: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ## 3 | ## Section: Abstract Interface: 4 | ## Defines an abstract interface for the compliation of a command 5 | ## that isn't specialized by a Target. 6 | ## 7 | ############################################################################### 8 | ## 9 | ############################################################################### 10 | ## 11 | ## Purpose: 12 | ## Produce command text for a dlw command, like 'images' that generates 13 | ## a single resulting command that isn't differenciated by any targets. 14 | ## 15 | ## Assume: 16 | ## Since bash variable names are passed to this routine, these names 17 | ## cannot overlap the variable names locally declared within the 18 | ## scope of this routine or its decendents. 19 | ## 20 | ## Input: 21 | ## $1 - Variable name to an associative array whose key is either the 22 | ## option or argument label and whose value represents the value 23 | ## associated to that label. 24 | ## $2 - Command name. 25 | ## $3 - Command's optional arguments. 26 | ## 27 | ## Output: 28 | ## SYSOUT - The entire properly formatted command 29 | ## 30 | ############################################################################### 31 | function VirtDockerCmmdAssembleSingle () { 32 | ScriptUnwind $LINENO "Please override: $FUNCNAME". 33 | } 34 | ############################################################################### 35 | ## 36 | ## Section: Implementation: 37 | ## Defines common implementation for functions required by all 38 | ## non specific commands. 39 | ## 40 | ############################################################################### 41 | ## 42 | ############################################################################### 43 | ## 44 | ## Purpose: 45 | ## When generating command options, only include those specified by 46 | ## command line, as options, specified for specific target, are irrational. 47 | ## 48 | ############################################################################### 49 | function VirtDockerCmmdAssemble () { 50 | local optsArgListNm="$1" 51 | local optsArgMapNm="$2" 52 | local commandNm="$3" 53 | # forward all SYSOUT generated so far to next pipeline step. 54 | PipeForwarder 55 | local -a optDockerList 56 | local -A optDockerMap 57 | local -r DOCKER_FILE_NAMESPACE='$DOCKER_CMMDLINE_' 58 | if ! OptionsArgsFilter "$optsArgListNm" "$optsArgMapNm" 'optDockerList' 'optDockerMap' '( [[ "$optArg" =~ ^-[^-].*$ ]] || [[ "$optArg" =~ ^--.*$ ]] ) && ! [[ "$optArg" =~ ^--dlw.*$ ]]' 'true'; then 59 | ScriptUnwind $LINENO "Failure while extracting Docker command line options." 60 | fi 61 | local temp="`OptionsArgsGen 'optDockerList' 'optDockerMap'`" 62 | eval local ${DOCKER_FILE_NAMESPACE:1}OPTION\=\"\`OptionsArgsGen \'optDockerList\'\ \'optDockerMap\'\`\" 63 | local dockerCmmd="`VirtDockerCmmdAssembleSingle "$optsArgMapNm" "$commandNm" "$DOCKER_CMMDLINE_OPTION"`" 64 | local packetCmmd 65 | PacketCreateFromStrings 'DockerCommand' "$dockerCmmd" 'packetCmmd' 66 | echo "$packetCmmd" 67 | return 0 68 | } 69 | FunctionOverrideIncludeGet 70 | ############################################################################### 71 | # 72 | # The MIT License (MIT) 73 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 74 | # 75 | # Permission is hereby granted, free of charge, to any person obtaining a copy 76 | # of this software and associated documentation files (the "Software"), to deal 77 | # in the Software without restriction, including without limitation the rights 78 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 79 | # copies of the Software, and to permit persons to whom the Software is 80 | # furnished to do so, subject to the following conditions: 81 | # The above copyright notice and this permission notice shall be included in 82 | # all copies or substantial portions of the Software. 83 | # 84 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 85 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 86 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 87 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 88 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 89 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 90 | # THE SOFTWARE. 91 | # 92 | ############################################################################### 93 | # 94 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 95 | # in the United States and/or other countries. Docker, Inc. and other parties 96 | # may also have trademark rights in other terms used herein. 97 | # 98 | ############################################################################### 99 | -------------------------------------------------------------------------------- /script/VirtDockerContainerInterface.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | ## 4 | ## Section: Abstract Interface: 5 | ## Declare abstract interface for container commands like 'start', 'kill'... 6 | ## 7 | ############################################################################### 8 | ## 9 | ############################################################################### 10 | ## 11 | ## Purpose: 12 | ## Identifies specific container command by outputting its dlw name. 13 | ## 14 | ## Input: 15 | ## None 16 | ## 17 | ## Output: 18 | ## When Successful: 19 | ## SYSOUT - Name of dlw command. 20 | ## When Failure: 21 | ## SYSERR - Displays informative error message. 22 | ## 23 | ############################################################################### 24 | function VirtDockerContainerCommandNameGet () { 25 | ScriptUnwind $LINENO "Please override: $FUNCNAME". 26 | } 27 | ############################################################################### 28 | ## 29 | ## Purpose: 30 | ## Determines the type of dependency graph navigation for the container 31 | ## command given the dependencies reflect the run/start command perspective. 32 | ## 33 | ## Input: 34 | ## None 35 | ## 36 | ## Output: 37 | ## When Successful: 38 | ## SYSOUT: 39 | ## 'true' - Use run/start command perspective. 40 | ## 'false' - Ordering adheres order of targets in argument list. 41 | ## 'reverse' - Reverse run/start command perspective 42 | ## When Failure: 43 | ## SYSERR - Displays informative error message. 44 | ## 45 | ############################################################################### 46 | function VirtDockerContainerOrderingGet () { 47 | ScriptUnwind $LINENO "Please override: $FUNCNAME". 48 | } 49 | ############################################################################### 50 | ## 51 | ## Purpose: 52 | ## Determines the type of dependency graph navigation for the container 53 | ## command given the dependencies reflect the run/start command perspective. 54 | ## 55 | ## Input: 56 | ## $1 - Determines if description or value of the default Component argument 57 | ## is written to SYSOUT. 58 | ## 'value' - write default value to SYSOUT 59 | ## otherwise - write its description. 60 | ## 61 | ## Output: 62 | ## When Successful: 63 | ## SYSOUT: 64 | ## Default Component argument value or its description. 65 | ## When Failure: 66 | ## SYSERR - Displays informative error message. 67 | ## 68 | ############################################################################### 69 | function VirtDockerContainerCompArgDefault () { 70 | ScriptUnwind $LINENO "Please override: $FUNCNAME". 71 | } 72 | ############################################################################### 73 | ## 74 | ## Section: Shared Impementation: 75 | ## Implementation of virtual functions common to commands 76 | ## targeting containers. 77 | ## 78 | ############################################################################### 79 | ## 80 | ############################################################################## 81 | ## 82 | ## Purpose: 83 | ## Default implementation for this virtual function requires user to 84 | ## specify targeted Component names or 'all', as it is safer to require 85 | ## a target than defaulting to 'all'. 86 | ## 87 | ################################################################################# 88 | function VirtDockerContainerCompArgDefault () { 89 | if [ "$1" == 'value' ]; then echo ''; else echo 'Caution!'; fi 90 | } 91 | ############################################################################### 92 | ## 93 | ## Purpose: 94 | ## Define both the options and arguments accepted by container commands. 95 | ## 96 | ############################################################################### 97 | function VirtDockerCmmdOptionsArgsDef () { 98 | ComponentNmListArgument "`VirtDockerContainerCommandNameGet`" "`VirtDockerContainerCompArgDefault 'value'`" 99 | ComponentVersionArgument 'cur' 100 | echo '--dlwno-prereq single order=EXIST=true "ComponentNoPrereqVerify \<--dlwno-prereq\>" required ""' 101 | echo '--dlwign-state single false=EXIST=true "OptionsArgsBooleanVerify \<--dlwign-state\>" required ""' 102 | } 103 | ############################################################################### 104 | ## 105 | ## Purpose: 106 | ## Describes purpose and arguments for container commands. 107 | ## 108 | ## Output: 109 | ## SYSOUT - The command list with descriptions. 110 | ## 111 | ############################################################################### 112 | function VirtCmmdHelpDisplay () { 113 | local -r commandName="`VirtDockerContainerCommandNameGet`" 114 | cat <" required ""' 116 | VirtDockerImageArgOptionDef 117 | return 0 118 | } 119 | ############################################################################### 120 | ## 121 | ## Purpose: 122 | ## Describes the purpose and arguments for the common arguments supported 123 | ## by image commands. 124 | ## 125 | ## Input: 126 | ## VirtDockerImageHelpUsage - callback function providing help text for 127 | ## a command's usage section. 128 | ## VirtDockerImageHelpOptions - callback function providing help text 129 | ## describing options unique to a given command. 130 | ## VirtDockerImageCommandNameGet - callback function providing the dlw 131 | ## command name. 132 | ## 133 | ## Output: 134 | ## SYSOUT - The command help text. 135 | ## 136 | ############################################################################### 137 | function VirtCmmdHelpDisplay () { 138 | VirtDockerImageHelpUsage 139 | HelpCommandTarget 140 | HelpOptionHeading 141 | HelpComponentVersion 'cur' 142 | VirtDockerImageHelpOptions 143 | HelpComponentNoPrereq 'container actuation' 'false' 144 | HelpNoExecuteDocker 'false' 145 | HelpShowDocker 'false' 146 | HelpHelpDisplay 'false' 147 | DockerOptionsFormat "`VirtDockerImageCommandNameGet`" 148 | return 0 149 | } 150 | ############################################################################### 151 | ## 152 | ## Purpose: 153 | ## Given one or more Component names, version scope and the desired 154 | ## command/operation to be executed against these Component(s), map each 155 | ## Component to a Docker Image GUID. 156 | ## 157 | ## Assumption: 158 | ## Since bash variable names are passed to this routine, these names 159 | ## cannot overlap the variable names locally declared within the 160 | ## scope of this routine or its decendents. 161 | ## 162 | ## Inputs: 163 | ## $1 - Variable name to an array whose values contain the label names 164 | ## of the options and agruments appearing on the command line in the 165 | ## order specified by it. 166 | ## $2 - Variable name to an associative array whose key is either the 167 | ## option or argument label and whose value represents the value 168 | ## associated to that label. 169 | ## $3 - dlw command to execute. Maps 1 to 1 onto with Docker command line. 170 | ## VirtDockerImageNoPrereqSetting - A callback function that provides the 171 | ## noPrereq setting required by this routine. 172 | ## 173 | ## Return Code: 174 | ## When Success: 175 | ## SYSOUT - provides . 176 | ## When Failure: 177 | ## SYSERR - provides . 178 | ## 179 | ############################################################################### 180 | function VirtDockerTargetGenerate (){ 181 | local -r optsArgListNm="$1" 182 | local -r optsArgMapNm="$2" 183 | local -r commandNm="$3" 184 | local -r noPrereq="`AssociativeMapAssignIndirect "$optsArgMapNm" '--dlwno-prereq'`" 185 | local dependGraph 186 | local excludePrereq 187 | NoPrereqSetting "$noPrereq" 'true' 'dependGraph' 'excludePrereq' 188 | if ! DockerTargetImageGUIDGenerate "$1" "$2" "$3" "$dependGraph" 'true' "$excludePrereq"; then ScriptUnwind $LINENO "Unexpectd return code."; fi 189 | } 190 | ############################################################################### 191 | ## 192 | ## Purpose: 193 | ## Provides a means of extending the bash variable name-value pairs 194 | ## defined during template resolution. 195 | ## 196 | ## Default implementation does nothing. 197 | ## 198 | ## Input: 199 | ## $1 - dlw command to execute. Maps 1 to 1 onto with Docker command line. 200 | ## 201 | ## Output: 202 | ## When Success: 203 | ## SYSOUT - Each record contains the desired bash varialble name 204 | ## seperated by whitespace from the packet field name that 205 | ## refers to the desired field value to be assigned to the 206 | ## bash variable name. 207 | ## When Failure: 208 | ## Issues an error messages written to SYSERR, then terminate the process. 209 | ## 210 | ############################################################################### 211 | VirtDockerCmmdAssembleTemplateResolvePacketField () { 212 | echo 'PACKET_IMAGE_GUID ImageGUID' 213 | return 0 214 | } 215 | ############################################################################### 216 | ## 217 | ## Purpose: 218 | ## Define build command template. The 'build' type supported creates an 219 | ## image with whose name is identical to the component name and whose tag 220 | ## is defined as ":latest". The build context is defined as the component's 221 | ## local build context directory. 222 | ## 223 | ############################################################################### 224 | function VirtDockerCmmdAssembleTemplate () { 225 | echo '$DOCKER_CMMDLINE_OPTION $PACKET_IMAGE_GUID $DOCKER_CMMDLINE_COMMAND $DOCKER_CMMDLINE_ARG' 226 | return 0 227 | } 228 | ############################################################################### 229 | function VirtDockerCmmdExecutePacketForward () { 230 | echo 'false' 231 | return 0 232 | } 233 | ############################################################################### 234 | ## 235 | ## Purpose: 236 | ## Implements the dlw image command. 237 | ## 238 | ## Assumption: 239 | ## Since bash variable names are passed to this routine, these names 240 | ## cannot overlap the variable names locally declared within the 241 | ## scope of this routine or is decendents. 242 | ## 243 | ## Inputs: 244 | ## $1 - Variable name to an array whose values contain the label names 245 | ## of the options and agruments appearing on the command line in the 246 | ## order specified by it. 247 | ## $2 - Variable name to an associative array whose key is either the 248 | ## option or argument label and whose value represents the value 249 | ## associated to that label. 250 | ## VirtDockerImageCommandNameGet - callback function to obtain the Docker 251 | ## command to be generated. 252 | ## 253 | ## Outputs: 254 | ## When Successful: 255 | ## SYSOUT - Reflects output from execution of Docker command or the 256 | ## set of Docker commands to execute. 257 | ## When Failure: 258 | ## SYSERR - Displays informative error message. 259 | ## 260 | ############################################################################### 261 | function VirtCmmdExecute (){ 262 | VirtDockerMain "$1" "$2" "`VirtDockerImageCommandNameGet`" 263 | } 264 | FunctionOverrideIncludeGet 265 | ############################################################################### 266 | # 267 | # The MIT License (MIT) 268 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 269 | # 270 | # Permission is hereby granted, free of charge, to any person obtaining a copy 271 | # of this software and associated documentation files (the "Software"), to deal 272 | # in the Software without restriction, including without limitation the rights 273 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 274 | # copies of the Software, and to permit persons to whom the Software is 275 | # furnished to do so, subject to the following conditions: 276 | # The above copyright notice and this permission notice shall be included in 277 | # all copies or substantial portions of the Software. 278 | # 279 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 280 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 281 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 282 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 283 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 284 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 285 | # THE SOFTWARE. 286 | # 287 | ############################################################################### 288 | # 289 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 290 | # in the United States and/or other countries. Docker, Inc. and other parties 291 | # may also have trademark rights in other terms used herein. 292 | # 293 | ############################################################################### 294 | -------------------------------------------------------------------------------- /script/VirtDockerReportingCmmdMultiInterface.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | ## 4 | ## Section: Abstract Interface: 5 | ## Declate abstract interface for reporting commands like 'history' & 6 | ## 'top' that require aggregating output from one or more individual 7 | ## commands to produce a consolidated report. 8 | ## 9 | ############################################################################### 10 | ## 11 | ############################################################################### 12 | ## 13 | ## Purpose: 14 | ## Identifies dlw attribute name of the desired GUID. Essentially, two 15 | ## types: 'ImageGUID' and a 'ContainerGUID'. 16 | ## 17 | ## Inputs: 18 | ## None 19 | ## 20 | ## Outputs: 21 | ## When Successful: 22 | ## SYSOUT - Name of dlw attrubute name. 23 | ## When Failure: 24 | ## SYSERR - Displays informative error message. 25 | ## 26 | ############################################################################### 27 | function VirtDockerReportingGUIDattribNameGet () { 28 | ScriptUnwind $LINENO "Please override: $FUNCNAME". 29 | } 30 | ############################################################################### 31 | ## 32 | ## Purpose: 33 | ## Define common options and arguments accepted by reports 34 | ## generated by aggregating multiple Docker container commands. 35 | ## 36 | ############################################################################### 37 | function VirtDockerCmmdOptionsArgsDef () { 38 | local -r commandName="`VirtDockerReportingCommandNameGet`" 39 | ComponentNmListArgument "$commandName" 'all' 40 | ComponentVersionArgument 'cur' 41 | ColumnHeadingRemove 42 | echo '--dlwcol single "ComponentName/COMPONENT/15,ContainerGUID/CONTAINER ID/12,=EXIST=none" "ColumnSelectExcludeVerify \<--dlwcol\>" required ""' 43 | echo '--dlwno-prereq single order=EXIST=true "ComponentNoPrereqVerify \<--dlwno-prereq\>" required ""' 44 | echo '--dlwign-state single false=EXIST=true "OptionsArgsBooleanVerify \<--dlwign-state\>" required ""' 45 | return 0 46 | } 47 | ############################################################################### 48 | ## 49 | ## Purpose: 50 | ## Describes purpose and arguments common options and arguments 51 | ## accepted by reports generated by aggregating multiple Docker 52 | ## container commands. 53 | ## 54 | ############################################################################### 55 | function VirtCmmdHelpDisplay () { 56 | local -r commandName="`VirtDockerReportingCommandNameGet`" 57 | ComponentNmListArgument "$commandName" 'all' 58 | 59 | cat <" required ""' 31 | # by default show the generated command(s) 32 | echo '--dlwshow single true=EXIST=true "ShowOptionVerify \<--dlwshow\>" required ""' 33 | echo '--dlwno-prereq single order=EXIST=true "ComponentNoPrereqVerify \<--dlwno-prereq\>" required ""' 34 | echo '--dlwign-state single false=EXIST=true "OptionsArgsBooleanVerify \<--dlwign-state\>" required ""' 35 | } 36 | ############################################################################### 37 | ## 38 | ## Purpose: 39 | ## Describes purpose and arguments for container commands. 40 | ## 41 | ## Output: 42 | ## SYSOUT - The command list with descriptions. 43 | ## 44 | ############################################################################### 45 | function VirtCmmdHelpDisplay () { 46 | local -r commandName="`VirtDockerContainerCommandNameGet`" 47 | cat <" required "" 20 | --dlwforce single false=EXIST=true "OptionsArgsBooleanVerify \\<--dlwforce\\>" required "" 21 | --dlwm single "" "" optional "" 22 | OPTIONARGS 23 | ComponentNmListArgument 'build' 'all' 24 | return 0 25 | } 26 | 27 | ############################################################################### 28 | ## 29 | ## Purpose: 30 | ## Describes purpose and arguments for the 'help' command itself. 31 | ## 32 | ## Outputs: 33 | ## SYSOUT - The command list with descriptions. 34 | ## 35 | ############################################################################### 36 | function VirtCmmdHelpDisplay () { 37 | cat <\&\1 \>\ \>\( \VirtDockerCmmdExecuteFilter \) 41 | return 0; 42 | } 43 | ############################################################################## 44 | function VirtDockerReportingHeadingRegex () { 45 | echo '^I\ FILE' 46 | return 0 47 | } 48 | FunctionOverrideCommandGet 49 | source "ArgumentsMainInclude.sh"; 50 | ############################################################################### 51 | # 52 | # The MIT License (MIT) 53 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 54 | # 55 | # Permission is hereby granted, free of charge, to any person obtaining a copy 56 | # of this software and associated documentation files (the "Software"), to deal 57 | # in the Software without restriction, including without limitation the rights 58 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 59 | # copies of the Software, and to permit persons to whom the Software is 60 | # furnished to do so, subject to the following conditions: 61 | # The above copyright notice and this permission notice shall be included in 62 | # all copies or substantial portions of the Software. 63 | # 64 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 67 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 68 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 69 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 70 | # THE SOFTWARE. 71 | # 72 | ############################################################################### 73 | # 74 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 75 | # in the United States and/or other countries. Docker, Inc. and other parties 76 | # may also have trademark rights in other terms used herein. 77 | # 78 | ############################################################################### 79 | -------------------------------------------------------------------------------- /script/command/help.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArgumentsGetInclude.sh"; 4 | source "ArrayMapTestInclude.sh"; 5 | source "VirtCmmdInterface.sh"; 6 | ############################################################################### 7 | ## 8 | ## Purpose: 9 | ## Insure dlw.sh has established a valid path to the command directory. 10 | ## 11 | ## Input: 12 | ## $0 - Name of running script that included this configuration interface. 13 | ## 14 | ## Output: 15 | ## When Failure: 16 | ## SYSERR - Reflect message indicating reason for error 17 | ## 18 | ################################################################################# 19 | function VirtCmmdConfigSetDefault (){ 20 | return 0 21 | } 22 | ############################################################################### 23 | ## 24 | ## Purpose: 25 | ## Define both the options and arguments accepted by the 'help' command. 26 | ## 27 | ############################################################################### 28 | function VirtCmmdOptionsArgsDef (){ 29 | cat <" required "" 31 | --dlwcmdlst single false=EXIST=true "OptionsArgsBooleanVerify \\<--dlwcmdlst\\>" required "" 32 | OPTIONARGS 33 | return 0 34 | } 35 | ############################################################################### 36 | ## 37 | ## Purpose: 38 | ## Verify that the command name, including all, 39 | ## appears in the list of commands supported by this script. 40 | ## 41 | ## Inputs: 42 | ## $1 - Command name 43 | ## 44 | ## Outputs: 45 | ## When Failure: 46 | ## SYSERR - A message indicating reason for an error. 47 | ############################################################################### 48 | function CommandListHelpVerify () { 49 | local -r cmdName="$1" 50 | if [ "$cmdName" == "all" ]; then return 0; fi 51 | if [ "$cmdName" == "onlyDocker" ]; then return 0; fi 52 | CommandListVerify "$cmdName" 53 | } 54 | ############################################################################### 55 | ## 56 | ## Purpose: 57 | ## Verify that the command name appears in the list of commands supported 58 | ## by this script. 59 | ## 60 | ## Inputs: 61 | ## $1 - Command name 62 | ## 63 | ## Outputs: 64 | ## When Failure: 65 | ## SYSERR - A message indicating reason for an error. 66 | ############################################################################### 67 | function CommandListVerify () { 68 | local -r cmdName="$1" 69 | local cmdEntry 70 | while read cmdEntry; do 71 | if [ "$cmdName" == "$cmdEntry" ]; then return 0; fi 72 | done < <( CommandList 'all') 73 | echo "Command Name: '$cmdName' unknown.">&2 74 | return 1 75 | } 76 | ############################################################################### 77 | ## 78 | ## Purpose: 79 | ## Produce a list of only command names supported by this script. There 80 | ## are two varieties of commands: dlw specific ones, that is, dlw commands 81 | ## that have no Docker equivalent and dlw commands that wrap existing Docker 82 | ## commands. The dlw specific commands must appear after the wrapper 83 | ## commands and follow the "section" named 'dlw specific:' 84 | ## 85 | ## Input: 86 | ## $1 - Command scope: 87 | ## 'all' - All commands available through the dlw CLI. 88 | ## 'onlyDocker' - Only those dlw commands that wrap specific Docker 89 | ## commands. 90 | ## 91 | ## Outputs: 92 | ## When Success: 93 | ## SYSOUT - a list of potentially filtered commands, each on a separate 94 | ## line. 95 | ## When Failure: 96 | ## SYSERR - A message indicating reason for an error. 97 | ## 98 | ############################################################################### 99 | function CommandList () { 100 | local -r cmmdScope="$1" 101 | function CommandExtract (){ 102 | echo "$1" 103 | } 104 | local cmdEntry 105 | local scanState='COMMAND:' 106 | while read cmdEntry; do 107 | if [ "$cmdEntry" == "$scanState" ]; then 108 | scanState='PROCESS_CMDS' 109 | elif [ "$scanState" == 'PROCESS_CMDS' ]; then 110 | # empty line signifies end of command list 111 | if [ -z "$cmdEntry" ]; then return 0; fi 112 | # remove section header 113 | if [ "$cmdEntry" == 'dlw specific:' ]; then continue; fi 114 | CommandExtract $cmdEntry 115 | fi 116 | done < <( CommandHelp "$cmmdScope" ) 117 | return 0 118 | } 119 | ############################################################################### 120 | ## 121 | ## Purpose: 122 | ## Defines the list of commands supported by the dlw and provides a 123 | ## short description explaining the purpose for each one. 124 | ## 125 | ## Constraints: 126 | ## The list of commands is immediately preceeded, without whitespace, by the 127 | ## word "COMMAND:", starting in the first column and followed by End Of Line. 128 | ## Each line of the command list begins with a command name, separated by 129 | ## whitespace from its short description. There are no empty lines separating commands. 130 | ## Termination of the command list occurs with either the fist blank line 131 | ## or no more lines. 132 | ## 133 | ## Input: 134 | ## $1 - Command scope: 135 | ## 'all' - All commands available through the dlw CLI. 136 | ## 'onlyDocker' - Only those dlw commands that wrap specific Docker 137 | ## commands. 138 | ## 139 | ## Outputs: 140 | ## SYSOUT - The command list with descriptions. 141 | ## 142 | ############################################################################### 143 | function CommandHelp () { 144 | if [ "$1" == 'all' ]; then 145 | if ! helpDoc.sh; then 146 | ScriptUnwind $LINENO "Missing help text for dlw commands. File missing or returned fatal error: 'helpDoc.sh'." 147 | fi 148 | return 0; 149 | fi 150 | if [ "$1" != 'onlyDocker' ]; then 151 | ScriptUnwind $LINENO "Unknown command scope: '$1'. Should be: 'all' or 'onlyDocker'." 152 | fi 153 | # display only Docker wrapped command help 154 | local entry 155 | local scanState='Initial' 156 | while read entry; do 157 | case "$scanState" in 158 | Initial) 159 | if [ "$entry" == 'COMMAND:' ]; then scanState='OnlyDocker'; fi 160 | ;; 161 | OnlyDocker) 162 | if [ "$entry" == 'dlw specific:' ]; then 163 | scanState='SkipDLW' 164 | continue 165 | elif [ -z "$entry" ]; then 166 | scanState='IncludeRemaining' 167 | fi 168 | ;; 169 | SkipDLW) 170 | if [ -z "$entry" ]; then 171 | scanState='IncludeRemaining' 172 | else 173 | continue 174 | fi 175 | ;; 176 | IncludeRemaining) 177 | ;; 178 | *) ScriptUnwind $LINENO "Transitioned to unknown state: '$scanState'." 179 | ;; 180 | esac 181 | echo "$entry" 182 | done < <( helpDoc.sh ) 183 | return 0 184 | } 185 | ############################################################################### 186 | ## 187 | ## Purpose: 188 | ## Describes purpose and arguments for the 'help' command itself. 189 | ## 190 | ## Outputs: 191 | ## SYSOUT - The command list with descriptions. 192 | ## 193 | ############################################################################### 194 | function VirtCmmdHelpDisplay () { 195 | cat <" required ""' 31 | # by default show the generated command(s) 32 | echo '--dlwshow single true=EXIST=true "ShowOptionVerify \<--dlwshow\>" required ""' 33 | echo '--dlwno-prereq single order=EXIST=true "ComponentNoPrereqVerify \<--dlwno-prereq\>" required ""' 34 | echo '--dlwign-state single false=EXIST=true "OptionsArgsBooleanVerify \<--dlwign-state\>" required ""' 35 | } 36 | ############################################################################### 37 | ## 38 | ## Purpose: 39 | ## Describes purpose and arguments for container commands. 40 | ## 41 | ## Output: 42 | ## SYSOUT - The command list with descriptions. 43 | ## 44 | ############################################################################### 45 | function VirtCmmdHelpDisplay () { 46 | local -r commandName="`VirtDockerContainerCommandNameGet`" 47 | cat <\&\1 \>\ \>\( \VirtDockerCmmdExecuteFilter \) 51 | return 0; 52 | } 53 | ############################################################################## 54 | function VirtDockerReportingHeadingRegex () { 55 | echo '^PORT\ MAP' 56 | return 0 57 | } 58 | FunctionOverrideCommandGet 59 | source "ArgumentsMainInclude.sh"; 60 | ############################################################################### 61 | # 62 | # The MIT License (MIT) 63 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 64 | # 65 | # Permission is hereby granted, free of charge, to any person obtaining a copy 66 | # of this software and associated documentation files (the "Software"), to deal 67 | # in the Software without restriction, including without limitation the rights 68 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 69 | # copies of the Software, and to permit persons to whom the Software is 70 | # furnished to do so, subject to the following conditions: 71 | # The above copyright notice and this permission notice shall be included in 72 | # all copies or substantial portions of the Software. 73 | # 74 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 75 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 76 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 77 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 78 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 79 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 80 | # THE SOFTWARE. 81 | # 82 | ############################################################################### 83 | # 84 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 85 | # in the United States and/or other countries. Docker, Inc. and other parties 86 | # may also have trademark rights in other terms used herein. 87 | # 88 | ############################################################################### 89 | -------------------------------------------------------------------------------- /script/command/ps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArgumentsGetInclude.sh"; 4 | source "ArrayMapTestInclude.sh"; 5 | source "ComponentListVerifyInclude.sh"; 6 | source "ArgumentsDockerVerifyInclude.sh"; 7 | source "VirtCmmdInterface.sh"; 8 | source "VirtDockerInterface.sh"; 9 | source "VirtDockerReportingInterface.sh"; 10 | source "VirtDockerReportingCmmdSingleInterface.sh"; 11 | source "PacketInclude.sh"; 12 | ############################################################################## 13 | ## 14 | ## Purpose: 15 | ## Configure reporting virtual functions to implement 'ps' command. 16 | ## 17 | ################################################################################# 18 | ## 19 | function VirtDockerReportingCommandNameGet () { 20 | echo 'ps' 21 | return 0 22 | } 23 | ############################################################################## 24 | function VirtDockerReportingTargetGenerate () { 25 | local -r optsArgListNm="$1" 26 | local -r optsArgMapNm="$2" 27 | local -r commandNm="$3" 28 | local -r computePrereqs="$4" 29 | local -r truncGUID="$5" 30 | DockerTargetContainerGUIDGenerate "$optsArgListNm" "$optsArgMapNm" "$commandNm" "$computePrereqs" "$truncGUID" 'false' 'false' 31 | } 32 | ############################################################################## 33 | function VirtDockerReportingJoinGUIDcolmNameGet () { 34 | echo 'CONTAINER ID' 35 | return 0 36 | } 37 | ############################################################################## 38 | function VirtDockerReportingHeadingRegex () { 39 | echo '^CONTAINER\ ID\ *IMAGE.*' 40 | return 0 41 | } 42 | ############################################################################## 43 | function VirtDockerReportingGUIDattribNameGet () { 44 | echo 'ContainerGUID' 45 | return 0 46 | } 47 | FunctionOverrideCommandGet 48 | source "ArgumentsMainInclude.sh"; 49 | ############################################################################### 50 | # 51 | # The MIT License (MIT) 52 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 53 | # 54 | # Permission is hereby granted, free of charge, to any person obtaining a copy 55 | # of this software and associated documentation files (the "Software"), to deal 56 | # in the Software without restriction, including without limitation the rights 57 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 58 | # copies of the Software, and to permit persons to whom the Software is 59 | # furnished to do so, subject to the following conditions: 60 | # The above copyright notice and this permission notice shall be included in 61 | # all copies or substantial portions of the Software. 62 | # 63 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 64 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 65 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 66 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 67 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 68 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 69 | # THE SOFTWARE. 70 | # 71 | ############################################################################### 72 | # 73 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 74 | # in the United States and/or other countries. Docker, Inc. and other parties 75 | # may also have trademark rights in other terms used herein. 76 | # 77 | ############################################################################### 78 | -------------------------------------------------------------------------------- /script/command/restart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArgumentsGetInclude.sh"; 4 | source "ArrayMapTestInclude.sh"; 5 | source "ComponentListVerifyInclude.sh"; 6 | source "ArgumentsDockerVerifyInclude.sh"; 7 | source "VirtCmmdInterface.sh"; 8 | source "VirtDockerInterface.sh"; 9 | source "VirtDockerContainerInterface.sh"; 10 | source "PacketInclude.sh"; 11 | ############################################################################## 12 | ## 13 | ## Purpose: 14 | ## Configure container virtual functions to implement 'restart' command. 15 | ## 16 | ################################################################################# 17 | ## 18 | function VirtDockerContainerCommandNameGet () { 19 | echo 'restart' 20 | } 21 | ################################################################################# 22 | function VirtDockerContainerOrderingGet () { 23 | echo 'true' 24 | } 25 | ############################################################################## 26 | function VirtContainerStateFilterApply () { 27 | local -r dockerStatus="$1" 28 | if [ "${dockerStatus:0:2}" == 'Up' ] && ! [[ "$dockerStatus" =~ .*\(Paused\) ]]; then 29 | return 0; 30 | fi 31 | if [ "${dockerStatus:0:2}" == ' ' ] || [ "${dockerStatus:0:6}" == 'Exited' ] || [ "${dockerStatus:0:7}" == 'Created' ] ; then 32 | # restart acts as start 33 | return 0; 34 | fi 35 | return 1 36 | } 37 | FunctionOverrideCommandGet 38 | source "ArgumentsMainInclude.sh"; 39 | ############################################################################### 40 | # 41 | # The MIT License (MIT) 42 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 43 | # 44 | # Permission is hereby granted, free of charge, to any person obtaining a copy 45 | # of this software and associated documentation files (the "Software"), to deal 46 | # in the Software without restriction, including without limitation the rights 47 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 48 | # copies of the Software, and to permit persons to whom the Software is 49 | # furnished to do so, subject to the following conditions: 50 | # The above copyright notice and this permission notice shall be included in 51 | # all copies or substantial portions of the Software. 52 | # 53 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 54 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 55 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 56 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 57 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 58 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 59 | # THE SOFTWARE. 60 | # 61 | ############################################################################### 62 | # 63 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 64 | # in the United States and/or other countries. Docker, Inc. and other parties 65 | # may also have trademark rights in other terms used herein. 66 | # 67 | ############################################################################### 68 | -------------------------------------------------------------------------------- /script/command/rm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArgumentsGetInclude.sh"; 4 | source "ArrayMapTestInclude.sh"; 5 | source "ComponentListVerifyInclude.sh"; 6 | source "ArgumentsDockerVerifyInclude.sh"; 7 | source "VirtCmmdInterface.sh"; 8 | source "VirtDockerInterface.sh"; 9 | source "VirtDockerContainerInterface.sh"; 10 | source "PacketInclude.sh"; 11 | ############################################################################### 12 | ## 13 | ## Purpose: 14 | ## Configure container virtual functions to implement 'stop' command. 15 | ## 16 | ############################################################################### 17 | ## 18 | function VirtDockerContainerCommandNameGet () { 19 | echo 'rm' 20 | } 21 | ############################################################################## 22 | ## 23 | ## Purpose: 24 | ## Configure container virtual functions to implement 'rm' command. 25 | ## 26 | ################################################################################# 27 | ## 28 | function VirtDockerCmmdOptionsArgsDef () { 29 | ComponentNmListArgument 'rm' '' 30 | ComponentVersionArgument 31 | } 32 | ############################################################################### 33 | ## 34 | ## Purpose: 35 | ## Describes purpose and arguments for the 'help' command itself. 36 | ## 37 | ## Outputs: 38 | ## SYSOUT - The command list with descriptions. 39 | ## 40 | ############################################################################### 41 | function VirtCmmdHelpDisplay () { 42 | cat <'} 44 | '' Replace with one that keeps SYSIN open, 45 | like 'start', 'run', 'attach', 'watch' .... Should 46 | be enclosed in single/double quotes with appropriate 47 | escaping of potential inner quotes when inner quotes 48 | specified. 49 | SESSION_NAME: { '$PROJECT_NAME' | } 50 | Replace with label that either uniquely selects 51 | an existing screen session or will create a new one. 52 | SESSTION_NAME is an alias for socket name: 53 | '-S' option :: do not specify this linux screen option. 54 | COMMAND_HELP_Purpose 55 | HelpOptionHeading 56 | HelpNoExecuteDocker 'false' 57 | HelpShowDocker 'false' 58 | HelpHelpDisplay 'false' 59 | ScreenOptionsFormat 60 | return 0 61 | } 62 | ############################################################################### 63 | ## 64 | ## Purpose: 65 | ## Obtain help text for the linux screen commmand. 66 | ## 67 | ## Input: 68 | ## None 69 | ## 70 | ## Output: 71 | ## SYSOUT - Help text describing only screen's options. 72 | ## 73 | ############################################################################### 74 | function ScreenOptionsFormat () { 75 | function VirtOptionsExtractHelpDisplay () { 76 | screen --help 77 | } 78 | OptionsExtract 'screen' 79 | return 0 80 | } 81 | ############################################################################### 82 | ## 83 | ## Purpose: 84 | ## Executes the provided dlw command to generate one or more Docker 85 | ## commands. Each of the Docker commands becomes the target command 86 | ## for the screen utility. 87 | ## 88 | ## Assume: 89 | ## Since bash variable names are passed to this routine, these names 90 | ## cannot overlap the variable names locally declared within the 91 | ## scope of this routine or its decendents. 92 | ## 93 | ## Input: 94 | ## $1 - Variable name to an array whose values contain the label names 95 | ## of the options and agruments appearing on the command line in the 96 | ## order specified by it. 97 | ## $2 - Variable name to an associative array whose key is either the 98 | ## option or argument label and whose value represents the value 99 | ## associated to that label. 100 | ## $3 - dlw command to execute. Maps 1 to 1 onto with Docker command line. 101 | ## 102 | ## Output: 103 | ## SYSOUT - Packets containing attributes specific to a given Docker Target. 104 | ## For example, Docker commands that operate on containers require a 105 | ## Container GUID. In this situation, the packet will contain a 106 | ## Container GUID field. 107 | ## 108 | ############################################################################### 109 | function VirtDockerTargetGenerate (){ 110 | local -r optsArgListNm="$1" 111 | local -r optsArgMapNm="$2" 112 | local -r commandName="$3" 113 | local screenCmmd 114 | # get the dlw command to execute 115 | AssociativeMapAssignIndirect "$optsArgMapNm" '--dlwc' 'screenCmmd' 116 | screenCmmd+=' ' 117 | # ensure dlw command isn't executed and request that the entire 118 | # packet be forwarded to this pipeline so its attributes can 119 | # be accessed to help assemble the linux screen command. 120 | screenCmmd="${screenCmmd/ / --dlwno-exec=true --dlwshow=packet }" 121 | local dockerPacket 122 | while read dockerPacket; do 123 | PipeScriptNotifyAbort "$dockerPacket" 124 | if ! PacketPreambleMatch "$dockerPacket"; then 125 | # not a packet - forward 126 | echo "$dockerPacket" 127 | continue 128 | fi 129 | # packet detected 130 | local -A dockerCmmdMap 131 | unset dockerCmmdMap 132 | local -A dockerCmmdMap 133 | PacketConvertToAssociativeMap "$dockerPacket" 'dockerCmmdMap' 134 | # does packet contain generated Docker command 135 | local dockerCmmd="${dockerCmmdMap['DockerCommand']}" 136 | if [ -z "$dockerCmmd" ]; then 137 | # packet doesn't contain a docker command :: forward it. 138 | echo "$dockerPacket" 139 | continue 140 | fi 141 | if [ -n "${dockerCmmdMap['ComponentName']}" ]; then 142 | # change the current packet's command context to reference 'screen' context. 143 | local componentContextPath="$COMPONENT_CAT_DIR/${dockerCmmdMap['ComponentName']}/context/$commandName" 144 | else 145 | # a command, like Watch, that will execute a dlw command as it's not target specific. 146 | # TODO: perhaps implement a project wide 'context' for non-targeted commands? Might also want to implement inheritance mechanism for even targeted commands. 147 | local componentContextPath="$PROJECT_DIR/context/$commandName" 148 | fi 149 | # reference docker command as 'ScreenCommand' attribute and add the new value of the ComponentContextPath 150 | # to the packet's end so it can override the initial value established by the dlw command. 151 | PacketAddFromStrings "$dockerPacket" 'ScreenCommand' "$dockerCmmd" 'ComponentContextPath' "$componentContextPath" 'dockerPacket' 152 | echo "$dockerPacket" 153 | done < <( eval dlw.sh $screenCmmd ) 154 | } 155 | ############################################################################### 156 | ## 157 | ## Purpose: 158 | ## Provides a means of extending the bash variable name-value pairs 159 | ## defined during template resolution. 160 | ## 161 | ## Input: 162 | ## $1 - dlw command to execute. Maps 1 to 1 onto with Docker command line. 163 | ## 164 | ## Output: 165 | ## When Success: 166 | ## SYSOUT - Each record contains the desired bash varialble name 167 | ## seperated by whitespace from the packet field name that 168 | ## refers to the desired field value to be assigned to the 169 | ## bash variable name. 170 | ## When Failure: 171 | ## Issues an error messages written to SYSERR, then terminate the process. 172 | ## 173 | ############################################################################### 174 | VirtDockerCmmdAssembleTemplateResolvePacketField () { 175 | echo 'PACKET_DOCKER_COMMAND ScreenCommand' 176 | return 0 177 | } 178 | ############################################################################### 179 | ## 180 | ## Purpose: 181 | ## Define container command template. Container commands typically accept 182 | ## options followed by the container GUID. 183 | ## 184 | ############################################################################### 185 | function VirtDockerCmmdAssembleTemplate () { 186 | echo '-S "`AssociativeMapAssignIndirect "$optsArgMapNm" 'Arg1'`" -X screen $DOCKER_CMMDLINE_OPTION -t "`if [ -n "$PACKET_COMPONENT_NAME" ]; then echo "$PACKET_COMPONENT_NAME"; else echo '"\'"'$( QuoteSingleReplace "$PACKET_DOCKER_COMMAND" ' ' )'"\'"'; fi`" $PACKET_DOCKER_COMMAND' 187 | return 0 188 | } 189 | ############################################################################### 190 | ## 191 | ## Purpose: 192 | ## Establish 'screen' as 'primary' command while assembling templates. 193 | ## 194 | ## Input: 195 | ## None 196 | ## 197 | ## Output: 198 | ## SYSOUT - Since the secondary command is already 'screen', output 199 | ## a null string as the primary one. 200 | ## 201 | ############################################################################### 202 | function VirtDockerCmmdExecPrimaryName () { 203 | echo "" 204 | } 205 | ############################################################################### 206 | ## 207 | ## Purpose: 208 | ## Execute the linux screen command creating a new detached session (socket daemon) 209 | ## or if the session exists, simply add the each Docker command as a new 210 | ## screen to the specified session. 211 | ## 212 | ## Input: 213 | ## $1 - dlw command to execute. Maps 1 to 1 onto with Docker command line. 214 | ## 215 | ## Output: 216 | ## When Success: 217 | ## The screen with the given session name contains one or more windows 218 | ## for containers with open STDIN streams. 219 | ## When Failure: 220 | ## Issues an error messages written to SYSERR, then terminate the process. 221 | ## 222 | ############################################################################### 223 | function VirtDockerCmmdExecute () { 224 | local screenCmmd="$5" 225 | # try running screen. This will simply add more screen windows to an 226 | # existing session. If the named session doesn't exist, it will fail, 227 | # then try executing it as deamon to create the session. 228 | eval $screenCmmd \>\/\dev\/\null\ \2\>\/\dev\/\null 229 | if [ "$?" -ne '0' ]; then 230 | screenCmmd="${screenCmmd/screen -S/screen -dmS}" 231 | screenCmmd="${screenCmmd/-X screen /}" 232 | eval $screenCmmd 233 | fi 234 | } 235 | ############################################################################### 236 | ## 237 | ## Purpose: 238 | ## Configure container virtual function to report implement 'screen' command. 239 | ## 240 | ############################################################################### 241 | function VirtDockerContainerCommandNameGet () { 242 | echo 'screen' 243 | } 244 | FunctionOverrideCommandGet 245 | source "ArgumentsMainInclude.sh"; 246 | ############################################################################### 247 | # 248 | # The MIT License (MIT) 249 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 250 | # 251 | # Permission is hereby granted, free of charge, to any person obtaining a copy 252 | # of this software and associated documentation files (the "Software"), to deal 253 | # in the Software without restriction, including without limitation the rights 254 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 255 | # copies of the Software, and to permit persons to whom the Software is 256 | # furnished to do so, subject to the following conditions: 257 | # The above copyright notice and this permission notice shall be included in 258 | # all copies or substantial portions of the Software. 259 | # 260 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 261 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 262 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 263 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 264 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 265 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 266 | # THE SOFTWARE. 267 | # 268 | ############################################################################### 269 | # 270 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 271 | # in the United States and/or other countries. Docker, Inc. and other parties 272 | # may also have trademark rights in other terms used herein. 273 | # 274 | ############################################################################### 275 | -------------------------------------------------------------------------------- /script/command/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArgumentsGetInclude.sh"; 4 | source "ArrayMapTestInclude.sh"; 5 | source "ComponentListVerifyInclude.sh"; 6 | source "ArgumentsDockerVerifyInclude.sh"; 7 | source "VirtCmmdInterface.sh"; 8 | source "VirtDockerInterface.sh"; 9 | source "VirtDockerContainerInterface.sh"; 10 | source "PacketInclude.sh"; 11 | ############################################################################### 12 | ## 13 | ## Purpose: 14 | ## Configure container virtual functions to implement 'start' command. 15 | ## 16 | ############################################################################### 17 | ## 18 | function VirtDockerContainerCommandNameGet () { 19 | echo 'start' 20 | } 21 | ############################################################################### 22 | function VirtDockerContainerOrderingGet () { 23 | echo 'true' 24 | } 25 | ############################################################################### 26 | function VirtDockerContainerCompArgDefault () { 27 | if [ "$1" == 'value' ]; then echo 'all'; else echo 'Default behavior.'; fi 28 | } 29 | ############################################################################## 30 | function VirtContainerStateFilterApply () { 31 | local -r dockerStatus="$1" 32 | if [ "${dockerStatus:0:2}" == ' ' ] || [ "${dockerStatus:0:6}" == 'Exited' ] || [ "${dockerStatus:0:7}" == 'Created' ] ; then 33 | return 0; 34 | fi 35 | return 1 36 | } 37 | FunctionOverrideCommandGet 38 | source "ArgumentsMainInclude.sh"; 39 | ############################################################################### 40 | # 41 | # The MIT License (MIT) 42 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 43 | # 44 | # Permission is hereby granted, free of charge, to any person obtaining a copy 45 | # of this software and associated documentation files (the "Software"), to deal 46 | # in the Software without restriction, including without limitation the rights 47 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 48 | # copies of the Software, and to permit persons to whom the Software is 49 | # furnished to do so, subject to the following conditions: 50 | # The above copyright notice and this permission notice shall be included in 51 | # all copies or substantial portions of the Software. 52 | # 53 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 54 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 55 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 56 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 57 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 58 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 59 | # THE SOFTWARE. 60 | # 61 | ############################################################################### 62 | # 63 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 64 | # in the United States and/or other countries. Docker, Inc. and other parties 65 | # may also have trademark rights in other terms used herein. 66 | # 67 | ############################################################################### 68 | -------------------------------------------------------------------------------- /script/command/stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArgumentsGetInclude.sh"; 4 | source "ArrayMapTestInclude.sh"; 5 | source "ComponentListVerifyInclude.sh"; 6 | source "ArgumentsDockerVerifyInclude.sh"; 7 | source "VirtCmmdInterface.sh"; 8 | source "VirtDockerInterface.sh"; 9 | source "VirtDockerContainerInterface.sh"; 10 | source "PacketInclude.sh"; 11 | ############################################################################### 12 | ## 13 | ## Purpose: 14 | ## Configure container virtual functions to implement 'stop' command. 15 | ## 16 | ############################################################################### 17 | ## 18 | function VirtDockerContainerCommandNameGet () { 19 | echo 'stop' 20 | } 21 | ############################################################################### 22 | function VirtDockerContainerOrderingGet () { 23 | echo 'reverse' 24 | } 25 | ############################################################################## 26 | function VirtContainerStateFilterApply () { 27 | local -r dockerStatus="$1" 28 | if [ "${dockerStatus:0:2}" == 'Up' ] && ! [[ "$dockerStatus" =~ .*\(Paused\) ]]; then 29 | return 0; 30 | fi 31 | return 1 32 | } 33 | 34 | FunctionOverrideCommandGet 35 | source "ArgumentsMainInclude.sh"; 36 | ############################################################################### 37 | # 38 | # The MIT License (MIT) 39 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 40 | # 41 | # Permission is hereby granted, free of charge, to any person obtaining a copy 42 | # of this software and associated documentation files (the "Software"), to deal 43 | # in the Software without restriction, including without limitation the rights 44 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 45 | # copies of the Software, and to permit persons to whom the Software is 46 | # furnished to do so, subject to the following conditions: 47 | # The above copyright notice and this permission notice shall be included in 48 | # all copies or substantial portions of the Software. 49 | # 50 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 51 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 52 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 53 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 54 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 55 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 56 | # THE SOFTWARE. 57 | # 58 | ############################################################################### 59 | # 60 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 61 | # in the United States and/or other countries. Docker, Inc. and other parties 62 | # may also have trademark rights in other terms used herein. 63 | # 64 | ############################################################################### 65 | -------------------------------------------------------------------------------- /script/command/top.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArgumentsGetInclude.sh"; 4 | source "ArrayMapTestInclude.sh"; 5 | source "ComponentListVerifyInclude.sh"; 6 | source "ArgumentsDockerVerifyInclude.sh"; 7 | source "VirtCmmdInterface.sh"; 8 | source "VirtDockerInterface.sh"; 9 | source "VirtDockerContainerInterface.sh"; 10 | source "VirtDockerReportingInterface.sh"; 11 | source "VirtDockerReportingCmmdMultiInterface.sh"; 12 | source "PacketInclude.sh"; 13 | ############################################################################## 14 | ## 15 | ## Purpose: 16 | ## Configure container virtual functions to implement 'top' command. 17 | ## 18 | ################################################################################# 19 | ## 20 | ############################################################################## 21 | function VirtDockerReportingCommandNameGet () { 22 | echo 'top' 23 | } 24 | function VirtDockerContainerCommandNameGet () { 25 | VirtDockerReportingCommandNameGet 26 | } 27 | function VirtDockerContainerOrderingGet () { 28 | # order of prerequsites as they are, not in reverse 29 | echo 'true' 30 | } 31 | function VirtDockerReportingHeadingRegex () { 32 | echo '^UID|LABEL\ *PID\ ' 33 | return 0 34 | } 35 | FunctionOverrideCommandGet 36 | source "ArgumentsMainInclude.sh"; 37 | ############################################################################### 38 | # 39 | # The MIT License (MIT) 40 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 41 | # 42 | # Permission is hereby granted, free of charge, to any person obtaining a copy 43 | # of this software and associated documentation files (the "Software"), to deal 44 | # in the Software without restriction, including without limitation the rights 45 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 46 | # copies of the Software, and to permit persons to whom the Software is 47 | # furnished to do so, subject to the following conditions: 48 | # The above copyright notice and this permission notice shall be included in 49 | # all copies or substantial portions of the Software. 50 | # 51 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 52 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 53 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 54 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 55 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 56 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 57 | # THE SOFTWARE. 58 | # 59 | ############################################################################### 60 | # 61 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 62 | # in the United States and/or other countries. Docker, Inc. and other parties 63 | # may also have trademark rights in other terms used herein. 64 | # 65 | ############################################################################### 66 | -------------------------------------------------------------------------------- /script/command/unpause.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArgumentsGetInclude.sh"; 4 | source "ArrayMapTestInclude.sh"; 5 | source "ComponentListVerifyInclude.sh"; 6 | source "ArgumentsDockerVerifyInclude.sh"; 7 | source "VirtCmmdInterface.sh"; 8 | source "VirtDockerInterface.sh"; 9 | source "VirtDockerContainerInterface.sh"; 10 | source "PacketInclude.sh"; 11 | 12 | ############################################################################## 13 | ## 14 | ## Purpose: 15 | ## Configure container virtual functions to implement 'unpause' command. 16 | ## 17 | ################################################################################# 18 | ## 19 | ############################################################################## 20 | function VirtDockerContainerCommandNameGet () { 21 | echo 'unpause' 22 | } 23 | ############################################################################### 24 | function VirtDockerContainerCompArgDefault () { 25 | if [ "$1" == 'value' ]; then echo 'all'; else echo 'Default behavior.'; fi 26 | } 27 | ############################################################################## 28 | function VirtDockerContainerOrderingGet () { 29 | echo 'true' 30 | } 31 | ############################################################################## 32 | function VirtContainerStateFilterApply () { 33 | local -r dockerStatus="$1" 34 | if [ "${dockerStatus:0:2}" == 'Up' ] && [[ "$dockerStatus" =~ .*\(Paused\) ]]; then 35 | return 0; 36 | fi 37 | return 1 38 | } 39 | 40 | FunctionOverrideCommandGet 41 | source "ArgumentsMainInclude.sh"; 42 | ############################################################################### 43 | # 44 | # The MIT License (MIT) 45 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 46 | # 47 | # Permission is hereby granted, free of charge, to any person obtaining a copy 48 | # of this software and associated documentation files (the "Software"), to deal 49 | # in the Software without restriction, including without limitation the rights 50 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 51 | # copies of the Software, and to permit persons to whom the Software is 52 | # furnished to do so, subject to the following conditions: 53 | # The above copyright notice and this permission notice shall be included in 54 | # all copies or substantial portions of the Software. 55 | # 56 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 57 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 58 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 59 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 60 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 61 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 62 | # THE SOFTWARE. 63 | # 64 | ############################################################################### 65 | # 66 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 67 | # in the United States and/or other countries. Docker, Inc. and other parties 68 | # may also have trademark rights in other terms used herein. 69 | # 70 | ############################################################################### 71 | -------------------------------------------------------------------------------- /script/command/version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source "MessageInclude.sh"; 3 | source "ArgumentsGetInclude.sh"; 4 | source "ArrayMapTestInclude.sh"; 5 | source "VirtCmmdInterface.sh"; 6 | ############################################################################### 7 | ## 8 | ## Purpose: 9 | ## Insure dlw.sh has established a valid path to the command directory. 10 | ## 11 | ## Input: 12 | ## $0 - Name of running script that included this configuration interface. 13 | ## 14 | ## Output: 15 | ## When Failure: 16 | ## SYSERR - Reflect message indicating reason for error 17 | ## 18 | ################################################################################# 19 | function VirtCmmdConfigSetDefault (){ 20 | return 0 21 | } 22 | ############################################################################### 23 | ## 24 | ## Purpose: 25 | ## Define both the options and arguments accepted by the 'help' command. 26 | ## 27 | ############################################################################### 28 | function VirtCmmdOptionsArgsDef (){ 29 | cat <" required "" 31 | --dlwlicense single false=EXIST=true "OptionsArgsBooleanVerify \\<--dlwlicense\\>" required "" 32 | --dlwbugs single false=EXIST=true "OptionsArgsBooleanVerify \\<--dlwbugs\\>" required "" 33 | OPTIONARGS 34 | return 0 35 | } 36 | ############################################################################### 37 | ## 38 | ## Purpose: 39 | ## Describes purpose and arguments for the 'version' command. 40 | ## 41 | ## Outputs: 42 | ## SYSOUT - The command list with descriptions. 43 | ## 44 | ############################################################################### 45 | function VirtCmmdHelpDisplay () { 46 | cat <" required ""' 23 | echo '--dlwshow single true=EXIST=true "ShowOptionVerify \<--dlwshow\>" required ""' 24 | } 25 | ############################################################################### 26 | ## 27 | ## Purpose: 28 | ## Describes purpose and arguments for the screen command. 29 | ## 30 | ## Output: 31 | ## SYSOUT - Help to use screen. 32 | ## 33 | ############################################################################### 34 | function VirtCmmdHelpDisplay () { 35 | local -r commandName="`VirtDockerContainerCommandNameGet`" 36 | cat <'} 44 | '' Replace with one that makes sense for 45 | linux watch like 'ps', 'images', 'build'... . Should 46 | be enclosed in single/double quotes with appropriate 47 | escaping of potential inner quotes when inner quotes 48 | specified. 49 | 50 | COMMAND_HELP_Purpose 51 | HelpOptionHeading 52 | HelpNoExecuteDocker 'true' 53 | HelpShowDocker 'true' 54 | HelpHelpDisplay 'false' 55 | WatchOptionsFormat 56 | return 0 57 | } 58 | ############################################################################### 59 | ## 60 | ## Purpose: 61 | ## Obtain help text for the linux watch commmand. 62 | ## 63 | ## Input: 64 | ## None 65 | ## 66 | ## Output: 67 | ## SYSOUT - Help text describing only watch's options. 68 | ## 69 | ############################################################################### 70 | function WatchOptionsFormat () { 71 | function VirtOptionsExtractHelpDisplay () { 72 | watch --help 73 | } 74 | OptionsExtract 'watch' 75 | return 0 76 | } 77 | ############################################################################### 78 | function VirtDockerTargetGenerate (){ 79 | return 0 80 | } 81 | ############################################################################### 82 | function VirtDockerCmmdAssembleSingle () { 83 | local -r optArgMapNm="$1" 84 | local -r commandNm="$2" 85 | local -r commandOpts="$3" 86 | local dlwCommand 87 | AssociativeMapAssignIndirect "$optArgMapNm" '--dlwc' 'dlwCommand' 88 | echo "watch $commandOpts '$SCRIPT_DIR_DLW/dlw.sh' $dlwCommand" 89 | } 90 | ############################################################################### 91 | ## 92 | ## Purpose: 93 | ## Establish 'screen' as 'primary' command while assembling templates. 94 | ## 95 | ## Input: 96 | ## None 97 | ## 98 | ## Output: 99 | ## SYSOUT - Since the secondary command is already 'screen', output 100 | ## a null string as the primary one. 101 | ## 102 | ############################################################################### 103 | function VirtDockerCmmdExecPrimaryName () { 104 | echo "watch" 105 | } 106 | VirtDockerCmmdExecutePacketForward () { 107 | echo 'false' 108 | } 109 | function VirtCmmdExecute (){ 110 | VirtDockerMain "$1" "$2" 'watch' 111 | } 112 | FunctionOverrideCommandGet 113 | source "ArgumentsMainInclude.sh"; 114 | ############################################################################### 115 | # 116 | # The MIT License (MIT) 117 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 118 | # 119 | # Permission is hereby granted, free of charge, to any person obtaining a copy 120 | # of this software and associated documentation files (the "Software"), to deal 121 | # in the Software without restriction, including without limitation the rights 122 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 123 | # copies of the Software, and to permit persons to whom the Software is 124 | # furnished to do so, subject to the following conditions: 125 | # The above copyright notice and this permission notice shall be included in 126 | # all copies or substantial portions of the Software. 127 | # 128 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 129 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 130 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 131 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 132 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 133 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 134 | # THE SOFTWARE. 135 | # 136 | ############################################################################### 137 | # 138 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 139 | # in the United States and/or other countries. Docker, Inc. and other parties 140 | # may also have trademark rights in other terms used herein. 141 | # 142 | ############################################################################### 143 | -------------------------------------------------------------------------------- /script/makefileFunExtend.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source 'MessageInclude.sh' 3 | ############################################################################### 4 | ## 5 | ## Purpose: 6 | ## Retrieve a list of component names that comprise the project. For each 7 | ## component name, determine if the Context associated to a given target 8 | ## type, exists. If so, generate the target name by concatenating the 9 | ## component name with the provided suffix. 10 | ## 11 | ## Input: 12 | ## $1 - Directory path to component directory. 13 | ## $2 - Context path scheme. A path containing the replaceable keyword 14 | ## "". 15 | ## $3 - Context suffix value. 16 | ## 17 | ## Output: 18 | ## When Successful: 19 | ## SYSOUT - A list of target names presented as a single row. 20 | ## 21 | ############################################################################### 22 | function ContextTargetGen () { 23 | local -r pathScheme="$2" 24 | local -r suffixValue="$3" 25 | local componentName 26 | local targetNameList='' 27 | for componentName in `ls -F -- "$1"` 28 | do 29 | local directoryContext 30 | directoryContext="${pathScheme//$componentName}" 31 | if [ -d "$directoryContext" ]; then 32 | local targetName="${componentName/\//$suffixValue}" 33 | targetNameList+=" $targetName" 34 | fi 35 | done 36 | echo "${targetNameList:1}" 37 | return 0 38 | } 39 | ############################################################################### 40 | ## 41 | ## Purpose: 42 | ## Attempts to replicate a 'make' timestamp comparison between a prerequsite 43 | ## and its target. 44 | ## 45 | ## Input: 46 | ## $1 - File name of target. 47 | ## $2 - File name of a prerequsite resource to the target 48 | ## 49 | ## Output: 50 | ## 0 - true: target must be rebuilt. 51 | ## 1 - false: target need not be rebuilt. 52 | ## 53 | ############################################################################### 54 | function TimeStampTripIs () { 55 | local -r TARGET=`find "$1" -type f -printf '%T@ %p\n' 2> /dev/null | sort -n | tail -1 | awk '{print $1}'` 56 | local -r PREREQ=`find "$2" -type f -printf '%T@ %p\n' 2> /dev/null | sort -n | tail -1 | awk '{print $1}'` 57 | # prerequsite or target don't exist, then return true 58 | if [ -z "$PREREQ" ] || [ -z "$TARGET" ]; then return 0; fi 59 | # prerequsite older than the target - return false 60 | if [[ "$PREREQ" > "$TARGET" ]]; then return 1; fi 61 | # prerequsite same age or younger than target - return true 62 | return 0 63 | } 64 | ############################################################################### 65 | ## 66 | ## Purpose: 67 | ## Given a directory, recursively retrive all its subdirectories and 68 | ## create one long prerequsite line. The prerequsite includes all 69 | ## nonempty directories and their associated files via the wildcard, 70 | ## '*', specification. 71 | ## 72 | ## Input: 73 | ## $1 - Directory to recurse and return all other directories. 74 | ## 75 | ## Output: 76 | ## When Successful: 77 | ## A single line of all nonempty subdirectories appended with wildcard. 78 | ## When Failure: 79 | ## Issue message to STDERR and return "BuildContextEmpty" as a prerequsite 80 | ## via STDOUT. 81 | ## 82 | ############################################################################### 83 | function DirectoryRecurse () { 84 | local dirPathList 85 | local fileEntry 86 | if [ -z "$(ls -A "$1")" ]; then 87 | ScriptError "Empty build context: '$1'. Needs at least 'Dockerfile'." 88 | # generate a prerequsite that references a target that will result in 89 | # a failure detected by make. 90 | echo "BuildContextEmpty" 91 | return 1 92 | fi 93 | # use while - read instead of for loop because file name can contain spaces. 94 | # However, newlines in file names will break this code. 95 | while read fileEntry; do 96 | # Escape spaces in the directory name. Vaccinates make from spaces within 97 | # prequsite names. 98 | fileEntry="${fileEntry// /\\ }" 99 | # include a reference to the directory, as a change to it may reflect 100 | # a deletion of a subdirectory or file that would not be detected by 101 | # simply including its contents appending '/*' wildcard. 102 | dirPathList+="$fileEntry " 103 | # An empty directory causes make to fail as it doesn't know how to build 104 | # nothing, therefore, if a directory is empty ignore it. 105 | if [ -z "$(ls -A $fileEntry)" ]; then continue; fi 106 | # Include all the current directory's files as prerequsites. 107 | dirPathList+="$fileEntry/* " 108 | done < <( find "$1" -type d ) 109 | echo "$dirPathList" 110 | return 0 111 | } 112 | ############################################################################### 113 | ## 114 | ## Purpose: 115 | ## Encapsulates shell methods used within the makefile layer to manage 116 | ## its abstractions/concepts. 117 | ## 118 | ## Input: 119 | ## $1 - Method name. 120 | ## $2-$N - Method argument list. 121 | ## 122 | ############################################################################### 123 | case "$1" in 124 | ContextTargetGen) ContextTargetGen "$2" "$3" "$4" ;; 125 | TimeStampTripIs) TimeStampTripIs "$2" "$3" ;; 126 | DirectoryRecurse) DirectoryRecurse "$2" ;; 127 | *) ScriptUnwind "$LINENO" "Unknown method specified: '$1'" ;; 128 | esac 129 | exit $?; 130 | ############################################################################### 131 | # 132 | # The MIT License (MIT) 133 | # Copyright (c) 2014-2015 Richard Moyse License@Moyse.US 134 | # 135 | # Permission is hereby granted, free of charge, to any person obtaining a copy 136 | # of this software and associated documentation files (the "Software"), to deal 137 | # in the Software without restriction, including without limitation the rights 138 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 139 | # copies of the Software, and to permit persons to whom the Software is 140 | # furnished to do so, subject to the following conditions: 141 | # The above copyright notice and this permission notice shall be included in 142 | # all copies or substantial portions of the Software. 143 | # 144 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 145 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 146 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 147 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 148 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 149 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 150 | # THE SOFTWARE. 151 | # 152 | ############################################################################### 153 | # 154 | # Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. 155 | # in the United States and/or other countries. Docker, Inc. and other parties 156 | # may also have trademark rights in other terms used herein. 157 | # 158 | ############################################################################### 159 | -------------------------------------------------------------------------------- /scriptInstall/dlwLogin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # 4 | # Purpose: 5 | # Ehance the typical login process to adapt the 'dlw' container account's 6 | # UID and GID list so it matches/extends the external ones provided when the 7 | # container was initially created (docker create/run). 8 | # 9 | # Inputs: 10 | # 1. ASSUME_UID - Environment variable potentially set with external 11 | # account's (account outside container) UID during 12 | # 'docker run/create' 13 | # 2. ASSUME_GID_LIST - Environment variable potentially set with external 14 | # account's (account outside container) GID list during 15 | # 'docker run/create' 16 | # 17 | ############################################################################### 18 | if ! [ -e "${BASH_SOURCE[0]}.FirstTimeCompleted" ]; then 19 | userUID_GID_Reassign.sh 'dlw' "$ASSUME_UID" "$ASSUME_GID_LIST" 20 | touch "${BASH_SOURCE[0]}.FirstTimeCompleted" 21 | fi 22 | login dlw 23 | -------------------------------------------------------------------------------- /scriptInstall/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # 4 | # Purpose: 5 | # Generic install script to facilitate encoding package installs. 6 | # 7 | # Input: 8 | # $1 - Package name. 9 | # 10 | ############################################################################### 11 | if [ -z "$1" ]; then echo "Error: ${FUNCNAME}: Expects package name as first argument.">&2; fi 12 | # Script is coupled with versionSpecifiers.sh to load environment 13 | # variables that specify the package's version. 14 | source versionSpecifiers.sh 15 | # Certain installs may require preprocessing to prepare the package library 16 | # for their inclusion. 17 | if which "installPrep_${1}.sh"; then 18 | if ! "installPrep_${1}.sh"; then exit 1; fi 19 | fi 20 | # Use a simple mapping function to associate a package name to its version 21 | # environment variable value. 22 | # Translate package name characters that aren't valid for environment variable 23 | # names. 24 | EVIRONMENT_NAME_SUFFIX=$( echo "$1" | sed 's/[^a-zA-Z0-9]/_/g' ) 25 | eval COMPONENT_VERSION_SPEC=\"\$VERSION_${EVIRONMENT_NAME_SUFFIX}\" 26 | # execute the install 27 | apt-get install -y ${1}${COMPONENT_VERSION_SPEC} 28 | 29 | 30 | -------------------------------------------------------------------------------- /scriptInstall/installPackages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # 4 | # Purpose: 5 | # Install provided list of packages. 6 | # 7 | # Input: 8 | # $1-N - Package names to install 9 | # 10 | # Output: 11 | # When failure: 12 | # Either the error code from failed install process or rm failure code 13 | # 14 | ############################################################################### 15 | SCRIPT_DIR_INSTALLATION="`dirname "${BASH_SOURCE[0]}"`" 16 | # Resolve helper script names within same install directory of this module 17 | # before searching rest of the path. 18 | PATH=$SCRIPT_DIR_INSTALLATION:$PATH 19 | # Initialize ubuntu distribution library list 20 | apt-get update 21 | while [ "$#" -gt '0' ]; do 22 | # execute an install for package listed as an argument 23 | if ! install.sh "$1"; then exit; fi 24 | shift 25 | done 26 | 27 | 28 | -------------------------------------------------------------------------------- /scriptInstall/installPrep_docker-engine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # 4 | # Purpose: Install Docker Daemon from ubuntu distribution libraries. 5 | # 6 | ############################################################################### 7 | # Install secure protocol to enable secure package updates. 8 | install.sh 'apt-transport-https' 9 | # Install docker package key and distribution directory. 10 | if ! apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D; then exit 1; fi 11 | if ! sh -c "echo deb https://apt.dockerproject.org/repo ubuntu-precise main > /etc/apt/sources.list.d/docker.list"; then exit 1; fi 12 | if ! apt-get update; then exit 1; fi 13 | 14 | -------------------------------------------------------------------------------- /scriptInstall/installPrep_tmux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # 4 | # Purpose: Add very recent percise backported version of tmux 5 | # 6 | ############################################################################### 7 | # attepted to use trusted precise backported version but couldn't get it wwork. 8 | # this untrusted ppa made it easily possible. 9 | echo 'deb http://ppa.launchpad.net/pi-rho/dev/ubuntu precise main '>>/etc/apt/sources.list 10 | echo 'deb-src http://ppa.launchpad.net/pi-rho/dev/ubuntu precise main'>>/etc/apt/sources.list 11 | if ! apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 779C27D7; then exit 1; fi 12 | if ! apt-get update; then exit 1; fi 13 | 14 | -------------------------------------------------------------------------------- /scriptInstall/installUser_dlw.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # 4 | # Purpose: 5 | # Provide username, password, and group settings for dlw user. 6 | # 7 | # Input: 8 | # $1 - Request name. 9 | # 10 | # Output: 11 | # When failure: 12 | # Either the error code from failed install process or rm failure code 13 | # 14 | ############################################################################### 15 | if [ "$1" == 'adduser' ]; then 16 | echo '--disabled-password --gecos -- dlw' 17 | elif [ "$1" == 'passwd' ]; then 18 | # Remove password for dlw. 19 | echo '-d dlw' 20 | elif [ "$1" == 'gpasswd' ]; then 21 | # Associate dlw to docker group to enable dlw execution without specifying 'sudo'. 22 | echo '-a dlw docker' 23 | else 24 | echo "Error: $0: Argument value: '$1' not supported." 25 | exit 1 26 | fi 27 | exit 0 28 | 29 | -------------------------------------------------------------------------------- /scriptInstall/installUsers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # 4 | # Purpose: 5 | # Install one or more users. 6 | # 7 | # Input: 8 | # $1-N - Names of users to install/ 9 | # 10 | ############################################################################### 11 | SCRIPT_DIR_INSTALLATION="`dirname "${BASH_SOURCE[0]}"`" 12 | # Resolve helper script names within same install directory of this module 13 | # before searching rest of the path. 14 | PATH=$SCRIPT_DIR_INSTALLATION:$PATH 15 | while [ "$#" -gt '0' ]; do 16 | # Ensure specific user setup script available 17 | if ! which "installUser_${1}.sh"; then 18 | echo "Error: $0: Missing user configuration script: 'installUser_${1}.sh'." 19 | exit 1 20 | fi 21 | addOpts="$(installUser_${1}.sh 'adduser')" 22 | if [ "$?" -ne '0' ]; then exit 1; fi 23 | if ! adduser $addOpts; then exit 1; fi 24 | passwdOpts="$(installUser_${1}.sh 'passwd')" 25 | if [ "$?" -ne '0' ]; then exit 1; fi 26 | if ! passwd $passwdOpts; then exit 1; fi 27 | while read groupList; do 28 | if ! gpasswd $groupList; then exit 1; fi 29 | done < <( if ! installUser_${1}.sh 'gpasswd'; then exit 1; fi ) 30 | shift 31 | done 32 | 33 | exit 0 34 | 35 | -------------------------------------------------------------------------------- /scriptInstall/userUID_GID_Reassign.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # 4 | # Purpose: 5 | # Adapt a container account's UID and GID list so it matches/extends the 6 | # ones assigned to an external account provided when the container was 7 | # initially created (docker create/run). This allows a container account 8 | # to present the identity associated to the external one so it can assume 9 | # the same read and write permissions to the host directories/files exposed 10 | # to the container via docker volume mount (-v). Avoids having to manually 11 | # set host ACL lists to permit container account to access host 12 | # file/directories. 13 | # 14 | # Inputs: 15 | # 1. $1 - Static container username whose UID/GID list will be adapted 16 | # to assume the external account's permissions. 17 | # 1. $2 - UID of external account. 18 | # 2. $3 - GID list for external account. 19 | # 20 | ############################################################################### 21 | function main () { 22 | declare -r user_name="$1" 23 | declare -r UID_new="$2" 24 | declare -r GID_list="$3" 25 | if [ -n "$UID_new" ]; then 26 | UIDadapt "$user_name" "$UID_new" 27 | fi 28 | if [ -n "$GID_list" ]; then 29 | GIDadapt "$user_name" "$GID_list" 30 | fi 31 | } 32 | ############################################################################### 33 | # 34 | # Purpose: 35 | # Adapt the statically defined container account to reflect the 36 | # UID specified when creating the container from its image. This will 37 | # currently permit processes running within the container to mimic the 38 | # UID specified when the container was created from its image. This allows 39 | # processes within the container to access the same set of files, via owner 40 | # permissions, for the provided UID. 41 | # 42 | # Assumes: 43 | # > If it is called more than once, all calls must provide same external 44 | # account UID, otherwise, the container's primary GID will most likely 45 | # be 'forgotten', preventing access to the container's account's 46 | # files created when generating the image. 47 | # 48 | # Inputs: 49 | # 1. $1 - The textual linux account name defined within the container 50 | # that will assume the UID of the external account. 51 | # 2. $2 - The UID of the external account specified during docker create/run. 52 | # 53 | ############################################################################### 54 | function UIDadapt () { 55 | declare -r user_name="$1" 56 | declare -r UID_new="$2" 57 | 58 | declare -r UID_original="`id -u "$user_name"`" 59 | if [ "$UID_original" == "$UID_new" ]; then 60 | # Existing container UID identical to the one we want to assume 61 | # :: existing UNIX ACLs do not require adjustment. 62 | return 0 63 | fi 64 | # Must adapt container account UID to honor its current group ACLs, 65 | # and change its UID so it assumes the same identity as the privided UID 66 | if ! usermod -u $UID_new "$user_name"; then Abort $LINENO "Failed to update container UID from: '$UID_original' to: '$UID_new' for user: '$user_name'"; fi 67 | } 68 | ############################################################################### 69 | # 70 | # Purpose: 71 | # Adapt the statically defined container account to assume an extended GID 72 | # set including the initial container account GIDs and GIDs specified 73 | # for the eternal account. The set union operator implements extending 74 | # the container account's GID set, so processes started 75 | # by the container account within the container can continue to 76 | # access resources created during image generation, and when these container 77 | # processes attempt to access external resources made available to 78 | # the container, that they will be able to do so. 79 | # 80 | # Assumes: 81 | # > Since the GID's betweeen the container and enternal environment aren't 82 | # correlated and this function generates a composite GID set for 83 | # the account running in the container, this composite set will 84 | # potentially broaden access to resources both within the container 85 | # and those external to the container that was potentially restricted. 86 | # 87 | # Inputs: 88 | # 1. $1 - The textual linux account name defined within the container 89 | # that will assume the UID of the external account. 90 | # 2. $2 - The list of GIDs associated to the external account 91 | # specified during docker create/run. 92 | # 93 | ############################################################################### 94 | function GIDadapt () { 95 | declare user_name="$1" 96 | declare GID_list="$2" 97 | declare -A GID_map 98 | 99 | declare GID_primary_new 100 | declare GID 101 | for GID in $GID_list 102 | do 103 | if [ -z "$GID_primary_new" ]; then GID_primary_new="$GID"; fi 104 | GID_map[$GID]="$GID" 105 | # this external GID may or may not be in container /etc/groups, 106 | # add it and ignore overlaps. 107 | groupadd --gid $GID "$GID" >/dev/null 2>/dev/null 108 | done 109 | # include the already associated container GIDs in the combined set 110 | # and mark them as such. 111 | declare GID_name 112 | declare scan='true' 113 | for GID_name in $( groups "$user_name" ) 114 | do 115 | if $scan; then 116 | if [ "$GID_name" == ':' ]; then scan='false'; fi 117 | continue 118 | fi 119 | GID="`getent group "$GID_name" | cut -d: -f3`" 120 | if [ -z "$GID" ]; then Abort "$LINENO" "Failed to generate GID for group name: '$GID_name' associated to: '$user_name'."; fi 121 | GID_map[$GID]='ASSOCIATED' 122 | done 123 | # iterate over GIDs and add them to the container's account GID list if they haven't aleady been associated. 124 | declare key 125 | for key in "${!GID_map[@]}" 126 | do 127 | GID_name="${GID_map[$key]}" 128 | if [ "$GID_name" != 'ASSOCIATED' ]; then 129 | if ! usermod -a -G "$GID_name" -- "$user_name"; then Abort "$LINENO" "Adding external GID: '$key' to container account: '$user_name' failed."; fi 130 | fi 131 | done 132 | # first GID in list to become primary GID 133 | declare GID_primary_cur="`id -g -- "$user_name"`" 134 | if [ "$GID_primary_cur" != "$GID_primary_new" ]; then 135 | # need to remember name, not GID, of current primary group 136 | GID_primary_cur="`id -g -n -- "$user_name"`" 137 | if ! usermod --gid "$GID_primary_new" -- "$user_name"; then Abort "$LINENO" "Establishing external primary GID: '$GID_primary_new' for username: '$user_name' failed."; fi 138 | if ! usermod -a -G "$GID_primary_cur" -- "$user_name"; then Abort "$LINENO" "Adding container primary GID: '$GID_primary_cur' to container account: '$user_name' failed."; fi 139 | fi 140 | return 0 141 | } 142 | ############################################################################### 143 | # 144 | # Purpose: 145 | # Terminate this process writing abort message to STDERR. 146 | # 147 | # Inputs: 148 | # 1. $1 - Line number. 149 | # 2. $2 - Abort message. 150 | # 151 | ############################################################################### 152 | function Abort (){ 153 | echo "Abort: '$0', LineNo: '$1', Message: $2" >&2 154 | exit 1 155 | } 156 | ############################################################################### 157 | main "$@" 158 | -------------------------------------------------------------------------------- /scriptInstall/versionSpecifiers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | VERSION_apt_transport_https='=0.8.16~exp12ubuntu10.21' 3 | VERSION_lxc_docker='=1.8.1-0~precise' 4 | VERSION_make='=3.81-8.1ubuntu1.1' 5 | VERSION_tmux='=1.9a-1~ppa1~p' 6 | --------------------------------------------------------------------------------