install.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. sudo rm -rf /root/car/
  2. sudo systemctl stop car.service
  3. sudo rm /lib/systemd/system/car.service
  4. sudo mkdir /root/car/
  5. echo "下载安装包..."
  6. if sudo wget -O /root/car/car.zip https://cloud.caner.top/api/v3/file/get/4667/car.zip?sign=LHXY5OdRwtfqu7EaGYMC95DgKlPygn7S3VwScqG4vUs%3D%3A0; then
  7. echo '开始解压...'
  8. else
  9. echo '下载失败,请重试!'
  10. exit 1
  11. fi
  12. if unzip -o /root/car/car.zip -d /root/car/;then
  13. rm /root/car/car.zip
  14. sudo chmod 744 /root/car/index.js
  15. sudo chmod 744 /root/car/lib/node
  16. echo ''
  17. else
  18. echo '解压失败!'
  19. exit 1
  20. fi
  21. echo '开始安装gstreamer 依赖...'
  22. 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
  23. echo 'gstreamer 安装成功'
  24. else
  25. echo 'gstreamer 安装失败,请重试!'
  26. exit 1
  27. fi
  28. read -p "输入车端socket地址(ws://ip:port):" URL
  29. URL=${URL:-URL}
  30. if [ ! -n "$URL" ] ;then
  31. echo "请输入车端socket地址"
  32. exit 1
  33. else
  34. echo "遥控端地址:$URL"
  35. fi
  36. echo "[Unit]
  37. Description=Car-server
  38. After=network.target
  39. [Service]
  40. Type=simple
  41. User=root
  42. ExecStart=/root/car/lib/node /root/car/index.js $URL &
  43. Restart=always
  44. RestartSec=3s
  45. [Install]
  46. WantedBy=multi-user.target" | sudo tee /lib/systemd/system/car.service
  47. echo 'systmctl 服务安装成功'
  48. echo ''
  49. sudo systemctl daemon-reload
  50. if sudo systemctl enable car.service;then
  51. echo '开机添加成功'
  52. else
  53. echo '开机添加失败,请重试!'
  54. exit 1
  55. fi
  56. echo ''
  57. if sudo systemctl start car.service;then
  58. echo '车端服务启动成功!'
  59. else
  60. echo '车端服务启动失败,请重试!'
  61. exit 1
  62. fi
  63. exit