Browse Source

support new package format

Darien Raymond 7 years ago
parent
commit
1c58e74894
1 changed files with 24 additions and 16 deletions
  1. 24 16
      release/install-release.sh

+ 24 - 16
release/install-release.sh

@@ -154,6 +154,7 @@ getPMT(){
     return 0
 }
 
+VSRC_ROOT=/
 
 extract(){
     colorEcho ${BLUE}"Extracting V2Ray package to /tmp/v2ray."
@@ -163,6 +164,12 @@ extract(){
         colorEcho ${RED} "Failed to extract V2Ray."
         return 2
     fi
+    if [[ -d "/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}" ]]; then
+      VSRC_ROOT="/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}"
+    fi
+    if [[ -d "/tmp/v2ray/v2ray-linux-${VDIS}" ]]; then
+      VSRC_ROOT="/tmp/v2ray/v2ray-linux-${VDIS}"
+    fi
     return 0
 }
 
@@ -221,7 +228,7 @@ startV2ray(){
 
 copyFile() {
     NAME=$1
-    ERROR=`cp "/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}/${NAME}" "/usr/bin/v2ray/${NAME}" 2>&1`
+    ERROR=`cp "${VSRC_ROOT}/${NAME}" "/usr/bin/v2ray/${NAME}" 2>&1`
     if [[ $? -ne 0 ]]; then
         colorEcho ${YELLOW} "${ERROR}"
         return 1
@@ -250,7 +257,7 @@ installV2Ray(){
     if [[ ! -f "/etc/v2ray/config.json" ]]; then
         mkdir -p /etc/v2ray
         mkdir -p /var/log/v2ray
-        cp "/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}/vpoint_vmess_freedom.json" "/etc/v2ray/config.json"
+        cp "${VSRC_ROOT}/vpoint_vmess_freedom.json" "/etc/v2ray/config.json"
         if [[ $? -ne 0 ]]; then
             colorEcho ${YELLOW} "Failed to create V2Ray configuration file. Please create it manually."
             return 1
@@ -272,14 +279,14 @@ installInitScript(){
     if [[ -n "${SYSTEMCTL_CMD}" ]];then
         if [[ ! -f "/etc/systemd/system/v2ray.service" ]]; then
             if [[ ! -f "/lib/systemd/system/v2ray.service" ]]; then
-                cp "/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}/systemd/v2ray.service" "/etc/systemd/system/"
+                cp "${VSRC_ROOT}/systemd/v2ray.service" "/etc/systemd/system/"
                 systemctl enable v2ray.service
             fi
         fi
         return
     elif [[ -n "${SERVICE_CMD}" ]] && [[ ! -f "/etc/init.d/v2ray" ]]; then
         installSoftware "daemon" || return $?
-        cp "/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}/systemv/v2ray" "/etc/init.d/v2ray"
+        cp "${VSRC_ROOT}/systemv/v2ray" "/etc/init.d/v2ray"
         chmod +x "/etc/init.d/v2ray"
         update-rc.d v2ray defaults
     fi
@@ -371,21 +378,22 @@ main(){
     sysArch
     # extract local file
     if [[ $LOCAL_INSTALL -eq 1 ]]; then
-        echo "Installing V2Ray via local file"
+        colorEcho ${YELLOW} "Installing V2Ray via local file. Please make sure the file is a valid V2Ray package, as we are not able to determine that."
+        NEW_VER=local
         installSoftware unzip || return $?
         rm -rf /tmp/v2ray
         extract $LOCAL || return $?
-        FILEVDIS=`ls /tmp/v2ray |grep v2ray-v |cut -d "-" -f4`
-        SYSTEM=`ls /tmp/v2ray |grep v2ray-v |cut -d "-" -f3`
-        if [[ ${SYSTEM} != "linux" ]]; then
-            colorEcho ${RED} "The local V2Ray can not be installed in linux."
-            return 1
-        elif [[ ${FILEVDIS} != ${VDIS} ]]; then
-            colorEcho ${RED} "The local V2Ray can not be installed in ${ARCH} system."
-            return 1
-        else
-            NEW_VER=`ls /tmp/v2ray |grep v2ray-v |cut -d "-" -f2`
-        fi
+        #FILEVDIS=`ls /tmp/v2ray |grep v2ray-v |cut -d "-" -f4`
+        #SYSTEM=`ls /tmp/v2ray |grep v2ray-v |cut -d "-" -f3`
+        #if [[ ${SYSTEM} != "linux" ]]; then
+        #    colorEcho ${RED} "The local V2Ray can not be installed in linux."
+        #    return 1
+        #elif [[ ${FILEVDIS} != ${VDIS} ]]; then
+        #    colorEcho ${RED} "The local V2Ray can not be installed in ${ARCH} system."
+        #    return 1
+        #else
+        #    NEW_VER=`ls /tmp/v2ray |grep v2ray-v |cut -d "-" -f2`
+        #fi
     else
         # download via network and extract
         installSoftware "curl" || return $?