131c75014Sopenharmony_ci#!/bin/bash 231c75014Sopenharmony_ci 331c75014Sopenharmony_ci# ---------------------------------------------------------------------------- 431c75014Sopenharmony_ci# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. 531c75014Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 631c75014Sopenharmony_ci# you may not use this file except in compliance with the License. 731c75014Sopenharmony_ci# You may obtain a copy of the License at 831c75014Sopenharmony_ci# 931c75014Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 1031c75014Sopenharmony_ci# 1131c75014Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 1231c75014Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 1331c75014Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1431c75014Sopenharmony_ci# See the License for the specific language governing permissions and 1531c75014Sopenharmony_ci# limitations under the License. 1631c75014Sopenharmony_ci# ---------------------------------------------------------------------------- 1731c75014Sopenharmony_ci 1831c75014Sopenharmony_ci# ---------------------------------------------------------------------------- 1931c75014Sopenharmony_ci# Hvigor startup script, version 1.0.0 2031c75014Sopenharmony_ci# 2131c75014Sopenharmony_ci# Required ENV vars: 2231c75014Sopenharmony_ci# ------------------ 2331c75014Sopenharmony_ci# NODE_HOME - location of a Node home dir 2431c75014Sopenharmony_ci# or 2531c75014Sopenharmony_ci# Add /usr/local/nodejs/bin to the PATH environment variable 2631c75014Sopenharmony_ci# ---------------------------------------------------------------------------- 2731c75014Sopenharmony_ci 2831c75014Sopenharmony_ciHVIGOR_APP_HOME=$(dirname $(readlink -f $0)) 2931c75014Sopenharmony_ciHVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js 3031c75014Sopenharmony_ciwarn() { 3131c75014Sopenharmony_ci echo "" 3231c75014Sopenharmony_ci echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 3331c75014Sopenharmony_ci} 3431c75014Sopenharmony_ci 3531c75014Sopenharmony_cierror() { 3631c75014Sopenharmony_ci echo "" 3731c75014Sopenharmony_ci echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 3831c75014Sopenharmony_ci} 3931c75014Sopenharmony_ci 4031c75014Sopenharmony_cifail() { 4131c75014Sopenharmony_ci error "$@" 4231c75014Sopenharmony_ci exit 1 4331c75014Sopenharmony_ci} 4431c75014Sopenharmony_ci 4531c75014Sopenharmony_ci# Determine node to start hvigor wrapper script 4631c75014Sopenharmony_ciif [ -n "${NODE_HOME}" ];then 4731c75014Sopenharmony_ci EXECUTABLE_NODE="${NODE_HOME}/bin/node" 4831c75014Sopenharmony_ci if [ ! -x "$EXECUTABLE_NODE" ];then 4931c75014Sopenharmony_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" 5031c75014Sopenharmony_ci fi 5131c75014Sopenharmony_cielse 5231c75014Sopenharmony_ci EXECUTABLE_NODE="node" 5331c75014Sopenharmony_ci which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" 5431c75014Sopenharmony_cifi 5531c75014Sopenharmony_ci 5631c75014Sopenharmony_ci# Check hvigor wrapper script 5731c75014Sopenharmony_ciif [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then 5831c75014Sopenharmony_ci fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" 5931c75014Sopenharmony_cifi 6031c75014Sopenharmony_ci 6131c75014Sopenharmony_ci# start hvigor-wrapper script 6231c75014Sopenharmony_ciexec "${EXECUTABLE_NODE}" \ 6331c75014Sopenharmony_ci "${HVIGOR_WRAPPER_SCRIPT}" "$@" 64