echo "=====================================================create====================================================="

#!/usr/bin/env bash

function create() {

  if [ -d "$nervui_app_home" ];then
    echo "$nervui_app_home exists!"
  else
    echo "start mkdir $nervui_app_home"
    mkdir -p "$nervui_app_home"
  fi

  pkg_file_name=${pkg_url##*/}
  pkg_file_path="$nervui_app_home$pkg_file_name"


  echo "start download $pkg_url"
  curl -L -o $pkg_file_path $pkg_url


  echo "start install $pkg_file_path"
  tar -xf $pkg_file_path -C $nervui_app_home

}

if [ "$pkg_url" == "" ]; then
    echo {\"error\":\"pkg_url is empty\"}
    exit 1
elif [ "$nervui_app_home" == ""  ]; then
    echo {\"error\":\"nervui_app_home is empty\"}
    exit 1
else
    create
fi
