mirror of https://github.com/v2ray/v2ray-core
				
				
				
			refactor: Install directly from zip file
							parent
							
								
									f9dc0a7fb6
								
							
						
					
					
						commit
						01e940fd8e
					
				|  | @ -312,45 +312,39 @@ startV2ray(){ | ||||||
| 
 | 
 | ||||||
| installV2Ray(){ | installV2Ray(){ | ||||||
|     # Install V2Ray binary to /usr/bin/v2ray |     # Install V2Ray binary to /usr/bin/v2ray | ||||||
|     mkdir -p '/usr/bin/v2ray' '/etc/v2ray' '/var/log/v2ray' && \ |     mkdir -p '/etc/v2ray' '/var/log/v2ray' && \ | ||||||
|     cp "${VSRC_ROOT}/v2ray" \ |     unzip -oj "$1" "$2v2ray" "$2v2ctl" "$2geoip.dat" "$2geosite.dat" -d '/usr/bin/v2ray' && \ | ||||||
|         "${VSRC_ROOT}/v2ctl" \ |  | ||||||
|         "${VSRC_ROOT}/geoip.dat" \ |  | ||||||
|         "${VSRC_ROOT}/geosite.dat" \ |  | ||||||
|         "/usr/bin/v2ray/" && \ |  | ||||||
|     chmod +x '/usr/bin/v2ray/v2ray' '/usr/bin/v2ray/v2ctl' || { |     chmod +x '/usr/bin/v2ray/v2ray' '/usr/bin/v2ray/v2ctl' || { | ||||||
|         colorEcho ${RED} "Failed to copy V2Ray binary and resources." |         colorEcho ${RED} "Failed to copy V2Ray binary and resources." | ||||||
|         return 1 |         return 1 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     # Install V2Ray server config to /etc/v2ray |     # Install V2Ray server config to /etc/v2ray | ||||||
|     if [[ ! -f "/etc/v2ray/config.json" ]]; then |     if [ ! -f '/etc/v2ray/config.json' ]; then | ||||||
|         cp "${VSRC_ROOT}/vpoint_vmess_freedom.json" "/etc/v2ray/config.json" |         local PORT="$(($RANDOM + 10000))" | ||||||
|         if [[ $? -ne 0 ]]; then |         local UUID="$(cat '/proc/sys/kernel/random/uuid')" | ||||||
|  | 
 | ||||||
|  |         unzip -pq "$1" "$2vpoint_vmess_freedom.json" | \ | ||||||
|  |         sed -e "s/10086/${PORT}/g; s/23ad6b10-8d1a-40f7-8ad0-e3e35cd38297/${UUID}/g;" - > \ | ||||||
|  |         '/etc/v2ray/config.json' || { | ||||||
|             colorEcho ${YELLOW} "Failed to create V2Ray configuration file. Please create it manually." |             colorEcho ${YELLOW} "Failed to create V2Ray configuration file. Please create it manually." | ||||||
|             return 1 |             return 1 | ||||||
|         fi |         } | ||||||
|         let PORT=$RANDOM+10000 |  | ||||||
|         UUID=$(cat /proc/sys/kernel/random/uuid) |  | ||||||
| 
 |  | ||||||
|         sed -i "s/10086/${PORT}/g" "/etc/v2ray/config.json" |  | ||||||
|         sed -i "s/23ad6b10-8d1a-40f7-8ad0-e3e35cd38297/${UUID}/g" "/etc/v2ray/config.json" |  | ||||||
| 
 | 
 | ||||||
|         colorEcho ${BLUE} "PORT:${PORT}" |         colorEcho ${BLUE} "PORT:${PORT}" | ||||||
|         colorEcho ${BLUE} "UUID:${UUID}" |         colorEcho ${BLUE} "UUID:${UUID}" | ||||||
|     fi |     fi | ||||||
|     return 0 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| installInitScript(){ | installInitScript(){ | ||||||
|     if [[ -n "${SYSTEMCTL_CMD}" ]] && [[ ! -f "/etc/systemd/system/v2ray.service" && ! -f "/lib/systemd/system/v2ray.service" ]]; then |     if [[ -n "${SYSTEMCTL_CMD}" ]] && [[ ! -f "/etc/systemd/system/v2ray.service" && ! -f "/lib/systemd/system/v2ray.service" ]]; then | ||||||
|         cp "${VSRC_ROOT}/systemd/v2ray.service" "/etc/systemd/system/" |         unzip -oj "$1" "$2systemd/v2ray.service" -d '/etc/systemd/system' && \ | ||||||
|         systemctl enable v2ray.service |         systemctl enable v2ray.service | ||||||
|     elif [[ -n "${SERVICE_CMD}" ]] && [[ ! -f "/etc/init.d/v2ray" ]]; then |     elif [[ -n "${SERVICE_CMD}" ]] && [[ ! -f "/etc/init.d/v2ray" ]]; then | ||||||
|         installSoftware "daemon" || return $? |         installSoftware 'daemon' && \ | ||||||
|         cp "${VSRC_ROOT}/systemv/v2ray" "/etc/init.d/v2ray" |         unzip -oj "$1" "$2systemv/v2ray" -d '/etc/init.d' && \ | ||||||
|         chmod +x "/etc/init.d/v2ray" |         chmod +x '/etc/init.d/v2ray' && \ | ||||||
|         update-rc.d v2ray defaults |         update-rc.d v2ray defaults | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
|  | @ -480,6 +474,8 @@ main(){ | ||||||
|         fi |         fi | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|  |     local ZIPROOT="$(zipRoot "${ZIPFILE}")" | ||||||
|  | 
 | ||||||
|     if [ -n "${EXTRACT_ONLY}" ]; then |     if [ -n "${EXTRACT_ONLY}" ]; then | ||||||
|         colorEcho ${GREEN} "V2Ray extracted to ${VSRC_ROOT}, and exiting..." |         colorEcho ${GREEN} "V2Ray extracted to ${VSRC_ROOT}, and exiting..." | ||||||
|         return 0 |         return 0 | ||||||
|  | @ -489,8 +485,8 @@ main(){ | ||||||
|         V2RAY_RUNNING=1 |         V2RAY_RUNNING=1 | ||||||
|         stopV2ray |         stopV2ray | ||||||
|     fi |     fi | ||||||
|     installV2Ray || return $? |     installV2Ray "${ZIPFILE}" "${ZIPROOT}" || return $? | ||||||
|     installInitScript || return $? |     installInitScript "${ZIPFILE}" "${ZIPROOT}" || return $? | ||||||
|     if [[ ${V2RAY_RUNNING} -eq 1 ]];then |     if [[ ${V2RAY_RUNNING} -eq 1 ]];then | ||||||
|         colorEcho ${BLUE} "Restarting V2Ray service." |         colorEcho ${BLUE} "Restarting V2Ray service." | ||||||
|         startV2ray |         startV2ray | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 xymopen
						xymopen