2 # Copyright 2020 Huawei Technologies Co., Ltd.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # Validates if ip is valid
20 # checks if variable is unset
21 if [ -z "$ip_var" ] ; then
26 if ! echo "$ip_var" | grep -qE '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.)' ; then
35 if [ "${len}" -gt "64" ]; then
38 if ! echo "$hostname" | grep -qE '^[a-zA-Z0-9]*$|^[a-zA-Z0-9][a-zA-Z0-9_\-]*[a-zA-Z0-9]$'; then
44 # validates whether file exist
45 validate_file_exists() {
48 # checks variable is unset
49 if [ -z "$file_path" ]; then
50 echo "file path variable is not set"
54 # checks if file exists
55 if [ ! -f "$file_path" ]; then
56 echo "file does not exist"
63 validate_ip "$LISTEN_IP"
65 if [ ! "$valid_listen_ip" -eq "0" ]; then
66 echo "invalid ip address for listen ip"
70 if [ ! -z "$SERVER_NAME" ]; then
71 validate_name "$SERVER_NAME"
73 if [ ! "$valid_name" -eq "0" ]; then
74 echo "invalid ssl server name"
79 # ssl parameters validation
80 validate_file_exists "/usr/app/ssl/server_tls.crt"
81 valid_ssl_server_cert="$?"
82 if [ ! "$valid_ssl_server_cert" -eq "0" ]; then
83 echo "invalid ssl server certificate"
87 # ssl parameters validation
88 validate_file_exists "/usr/app/ssl/server_tls.key"
89 valid_ssl_server_key="$?"
90 if [ ! "$valid_ssl_server_key" -eq "0" ]; then
91 echo "invalid ssl server key"
95 # ssl parameters validation
96 validate_file_exists "/usr/app/ssl/ca.crt"
98 if [ ! "$valid_ssl_ca_crt" -eq "0" ]; then
99 echo "invalid ssl ca cert"
103 echo "Running Retail App"