provisioning tool for building opinionated architecture
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

105 lines
1.8 KiB

#!/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