# 同步hi-ui
# 同步modules
# 同步login、main

# 工号，项目

if [ $# -gt 4 ] ; then
    echo "$3 操作命令有误，请重新输入！"
    exit 1
fi

# basePath='/opt/eap5/desktop'
basePath='/eap5.0/desktop'
tagPath=$basePath'/preview'
# tmpPath=$basePath'/project-template'
tmpPath='/eap5.0/hiruntime/project/desktop/project-template'
workName=$1
projectName=$2
oper=$3
uploadPath=$4

function read_dir(){
    for file in `ls $1`
    do
        if [ -d $1"/"$file ]  
        then
            read_dir $1"/"$file
        else
            echo $1"/"$file
        fi
    done
}

if [ $3 = "sync" ] ; then
    read_dir "${tagPath}/${workName}"
fi




#需要校验的IP
IP_ADDR=192.168.0.111

#获取本机IP地址列表
machine_ips=$(ip addr | grep 'inet' | grep -v 'inet6\|127.0.0.1' | grep -v grep | awk -F '/' '{print $1}' | awk '{print $2}')
log_info "current machine ips: ${machine_ips}"

#输入的IP与本机IP进行校验
ip_check=false
for machine_ip in ${machine_ips}; do
  if [[ "X${machine_ip}" == "X${IP_ADDR}" ]]; then
    ip_check=true
  fi
done

if [[ ${ip_check} != true ]]; then
  log_error "your input ip: ${IP_ADDR} is not the current IP address of this machine!"
  exit 1
fi 