Use sh instead of ash in apex-pdp
[policy/apex-pdp.git] / packages / apex-pdp-package-full / src / main / package / scripts / apexEngine.sh
1 #!/usr/bin/env sh
2
3 #-------------------------------------------------------------------------------
4 # ============LICENSE_START=======================================================
5 #  Copyright (C) 2016-2018 Ericsson. All rights reserved.
6 #  Modifications Copyright (C) 2020-2021 AT&T Intellectual Property.
7 # ================================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #      http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20 # SPDX-License-Identifier: Apache-2.0
21 # ============LICENSE_END=========================================================
22 #-------------------------------------------------------------------------------
23
24 ##
25 ## Script to run the APEX, calls apexApps.sh
26 ##
27 ## @package    org.onap.policy.apex
28 ## @author     Sven van der Meer <sven.van.der.meer@ericsson.com>
29 ## @version    v2.0.0
30
31 ##
32 ## DO NOT CHANGE CODE BELOW, unless you know what you are doing
33 ##
34
35 if [ -z "${APEX_USER}" ]; then
36         APEX_USER="apexuser"
37 fi
38
39 id $APEX_USER > /dev/null 2>& 1
40 if [ "$?" != "0" ]; then
41         echo 'cannot run apex, user "'$APEX_USER'" does not exit'
42         exit
43 fi
44
45 if [ $(whoami) != "$APEX_USER" ]; then
46         echo 'Apex must be run as user "'$APEX_USER'"'
47         exit
48 fi
49
50 if [ -z "${APEX_HOME}" ]; then
51         APEX_HOME="/opt/app/policy/apex-pdp"
52 fi
53
54 if [ ! -d "${APEX_HOME}" ]; then
55         echo
56         echo 'Apex directory "'$APEX_HOME'" not set or not a directory'
57         echo "Please set environment for 'APEX_HOME'"
58         exit
59 fi
60
61 if [ $(whoami) = "$APEX_USER" ]; then
62         $APEX_HOME/bin/apexApps.sh engine $*
63 else
64         su $APEX_USER -c "$APEX_HOME/bin/apexApps.sh engine $*"
65 fi