23796c68e4fcb13caa64bac6152175ba9e8d7f84
[ealt-edge.git] / example-apps / ROBO / retail_app / configs / start.sh
1 #!/bin/bash
2 # Copyright 2020 Huawei Technologies Co., Ltd.
3 #
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
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15
16 # Validates if ip is valid
17 validate_ip()
18 {
19  ip_var="$1"
20     # checks if variable is unset
21  if [ -z "$ip_var" ] ; then
22     echo "ip is not set"
23     return 1
24  fi
25
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
27    return 1
28  fi
29  return 0
30 }
31
32 validate_name() {
33   hostname="$1"
34   len="${#hostname}"
35   if [ "${len}" -gt "64" ]; then
36     return 1
37   fi
38   if ! echo "$hostname" | grep -qE '^[a-zA-Z0-9]*$|^[a-zA-Z0-9][a-zA-Z0-9_\-]*[a-zA-Z0-9]$'; then
39     return 1
40   fi
41   return 0
42 }
43
44 echo "Running Retail App"
45 umask 0027
46 cd /usr/app || exit
47 python -u run.py