Browse Source

Signed-off-by: caner <5658514@qq.com>

caner 3 years ago
parent
commit
dc88023161
1 changed files with 27 additions and 34 deletions
  1. 27 34
      install.sh

+ 27 - 34
install.sh

@@ -1,49 +1,42 @@
-echo '清除缓存...'
-sudo rm /tmp/car.tar.gz
-sudo rm -rf /root/car
-sudo rm /usr/bin/node
+sudo rm -rf /root/car/
+sudo systemctl stop car.service
 sudo rm /lib/systemd/system/car.service
-sudo systemctl daemon-reload
-echo ''
-
+sudo mkdir /root/car/
 echo "下载安装包..."
-if wget -O /tmp/car.tar.gz https://git.caner.top/Pip-Telecar/Car/archive/car.tar.gz; then
-    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
-echo ''
-echo '开始解压...'
-if tar -zxf /tmp/car.tar.gz -C /root/;then
-    echo '解压成功'
+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 '解压失败,请重试!'
+    echo '解压失败!'
     exit 1
-echo ''
+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
-echo ''
-echo '安装 node 服务'
-if ln -s /root/car/lib/node /usr/bin/node;then
-    echo 'node安装成功'
-else
-    echo 'node安装失败,请重试!'
-    exit 1
-echo ''
+fi
 
-read -p "输入车端socket地址(ws://ip:port):" wsUrl
-wsUrl=${wsUrl}
-if "";then
-    echo "遥控端地址:$wsUrl"
-else
-    echo '地址不能为空!'
+read -p "输入车端socket地址(ws://ip:port):" URL
+URL=${URL:-URL}
+if  [ ! -n "$URL" ] ;then
+    echo "请输入车端socket地址"
     exit 1
+else
+    echo "遥控端地址:$URL"
+fi
 
-echo '安装 systemctl 开机启动服务'
 echo "[Unit]
 Description=Car-server
 After=network.target
@@ -51,26 +44,26 @@ After=network.target
 [Service]
 Type=simple
 User=root
-ExecStart=/usr/bin/node /root/car/index.js $wsUrl &
+ExecStart=/root/car/lib/node /root/car/index.js $URL &
 Restart=always
 RestartSec=3s
 
 [Install]
-WantedBy=multi-user.target" | sudo tee /etc/systemd/system/car.service
+WantedBy=multi-user.target" | sudo tee /lib/systemd/system/car.service
 echo 'systmctl 服务安装成功'
 echo ''
-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
-echo ''
+fi    
 exit