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