119e95205Sopenharmony_ci#/** 219e95205Sopenharmony_ci# * Copyright (C) 2022 Huawei Device Co., Ltd. 319e95205Sopenharmony_ci# * Licensed under the Apache License, Version 2.0 (the "License"); 419e95205Sopenharmony_ci# * you may not use this file except in compliance with the License. 519e95205Sopenharmony_ci# * You may obtain a copy of the License at 619e95205Sopenharmony_ci# * 719e95205Sopenharmony_ci# * http://www.apache.org/licenses/LICENSE-2.0 819e95205Sopenharmony_ci# * 919e95205Sopenharmony_ci# * Unless required by applicable law or agreed to in writing, software 1019e95205Sopenharmony_ci# * distributed under the License is distributed on an "AS IS" BASIS, 1119e95205Sopenharmony_ci# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1219e95205Sopenharmony_ci# * See the License for the specific language governing permissions and 1319e95205Sopenharmony_ci# * limitations under the License. 1419e95205Sopenharmony_ci# */ 1519e95205Sopenharmony_ci#!/bin/bash 1619e95205Sopenharmony_ci 1719e95205Sopenharmony_ci# ---------------------------------------------------------------------------- 1819e95205Sopenharmony_ci# Hvigor startup script, version 1.0.0 1919e95205Sopenharmony_ci# 2019e95205Sopenharmony_ci# Required ENV vars: 2119e95205Sopenharmony_ci# ------------------ 2219e95205Sopenharmony_ci# NODE_HOME - location of a Node home dir 2319e95205Sopenharmony_ci# or 2419e95205Sopenharmony_ci# Add /usr/local/nodejs/bin to the PATH environment variable 2519e95205Sopenharmony_ci# ---------------------------------------------------------------------------- 2619e95205Sopenharmony_ci 2719e95205Sopenharmony_ciHVIGOR_APP_HOME=$(dirname $(readlink -f $0)) 2819e95205Sopenharmony_ciHVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js 2919e95205Sopenharmony_ciwarn() { 3019e95205Sopenharmony_ci echo "" 3119e95205Sopenharmony_ci echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 3219e95205Sopenharmony_ci} 3319e95205Sopenharmony_ci 3419e95205Sopenharmony_cierror() { 3519e95205Sopenharmony_ci echo "" 3619e95205Sopenharmony_ci echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 3719e95205Sopenharmony_ci} 3819e95205Sopenharmony_ci 3919e95205Sopenharmony_cifail() { 4019e95205Sopenharmony_ci error "$@" 4119e95205Sopenharmony_ci exit 1 4219e95205Sopenharmony_ci} 4319e95205Sopenharmony_ci 4419e95205Sopenharmony_ci# Determine node to start hvigor wrapper script 4519e95205Sopenharmony_ciif [ -n "${NODE_HOME}" ];then 4619e95205Sopenharmony_ci EXECUTABLE_NODE="${NODE_HOME}/bin/node" 4719e95205Sopenharmony_ci if [ ! -x "$EXECUTABLE_NODE" ];then 4819e95205Sopenharmony_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" 4919e95205Sopenharmony_ci fi 5019e95205Sopenharmony_cielse 5119e95205Sopenharmony_ci EXECUTABLE_NODE="node" 5219e95205Sopenharmony_ci which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" 5319e95205Sopenharmony_cifi 5419e95205Sopenharmony_ci 5519e95205Sopenharmony_ci# Check hvigor wrapper script 5619e95205Sopenharmony_ciif [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then 5719e95205Sopenharmony_ci fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" 5819e95205Sopenharmony_cifi 5919e95205Sopenharmony_ci 6019e95205Sopenharmony_ci# start hvigor-wrapper script 6119e95205Sopenharmony_ciexec "${EXECUTABLE_NODE}" \ 6219e95205Sopenharmony_ci "${HVIGOR_WRAPPER_SCRIPT}" "$@" 63