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.

111 lines
1.9 KiB

1 month ago
  1. #!/bin/bash
  2. function _read() {
  3. return 0
  4. }
  5. function _create() {
  6. echo "creating discourse-docker instance for <$shortname> ... "
  7. echo "initialize discourse-docker $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:,data: -- "$@")
  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. data="unset"
  34. # extract options and their arguments into variables.
  35. while true; do
  36. case "$1" in
  37. --port)
  38. port=$2
  39. shift 2
  40. ;;
  41. --fqdn)
  42. fqdn=$2
  43. shift 2
  44. ;;
  45. --container)
  46. container=$2
  47. shift 2
  48. ;;
  49. --name)
  50. shortname=$2
  51. longname="cagettepei-$shortname"
  52. shift 2
  53. ;;
  54. --data)
  55. data=$2
  56. shift 2
  57. ;;
  58. -c)
  59. [[ "$action" == "unset" ]] || usage
  60. action="_create"
  61. shift 1
  62. ;;
  63. -r)
  64. [[ "$action" == "unset" ]] || usage
  65. action="_read"
  66. shift 1
  67. ;;
  68. -u)
  69. [[ "$action" == "unset" ]] || usage
  70. action="_update"
  71. shift 1
  72. ;;
  73. -d)
  74. [[ "$action" == "unset" ]] || usage
  75. action="_delete"
  76. shift 1
  77. ;;
  78. --)
  79. shift
  80. break
  81. ;;
  82. *)
  83. echo "Internal error!"
  84. exit 1
  85. ;;
  86. esac
  87. done
  88. [[
  89. "$action" != unset &&
  90. "$port" != unset &&
  91. "$container" != unset &&
  92. "$fqdn" != unset &&
  93. "$data" != unset &&
  94. "$shortname" != unset ]] || usage
  95. . "$MIAOU_BASEDIR/lib/init.sh"
  96. $action