13e0f1854Sopenharmony_ci # Copyright (c) 2024-2024 Huawei Device Co., Ltd. 23e0f1854Sopenharmony_ci # Licensed under the Apache License, Version 2.0 (the "License"); 33e0f1854Sopenharmony_ci # you may not use this file except in compliance with the License. 43e0f1854Sopenharmony_ci # You may obtain a copy of the License at 53e0f1854Sopenharmony_ci # 63e0f1854Sopenharmony_ci # http://www.apache.org/licenses/LICENSE-2.0 73e0f1854Sopenharmony_ci # 83e0f1854Sopenharmony_ci # Unless required by applicable law or agreed to in writing, software 93e0f1854Sopenharmony_ci # distributed under the License is distributed on an "AS IS" BASIS, 103e0f1854Sopenharmony_ci # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 113e0f1854Sopenharmony_ci # See the License for the specific language governing permissions and 123e0f1854Sopenharmony_ci # limitations under the License. 133e0f1854Sopenharmony_ci 143e0f1854Sopenharmony_ci 153e0f1854Sopenharmony_ci 163e0f1854Sopenharmony_ci 173e0f1854Sopenharmony_ci#!/bin/bash 183e0f1854Sopenharmony_ci 193e0f1854Sopenharmony_ci# ---------------------------------------------------------------------------- 203e0f1854Sopenharmony_ci# Hvigor startup script, version 1.0.0 213e0f1854Sopenharmony_ci# 223e0f1854Sopenharmony_ci# Required ENV vars: 233e0f1854Sopenharmony_ci# ------------------ 243e0f1854Sopenharmony_ci# NODE_HOME - location of a Node home dir 253e0f1854Sopenharmony_ci# or 263e0f1854Sopenharmony_ci# Add /usr/local/nodejs/bin to the PATH environment variable 273e0f1854Sopenharmony_ci# ---------------------------------------------------------------------------- 283e0f1854Sopenharmony_ci 293e0f1854Sopenharmony_ciHVIGOR_APP_HOME="`pwd -P`" 303e0f1854Sopenharmony_ciHVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js 313e0f1854Sopenharmony_ciwarn() { 323e0f1854Sopenharmony_ci echo "" 333e0f1854Sopenharmony_ci echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 343e0f1854Sopenharmony_ci} 353e0f1854Sopenharmony_ci 363e0f1854Sopenharmony_cierror() { 373e0f1854Sopenharmony_ci echo "" 383e0f1854Sopenharmony_ci echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 393e0f1854Sopenharmony_ci} 403e0f1854Sopenharmony_ci 413e0f1854Sopenharmony_cifail() { 423e0f1854Sopenharmony_ci error "$@" 433e0f1854Sopenharmony_ci exit 1 443e0f1854Sopenharmony_ci} 453e0f1854Sopenharmony_ci 463e0f1854Sopenharmony_ci# Determine node to start hvigor wrapper script 473e0f1854Sopenharmony_ciif [ -n "${NODE_HOME}" ];then 483e0f1854Sopenharmony_ci EXECUTABLE_NODE="${NODE_HOME}/bin/node" 493e0f1854Sopenharmony_ci if [ ! -x "$EXECUTABLE_NODE" ];then 503e0f1854Sopenharmony_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" 513e0f1854Sopenharmony_ci fi 523e0f1854Sopenharmony_cielse 533e0f1854Sopenharmony_ci EXECUTABLE_NODE="node" 543e0f1854Sopenharmony_ci which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" 553e0f1854Sopenharmony_cifi 563e0f1854Sopenharmony_ci 573e0f1854Sopenharmony_ci# Check hvigor wrapper script 583e0f1854Sopenharmony_ciif [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then 593e0f1854Sopenharmony_ci fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" 603e0f1854Sopenharmony_cifi 613e0f1854Sopenharmony_ci 623e0f1854Sopenharmony_ci# start hvigor-wrapper script 633e0f1854Sopenharmony_ciexec "${EXECUTABLE_NODE}" \ 643e0f1854Sopenharmony_ci "${HVIGOR_WRAPPER_SCRIPT}" "$@" 65