install.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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
  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
  20. fi
  21. echo '更换国内镜像'
  22. if echo "deb https://mirror.nju.edu.cn/debian/ bullseye main contrib non-free
  23. deb https://mirror.nju.edu.cn/debian-security/ bullseye-security main contrib non-free
  24. deb https://mirror.nju.edu.cn/debian bullseye-updates main contrib non-free
  25. " >> /etc/apt/sources.list;then
  26. echo ''
  27. else
  28. echo '更换失败,请手动更换!'
  29. exit
  30. fi
  31. if echo "deb https://mirror.nju.edu.cn/raspberrypi/debian/ bullseye main" >> /etc/apt/sources.list.d/raspi.list;then
  32. echo ''
  33. else
  34. echo '更换失败,请手动更换!'
  35. exit
  36. fi
  37. echo '更新镜像'
  38. if apt update && upgrade;then
  39. echo ''
  40. else
  41. echo '更新失败!'
  42. exit
  43. fi
  44. echo '开始安装gstreamer 依赖...'
  45. 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
  46. echo 'gstreamer 安装成功'
  47. else
  48. echo 'gstreamer 安装失败,请重试!'
  49. exit
  50. fi
  51. chmod 777 /root/car/start.sh
  52. if echo "[Unit]
  53. Description=Car-server
  54. After=network.target
  55. [Service]
  56. Type=simple
  57. User=root
  58. ExecStart=/root/car/start.sh &
  59. Restart=always
  60. RestartSec=3s
  61. [Install]
  62. WantedBy=multi-user.target" >> /lib/systemd/system/car.service;then
  63. echo ''
  64. else
  65. echo '自动设置开机启动失败,请稍后手动添加!'
  66. exit
  67. fi
  68. sudo systemctl daemon-reload
  69. if sudo systemctl enable car.service;then
  70. echo ''
  71. else
  72. echo '开机添加失败,请重试!'
  73. exit
  74. fi
  75. if sudo systemctl start car.service;then
  76. echo '车端服务启动成功!'
  77. else
  78. echo '车端服务启动失败,请重试!'
  79. exit
  80. fi
  81. exit