#!/bin/bash # 获取系统sudo权限 echo "1" | sudo -S su # 方法:检查apt安装的包是否成功 function apt_check(){ dpkg -l | grep -i $1 if [ $? -eq 0 ];then echo "======$1 已安装!=======" else echo "======$1 安装失败!=======" fi } # 方法:检查pip安装的包是否成功 function pip_check(){ pip3 list | grep -i $1 if [ $? -eq 0 ];then echo "======$1 已安装!=======" else echo "======$1 安装失败!=======" fi } # 写日志 echo "# " | sudo tee -a /home/$USER/Documents/test_env_report.log echo "# " | sudo tee -a /home/$USER/Documents/test_env_report.log echo "# " | sudo tee -a /home/$USER/Documents/test_env_report.log echo "# ==================查询测试环境是否安装成功======================= #" | sudo tee -a /home/$USER/Documents/test_env_report.log echo $(date) | sudo tee -a /home/$USER/Documents/test_env_report.log echo "# ============================================================= #" | sudo tee -a /home/$USER/Documents/test_env_report.log #===================================更新三方库的源================================== sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak sudo cp ./sources.list.other /etc/apt/sources.list && echo "三方源复制成功" | sudo tee -a /home/$USER/Documents/test_env_report.log sudo apt-get update && echo "三方源更新成功" | sudo tee -a /home/$USER/Documents/test_env_report.log #===================================测试环境安装================================== # pip3 sudo apt-get -y install python3-pip # git sudo apt-get -y install git # 安装pyautogui sudo pip3 install pillow sudo pip3 install python3-xlib sudo apt-get -y install scrot sudo apt-get -y install python3-tk sudo apt-get -y install python3-dev sudo pip3 install pyautogui -i http://pypi.douban.com/simple --trusted-host pypi.douban.com # 安装dogtail sudo apt-get -y install python3-pyatspi sudo pip3 install dogtail -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com # pip三方库 sudo pip3 install ddt sudo pip3 install BeautifulReport #sudo pip3 install unittestreport sudo pip3 install unittest-xml-reporting sudo pip3 install xlrd sudo pip3 install PyYAML sudo pip3 install pyscreenshot sudo pip3 install pytesseract # apt三方库 sudo apt-get -y install tesseract-ocr sudo apt-get -y install tesseract-ocr-eng sudo apt-get -y install tesseract-ocr-chi-sim # opencv sudo apt-get -y install python3-opencv || sudo apt install -f && sudo apt-get -y install python3-opencv sudo apt-get -y install python3-numpy # =======================检查测试是否安装成功============================== for i in python3-pip scrot python3-tk python3-dev python3-pyatspi tesseract-ocr do apt_check $i | sudo tee -a /home/$USER/Documents/test_env_report.log done for i in pillow python3-xlib pyautogui dogtail ddt BeautifulReport xlrd PyYAML pyscreenshot python3-opencv do pip_check $i | sudo tee -a /home/$USER/Documents/test_env_report.log done #===================================应用版本================================== echo "# " | sudo tee -a /home/$USER/Documents/app_version.log echo "# " | sudo tee -a /home/$USER/Documents/app_version.log echo "# " | sudo tee -a /home/$USER/Documents/app_version.log echo "# ==================查询应用版本======================= #" | sudo tee -a /home/$USER/Documents/app_version.log echo $(date) | sudo tee -a /home/$USER/Documents/app_version.log echo "# =================================================== #" | sudo tee -a /home/$USER/Documents/app_version.log #=======================更新多媒体应用的源============================ sudo cp ./sources.list.media /etc/apt/sources.list && echo "多媒体源复制成功" | sudo tee -a /home/$USER/Documents/app_version.log sudo apt-get update && echo "多媒体源更新成功" | sudo tee -a /home/$USER/Documents/app_version.log for i in libdde-file-manager dde-file-manager dde-desktop dde-disk-mount-plugin deepin-screen-recorder deepin-album deepin-music deepin-movie deepin-draw deepin-image-viewer do apt_get $i done # ========================查询应用版本============================= for i in libdde-file-manager dde-file-manager dde-desktop dde-disk-mount-plugin deepin-screen-recorder deepin-album deepin-music deepin-movie deepin-draw deepin-image-viewer do sudo apt policy $i | head -2 | sudo tee -a /home/$USER/Documents/app_version.log done # ========================从gitlab拉取代码============================= cd /home/$USER/Documents/ CONUSER=$( echo "dXQwMDEyMDMK" | base64 -d ) CONPASS=$( echo "MjAyMEBobXF6eQo" | base64 -d ) #cd /data/web/ git reset --hard expect -c "spawn git clone https://gitlabcd.uniontech.com/autotest/cd-desktop-app.git; expect "*Username*" { send "${CONUSER} "; exp_continue } "*Password*" { send "${CONPASS} " }; interact" # ======================================================================= # 复制静态资源到图片目录 cd - sudo cp -R ./ATimage /home/$USER/Pictures/ && echo "图片资源复制成功" | sudo tee -a /home/$USER/Documents/app_version.log cd /home/$USER/Pictures/ sudo chmod -R 777 ATimage cd - # 复制视频资源 rm -rf /home/$USER/Videos/*.mp4 if [ -f /usr/share/dde-introduction/introduction.mp4 ];then cp /usr/share/dde-introduction/introduction.mp4 ~/Videos/introduction.mp4 echo '视频文件复制成功。' else echo '视频文件不存在!' fi # 替换tree.py sudo cp ./tree.py /usr/local/lib/python3.7/dist-packages/dogtail/tree.py # 将画板、看图、影院发送到任务栏 dbus-send --session --print-reply --dest=com.deepin.dde.daemon.Dock /com/deepin/dde/daemon/Dock com.deepin.dde.daemon.Dock.RequestDock string:/usr/share/applications/deepin-draw.desktop int32:0 dbus-send --session --print-reply --dest=com.deepin.dde.daemon.Dock /com/deepin/dde/daemon/Dock com.deepin.dde.daemon.Dock.RequestDock string:/usr/share/applications/deepin-image-viewer.desktop int32:0 dbus-send --session --print-reply --dest=com.deepin.dde.daemon.Dock /com/deepin/dde/daemon/Dock com.deepin.dde.daemon.Dock.RequestDock string:/usr/share/applications/deepin-movie.desktop int32:0