Browse Source

更新 'install.sh'

Caner 3 years ago
parent
commit
fc9c0e5582
1 changed files with 17 additions and 13 deletions
  1. 17 13
      install.sh

+ 17 - 13
install.sh

@@ -4,10 +4,10 @@ sudo rm /lib/systemd/system/car.service
 sudo mkdir /root/car/
 sudo mkdir /root/car/
 echo "下载安装包..."
 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
 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 '开始解压...'
+    echo ''
 else
 else
     echo '下载失败,请重试!'
     echo '下载失败,请重试!'
-    exit 1
+    exit
 fi
 fi
 
 
 if unzip -o /root/car/car.zip -d /root/car/;then
 if unzip -o /root/car/car.zip -d /root/car/;then
@@ -17,7 +17,7 @@ if unzip -o /root/car/car.zip -d /root/car/;then
     echo ''
     echo ''
 else
 else
     echo '解压失败!'
     echo '解压失败!'
-    exit 1
+    exit
 fi
 fi
   
   
 echo '开始安装gstreamer 依赖...'
 echo '开始安装gstreamer 依赖...'
@@ -25,19 +25,19 @@ if sudo apt-get install libx264-dev libjpeg-dev libgstreamer1.0-dev libgstreamer
     echo 'gstreamer 安装成功'
     echo 'gstreamer 安装成功'
 else
 else
     echo 'gstreamer 安装失败,请重试!'
     echo 'gstreamer 安装失败,请重试!'
-    exit 1
+    exit
 fi
 fi
 
 
 read -p "输入车端socket地址(ws://ip:port):" URL
 read -p "输入车端socket地址(ws://ip:port):" URL
 URL=${URL:-URL}
 URL=${URL:-URL}
 if  [ ! -n "$URL" ] ;then
 if  [ ! -n "$URL" ] ;then
     echo "请输入车端socket地址"
     echo "请输入车端socket地址"
-    exit 1
+    exit
 else
 else
     echo "遥控端地址:$URL"
     echo "遥控端地址:$URL"
 fi
 fi
 
 
-echo "[Unit]
+if echo "[Unit]
 Description=Car-server
 Description=Car-server
 After=network.target
 After=network.target
 
 
@@ -49,21 +49,25 @@ Restart=always
 RestartSec=3s
 RestartSec=3s
 
 
 [Install]
 [Install]
-WantedBy=multi-user.target" | sudo tee /lib/systemd/system/car.service
-echo 'systmctl 服务安装成功'
-echo ''
+WantedBy=multi-user.target" >> /lib/systemd/system/car.service;then
+   echo ''
+else
+    echo '自动设置开机启动失败,请稍后手动添加!'
+    exit 
+fi   
+
 sudo systemctl daemon-reload
 sudo systemctl daemon-reload
 if sudo systemctl enable car.service;then
 if sudo systemctl enable car.service;then
-    echo '开机添加成功'
+    echo ''
 else
 else
     echo '开机添加失败,请重试!'
     echo '开机添加失败,请重试!'
-    exit 1
+    exit
 fi
 fi
-echo ''
+
 if sudo systemctl start car.service;then
 if sudo systemctl start car.service;then
     echo '车端服务启动成功!'
     echo '车端服务启动成功!'
 else
 else
     echo '车端服务启动失败,请重试!'
     echo '车端服务启动失败,请重试!'
-    exit 1
+    exit
 fi    
 fi    
 exit
 exit