Compare commits
1 Commits
f2143633c5
...
4d0220f129
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d0220f129 |
@@ -75,6 +75,7 @@ EOF
|
|||||||
|
|
||||||
# Unset vars
|
# Unset vars
|
||||||
unset _array
|
unset _array
|
||||||
|
declare -a _quiet=(">" "/dev/null" "2>&1")
|
||||||
|
|
||||||
# Parse input and set switches using getopt
|
# Parse input and set switches using getopt
|
||||||
if _input=$(getopt -o +c:i:r:a:ndsh -l container:,image:,release:,ephemeral,recreate,no-sh,debug,array:,silent,help -- "$@"); then
|
if _input=$(getopt -o +c:i:r:a:ndsh -l container:,image:,release:,ephemeral,recreate,no-sh,debug,array:,silent,help -- "$@"); then
|
||||||
@@ -101,6 +102,7 @@ EOF
|
|||||||
;;
|
;;
|
||||||
--debug)
|
--debug)
|
||||||
_debug="true"
|
_debug="true"
|
||||||
|
unset _quiet
|
||||||
echo "Debugging on!"
|
echo "Debugging on!"
|
||||||
;;
|
;;
|
||||||
--array|-a)
|
--array|-a)
|
||||||
@@ -141,8 +143,6 @@ EOF
|
|||||||
declare -a _cmd_array
|
declare -a _cmd_array
|
||||||
_program="$1"
|
_program="$1"
|
||||||
_cmd_array=("$@")
|
_cmd_array=("$@")
|
||||||
|
|
||||||
[[ -n $_debug ]] && echo "_cmd_array:" "${_cmd_array[@]}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -153,6 +153,8 @@ EOF
|
|||||||
if [[ -z $_no_sh ]]; then
|
if [[ -z $_no_sh ]]; then
|
||||||
_cmd_array=("sh" "-c" "${_cmd_array[@]}")
|
_cmd_array=("sh" "-c" "${_cmd_array[@]}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[[ -n $_debug ]] && echo "_cmd_array:" "${_cmd_array[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -164,11 +166,20 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_toolboxCreate () {
|
||||||
|
|
||||||
|
_runDebug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
|
toolbox create -c "$_cname" "${_image[@]}" "${_release[@]}" "${_quiet[@]}"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_toolboxRemove () {
|
_toolboxRemove () {
|
||||||
|
|
||||||
_runDebug "${FUNCNAME[0]}"
|
_runDebug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
toolbox rm "$_cname"
|
toolbox rm "$_cname" "${_quiet[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -180,14 +191,6 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_toolboxCreate () {
|
|
||||||
|
|
||||||
_runDebug "${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
toolbox create -c "$_cname" "${_image[@]}" "${_release[@]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
__main () {
|
__main () {
|
||||||
|
|
||||||
# Get input
|
# Get input
|
||||||
@@ -201,15 +204,18 @@ EOF
|
|||||||
|
|
||||||
# Check if container exists
|
# Check if container exists
|
||||||
if _toolboxExists; then
|
if _toolboxExists; then
|
||||||
[[ -n $_recreate ]] && _toolboxRemove
|
if [[ -n $_recreate ]]; then # First remove container if --recreate
|
||||||
|
_toolboxRemove
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
_toolboxCreate
|
_toolboxCreate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_toolboxRun
|
_toolboxRun
|
||||||
|
|
||||||
[[ -n $_ephemeral ]] && _toolboxRemove
|
if [[ -n $_ephemeral ]]; then
|
||||||
|
_toolboxRemove
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Allow this function to be executed directly
|
# Allow this function to be executed directly
|
||||||
|
|||||||
Reference in New Issue
Block a user