From 2bf828923845ca1be88fcf6f54db87844f07b09f Mon Sep 17 00:00:00 2001 From: pvincent Date: Mon, 26 Feb 2024 22:57:41 +0400 Subject: [PATCH] nested lxd wip1 --- lib/install.sh | 55 ++++++++++++++++++++++++---------- recipes/odoo12/crud.sh | 3 ++ scripts/lxc-miaou-create | 23 ++++++++++---- scripts/miaou | 5 ++++ templates/etc/defaults.yaml.j2 | 2 -- 5 files changed, 66 insertions(+), 22 deletions(-) diff --git a/lib/install.sh b/lib/install.sh index 9f43e29..f903976 100755 --- a/lib/install.sh +++ b/lib/install.sh @@ -47,14 +47,39 @@ function prepare_lxd { echo "bridge down, so initialization will use default preseed..." - empty_block_partition='' - if lsblk -o NAME,FSTYPE,GROUP --noheadings -p | grep -E ^.─ | grep disk; then - # FIXME: when nesting no DISK type partition found! + if [[ $(printenv container) == 'lxc' ]]; then + echo "nested configuration applying..." + cat < found implies it has been already initialized!" fi - set_alias 'sameuser' "exec @ARG1@ -- su --whitelist-environment container_hostname - $(whoami)" - set_alias 'login' 'exec @ARGS@ --mode interactive -- /bin/bash -c $@${user:-root} - exec su --whitelist-environment container_hostname - ' + set_alias 'sameuser' "exec @ARG1@ -- su --whitelist-environment container,container_hostname - $(whoami)" + set_alias 'login' 'exec @ARGS@ --mode interactive -- /bin/bash -c $@${user:-root} - exec su --whitelist-environment container,container_hostname - ' set_alias 'll' 'list -c ns4mDN' # test environment container hostname @@ -194,8 +220,7 @@ function check_credential { check_yaml_defined_value /etc/miaou/defaults.yaml 'credential.username' && check_yaml_defined_value /etc/miaou/defaults.yaml 'credential.shadow' && - check_yaml_defined_value /etc/miaou/defaults.yaml 'credential.email' && - check_yaml_defined_value /etc/miaou/defaults.yaml 'credential.password' + check_yaml_defined_value /etc/miaou/defaults.yaml 'credential.email' } diff --git a/recipes/odoo12/crud.sh b/recipes/odoo12/crud.sh index f4fd0a7..0309975 100755 --- a/recipes/odoo12/crud.sh +++ b/recipes/odoo12/crud.sh @@ -44,8 +44,11 @@ function _create() { db-psql create "$longname" echo "create empty database <$longname> ... OK" + #FIXME: load credential from data argument wth yq parsing!!! + credential_username=$(load_yaml_from_expanded credential.username) credential_password=$(load_yaml_from_expanded credential.password) + cat </dev/null '; do + attempt=$((attempt++)) + if [[ $attempt -gt $max_attempt ]]; then + echoerr "systemd unavailable after $(bc <<<"$max_attempt * $delay") seconds" + exit 1 + else + sleep $delay + fi + done if [[ "$OPTION_SAMEUSER" == true ]]; then if ! lxc exec "$CONTAINER" -- grep "$miaou_user" /etc/passwd; then diff --git a/scripts/miaou b/scripts/miaou index df47043..ecf15ab 100755 --- a/scripts/miaou +++ b/scripts/miaou @@ -413,6 +413,11 @@ function build_services() { app=${item[5]} name=${item[6]:-} + domain=${item[0]} + subdomain=${item[1]} + data=$(yqm ".services.\"$domain\".\"$subdomain\".data") + echo "domain=$domain, subdomain=$subdomain, data=$data" + recipe="$MIAOU_BASEDIR/recipes/$app/crud.sh" if [[ -f "$recipe" ]]; then echo "read [$app:$name] onto container <$container>" diff --git a/templates/etc/defaults.yaml.j2 b/templates/etc/defaults.yaml.j2 index cebe29e..8bf1ee9 100644 --- a/templates/etc/defaults.yaml.j2 +++ b/templates/etc/defaults.yaml.j2 @@ -6,5 +6,3 @@ credential: username: {{env.current_user}} shadow: {{env.shadow_passwd}} email: TO BE DEFINED # example user@domain.tld - password: TO BE DEFINED -