194f5b7a1Sopenharmony_ci#!/bin/bash 294f5b7a1Sopenharmony_ci 394f5b7a1Sopenharmony_ci# ---------------------------------------------------------------------------- 494f5b7a1Sopenharmony_ci# Hvigor startup script, version 1.0.0 594f5b7a1Sopenharmony_ci# 694f5b7a1Sopenharmony_ci# Required ENV vars: 794f5b7a1Sopenharmony_ci# ------------------ 894f5b7a1Sopenharmony_ci# NODE_HOME - location of a Node home dir 994f5b7a1Sopenharmony_ci# or 1094f5b7a1Sopenharmony_ci# Add /usr/local/nodejs/bin to the PATH environment variable 1194f5b7a1Sopenharmony_ci# ---------------------------------------------------------------------------- 1294f5b7a1Sopenharmony_ci 1394f5b7a1Sopenharmony_ciHVIGOR_APP_HOME="`pwd -P`" 1494f5b7a1Sopenharmony_ciHVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js 1594f5b7a1Sopenharmony_ciwarn() { 1694f5b7a1Sopenharmony_ci echo "" 1794f5b7a1Sopenharmony_ci echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 1894f5b7a1Sopenharmony_ci} 1994f5b7a1Sopenharmony_ci 2094f5b7a1Sopenharmony_cierror() { 2194f5b7a1Sopenharmony_ci echo "" 2294f5b7a1Sopenharmony_ci echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 2394f5b7a1Sopenharmony_ci} 2494f5b7a1Sopenharmony_ci 2594f5b7a1Sopenharmony_cifail() { 2694f5b7a1Sopenharmony_ci error "$@" 2794f5b7a1Sopenharmony_ci exit 1 2894f5b7a1Sopenharmony_ci} 2994f5b7a1Sopenharmony_ci 3094f5b7a1Sopenharmony_ci# Determine node to start hvigor wrapper script 3194f5b7a1Sopenharmony_ciif [ -n "${NODE_HOME}" ];then 3294f5b7a1Sopenharmony_ci EXECUTABLE_NODE="${NODE_HOME}/bin/node" 3394f5b7a1Sopenharmony_ci if [ ! -x "$EXECUTABLE_NODE" ];then 3494f5b7a1Sopenharmony_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" 3594f5b7a1Sopenharmony_ci fi 3694f5b7a1Sopenharmony_cielse 3794f5b7a1Sopenharmony_ci EXECUTABLE_NODE="node" 3894f5b7a1Sopenharmony_ci which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" 3994f5b7a1Sopenharmony_cifi 4094f5b7a1Sopenharmony_ci 4194f5b7a1Sopenharmony_ci# Check hvigor wrapper script 4294f5b7a1Sopenharmony_ciif [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then 4394f5b7a1Sopenharmony_ci fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" 4494f5b7a1Sopenharmony_cifi 4594f5b7a1Sopenharmony_ci 4694f5b7a1Sopenharmony_ci# start hvigor-wrapper script 4794f5b7a1Sopenharmony_ciexec "${EXECUTABLE_NODE}" \ 4894f5b7a1Sopenharmony_ci "${HVIGOR_WRAPPER_SCRIPT}" "$@" 49