16e80583aSopenharmony_ci#!/bin/bash 26e80583aSopenharmony_ci 36e80583aSopenharmony_ci# ---------------------------------------------------------------------------- 46e80583aSopenharmony_ci# Hvigor startup script, version 1.0.0 56e80583aSopenharmony_ci# 66e80583aSopenharmony_ci# Required ENV vars: 76e80583aSopenharmony_ci# ------------------ 86e80583aSopenharmony_ci# NODE_HOME - location of a Node home dir 96e80583aSopenharmony_ci# or 106e80583aSopenharmony_ci# Add /usr/local/nodejs/bin to the PATH environment variable 116e80583aSopenharmony_ci# ---------------------------------------------------------------------------- 126e80583aSopenharmony_ci 136e80583aSopenharmony_ciHVIGOR_APP_HOME="`pwd -P`" 146e80583aSopenharmony_ciHVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js 156e80583aSopenharmony_ciwarn() { 166e80583aSopenharmony_ci echo "" 176e80583aSopenharmony_ci echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 186e80583aSopenharmony_ci} 196e80583aSopenharmony_ci 206e80583aSopenharmony_cierror() { 216e80583aSopenharmony_ci echo "" 226e80583aSopenharmony_ci echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 236e80583aSopenharmony_ci} 246e80583aSopenharmony_ci 256e80583aSopenharmony_cifail() { 266e80583aSopenharmony_ci error "$@" 276e80583aSopenharmony_ci exit 1 286e80583aSopenharmony_ci} 296e80583aSopenharmony_ci 306e80583aSopenharmony_ci# Determine node to start hvigor wrapper script 316e80583aSopenharmony_ciif [ -n "${NODE_HOME}" ];then 326e80583aSopenharmony_ci EXECUTABLE_NODE="${NODE_HOME}/bin/node" 336e80583aSopenharmony_ci if [ ! -x "$EXECUTABLE_NODE" ];then 346e80583aSopenharmony_ci fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" 356e80583aSopenharmony_ci fi 366e80583aSopenharmony_cielse 376e80583aSopenharmony_ci EXECUTABLE_NODE="node" 386e80583aSopenharmony_ci which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" 396e80583aSopenharmony_cifi 406e80583aSopenharmony_ci 416e80583aSopenharmony_ci# Check hvigor wrapper script 426e80583aSopenharmony_ciif [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then 436e80583aSopenharmony_ci fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" 446e80583aSopenharmony_cifi 456e80583aSopenharmony_ci 466e80583aSopenharmony_ci# start hvigor-wrapper script 476e80583aSopenharmony_ciexec "${EXECUTABLE_NODE}" \ 486e80583aSopenharmony_ci "${HVIGOR_WRAPPER_SCRIPT}" "$@" 49