#!/bin/bash set -e update(){ sudo apt update sudo timedatectl set-timezone Asia/Shanghai } get_supervisor(){ echo "开始安装supervisor" sudo apt install supervisor # shellcheck disable=SC2181 echo $? if [ $? != 0 ] then echo "supervisor install failed" else sudo cp /etc/supervisor/supervisord.conf /etc/supervisor/supervisord.conf.bak sudo cp conf/example/supervisord.conf /etc/supervisor/supervisord.conf sudo chmod 777 /etc/supervisor/conf.d sudo systemctl start supervisor sudo systemctl enable supervisor echo "supervisor install done!" fi } get_ffmpeg(){ echo "开始安装ffmpeg" sudo apt install ffmpeg -y # shellcheck disable=SC2181 echo $? if [ $? != 0 ] then echo "ffmpeg install failed" exit 1 else echo "ffmpeg install done!" fi } get_git(){ echo "开始安装git" sudo apt install git # shellcheck disable=SC2181 echo $? if [ $? != 0 ] then echo "git install failed" exit 1 else echo "git install done!" fi } install_appendent(){ if [ ! -d "/home/pi" ] then echo "创建目录 /home/pi" sudo mkdir /home/pi cd /home/pi echo 'lihai_lot_walnutpi_dev_1' | tee device_name fi if [ -d "/home/pi/lot_manager" ] then echo "lot_manager already exits" exit 1 fi echo "获取lot_manager项目" if git clone "https://gitea.lihaink.cn/xyj/lot_manager.git" "/home/pi" then echo "克隆成功" cd lot_manager if pip install --verbose -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple then echo "安装成功" else echo "失败" exit 1 fi if sudo pip install Adafruit-Blinka then echo "安装成功" else echo "失败" exit 1 fi else sudo rm -rf /home/pi echo "克隆失败,退出状态为 $?" fi } db_init(){ python /home/pi/lot_manager/create_db.py if [ ! -d "/home/pi/mp4" ] then echo "创建目录 /home/pi/mp4" sudo mkdir /home/pi/mp4 else echo "/home/pi/mp4 is already exits" exit 1 fi } final(){ sudo systemctl restart supervisor supervisorctl reload }