19b256929Sopenharmony_ci#!/bin/bash 29b256929Sopenharmony_ci 39b256929Sopenharmony_ci# ---------------------------------------------------------------------------- 49b256929Sopenharmony_ci# Hvigor startup script, version 1.0.0 59b256929Sopenharmony_ci# 69b256929Sopenharmony_ci# Required ENV vars: 79b256929Sopenharmony_ci# ------------------ 89b256929Sopenharmony_ci# NODE_HOME - location of a Node home dir 99b256929Sopenharmony_ci# or 109b256929Sopenharmony_ci# Add /usr/local/nodejs/bin to the PATH environment variable 119b256929Sopenharmony_ci# ---------------------------------------------------------------------------- 129b256929Sopenharmony_ci 139b256929Sopenharmony_ciHVIGOR_APP_HOME=$(dirname $(readlink -f $0)) 149b256929Sopenharmony_ciHVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js 159b256929Sopenharmony_ciwarn() { 169b256929Sopenharmony_ci echo "" 179b256929Sopenharmony_ci echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 189b256929Sopenharmony_ci} 199b256929Sopenharmony_ci 209b256929Sopenharmony_cierror() { 219b256929Sopenharmony_ci echo "" 229b256929Sopenharmony_ci echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 239b256929Sopenharmony_ci} 249b256929Sopenharmony_ci 259b256929Sopenharmony_cifail() { 269b256929Sopenharmony_ci error "$@" 279b256929Sopenharmony_ci exit 1 289b256929Sopenharmony_ci} 299b256929Sopenharmony_ci 309b256929Sopenharmony_ci# Determine node to start hvigor wrapper script 319b256929Sopenharmony_ciif [ -n "${NODE_HOME}" ];then 329b256929Sopenharmony_ci EXECUTABLE_NODE="${NODE_HOME}/bin/node" 339b256929Sopenharmony_ci if [ ! -x "$EXECUTABLE_NODE" ];then 349b256929Sopenharmony_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" 359b256929Sopenharmony_ci fi 369b256929Sopenharmony_cielse 379b256929Sopenharmony_ci EXECUTABLE_NODE="node" 389b256929Sopenharmony_ci which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" 399b256929Sopenharmony_cifi 409b256929Sopenharmony_ci 419b256929Sopenharmony_ci# Check hvigor wrapper script 429b256929Sopenharmony_ciif [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then 439b256929Sopenharmony_ci fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" 449b256929Sopenharmony_cifi 459b256929Sopenharmony_ci 469b256929Sopenharmony_ci# start hvigor-wrapper script 479b256929Sopenharmony_ciexec "${EXECUTABLE_NODE}" \ 489b256929Sopenharmony_ci "${HVIGOR_WRAPPER_SCRIPT}" "$@" 49