From 9f733bb6c9024fc7ca67c314eac5c080264aaa8c Mon Sep 17 00:00:00 2001 From: Alec Turner Date: Wed, 15 Jan 2025 08:50:49 -0800 Subject: [PATCH] add custom install script to clear v1 data The script `install.sh` largely copies the template from the hosted-app-utils project, with some key changes: 1. replace template parameters (`{{VAR}}`) with hard-coded values 2. define variables for org, app, install root, etc 3. if old version detected, remove data folder before installing update The modified script will: 1. delete v1 data 2. update normally when v2 or newer installations are present --- install.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ package | 3 ++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..c03da1a0 --- /dev/null +++ b/install.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# +# Copyright (C) Wendepunkt Medical Innovations, Inc - All Rights Reserved. +# Unauthorized copying of this file, via any medium is strictly prohibited. +# Proprietary and confidential +# +# For information: dev@signalytic.ca +# + +# +# Install the streamline-emr application +# +# The caller of this script must check the exit value and possibly do a +# roll-back if it is non-zero. If the exit value is non-zero services have not +# been restarted. +# +# Note: This version resets data from v1 installations + +LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +if [ "$EUID" -ne 0 ] + then echo "Please run as root" + exit 1 +fi + +set -e + +APP_SLUG="streamline_emr" +ORG_SLUG="streamline" +INSTALL_ROOT="/var/signalytic/clientapps/${ORG_SLUG}/${APP_SLUG}" +VERSION_FILE="${INSTALL_ROOT}/version" +DATA_ROOT="${INSTALL_ROOT}/data" + +# stop the application (if installed) +if [ -f ${INSTALL_ROOT}/stop ]; then + ${INSTALL_ROOT}/stop +fi + +# reset data for any v1 installations +if grep -q "^1." ${VERSION_FILE}; then + echo "v1 installation detected - resetting data" + rm -rf ${DATA_ROOT} +fi + +# copy root files (if present) +if [ -d "${LOCATION}/root" ] && [ -n "$(ls -A ${LOCATION}/root)" ]; then + echo "importing root files" + cp -rfv $LOCATION/root/* / +fi + +# import docker images (if present) +for f in $(find $LOCATION/images -name "*.img" 2>/dev/null);do + echo "importing docker image: $f" + docker load -i $f +done +for f in $(find $LOCATION/images -name "*.img.xz" 2>/dev/null);do + echo "importing docker image: $f" + xz -d -c $f | docker load +done + +# start the application +${INSTALL_ROOT}/start diff --git a/package b/package index bbde6d42..f20f1820 100755 --- a/package +++ b/package @@ -5,5 +5,6 @@ LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" CONFIG=${CONFIG:-${LOCATION}/config.json} SRC=${SRC:-${LOCATION}/src} BUILD_DIR=${BUILD_DIR:-${LOCATION}/build-packages} +INSTALL_SCRIPT=${LOCATION}/install.sh -${LOCATION}/hosted-app-utils/package ${CONFIG} ${SRC} output=${BUILD_DIR} $@ \ No newline at end of file +${LOCATION}/hosted-app-utils/package ${CONFIG} ${SRC} ${INSTALL_SCRIPT} output=${BUILD_DIR} $@