discourse
This commit is contained in:
Executable
+111
@@ -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
|
||||||
Executable
+35
@@ -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
|
||||||
|
)
|
||||||
+2
-2
@@ -140,7 +140,7 @@ function expand_conf() {
|
|||||||
index=0
|
index=0
|
||||||
for i in "${services[@]}"; do
|
for i in "${services[@]}"; do
|
||||||
read -r -a item <<<"$i"
|
read -r -a item <<<"$i"
|
||||||
exp=${item[7]}
|
exp=${item[-1]} # the last item
|
||||||
if [[ "$exp" == true ]]; then
|
if [[ "$exp" == true ]]; then
|
||||||
domain=${item[0]}
|
domain=${item[0]}
|
||||||
subdomain=${item[1]}
|
subdomain=${item[1]}
|
||||||
@@ -284,7 +284,7 @@ function monit_show() {
|
|||||||
else
|
else
|
||||||
builtin echo -ne "${RED}✘${NC}"
|
builtin echo -ne "${RED}✘${NC}"
|
||||||
fi
|
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
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,14 @@ server {
|
|||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "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' %}
|
{%- if target != 'prod' %}
|
||||||
|
|
||||||
include snippets/banner_{{ target }}.conf;
|
include snippets/banner_{{ target }}.conf;
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user