From 487c812364f8fcf8cec04c5e7b2b465d0ca46109 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Wed, 16 Feb 2022 15:46:38 +0100 Subject: [PATCH] WIP: beginning of new seq to install matrix-dimenstion --- seqs/matrix-dimension.cfg.example | 3 ++ seqs/matrix-dimension.sh | 79 +++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 seqs/matrix-dimension.cfg.example create mode 100755 seqs/matrix-dimension.sh diff --git a/seqs/matrix-dimension.cfg.example b/seqs/matrix-dimension.cfg.example new file mode 100644 index 0000000..9be8a25 --- /dev/null +++ b/seqs/matrix-dimension.cfg.example @@ -0,0 +1,3 @@ +#!/bin/bash + +SEQ_DIMENSION_DIR="/opt/matrix-dimension" diff --git a/seqs/matrix-dimension.sh b/seqs/matrix-dimension.sh new file mode 100755 index 0000000..c8821f2 --- /dev/null +++ b/seqs/matrix-dimension.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +toolName=matrix-dimension +toolDownUrl="https://github.com/turt2live/matrix-dimension.git" +toolAptDeps="nodejs" + +# Get script working directory +# (when called from a different directory) +WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)" +APTOPT= +CONFIG=0 +SCRIPT_FILE=$(basename -- $0) +SCRIPT_NAME=${SCRIPT_FILE%%.*} +CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg" +CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" + +step_config() { + ## or to use sequencer api with global config file: + initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" + if [ $? -eq 0 ] ; then + CONFIG=1 + else + # End if no configuration file exists + [ $DRY -eq 0 ] && return -1 + fi + + ## Apt cmdline option to suppress user interaction + [ $QUIET -ne 0 ] && APTOPT="-y" + + echoerr " [W] $SCRIPT_NAME is still in alpha stage" + echoerr " TODO: - systemd script" + echoerr " - initial config creation" + + ## Return of non zero value will abort the sequence + return 0 +} + +step_1_info() { echo "Install $toolName dependencies"; } +step_1_alias() { ALIAS="install"; } +step_1() { + exep curl -sL https://deb.nodesource.com/setup_12.x \| bash - + exe apt install $toolAptDeps $APTOPT +} + +step_2_info() { echo "Setup and build"; } +step_2_alias() { ALIAS="setup"; } +step_2() { + if [ ! -e "$SEQ_DIMENSION_DIR" ]; then + exe mkdir -p "$SEQ_DIMENSION_DIR" + exe cd "$SEQ_DIMENSION_DIR/.." + # Download dimension + exe git clone $toolDownUrl + fi + + exe cd "$SEQ_DIMENSION_DIR" + + # Install dependencies + exe npm install + + # Build it + exe npm run build +} + +step_10_info() { echo "Start $toolName"; } +step_10_alias() { ALIAS="start"; } +step_10() { + if [ ! -e "$SEQ_DIMENSION_DIR" ]; then + echoerr " [E] $toolName not found ad $SEQ_DIMENSION_DIR" + return 1; + fi + exe cd "$SEQ_DIMENSION_DIR" + # TODO is "node build/app/index.js" enough after build + # NODE_ENV=production npm run start:app runs actually: + # start:app: `npm run-script build && node build/app/index.js` + exep NODE_ENV=production node build/app/index.js +} + +VERSION_SEQREV=15 +. /usr/local/bin/sequencer.sh