Last active
November 11, 2020 02:03
-
-
Save fpGHwd/0aad6db00ecf267715cf8d9027220b49 to your computer and use it in GitHub Desktop.
replace your v2ray config.json outbounds part with corresponding part in vmess url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
vmess_file_path=$1 | |
config_file_path=$2 | |
vmess_line=$3 | |
line=`sed -n ${vmess_line}p $vmess_file_path` | |
result=`v2ray-tools vmess2config --port 8080 --url $line` | |
outbound=`echo $result | jq '.outbounds[0]'` | |
new_content=`cat "/etc/v2ray/config.json" | jq -r ".outbounds[0]=$outbound"` | |
sudo bash -c "echo '$new_content' > $config_file_path" | |
# change file config.json and restart v2ray.service | |
sudo systemctl restart v2ray.service | |
sudo systemctl status v2ray.service | sed -n 3p | |
# usage example: | |
# bash /home/wd/Documents/vmess/vmess.info /etc/v2ray/config.json 20 | |
# | |
# requirements: | |
# 1. npm -g install v2ray-tools | |
# 2. vmess.info, ie. vmess url list in a file named "vmess.info" | |
# | |
# notifications: | |
# 1. it's will not help you to create /etc/v2ray/config.json, you need a available config.json with replaceable outbounds | |
# 2. backup your config.json first | |
# | |
# todo: | |
# 1. also we can change the line number with vmess url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment