From c5de35ead2edd2cd77ca4d432ed364926acda9ae Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 25 Oct 2023 10:43:34 +0200 Subject: [PATCH 1/4] new: [base] add ``debian 12`` compatibility for python --- precise/base-0k/hooks/install.d/05-shyaml.sh | 5 +++-- precise/host/hooks/install.d/70-0k.sh | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/precise/base-0k/hooks/install.d/05-shyaml.sh b/precise/base-0k/hooks/install.d/05-shyaml.sh index 6116a12..84f7a28 100755 --- a/precise/base-0k/hooks/install.d/05-shyaml.sh +++ b/precise/base-0k/hooks/install.d/05-shyaml.sh @@ -7,7 +7,7 @@ set -eux case $(lsb_release -is) in Debian) case $(lsb_release -rs) in - 11) + 11|12) apt-get install -y python3-pip libyaml-dev python3-dev &1 | tail -n 1)" == "ImportError: No module named setuptools" ]; then pip install setuptools fi - pip install sact.epoch + pip install sact.epoch || + pip install sact.epoch --break-system-packages if [ "$(python -c 'import sact.epoch' 2>&1 | tail -n 1)" == "ImportError: No module named interface" ]; then echo "Error: conflicting installation of zope.interface detected. Trying workaround." ( From 3f2c4160946ad755cbd1774497ac24f1bd94d067 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Thu, 9 Nov 2023 17:38:42 +0100 Subject: [PATCH 2/4] fix: [mongo] make ``upgrade`` script work to detect error on non "mongo" named service --- mongo/actions/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mongo/actions/upgrade b/mongo/actions/upgrade index be1fc73..5c10ae9 100755 --- a/mongo/actions/upgrade +++ b/mongo/actions/upgrade @@ -289,8 +289,8 @@ while [[ "${#upgrade_path[@]}" != 0 ]]; do errlvl="0" break ;; - *"getaddrinfo(\"mongo\") failed: Name or service not known"*) - err "Mongo issue with resolving 'mongo'" + *"getaddrinfo(\"$SERVICE_NAME\") failed: Name or service not known"*) + err "Mongo issue with resolving '$SERVICE_NAME'" failed=1 break 3 ;; From 5e9e655d460314c4a171885083dc737dcfc4b48c Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 14 Nov 2023 09:31:27 +0100 Subject: [PATCH 3/4] new: [docker-host] add option to force upgrade of docker version --- precise/host/hooks/install.d/60-docker.sh | 118 +++++++++++++++++----- 1 file changed, 92 insertions(+), 26 deletions(-) diff --git a/precise/host/hooks/install.d/60-docker.sh b/precise/host/hooks/install.d/60-docker.sh index 0eeb060..6e2411c 100755 --- a/precise/host/hooks/install.d/60-docker.sh +++ b/precise/host/hooks/install.d/60-docker.sh @@ -1,8 +1,35 @@ #!/bin/bash +## Set NO_DOCKER_RESTART to prevent restarting docker after upgrade. +## Set ALLOW_DOCKER_CHANGE to allow change your docker version. +## Set TARGET_DOCKER_VERSION to force a version (use cautiously!) + +distro=$(lsb_release -is) +release=$(lsb_release -rs) + +if [ -z "$TARGET_DOCKER_VERSION" ]; then + case "$distro" in + Debian) + case "$release" in + 10|11|12) target_version=24;; + *) target_version=19;; + esac + ;; + Ubuntu) + case "$release" in + 22.04) target_version=24;; + *) target_version=19;; + esac + ;; + *) target_version=17;; + esac +else + target_version="$TARGET_DOCKER_VERSION" +fi + just_installed= -if ! type -p docker; then +if ! type -p docker >/dev/null; then echo "Installing docker..." type -p curl >/dev/null || apt-get install -y curl &2 + echo " client: $docker_client_version" >&2 + echo " server: $docker_server_version" >&2 + mismatch_client_server=1 +fi - if ! [[ "$(docker --version)" == "Docker version $docker_version"* ]]; then - version="$(apt-cache madison docker-ce | +distrib_available_version="$(apt-cache madison docker-ce | cut -f 2 -d \| | - grep "$docker_version" | + grep "$target_version" | head -n 1 | xargs echo)" - apt-get install -y --allow-downgrades docker-ce="$version" - need_restart=true + +cleaned_distrib_available_version="${distrib_available_version%%~*}" +cleaned_distrib_available_version="${distrib_available_version%-*}" +cleaned_distrib_available_version="${cleaned_distrib_available_version#*:}" +if [ -z "$mismatch_client_server" ] && + [[ "$docker_client_version" == "$cleaned_distrib_available_version" ]]; then + ## current and target versions match, no upgrade needed + echo "INFO: recommended target docker version $docker_client_version already installed" >&2 + echo " To set a different target version, set TARGET_DOCKER_VERSION" >&2 + exit 0 +fi + +## Should we skip upgrade? +if [ -z "$just_installed" ] && [ -z "$ALLOW_DOCKER_CHANGE" ]; then + if [ -n "$distrib_available_version" ]; then + if [ -z "$mismatch_client_server" ]; then + ## get current version for docker-ce debian package installed + current_debian_package_version="$(dpkg -s docker-ce | grep '^Version:' | cut -f 2 -d ' ')" + echo "INFO: docker recommended version available (current: $current_debian_package_version => recommended: $distrib_available_version)" >&2 + else + current_docker_ce_package_version="$(dpkg -s docker-ce | grep '^Version:' | cut -f 2 -d ' ')" + current_docker_ce_cli_package_version="$(dpkg -s docker-ce-cli | grep '^Version:' | cut -f 2 -d ' ')" + echo "WARNING: docker recommended version available (recommended: $distrib_available_version)" >&2 + echo " And your client ($current_docker_ce_cli_package_version) and server ($current_docker_ce_package_version) versions differ." >&2 + fi + echo " To change version, run this script with ALLOW_DOCKER_CHANGE=1" >&2 + else + echo "WARNING: your docker version does match target recommended version" >&2 + echo " And your distribution does not package target version." >&2 + echo " - Your distribution: $distro $release" >&2 + echo " - Current docker version: $docker_client_version" >&2 + echo " - Target recommended version: ${target_version}*" >&2 fi + exit 0 +fi - if [ -n "$need_restart" ] && [ -z "$NO_DOCKER_RESTART" ]; then +if [ -z "$distrib_available_version" ]; then + echo "ERROR: no docker version matching '${target_version}*' available for your distribution" >&2 + echo " Your distribution: $distro $release" >&2 + echo " Available versions:" >&2 + apt-cache madison docker-ce | cut -f 2 -d \| | sed -r 's/^/ -/g' >&2 + echo + echo " 1) You may need to contact your system administrator to upgrade this script." >&2 + echo " 2) Meanwhile, if you know what you are doing, you can set yourself a target version" >&2 + echo " by setting TARGET_DOCKER_VERSION." >&2 + exit 1 +fi + +apt-get install -y --allow-downgrades \ + docker-ce="$distrib_available_version" \ + docker-ce-cli="$distrib_available_version" Date: Wed, 15 Nov 2023 16:10:11 +0100 Subject: [PATCH 4/4] new: [docuseal] new charm --- docuseal/README.org | 5 +++ .../hooks/postgres_database-relation-joined | 17 +++++++++ docuseal/metadata.yml | 35 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 docuseal/README.org create mode 100755 docuseal/hooks/postgres_database-relation-joined create mode 100644 docuseal/metadata.yml diff --git a/docuseal/README.org b/docuseal/README.org new file mode 100644 index 0000000..28f8f89 --- /dev/null +++ b/docuseal/README.org @@ -0,0 +1,5 @@ +# -*- ispell-local-dictionary: "english" -*- + +* Info + +From: https://github.com/docusealco/docuseal diff --git a/docuseal/hooks/postgres_database-relation-joined b/docuseal/hooks/postgres_database-relation-joined new file mode 100755 index 0000000..ca195f3 --- /dev/null +++ b/docuseal/hooks/postgres_database-relation-joined @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +PASSWORD="$(relation-get password)" +USER="$(relation-get user)" +DBNAME="$(relation-get dbname)" + + +config-add "\ +services: + $MASTER_BASE_SERVICE_NAME: + environment: + DATABASE_URL: postgres://$USER:$PASSWORD@$TARGET_SERVICE_NAME/$DBNAME +" + +info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access." diff --git a/docuseal/metadata.yml b/docuseal/metadata.yml new file mode 100644 index 0000000..43b1b39 --- /dev/null +++ b/docuseal/metadata.yml @@ -0,0 +1,35 @@ +docker-image: docker.0k.io/docuseal:1.2.8 +data-resources: + - /data + +uses: + postgres-database: + #constraint: required | recommended | optional + #auto: pair | summon | none ## default: pair + constraint: required + auto: summon + solves: + database: "main storage" + web-proxy: + #constraint: required | recommended | optional + #auto: pair | summon | none ## default: pair + constraint: recommended + auto: pair + solves: + proxy: "Public access" + default-options: + target: !var-expand ${MASTER_BASE_SERVICE_NAME}:3000 + backup: + constraint: recommended + auto: pair + solves: + backup: "Automatic regular backup" + default-options: + ## First pattern matching wins, no pattern matching includes. + ## include-patterns are checked first, then exclude-patterns + ## Patterns rules: + ## - ending / for directory + ## - '*' authorized + ## - must start with a '/', will start from $SERVICE_DATASTORE + #exclude-patterns: + # - "/var/lib/odoo/sessions/" \ No newline at end of file