/
zssServer.sh
executable file
·150 lines (133 loc) · 3.74 KB
/
zssServer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/sh
# This program and the accompanying materials are
# made available under the terms of the Eclipse Public License v2.0 which accompanies
# this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
#
# SPDX-License-Identifier: EPL-2.0
#
# Copyright Contributors to the Zowe Project.
## launch the Zowe Secure Services Server
ZSS_SCRIPT_DIR=$(cd `dirname $0` && pwd)
echo "pwd = `pwd`"
echo "Script dir = $(cd `dirname $0` && pwd)"
if [ -n "$ZSS_CONFIG_FILE" ]
then
CONFIG_FILE=$ZSS_CONFIG_FILE
elif [ -n "$ZLUX_CONFIG_FILE" ]
then
CONFIG_FILE=$ZLUX_CONFIG_FILE
else
echo "No config file specified, using default"
CONFIG_FILE="${dir}/../deploy/instance/ZLUX/serverConfig/zluxserver.json"
fi
if [ -n "$ZSS_LOG_FILE" ]
then
if [[ $ZSS_LOG_FILE == /* ]]
then
echo "Absolute log location given."
else
ZSS_LOG_FILE="${ZSS_SCRIPT_DIR}/${ZSS_LOG_FILE}"
echo "Relative log location given, set to absolute path=$ZSS_LOG_FILE"
fi
if [ -n "$ZSS_LOG_DIR" ]
then
echo "ZSS_LOG_FILE set (value $ZSS_LOG_FILE). Ignoring ZSS_LOG_DIR."
fi
else
# _FILE was not specified; default filename, and check and maybe default _DIR
if [ -z "$ZSS_LOG_DIR" ]
then
ZSS_LOG_DIR="../log"
fi
if [ -f "$ZSS_LOG_DIR" ]
then
ZSS_LOG_FILE=$ZSS_LOG_DIR
elif [ ! -d "$ZSS_LOG_DIR" ]
then
echo "Will make log directory $ZSS_LOG_DIR"
mkdir -p $ZSS_LOG_DIR
if [ $? -ne 0 ]
then
echo "Cannot make log directory. Logging disabled."
ZSS_LOG_FILE=/dev/null
fi
fi
ZLUX_ROTATE_LOGS=0
if [ -d "$ZSS_LOG_DIR" ] && [ -z "$ZSS_LOG_FILE" ]
then
ZSS_LOG_FILE="$ZSS_LOG_DIR/zssServer-`date +%Y-%m-%d-%H-%M`.log"
if [ -z "$ZSS_LOGS_TO_KEEP" ]
then
ZSS_LOGS_TO_KEEP=5
fi
echo $ZSS_LOGS_TO_KEEP|egrep '^\-?[0-9]+$' >/dev/null
if [ $? -ne 0 ]
then
echo "ZSS_LOGS_TO_KEEP not a number. Defaulting to 5."
ZSS_LOGS_TO_KEEP=5
fi
if [ $ZSS_LOGS_TO_KEEP -ge 0 ]
then
ZLUX_ROTATE_LOGS=1
fi
fi
#Clean up excess logs, if appropriate.
if [ $ZLUX_ROTATE_LOGS -ne 0 ]
then
for f in `ls -r -1 $ZSS_LOG_DIR/zssServer-*.log 2>/dev/null | tail +$ZSS_LOGS_TO_KEEP`
do
echo zssServer.sh removing $f
rm -f $f
done
fi
fi
ZSS_CHECK_DIR="$(dirname "$ZSS_LOG_FILE")"
if [ ! -d "$ZSS_CHECK_DIR" ]
then
echo "ZSS_LOG_FILE contains nonexistent directories. Creating $ZSS_CHECK_DIR"
mkdir -p $ZSS_CHECK_DIR
if [ $? -ne 0 ]
then
echo "Cannot make log directory. Logging disabled."
ZSS_LOG_FILE=/dev/null
fi
fi
#Now sanitize final log filename: if it is relative, make it absolute before cd to js
if [ "$ZSS_LOG_FILE" != "/dev/null" ]
then
ZSS_CHECK_DIR=$(cd "$(dirname "$ZSS_LOG_FILE")"; pwd)
ZSS_LOG_FILE=$ZSS_CHECK_DIR/$(basename "$ZSS_LOG_FILE")
fi
echo ZSS_LOG_FILE=${ZSS_LOG_FILE}
export ZSS_LOG_FILE=$ZSS_LOG_FILE
if [ ! -e $ZSS_LOG_FILE ]
then
touch $ZSS_LOG_FILE
if [ $? -ne 0 ]
then
echo "Cannot make log file. Logging disabled."
ZSS_LOG_FILE=/dev/null
fi
else
if [ -d $ZSS_LOG_FILE ]
then
echo "ZSS_LOG_FILE is a directory. Must be a file. Logging disabled."
ZSS_LOG_FILE=/dev/null
fi
fi
if [ ! -w "$ZSS_LOG_FILE" ]
then
echo file "$ZSS_LOG_FILE" is not writable. Logging disabled.
ZSS_LOG_FILE=/dev/null
fi
#Determined log file. Run zssServer.
export dir=`dirname "$0"`
cd $dir
_BPX_SHAREAS=NO _BPX_JOBNAME=${ZOWE_PREFIX}SZ1 ./zssServer "${CONFIG_FILE}" 2>&1 | tee $ZSS_LOG_FILE
# This program and the accompanying materials are
# made available under the terms of the Eclipse Public License v2.0 which accompanies
# this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
#
# SPDX-License-Identifier: EPL-2.0
#
# Copyright Contributors to the Zowe Project.