move all bash to ash shell scripts - apex
[policy/apex-pdp.git] / packages / apex-pdp-package-full / src / main / package / scripts / apexOnapPf.sh
1 #!/usr/bin/env ash
2 #
3 # ============LICENSE_START=======================================================
4 #  Copyright (C) 2019-2020 Nordix Foundation.
5 #  Modifications Copyright (C) 2020 AT&T Intellectual Property
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 # SPDX-License-Identifier: Apache-2.0
20 # ============LICENSE_END=========================================================
21 #
22
23
24 ##
25 ## Script to run onappf PDP-A, calls apexApps.sh
26 ##
27 ## @package    org.onap.policy.apex
28 ## @author     Ajith Sreekumar <ajith.sreekumar@est.tech>
29 ## @version    v1.0.0
30
31
32 if [ -z "$APEX_USER" ]; then
33    APEX_USER="apexuser"
34 fi
35
36 id $APEX_USER > /dev/null 2>& 1
37 if [ "$?" != "0" ]; then
38    echo 'cannot run apex, user "'$APEX_USER'" does not exit'
39    exit
40 fi
41
42 if [ $(whoami) != "$APEX_USER" ]; then
43    echo 'Apex must be run as user "'$APEX_USER'"'
44    exit
45 fi
46
47 if [ -z $APEX_HOME ]; then
48    APEX_HOME="/opt/app/policy/apex-pdp"
49 fi
50
51 if [ ! -d $APEX_HOME ]; then
52    echo
53    echo 'Apex directory "'$APEX_HOME'" not set or not a directory'
54    echo "Please set environment for 'APEX_HOME'"
55    exit
56 fi
57
58 if [ -f "${HOME}/config/policy-truststore" ]; then
59     echo "overriding policy-truststore"
60     cp -f "${HOME}"/config/policy-truststore "${APEX_HOME}"/etc/ssl/
61 fi
62
63 if [ -f "${HOME}"/config/policy-keystore ]; then
64     echo "overriding policy-keystore"
65     cp -f "${HOME}"/config/policy-keystore "${APEX_HOME}"/etc/ssl/
66 fi
67
68 if [ -f "${HOME}"/config/logback.xml ]; then
69     echo "overriding logback.xml"
70     cp -f "${HOME}"/config/logback.xml "${APEX_HOME}"/etc/
71 fi
72
73 if [ $(whoami) = "$APEX_USER" ]; then
74    $APEX_HOME/bin/apexApps.sh onappf $*
75 else
76    su $APEX_USER -c "$APEX_HOME/bin/apexApps.sh onappf $*"
77 fi