forked from 0k/0k-charms
Browse Source
new: [monujo] upgrade to version 0.0.2 an support relation to odoo and map server
new: [monujo] upgrade to version 0.0.2 an support relation to odoo and map server
Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>nj-keycloak-17.0
Valentin Lab
3 years ago
6 changed files with 127 additions and 11 deletions
-
3gogocarto/metadata.yml
-
15monujo/hooks/init
-
27monujo/hooks/pre_deploy
-
76monujo/lib/common
-
14monujo/metadata.yml
-
3odoo-tecnativa/metadata.yml
@ -0,0 +1,27 @@ |
|||
#!/bin/bash |
|||
## Should be executable N time in a row with same result. |
|||
|
|||
. lib/common |
|||
|
|||
set -e |
|||
|
|||
if ! url=$(relation:get "${SERVICE_NAME}":odoo-server:web-proxy url); then |
|||
err "Monujo doesn't support odoo-server not having a web-proxy yet." |
|||
exit 1 |
|||
fi |
|||
if ! dbname=$(relation:get "${SERVICE_NAME}":odoo-server:postgres-database dbname); then |
|||
err "Can't find db name of our odoo-server relation." |
|||
exit 1 |
|||
fi |
|||
|
|||
monujo:config_merge "{ |
|||
\"lokapiHost\": \"$url\", |
|||
\"lokapiDb\": \"$dbname\" |
|||
}" |
|||
|
|||
|
|||
if map_url=$(relation:get "${SERVICE_NAME}":map-server:publish-dir url); then |
|||
monujo:config_merge "{ |
|||
\"mapUrl\": \"$map_url\" |
|||
}" |
|||
fi |
@ -0,0 +1,76 @@ |
|||
|
|||
|
|||
APP_NAME=monujo |
|||
VERSION=0.0.2 |
|||
SOURCE_URL="https://docker.0k.io/downloads/$APP_NAME-$VERSION.tar.bz2" |
|||
LOCATION="$SERVICE_DATASTORE/opt/apps/$APP_NAME" |
|||
CONFIGFILE="$LOCATION/config.json" |
|||
|
|||
|
|||
monujo:code_init() { |
|||
mkdir -p "$LOCATION" |
|||
if dir_is_empty "$LOCATION"; then |
|||
cd "$LOCATION" |
|||
wget -q "$SOURCE_URL" -O file.tar.bz2 |
|||
tar xjf file.tar.bz2 |
|||
rm file.tar.bz2 |
|||
chown root:root "$LOCATION" -R |
|||
fi |
|||
} |
|||
|
|||
|
|||
monujo:code_config_base() { |
|||
|
|||
MONUJO_OPTIONS=( |
|||
lokapi-host:string |
|||
lokapi-db:string |
|||
map-url:string |
|||
local-password-retention-time:string |
|||
) |
|||
|
|||
MONUJO_OPTIONS_CONCAT=" ${MONUJO_OPTIONS[*]} " |
|||
|
|||
service_def=$(get_compose_service_def "$SERVICE_NAME") || return 1 |
|||
echo "{}" > "$CONFIGFILE" |
|||
## XXXvlab: Should probably offer some lib to do this |
|||
while read-0 key val; do |
|||
key_option=${key//-/_} |
|||
case "$MONUJO_OPTIONS_CONCAT" in |
|||
*" ${key_option}:bool "*) |
|||
case "${val,,}" in |
|||
true|ok|yes|y) |
|||
val=yes |
|||
;; |
|||
false|ko|nok|no|n) |
|||
val=no |
|||
;; |
|||
*) |
|||
die "Invalid value for ${WHITE}$key$NORMAL, please use a boolean value." |
|||
;; |
|||
esac |
|||
;; |
|||
*" ${key_option}:numeric "*) |
|||
if ! is_int "$val"; then |
|||
die "Invalid value for ${WHITE}$key$NORMAL, please use numeric value." |
|||
fi |
|||
;; |
|||
*" ${key_option}:string "*) |
|||
: |
|||
;; |
|||
*) |
|||
key_option=$(echo "$key_option" | sed 's/_\([a-z0-9]\)/\U\1/g') |
|||
printf "%s %s\0" "$key_option" "$val" |
|||
;; |
|||
esac |
|||
done < <(printf "%s" "$service_def" | shyaml key-values-0 options) | |
|||
jq -R 'split("\u0000") | map(split(" ") | {key: .[0], value: .[1]}) | from_entries' > \ |
|||
"$CONFIGFILE" |
|||
|
|||
} |
|||
|
|||
|
|||
monujo:config_merge() { |
|||
local old_config new_config="$1" |
|||
old_config=$(cat "$CONFIGFILE") |
|||
e "$old_config" "$new_config" | jq -s 'reduce .[] as $x ({}; . * $x)' > "$CONFIGFILE" |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue