#!/bin/bash readonly EXPANDED_CONF="$MIAOU_CONFIGDIR/miaou.expanded.yaml" readonly ODOO15_DIR="/home/odoo/odoo15" readonly WKHTML_VERSION="0.12.6.1-3" readonly WKHTML_RELEASE="$WKHTML_VERSION.bookworm_amd64" function check_user_odoo() { (lxc exec "$CONTAINER" -- id odoo &>/dev/null) || return 12 return 0 } function check_target_bgcolor() { (lxc exec "$CONTAINER" -- grep -Pq "^\\\$o-community-color: $BACKGROUND_COLOR" "$ODOO15_DIR/addons/web/static/src/legacy/scss/primary_variables.scss") || return 13 return 0 } function check_file_odoo-addon-install() { (lxc exec "$CONTAINER" -- test -f /home/odoo/odoo15/odoo-addon-install) || return 23 return 0 } function check() { PREFIX="recipe:odoo15:check" check_user_odoo || return 21 check_target_bgcolor || return 22 check_file_odoo-addon-install || return 23 echo "container <$CONTAINER> approved successfully!" return 0 } function install() { PREFIX="recipe:odoo15:install" : $PREFIX launch_container "$CONTAINER" echo "initializing Odoo15 ... " lxc exec "$CONTAINER" -- bash < /dev/null echo "installing odoo15..." apt update && apt dist-upgrade -y echo "required packages" apt install -y postgresql-client build-essential zlib1g-dev libssl-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libpq-dev libffi-dev if [[ ! -d /usr/local/share/python3.9 ]]; then echo "install python-3.9.18" cd /tmp wget https://www.python.org/ftp/python/3.9.18/Python-3.9.18.tgz tar -xf Python-3.9.18.tgz mv Python-3.9.18 /usr/local/share/python3.9 cd /usr/local/share/python3.9 ./configure --enable-optimizations --enable-shared make -j \$(nproc) make altinstall ldconfig /usr/local/share/python3.9 else echo "python-3.9.18 already installed!" fi if dpkg -l | grep -s wkhtmltox | grep -qs $WKHTML_VERSION; then echo package=wkhtmltox version=$WKHTML_RELEASE already found! else echo "wkhtmltox version=$WKHTML_RELEASE has to be installed!" wget https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTML_VERSION/wkhtmltox_$WKHTML_RELEASE.deb dpkg -i wkhtmltox_$WKHTML_RELEASE.deb || (apt -fy install && rm wkhtmltox_$WKHTML_RELEASE.deb) fi if ! grep -q odoo /etc/passwd; then echo "add user " useradd -ms /bin/bash odoo else echo "user already set!" fi echo "install odoo15 in odoo userspace" cat < added!" EOF } function compute_bgcolor_target() { target=$(yq '.target' "$EXPANDED_CONF") case "$target" in dev) builtin echo "#17a2b8" ;; beta) builtin echo "#79A70A" ;; prod) builtin echo "#7C7BAD" ;; *) echoerr "unknown target <$target>" && exit 10 ;; esac } ### MAIN . "$MIAOU_BASEDIR/lib/init.sh" arg1_required "$@" readonly CONTAINER="$1" BACKGROUND_COLOR=$(compute_bgcolor_target) readonly BACKGROUND_COLOR check || ( install check )