1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| #!/bin/bash
action=$1 apptype=$2 svc=$3 ver=$4 webpath=$6
ROOT=/data
case $apptype in
'java') if [ ! -f /usr/lib/systemd/system/$svc.service ];then if [ ! -f $ROOT/java_demo.service ];then echo "java_demo.service not found"; exit ; fi sed "s/__SVC__/${svc}/g" $ROOT/java_demo.service > /usr/lib/systemd/system/$svc.service systemctl daemon-reload systemctl enable $svc.service fi
case $action in 'restart') systemctl restart $svc.service ;; 'update') ln -snf $ROOT/temp/${svc}-${ver}.jar $ROOT/app/${svc}.jar systemctl restart $svc.service ls -t $ROOT/temp/${svc}-[[:digit:]]*.jar | sed -n '11,$p' | xargs rm -vf ;; 'stop') systemctl stop $svc.service ;; 'restore') ver=$5 ln -snf $ROOT/temp/${svc}-${ver}.jar $ROOT/app/${svc}.jar systemctl restart $svc.service ;; *) ;; esac ;;
'js') case $action in update) rm -rf $ROOT/webapp/$webpath mkdir -p $ROOT/webapp/$webpath tar -xf $ROOT/temp/$svc-$ver.tgz -C $ROOT/webapp/$webpath ls -t $ROOT/temp/${svc}-[[:digit:]]*.tgz | sed -n '11,$p' | xargs rm -vf ;; restore) ver=$5 rm -rf $ROOT/webapp/${webpath} mkdir -p $ROOT/webapp/$webpath tar -xf $ROOT/temp/$svc-$ver.tgz -C $ROOT/webapp/$webpath ;; *) ;; esac ;; 'autotest') case $action in update) rm -rf $ROOT/autotest/web/$svc rm -rf $ROOT/autotest/web/${svc}*.html rm -rf $ROOT/autotest/web/${svc}*.log mkdir -p $ROOT/autotest/web/$svc/{logs,screen_shot}
rm -rf $ROOT/autotest/$svc mkdir -p $ROOT/autotest/$svc/ChromeDriver/linux/
export PATH=/opt/python3/bin:$PATH
tar -xf $ROOT/temp/$svc-$ver.tgz -C $ROOT/autotest/$svc
rm -rf /data/autotest/${svc}/ChromeDriver/linux/chromedriver rm -rf /data/autotest/${svc}/CommonLibrary/chromedriver.exe ln -sf $ROOT/autotest/chromedriver /data/autotest/${svc}/ChromeDriver/linux/chromedriver ln -sf $ROOT/autotest/chromedriver /data/autotest/${svc}/CommonLibrary/chromedriver.exe cd /data/autotest/$svc && python3 ./runs/run.py > $ROOT/autotest/web/${svc}.log 2>&1
\cp -rf $ROOT/autotest/$svc/reports/TestResult.html $ROOT/autotest/web/${svc}_TestResult.html \cp -rf $ROOT/autotest/$svc/logs/*.log $ROOT/autotest/web/${svc}/logs/ \cp -rf $ROOT/autotest/$svc/screen_shot/*.png $ROOT/autotest/web/${svc}/screen_shot/
sed -i 's|http://127.0.0.1/show_log/?log_path=/data/autotest/|http://autotest.farmbgy.com/|g' $ROOT/autotest/web/${svc}_TestResult.html sed -i 's|http://127.0.0.1/show_photo/?pic_path=/data/autotest/|http://autotest.farmbgy.com/|g' $ROOT/autotest/web/${svc}_TestResult.html sed -i 's|http://127.0.0.1:5000/show_log/?log_path=/data/autotest/|http://autotest.farmbgy.com/|g' $ROOT/autotest/web/${svc}_TestResult.html sed -i 's|http://127.0.0.1:5000/show_photo/?pic_path=/data/autotest/|http://autotest.farmbgy.com/|g' $ROOT/autotest/web/${svc}_TestResult.html ;; *) ;; esac ;;
*) ;; esac
|