#!/bin/bash function install_snap() { # Install and config SNAP # check if docker image already exists # TODO: "docker image inspect sen4cap/snap" might be also used instead images -q if [[ "$(docker images -q sen4cap/snap:8.0-proxy 2> /dev/null)" == "" ]]; then TARGET_SNAP_TMP_DIR="/mnt/archive/temp/$(date +%Y%m%d%H%M%S)/" echo "Using directory ${TARGET_SNAP_TMP_DIR} for SNAP image build working dir ..." mkdir -p ${TARGET_SNAP_TMP_DIR}/snap && \ cp -fR * ${TARGET_SNAP_TMP_DIR}/snap && \ wget -P ${TARGET_SNAP_TMP_DIR}/snap/ http://step.esa.int/downloads/8.0/installers/esa-snap_sentinel_unix_8_0.sh && \ chmod +x ${TARGET_SNAP_TMP_DIR}/snap/esa-snap_sentinel_unix_8_0.sh && \ docker build -t sen4cap/snap:8.0-proxy -f ${TARGET_SNAP_TMP_DIR}/snap/Dockerfile ${TARGET_SNAP_TMP_DIR}/snap/ if [ -d ${TARGET_SNAP_TMP_DIR} ] ; then echo "Removing ${TARGET_SNAP_TMP_DIR} ..." rm -fR ${TARGET_SNAP_TMP_DIR} fi else echo "No need to install SNAP container, it already exists ..." fi } install_snap