标签:count bash contain while gerrit rpo tac purpose change
从第3行到第6行,看出此脚本的执行目录是在上一层目录。
sos-ci git:(master) cat -n start-ci.sh
1 #!/bin/bash
2
3 mkdir sos-data
4
5 cd sos-ci
6 ./set-env-to-vars.sh
7
8 COUNTER=0
9
10 # Loop until ps aux | grep -> exit code 0 """sendmail: MTA: accepting connections"""
11 # sleep every 2 seconds, after 50 counts, re-execute /etc/init.d/sendmail start &
12 # after 300 counts, exit with 1 if grep still returns null
13
14 command="/etc/init.d/sendmail start &"
15 grep_command="ps aux | grep ‘sendmail: MTA: accepting connections‘"
16
17 while [ $COUNTER -lt 300 ] //调用sendmail,每100秒执行一次,共600秒。
18 do
19 if [ $COUNTER -eq 0 ] || [ $(($COUNTER % 50)) -eq 0 ]; then
20 $command
21 fi
22 eval $grep_command
23 if [ $? -eq 0 ]; then
24 break
25 else
26 COUNTER=$((COUNTER+1))
27 echo "Waiting for sendmail to start - Counter: $COUNTER"
28 sleep 2
29 fi
30 if [ $COUNTER -eq 299 ]; then
31 echo "FATAL ERROR: SENDMAIL FAILED TO START"
32 exit 1
33 fi
34 done
35
36 # os_ci is the main sos-ci code which will run the entire pipeline
37 # this will listen to gerrit event stream and put the patchsets to the queue and perform tempest testing on them
38
39 if [ ${#test_it_patch_num} -gt 1 ]
40 then
41 python sos-ci/testit.py $test_it_patch_num /sos-data
42 else
43 python sos-ci/os_ci.py
44 fi
45
46
47 # testit.py is for testing purpose
48 # this will run the entire process(install devstack, run tempest, publish logs) with one patchset that has been pushed to gerrit
49 # patchset is of the form ‘refs/changes/26/111226/3‘
50 # results_dir is of the form ‘/home/user/test-dir‘
51 # python sos-ci/testit.py <ref-patchset-num> <result-dir-location>
52
53
54 #python sos-ci/testit.py refs/changes/03/617503/11 /sos-data
55
56 # Use in debug mode to keep container alive after any failure for RCA
57 if [ -n "$STAGE" ]
58 then tail -f /dev/null
59 fi#
标签:count bash contain while gerrit rpo tac purpose change
原文地址:https://www.cnblogs.com/longchang/p/11239647.html