16e7c69efSopenharmony_ci#!/bin/bash 26e7c69efSopenharmony_ci# ---------------------------------------------------------------------------- 36e7c69efSopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd. 46e7c69efSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 56e7c69efSopenharmony_ci# you may not use this file except in compliance with the License. 66e7c69efSopenharmony_ci# You may obtain a copy of the License at 76e7c69efSopenharmony_ci# 86e7c69efSopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 96e7c69efSopenharmony_ci# 106e7c69efSopenharmony_ci# Unless required by applicable law or agreed to in writing, software 116e7c69efSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 126e7c69efSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136e7c69efSopenharmony_ci# See the License for the specific language governing permissions and 146e7c69efSopenharmony_ci# limitations under the License. 156e7c69efSopenharmony_ci# ---------------------------------------------------------------------------- 166e7c69efSopenharmony_ci# ---------------------------------------------------------------------------- 176e7c69efSopenharmony_ci# Hvigor startup script, version 1.0.0 186e7c69efSopenharmony_ci# 196e7c69efSopenharmony_ci# Required ENV vars: 206e7c69efSopenharmony_ci# ------------------ 216e7c69efSopenharmony_ci# NODE_HOME - location of a Node home dir 226e7c69efSopenharmony_ci# or 236e7c69efSopenharmony_ci# Add /usr/local/nodejs/bin to the PATH environment variable 246e7c69efSopenharmony_ci# ---------------------------------------------------------------------------- 256e7c69efSopenharmony_ci 266e7c69efSopenharmony_ciHVIGOR_APP_HOME=$(dirname $(readlink -f $0)) 276e7c69efSopenharmony_ciHVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js 286e7c69efSopenharmony_ciwarn() { 296e7c69efSopenharmony_ci echo "" 306e7c69efSopenharmony_ci echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 316e7c69efSopenharmony_ci} 326e7c69efSopenharmony_ci 336e7c69efSopenharmony_cierror() { 346e7c69efSopenharmony_ci echo "" 356e7c69efSopenharmony_ci echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 366e7c69efSopenharmony_ci} 376e7c69efSopenharmony_ci 386e7c69efSopenharmony_cifail() { 396e7c69efSopenharmony_ci error "$@" 406e7c69efSopenharmony_ci exit 1 416e7c69efSopenharmony_ci} 426e7c69efSopenharmony_ci 436e7c69efSopenharmony_ci# Determine node to start hvigor wrapper script 446e7c69efSopenharmony_ciif [ -n "${NODE_HOME}" ];then 456e7c69efSopenharmony_ci EXECUTABLE_NODE="${NODE_HOME}/bin/node" 466e7c69efSopenharmony_ci if [ ! -x "$EXECUTABLE_NODE" ];then 476e7c69efSopenharmony_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" 486e7c69efSopenharmony_ci fi 496e7c69efSopenharmony_cielse 506e7c69efSopenharmony_ci EXECUTABLE_NODE="node" 516e7c69efSopenharmony_ci which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" 526e7c69efSopenharmony_cifi 536e7c69efSopenharmony_ci 546e7c69efSopenharmony_ci# Check hvigor wrapper script 556e7c69efSopenharmony_ciif [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then 566e7c69efSopenharmony_ci fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" 576e7c69efSopenharmony_cifi 586e7c69efSopenharmony_ci 596e7c69efSopenharmony_ci# start hvigor-wrapper script 606e7c69efSopenharmony_ciexec "${EXECUTABLE_NODE}" \ 616e7c69efSopenharmony_ci "${HVIGOR_WRAPPER_SCRIPT}" "$@" 62