sudo rm -rf /root/car/ sudo systemctl stop car.service sudo rm /lib/systemd/system/car.service sudo mkdir /root/car/ echo "下载安装包..." if sudo wget -O /root/car/car.zip https://cloud.caner.top/api/v3/file/get/4667/car.zip?sign=LHXY5OdRwtfqu7EaGYMC95DgKlPygn7S3VwScqG4vUs%3D%3A0; then echo '' else echo '下载失败,请重试!' exit fi if unzip -o /root/car/car.zip -d /root/car/;then rm /root/car/car.zip sudo chmod 744 /root/car/index.js sudo chmod 744 /root/car/lib/node echo '' else echo '解压失败!' exit fi echo '更换国内镜像' if echo "deb https://mirror.nju.edu.cn/debian/ bullseye main contrib non-free deb https://mirror.nju.edu.cn/debian-security/ bullseye-security main contrib non-free deb https://mirror.nju.edu.cn/debian bullseye-updates main contrib non-free " >> /etc/apt/sources.list;then echo '' else echo '更换失败,请手动更换!' exit fi if echo "deb https://mirror.nju.edu.cn/raspberrypi/debian/ bullseye main" >> /etc/apt/sources.list.d/raspi.list;then echo '' else echo '更换失败,请手动更换!' exit fi echo '更新镜像' if apt update && upgrade;then echo '' else echo '更新失败!' exit fi echo '开始安装gstreamer 依赖...' if sudo apt-get install libx264-dev libjpeg-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-ugly gstreamer1.0-tools gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-pulseaudio -y;then echo 'gstreamer 安装成功' else echo 'gstreamer 安装失败,请重试!' exit fi chmod 777 /root/car/start.sh if echo "[Unit] Description=Car-server After=network.target [Service] Type=simple User=root ExecStart=/root/car/start.sh & Restart=always RestartSec=3s [Install] WantedBy=multi-user.target" >> /lib/systemd/system/car.service;then echo '' else echo '自动设置开机启动失败,请稍后手动添加!' exit fi sudo systemctl daemon-reload if sudo systemctl enable car.service;then echo '' else echo '开机添加失败,请重试!' exit fi if sudo systemctl start car.service;then echo '车端服务启动成功!' else echo '车端服务启动失败,请重试!' exit fi exit