discourse

This commit is contained in:
pvincent
2024-10-09 08:58:11 +04:00
parent 68d0a2650c
commit bf90cbb28e
4 changed files with 155 additions and 2 deletions
+111
View File
@@ -0,0 +1,111 @@
#!/bin/bash
function _read() {
return 0
}
function _create() {
echo "creating discourse-docker instance for <$shortname> ... "
echo "initialize discourse-docker $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:,data: -- "$@")
# shellcheck disable=SC2181
[[ "$?" -eq 0 ]] || usage
eval set -- "$TEMP"
action="unset"
port="unset"
container="unset"
shortname="unset"
longname="unset"
fqdn="unset"
data="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
;;
--data)
data=$2
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 &&
"$data" != unset &&
"$shortname" != unset ]] || usage
. "$MIAOU_BASEDIR/lib/init.sh"
$action
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
### CHECK
function check() {
PREFIX="recipe:discourse:check"
container_exists "$CONTAINER" || return 1
container_running "$CONTAINER" || return 2
echo "container <$CONTAINER> approved successfully!"
}
### INSTALL
function install() {
PREFIX="recipe:discourse:install"
: $PREFIX
launch_container "$CONTAINER"
echo "initializing discourse ... "
PREFIX="" echo "OK"
}
### MAIN
. "$MIAOU_BASEDIR/lib/init.sh"
arg1_required "$@"
readonly CONTAINER="$1"
check || (
install
check
)