|
@ -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" |
|
|
|
|
|
} |