domain + subdomain

This commit is contained in:
pvincent
2024-10-09 11:38:59 +04:00
parent 5ac2e4842d
commit ac7268731a
10 changed files with 179 additions and 28 deletions
+33 -9
View File
@@ -1,12 +1,26 @@
#!/bin/bash
function check_service_running() {
lxc exec "$container" -- bash -c "docker ps --format {{.Names}} | grep $1"
}
function _read() {
disable_trace
check_db_postgres_exists "$longname"
check_container "$container"
check_service_running "$shortname"
enable_trace
return 0
}
function _create() {
echo "creating discourse-docker instance for <$shortname> ... "
echo "initialize discourse-docker $shortname $longname ... OK"
echo "creating discourse instance for <$shortname> ... "
echo "initialize discourse $shortname $longname ... OK"
mkdir -p "$MIAOU_CONFIGDIR/apps/discourse"
APP_DOMAIN=$domain APP_SUBDOMAIN=$subdomain APP_FQDN=$fqdn APP_PORT=$port APP_NAME=$shortname tera -e --env-key env -t "$MIAOU_BASEDIR/templates/apps/discourse/forum.yml.j2" -o "$MIAOU_CONFIGDIR/apps/discourse/$longname.yml" "$MIAOU_CONFIGDIR/miaou.expanded.yaml"
echo "creating templates ... OK"
}
function _update() {
@@ -25,12 +39,12 @@ function usage() {
### MAIN
# init_strict
source "$(dirname "$0")/../base/common.sh"
COMMAND_NAME=$(basename "$0")
# read the options
TEMP=$(getopt -n "$COMMAND_NAME" -o crud --long port:,container:,name:,fqdn:,data: -- "$@")
TEMP=$(getopt -n "$COMMAND_NAME" -o crud --long port:,container:,name:,fqdn:,domain:,subdomain:,data: -- "$@")
# shellcheck disable=SC2181
[[ "$?" -eq 0 ]] || usage
eval set -- "$TEMP"
@@ -41,7 +55,8 @@ container="unset"
shortname="unset"
longname="unset"
fqdn="unset"
data="unset"
domain="unset"
subdomain="unset"
# extract options and their arguments into variables.
while true; do
@@ -60,11 +75,19 @@ while true; do
;;
--name)
shortname=$2
longname="cagettepei-$shortname"
longname="discourse-$shortname"
shift 2
;;
--domain)
domain=$2
shift 2
;;
--subdomain)
subdomain=$2
shift 2
;;
--data)
data=$2
# don't care
shift 2
;;
-c)
@@ -92,7 +115,7 @@ while true; do
break
;;
*)
echo "Internal error!"
echoerr "Internal error: unrecognized option: <$1>"
exit 1
;;
esac
@@ -103,7 +126,8 @@ done
"$port" != unset &&
"$container" != unset &&
"$fqdn" != unset &&
"$data" != unset &&
"$domain" != unset &&
"$subdomain" != unset &&
"$shortname" != unset ]] || usage
. "$MIAOU_BASEDIR/lib/init.sh"