discourse OK
This commit is contained in:
+5
-13
@@ -432,20 +432,12 @@ function launch_container() {
|
|||||||
arg1_required "$@"
|
arg1_required "$@"
|
||||||
local ct="$1"
|
local ct="$1"
|
||||||
if ! container_exists "$ct"; then
|
if ! container_exists "$ct"; then
|
||||||
echo "container <$ct> about to be created ..."
|
echo -e "container <$ct> about to be created ..."
|
||||||
local extra_release="${2:-}"
|
|
||||||
if [[ -n "$extra_release" ]] && ! lxc image info "${extra_release}-miaou" >/dev/null; then
|
|
||||||
echoerrn "unknown extra_release <${extra_release}-miaou>!\nHINT : please add it into /etc/miaou/defaults.yaml, then re-install miaou!"
|
|
||||||
exit 128
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "$extra_release" ]]; then
|
# shellcheck disable=SC2068
|
||||||
echoerrn "FIXME: lxc-miaou-create -o release=bookworm should be implemented ...."
|
lxc-miaou-create "$ct" ${@:2}
|
||||||
lxc-miaou-create "$ct" "$extra_release"
|
|
||||||
else
|
PREFIX="" echo "DONE"
|
||||||
lxc-miaou-create "$ct"
|
|
||||||
fi
|
|
||||||
echo "DONE"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! container_running "$ct"; then
|
if ! container_running "$ct"; then
|
||||||
|
|||||||
+21
-20
@@ -17,19 +17,6 @@ function _create() {
|
|||||||
echo "creating discourse instance for <$shortname> ... "
|
echo "creating discourse instance for <$shortname> ... "
|
||||||
echo "initialize discourse $shortname $longname ... OK"
|
echo "initialize discourse $shortname $longname ... OK"
|
||||||
|
|
||||||
admin_username=$(load_yaml_from_expanded services[\""$domain"\"][\""$subdomain"\"].data.admin.username)
|
|
||||||
admin_email=$(load_yaml_from_expanded services[\""$domain"\"][\""$subdomain"\"].data.admin.email)
|
|
||||||
admin_password=$(load_yaml_from_expanded services[\""$domain"\"][\""$subdomain"\"].data.admin.password)
|
|
||||||
redis_password=$(load_yaml_from_expanded credential.redis)
|
|
||||||
|
|
||||||
mkdir -p "$MIAOU_CONFIGDIR/apps/discourse"
|
|
||||||
APP_REDIS_PASSWORD=$redis_password APP_DOMAIN=$domain APP_SUBDOMAIN=$subdomain APP_FQDN=$fqdn APP_PORT=$port APP_NAME=$longname 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"
|
|
||||||
|
|
||||||
echo "copying files to container <$container> ... "
|
|
||||||
lxc file push --uid 0 --gid 0 "$MIAOU_CONFIGDIR/apps/discourse/$longname.yml" "$container/var/discourse/containers/$longname.yml"
|
|
||||||
echo "copying files to container <$container> ... OK"
|
|
||||||
|
|
||||||
if ! (db-psql list | grep -q "$longname"); then
|
if ! (db-psql list | grep -q "$longname"); then
|
||||||
echo "create empty database <$longname> ... "
|
echo "create empty database <$longname> ... "
|
||||||
db-psql create "$longname"
|
db-psql create "$longname"
|
||||||
@@ -40,14 +27,28 @@ function _create() {
|
|||||||
echo "database already exists!"
|
echo "database already exists!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
admin_username=$(load_yaml_from_expanded services[\""$domain"\"][\""$subdomain"\"].data.admin.username)
|
||||||
|
admin_email=$(load_yaml_from_expanded services[\""$domain"\"][\""$subdomain"\"].data.admin.email)
|
||||||
|
admin_password=$(load_yaml_from_expanded services[\""$domain"\"][\""$subdomain"\"].data.admin.password)
|
||||||
|
redis_password=$(load_yaml_from_expanded credential.redis)
|
||||||
|
|
||||||
|
mkdir -p "$MIAOU_CONFIGDIR/apps/discourse"
|
||||||
|
APP_REDIS_PASSWORD=$redis_password APP_DOMAIN=$domain APP_SUBDOMAIN=$subdomain APP_FQDN=$fqdn APP_PORT=$port APP_NAME=$longname 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" >/dev/null
|
||||||
|
echo "creating templates ... OK"
|
||||||
|
|
||||||
|
echo "copying files to container <$container> ... "
|
||||||
|
lxc file push --uid 0 --gid 0 --mode 600 "$MIAOU_CONFIGDIR/apps/discourse/$longname.yml" "$container/var/discourse/containers/$longname.yml"
|
||||||
|
echo "copying files to container <$container> ... OK"
|
||||||
|
|
||||||
|
console="u=User.create_with(email: '$admin_email', password: '$admin_password').find_or_initialize_by(username: '$admin_username'); u.save; u.activate"
|
||||||
|
# console="puts User.count"
|
||||||
|
activate_admin="rails runner \"$console\""
|
||||||
|
|
||||||
echo "build docker container $longname ..."
|
echo "build docker container $longname ..."
|
||||||
lxc exec "$container" -- bash <<EOF
|
lxc exec "$container" -- /var/discourse/launcher rebuild "$longname"
|
||||||
set -Eeuo pipefail
|
|
||||||
cd /var/discourse
|
echo "initialize admin user <$admin_username>"
|
||||||
./launcher rebuild $longname
|
lxc exec "$container" -- /var/discourse/launcher run "$longname" "$activate_admin"
|
||||||
command='u=User.create_with(email: "$admin_email", password: "$admin_password").find_or_initialize_by(username: "$admin_username"); u.save; u.activate'
|
|
||||||
./launcher run $longname "rails runner '\$command'"
|
|
||||||
EOF
|
|
||||||
echo "initialize discourse $longname ... OK"
|
echo "initialize discourse $longname ... OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ function check() {
|
|||||||
|
|
||||||
container_exists "$CONTAINER" || return 1
|
container_exists "$CONTAINER" || return 1
|
||||||
container_running "$CONTAINER" || return 2
|
container_running "$CONTAINER" || return 2
|
||||||
|
var_discourse_exists "$CONTAINER" || return 3
|
||||||
|
}
|
||||||
|
|
||||||
|
function var_discourse_exists() {
|
||||||
|
container="$1"
|
||||||
|
lxc exec "$container" -- test -d /var/discourse/containers
|
||||||
}
|
}
|
||||||
|
|
||||||
### INSTALL
|
### INSTALL
|
||||||
@@ -15,8 +21,21 @@ function install() {
|
|||||||
PREFIX="recipe:discourse:install"
|
PREFIX="recipe:discourse:install"
|
||||||
: $PREFIX
|
: $PREFIX
|
||||||
|
|
||||||
launch_container "$CONTAINER"
|
launch_container "$CONTAINER" "-o nesting"
|
||||||
echo "initializing discourse ... "
|
echo "initializing discourse ... "
|
||||||
|
lxc exec "$CONTAINER" -- bash <<EOF
|
||||||
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
|
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
|
||||||
|
chmod a+r /etc/apt/keyrings/docker.asc
|
||||||
|
echo \
|
||||||
|
"deb [arch=\$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
|
||||||
|
\$(. /etc/os-release && echo "\$VERSION_CODENAME") stable" | \
|
||||||
|
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
apt update
|
||||||
|
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||||
|
mkdir /var/discourse
|
||||||
|
git clone https://github.com/discourse/discourse_docker.git /var/discourse
|
||||||
|
EOF
|
||||||
PREFIX="" echo "OK"
|
PREFIX="" echo "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ function _create() {
|
|||||||
db-psql create "$longname"
|
db-psql create "$longname"
|
||||||
echo "create empty database <$longname> ... OK"
|
echo "create empty database <$longname> ... OK"
|
||||||
|
|
||||||
admin_username=$(cat "$data" | yq '.admin.username')
|
admin_username=$(echo -e "$data" | yq '.admin.username')
|
||||||
[[ $admin_username == 'null ' ]] && echoerr "odoo12 recipe requires \`data:admin:username\` into miaou.yaml service definition of <$fqdn>" && exit 1
|
[[ $admin_username == 'null ' ]] && echoerr "odoo12 recipe requires \`data:admin:username\` into miaou.yaml service definition of <$fqdn>" && exit 1
|
||||||
|
|
||||||
admin_password=$(cat "$data" | yq '.admin.password')
|
admin_password=$(echo -e "$data" | yq '.admin.password')
|
||||||
[[ $admin_password == 'null ' ]] && echoerr "odoo12 recipe requires \`data:admin:password\` into miaou.yaml service definition of <$fqdn>" && exit 1
|
[[ $admin_password == 'null ' ]] && echoerr "odoo12 recipe requires \`data:admin:password\` into miaou.yaml service definition of <$fqdn>" && exit 1
|
||||||
|
|
||||||
cat <<EOF | lxc_exec "$container"
|
cat <<EOF | lxc_exec "$container"
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ EOF
|
|||||||
db-psql create "$longname"
|
db-psql create "$longname"
|
||||||
echo "create empty database <$longname> ... OK"
|
echo "create empty database <$longname> ... OK"
|
||||||
|
|
||||||
admin_username=$(cat "$data" | yq '.admin.username')
|
admin_username=$(echo -e "$data" | yq '.admin.username')
|
||||||
[[ $admin_username == 'null ' ]] && echoerr "odoo12 recipe requires \`data:admin:username\` into miaou.yaml service definition of <$fqdn>" && exit 1
|
[[ $admin_username == 'null ' ]] && echoerr "odoo12 recipe requires \`data:admin:username\` into miaou.yaml service definition of <$fqdn>" && exit 1
|
||||||
|
|
||||||
admin_password=$(cat "$data" | yq '.admin.password')
|
admin_password=$(echo -e "$data" | yq '.admin.password')
|
||||||
[[ $admin_password == 'null ' ]] && echoerr "odoo12 recipe requires \`data:admin:password\` into miaou.yaml service definition of <$fqdn>" && exit 1
|
[[ $admin_password == 'null ' ]] && echoerr "odoo12 recipe requires \`data:admin:password\` into miaou.yaml service definition of <$fqdn>" && exit 1
|
||||||
|
|
||||||
cat <<EOF | lxc_exec "$container"
|
cat <<EOF | lxc_exec "$container"
|
||||||
|
|||||||
Reference in New Issue
Block a user