123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #!/bin/bash
- export JAVA_HOME=/root/jdk1.8.0_181
- export PATH=$JAVA_HOME/bin:$PATH
- export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
- bashPath=/root/maxcompute_job/flow
- odps_cmd=/root/maxcompute_job/flow/odpscmd
- debug=0
- if [ $# -eq 0 ]; then
- echo "---------------------------------------------------------------------------"
- # OS Type
- echo " OS Type: $(uname -o)"
- # OS Release Version and Name
- echo "OS Release Version and Name: $(cat /etc/issue | head -n 1)"
- #Architecture
- echo " Architecture: $(uname -m)"
- #Kernel Release
- echo " Kernel Release: $(uname -r)"
- #hostname
- echo " hostname: $HOSTNAME"
- #Internal IP
- echo " Internal IP: $(hostname -I)"
- #External IP
- echo " External IP: $(curl --connect-timeout 10 -m 20 -s ipecho.net/plain)"
- #DNS
- dnsservers=""
- for i in $(cat /etc/resolv.conf | grep '^nameserver' | awk '{print $NF}'); do
- dnsservers="$dnsservers$i "
- done
- echo " DNS: $dnsservers"
- #if connected to Internet or not
- echo " internet status: $(ping -c 2 www.baidu.com &>/dev/null && echo 'connected' || echo 'disconnected')"
- echo "---------------------------------------------------------------------------"
- fi
- if [ $# -eq 1 ]; then
- echo "启动debug模式"
- debug=1
- fi
- start_job() {
- echo "start job:$1"
- if [ $# -lt 1 ]; then
- echo ""
- # shellcheck disable=SC2242
- exit -1
- fi
- if [ $debug -eq 1 ]; then
- echo "debug model。。。"
- java -jar $bashPath/DataWorks-flow-touch.jar -f $bashPath/jobs/$1 -d
- return
- else
- echo ""
- java -jar $bashPath/DataWorks-flow-touch.jar -f $bashPath/jobs/$1 -odps $odps_cmd
- fi
- if [ $? -eq 0 ]; then
- echo "$1 succeed"
- else
- echo "$1 failed"
- exit $?
- fi
- }
- # shellcheck disable=SC2164
- cd $bashPath/repo
- git pull origin master # 拉取仓库
- cd ..
- java -jar $bashPath/DataWorks-flow-touch.jar -w
- if [ $? -eq 0 ]; then
- echo "上游数据已同步完成!"
- else
- echo "上游数据长时间未同步完成,程序中止!"
- exit $?
- fi
- java -jar $bashPath/DataWorks-flow-touch.jar -q
- if [ $? -eq 0 ]; then
- echo "company is not empty!"
- else
- echo "company is empty!"
- exit $?
- fi
- job_files=(task-step01.yaml task-step02.yaml task-step03.yaml task-step04.yaml)
- for e in ${job_files[@]}; do
- start_job $e
- done
- echo "end"
|