pvincent
8 months ago
2 changed files with 136 additions and 0 deletions
@ -0,0 +1,105 @@ |
|||
#!/bin/bash |
|||
|
|||
function _read() { |
|||
return 0 |
|||
} |
|||
|
|||
function _create() { |
|||
echo "creating Stub instance for <$shortname> ... " |
|||
echo "initialize Stub $shortname $longname ... OK" |
|||
} |
|||
|
|||
function _update() { |
|||
echo "update" |
|||
} |
|||
|
|||
function _delete() { |
|||
echo "delete" |
|||
} |
|||
|
|||
function usage() { |
|||
echo "Usage: $COMMAND_NAME -c|r|u|d --port PORT --container CONTAINER --name NAME" |
|||
exit 2 |
|||
} |
|||
|
|||
### MAIN |
|||
|
|||
# init_strict |
|||
|
|||
COMMAND_NAME=$(basename "$0") |
|||
|
|||
# read the options |
|||
|
|||
TEMP=$(getopt -n "$COMMAND_NAME" -o crud --long port:,container:,name:,fqdn: -- "$@") |
|||
# shellcheck disable=SC2181 |
|||
[[ "$?" -eq 0 ]] || usage |
|||
eval set -- "$TEMP" |
|||
|
|||
action="unset" |
|||
port="unset" |
|||
container="unset" |
|||
shortname="unset" |
|||
longname="unset" |
|||
fqdn="unset" |
|||
|
|||
# extract options and their arguments into variables. |
|||
while true; do |
|||
case "$1" in |
|||
--port) |
|||
port=$2 |
|||
shift 2 |
|||
;; |
|||
--fqdn) |
|||
fqdn=$2 |
|||
shift 2 |
|||
;; |
|||
--container) |
|||
container=$2 |
|||
shift 2 |
|||
;; |
|||
--name) |
|||
shortname=$2 |
|||
longname="cagettepei-$shortname" |
|||
shift 2 |
|||
;; |
|||
-c) |
|||
[[ "$action" == "unset" ]] || usage |
|||
action="_create" |
|||
shift 1 |
|||
;; |
|||
-r) |
|||
[[ "$action" == "unset" ]] || usage |
|||
action="_read" |
|||
shift 1 |
|||
;; |
|||
-u) |
|||
[[ "$action" == "unset" ]] || usage |
|||
action="_update" |
|||
shift 1 |
|||
;; |
|||
-d) |
|||
[[ "$action" == "unset" ]] || usage |
|||
action="_delete" |
|||
shift 1 |
|||
;; |
|||
--) |
|||
shift |
|||
break |
|||
;; |
|||
*) |
|||
echo "Internal error!" |
|||
exit 1 |
|||
;; |
|||
esac |
|||
done |
|||
|
|||
[[ |
|||
"$action" != unset && |
|||
"$port" != unset && |
|||
"$container" != unset && |
|||
"$fqdn" != unset && |
|||
"$shortname" != unset ]] || usage |
|||
|
|||
. "$MIAOU_BASEDIR/lib/init.sh" |
|||
|
|||
$action |
@ -0,0 +1,31 @@ |
|||
#!/bin/bash |
|||
|
|||
### CHECK |
|||
|
|||
function check() { |
|||
PREFIX="recipe:stub:check" |
|||
echo "container <$CONTAINER> approved successfully!" |
|||
} |
|||
|
|||
### INSTALL |
|||
|
|||
function install() { |
|||
PREFIX="recipe:stub:install" |
|||
: $PREFIX |
|||
|
|||
launch_container "$CONTAINER" |
|||
echo "initializing Stub ... " |
|||
PREFIX="" echo "OK" |
|||
} |
|||
|
|||
### MAIN |
|||
|
|||
. "$MIAOU_BASEDIR/lib/init.sh" |
|||
|
|||
arg1_required "$@" |
|||
readonly CONTAINER="$1" |
|||
|
|||
check || ( |
|||
install |
|||
check |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue