#!/bin/bash readonly EXPANDED_CONF="$MIAOU_CONFIGDIR/miaou.expanded.yaml" readonly WKHTML_VERSION="0.12.6-1" readonly WKHTML_RELEASE="$WKHTML_VERSION.buster_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" /home/odoo/odoo12/addons/web/static/src/scss/primary_variables.scss) || return 13 return 0 } function check_wkhtmltox() { (lxc exec "$CONTAINER" -- dpkg -l | grep -s wkhtmltox | grep -qs $WKHTML_VERSION) || return 1 } function check_python() { (lxc exec "$CONTAINER" -- test -d /opt/Python-3.7.13) || return 1 } function check_venv() { (lxc exec "$CONTAINER" -- test -d /home/odoo/venv) || return 1 } function check_favicon() { lxc exec "$CONTAINER" -- test -L /home/odoo/odoo12/addons/web/static/src/img/favicon.ico } function check_file_odoo-addon-install() { (lxc exec "$CONTAINER" -- test -f /home/odoo/odoo12/odoo12-addon-install) || return 23 } function check() { PREFIX="recipe:odoo12:check" check_wkhtmltox || return 10 check_python || return 11 check_user_odoo || return 12 check_target_bgcolor || return 13 check_venv || return 14 check_favicon || return 15 check_file_odoo-addon-install || return 23 } function install() { PREFIX="recipe:odoo12:install" : $PREFIX launch_container "$CONTAINER" echo "initializing Odoo12 ... " lxc exec "$CONTAINER" -- bash </dev/null; then echo "creating system user " useradd -rms /bin/bash odoo else echo "user already exists!" fi cat < added!" EOF echo "push various target-related favicons..." for favicon in "$MIAOU_BASEDIR"/templates/apps/odoo12/favicon/*.ico; do lxc file push --uid 0 --gid 0 "$favicon" "$CONTAINER/home/odoo/odoo12/addons/web/static/src/img/" done echo "OK" echo "adjust symbolic link according to target=<$TARGET>" lxc exec "$CONTAINER" -- rm -f /home/odoo/odoo12/addons/web/static/src/img/favicon.ico lxc exec "$CONTAINER" -- ln -s /home/odoo/odoo12/addons/web/static/src/img/favicon-"$TARGET".ico /home/odoo/odoo12/addons/web/static/src/img/favicon.ico echo "OK" } function compute_bgcolor_target() { case "$TARGET" in dev) echo "#17a2b8" ;; beta) echo "#79A70A" ;; prod) echo "#7C7BAD" ;; *) echoerr "unknown target <$TARGET>" && exit 10 ;; esac } ### MAIN . "$MIAOU_BASEDIR/lib/init.sh" arg1_required "$@" readonly CONTAINER="$1" TARGET=$(yq '.target' "$EXPANDED_CONF") readonly TARGET BACKGROUND_COLOR=$(compute_bgcolor_target) readonly BACKGROUND_COLOR check || ( install check )