Browse Source

discourse

main
pvincent 1 month ago
parent
commit
bf90cbb28e
  1. 111
      recipes/discourse/crud.sh
  2. 35
      recipes/discourse/install.sh
  3. 4
      scripts/miaou
  4. 7
      templates/nginx/hosts.j2

111
recipes/discourse/crud.sh

@ -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
recipes/discourse/install.sh

@ -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
)

4
scripts/miaou

@ -140,7 +140,7 @@ function expand_conf() {
index=0
for i in "${services[@]}"; do
read -r -a item <<<"$i"
exp=${item[7]}
exp=${item[-1]} # the last item
if [[ "$exp" == true ]]; then
domain=${item[0]}
subdomain=${item[1]}
@ -284,7 +284,7 @@ function monit_show() {
else
builtin echo -ne "${RED}✘${NC}"
fi
printf "\t%10.10s\thttps://%-40s\thttp://%s\n" "$app" "$fqdn" "$container:$port"
printf "\t%16.16s\thttps://%-40s\thttp://%s\n" "$app" "$fqdn" "$container:$port"
done
}

7
templates/nginx/hosts.j2

@ -22,8 +22,15 @@ server {
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
{%- if services[service.domain][service.subdomain]['data']['nginx']['extra'] %}
# From ... data.nginx.extra
{{ services[service.domain][service.subdomain]['data']['nginx']['extra'] }}
{%- endif %}
{%- if target != 'prod' %}
include snippets/banner_{{ target }}.conf;
{%- endif %}
}

Loading…
Cancel
Save