install.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. echo '清除缓存...'
  2. sudo rm /tmp/car.tar.gz
  3. sudo rm -rf /root/car
  4. sudo rm /usr/bin/node
  5. sudo rm /lib/systemd/system/car.service
  6. sudo systemctl daemon-reload
  7. echo ''
  8. echo "下载安装包..."
  9. if wget -O /tmp/car.tar.gz https://git.caner.top/Pip-Telecar/Car/archive/car.tar.gz; then
  10. echo '下载成功'
  11. else
  12. echo '下载失败,请重试!'
  13. exit 1
  14. echo ''
  15. echo '开始解压...'
  16. if tar -zxf /tmp/car.tar.gz -C /root/;then
  17. echo '解压成功'
  18. else
  19. echo '解压失败,请重试!'
  20. exit 1
  21. echo ''
  22. echo '开始安装gstreamer 依赖...'
  23. 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
  24. echo 'gstreamer 安装成功'
  25. else
  26. echo 'gstreamer 安装失败,请重试!'
  27. exit 1
  28. echo ''
  29. echo '安装 node 服务'
  30. if ln -s /root/car/lib/node /usr/bin/node;then
  31. echo 'node安装成功'
  32. else
  33. echo 'node安装失败,请重试!'
  34. exit 1
  35. echo ''
  36. read -p "输入车端socket地址(ws://ip:port):" wsUrl
  37. wsUrl=${wsUrl}
  38. if "";then
  39. echo "遥控端地址:$wsUrl"
  40. else
  41. echo '地址不能为空!'
  42. exit 1
  43. echo '安装 systemctl 开机启动服务'
  44. echo "[Unit]
  45. Description=Car-server
  46. After=network.target
  47. [Service]
  48. Type=simple
  49. User=root
  50. ExecStart=/usr/bin/node /root/car/index.js $wsUrl &
  51. Restart=always
  52. RestartSec=3s
  53. [Install]
  54. WantedBy=multi-user.target" | sudo tee /etc/systemd/system/car.service
  55. echo 'systmctl 服务安装成功'
  56. echo ''
  57. echo '添加开机启动..'
  58. sudo systemctl daemon-reload
  59. if sudo systemctl enable car.service;then
  60. echo '开机添加成功'
  61. else
  62. echo '开机添加失败,请重试!'
  63. exit 1
  64. echo ''
  65. if sudo systemctl start car.service;then
  66. echo '车端服务启动成功!'
  67. else
  68. echo '车端服务启动失败,请重试!'
  69. exit 1
  70. echo ''
  71. exit