From 272b8b320a5698167dd1209be33cdc642542cc5f Mon Sep 17 00:00:00 2001 From: Michael Perry Date: Mon, 25 Jun 2018 12:20:02 -0700 Subject: [PATCH] add parse_config function + bump version --- manifest.json | 4 ++-- run | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/manifest.json b/manifest.json index 1349604..82ba888 100644 --- a/manifest.json +++ b/manifest.json @@ -8,9 +8,9 @@ "source": "https://github.com/scitran-apps/parrec-mr-classifier", "license": "Apache-2.0", "flywheel": "0", - "version": "1.1.0", + "version": "1.1.1", "custom": { - "docker-image": "scitran/parrec-mr-classifier:1.1.0" + "docker-image": "scitran/parrec-mr-classifier:1.1.1" }, "config": { "timezone": { diff --git a/run b/run index de05a50..b78320f 100755 --- a/run +++ b/run @@ -16,18 +16,24 @@ MANIFEST_FILE=$FLYWHEEL_BASE/manifest.json ############################################################################## # Parse configuration -if [[ -f $CONFIG_FILE ]]; then - eval $(jq -r '.config | to_entries[] | "config_\(.key)=\(.value)"' $CONFIG_FILE) -else - CONFIG_FILE=$MANIFEST_FILE - eval $(jq -r '.config | to_entries[] | "config_\(.key)=\(.value.default)"' $CONFIG_FILE) -fi +function parse_config { + + CONFIG_FILE=$FLYWHEEL_BASE/config.json + MANIFEST_FILE=$FLYWHEEL_BASE/manifest.json + + if [[ -f $CONFIG_FILE ]]; then + echo "$(cat $CONFIG_FILE | jq -r '.config.'$1)" + else + CONFIG_FILE=$MANIFEST_FILE + echo "$(cat $MANIFEST_FILE | jq -r '.config.'$1'.default')" + fi +} ############################################################################## # Set Time Zone -TZ="${config_timezone}" +TZ="$(parse_config 'timezone')" echo "${CONTAINER} Setting time zone to: $TZ" echo "$TZ" > /etc/timezone && ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime dpkg-reconfigure -f noninteractive tzdata @@ -36,7 +42,8 @@ dpkg-reconfigure -f noninteractive tzdata ############################################################################## # Handle sync option -if [[ ${config_sync} == "true" ]]; then +SYNC=$(parse_config 'sync') +if [[ ${SYNC} == "true" ]]; then echo -e "$CONTAINER Syncing classification code from scitran-apps/dicom-mr-classifier/sync-classification-e4..." mv ${FLYWHEEL_BASE}/classification_from_label.py /tmp wget --quiet -O ${FLYWHEEL_BASE}/classification_from_label.py \