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

6 months ago
  1. #!/bin/bash
  2. function _read() {
  3. return 0
  4. }
  5. function _create() {
  6. echo "creating Stub instance for <$shortname> ... "
  7. echo "initialize Stub $shortname $longname ... OK"
  8. }
  9. function _update() {
  10. echo "update"
  11. }
  12. function _delete() {
  13. echo "delete"
  14. }
  15. function usage() {
  16. echo "Usage: $COMMAND_NAME -c|r|u|d --port PORT --container CONTAINER --name NAME"
  17. exit 2
  18. }
  19. ### MAIN
  20. # init_strict
  21. COMMAND_NAME=$(basename "$0")
  22. # read the options
  23. TEMP=$(getopt -n "$COMMAND_NAME" -o crud --long port:,container:,name:,fqdn: -- "$@")
  24. # shellcheck disable=SC2181
  25. [[ "$?" -eq 0 ]] || usage
  26. eval set -- "$TEMP"
  27. action="unset"
  28. port="unset"
  29. container="unset"
  30. shortname="unset"
  31. longname="unset"
  32. fqdn="unset"
  33. # extract options and their arguments into variables.
  34. while true; do
  35. case "$1" in
  36. --port)
  37. port=$2
  38. shift 2
  39. ;;
  40. --fqdn)
  41. fqdn=$2
  42. shift 2
  43. ;;
  44. --container)
  45. container=$2
  46. shift 2
  47. ;;
  48. --name)
  49. shortname=$2
  50. longname="cagettepei-$shortname"
  51. shift 2
  52. ;;
  53. -c)
  54. [[ "$action" == "unset" ]] || usage
  55. action="_create"
  56. shift 1
  57. ;;
  58. -r)
  59. [[ "$action" == "unset" ]] || usage
  60. action="_read"
  61. shift 1
  62. ;;
  63. -u)
  64. [[ "$action" == "unset" ]] || usage
  65. action="_update"
  66. shift 1
  67. ;;
  68. -d)
  69. [[ "$action" == "unset" ]] || usage
  70. action="_delete"
  71. shift 1
  72. ;;
  73. --)
  74. shift
  75. break
  76. ;;
  77. *)
  78. echo "Internal error!"
  79. exit 1
  80. ;;
  81. esac
  82. done
  83. [[
  84. "$action" != unset &&
  85. "$port" != unset &&
  86. "$container" != unset &&
  87. "$fqdn" != unset &&
  88. "$shortname" != unset ]] || usage
  89. . "$MIAOU_BASEDIR/lib/init.sh"
  90. $action