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 1 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 1 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 1 fi read -p "输入车端socket地址(ws://ip:port):" URL URL=${URL:-URL} if [ ! -n "$URL" ] ;then echo "请输入车端socket地址" exit 1 else echo "遥控端地址:$URL" fi echo "[Unit] Description=Car-server After=network.target [Service] Type=simple User=root ExecStart=/root/car/lib/node /root/car/index.js $URL & Restart=always RestartSec=3s [Install] WantedBy=multi-user.target" | sudo tee /lib/systemd/system/car.service echo 'systmctl 服务安装成功' echo '' sudo systemctl daemon-reload if sudo systemctl enable car.service;then echo '开机添加成功' else echo '开机添加失败,请重试!' exit 1 fi echo '' if sudo systemctl start car.service;then echo '车端服务启动成功!' else echo '车端服务启动失败,请重试!' exit 1 fi exit