X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=example-apps%2FROBO%2FaPaaS%2FObj_Detection_service%2Fconfigs%2Fstart.sh;h=de45014e0cde282dbf107da6e90d3dd07d9dbe94;hb=e6d40ddb2640f434a9d7d7ed99566e5e8fa60cc1;hp=ec14d8dabcf5b038b712ef2b0eafa4ee0687f7a9;hpb=e86a146ea3e8e8485dd7acec49afe2549d7e2875;p=ealt-edge.git diff --git a/example-apps/ROBO/aPaaS/Obj_Detection_service/configs/start.sh b/example-apps/ROBO/aPaaS/Obj_Detection_service/configs/start.sh index ec14d8d..de45014 100644 --- a/example-apps/ROBO/aPaaS/Obj_Detection_service/configs/start.sh +++ b/example-apps/ROBO/aPaaS/Obj_Detection_service/configs/start.sh @@ -16,17 +16,48 @@ # Validates if ip is valid validate_ip() { + ip_var="$1" + # checks if variable is unset + if [ -z "$ip_var" ] ; then + echo "ip is not set" + return 1 + fi - + 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 + return 1 + fi + return 0 } validate_name() { - + hostname="$1" + len="${#hostname}" + if [ "${len}" -gt "64" ]; then + return 1 + fi + if ! echo "$hostname" | grep -qE '^[a-zA-Z0-9]*$|^[a-zA-Z0-9][a-zA-Z0-9_\-]*[a-zA-Z0-9]$'; then + return 1 + fi + return 0 } # validates whether file exist validate_file_exists() { + file_path="$1" + + # checks variable is unset + if [ -z "$file_path" ]; then + echo "file path variable is not set" + return 1 + fi + + # checks if file exists + if [ ! -f "$file_path" ]; then + echo "file does not exist" + return 1 + fi + return 0 } validate_ip "$LISTEN_IP" @@ -72,4 +103,4 @@ fi echo "Running Monitoring Service" umask 0027 cd /usr/app || exit -python run.py +python run.py \ No newline at end of file