Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
233boy committed Oct 12, 2018
1 parent f799430 commit 2fd7b60
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
23 changes: 17 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,19 @@ install_v2ray() {
mkdir -p /tmp/v2ray

v2ray_tmp_file="/tmp/v2ray/v2ray.zip"
# v2ray_ver="$(curl -s https://api.github.com/repos/v2ray/v2ray-core/releases/latest | grep 'tag_name' | cut -d\" -f4)"
v2ray_ver="v3.46"
v2ray_ver="$(curl -H 'Cache-Control: no-cache' -s https://api.github.com/repos/v2ray/v2ray-core/releases/latest | grep 'tag_name' | cut -d\" -f4)"

if [[ ! $v2ray_ver ]]; then
echo
echo -e " $red获取 V2Ray 最新版本失败!!!$none"
echo
echo -e " 请尝试执行如下命令: $green echo 'nameserver 8.8.8.8' >/etc/resolv.conf $none"
echo
echo " 然后再继续安装脚本...."
echo
exit 1
fi

v2ray_download_link="https://github.com/v2ray/v2ray-core/releases/download/$v2ray_ver/v2ray-linux-${v2ray_bit}.zip"

if ! wget --no-check-certificate -O "$v2ray_tmp_file" $v2ray_download_link; then
Expand All @@ -919,18 +930,18 @@ install_v2ray() {

unzip $v2ray_tmp_file -d "/tmp/v2ray/"
mkdir -p /usr/bin/v2ray
cp -f "/tmp/v2ray/v2ray-${v2ray_ver}-linux-${v2ray_bit}/v2ray" "/usr/bin/v2ray/v2ray"
cp -f "/tmp/v2ray/v2ray" "/usr/bin/v2ray/v2ray"
chmod +x "/usr/bin/v2ray/v2ray"
cp -f "/tmp/v2ray/v2ray-${v2ray_ver}-linux-${v2ray_bit}/v2ctl" "/usr/bin/v2ray/v2ctl"
cp -f "/tmp/v2ray/v2ctl" "/usr/bin/v2ray/v2ctl"
chmod +x "/usr/bin/v2ray/v2ctl"

if [[ $systemd ]]; then
cp -f "/tmp/v2ray/v2ray-${v2ray_ver}-linux-${v2ray_bit}/systemd/v2ray.service" "/lib/systemd/system/"
cp -f "/tmp/v2ray/systemd/v2ray.service" "/lib/systemd/system/"
sed -i "s/on-failure/always/" /lib/systemd/system/v2ray.service
systemctl enable v2ray
else
apt-get install -y daemon
cp "/tmp/v2ray/v2ray-${v2ray_ver}-linux-${v2ray_bit}/systemv/v2ray" "/etc/init.d/v2ray"
cp "/tmp/v2ray/systemv/v2ray" "/etc/init.d/v2ray"
chmod +x "/etc/init.d/v2ray"
update-rc.d -f v2ray defaults
fi
Expand Down
20 changes: 16 additions & 4 deletions v2ray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ none='\e[0m'
# Root
[[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1

_version="v2.40"
_version="v2.41"

cmd="apt-get"

Expand Down Expand Up @@ -2903,7 +2903,19 @@ update_v2ray() {
mkdir -p /tmp/v2ray

v2ray_tmp_file="/tmp/v2ray/v2ray.zip"
v2ray_latest_ver="$(curl -s "https://api.github.com/repos/v2ray/v2ray-core/releases/latest?r=$RANDOM" | grep 'tag_name' | cut -d\" -f4)"
v2ray_latest_ver="$(curl -H 'Cache-Control: no-cache' -s "https://api.github.com/repos/v2ray/v2ray-core/releases/latest" | grep 'tag_name' | cut -d\" -f4)"

if [[ ! $v2ray_latest_ver ]]; then
echo
echo -e " $red获取 V2Ray 最新版本失败!!!$none"
echo
echo -e " 请尝试执行如下命令: $green echo 'nameserver 8.8.8.8' >/etc/resolv.conf $none"
echo
echo " 然后再继续...."
echo
exit 1
fi

if [[ $v2ray_ver != $v2ray_latest_ver ]]; then
echo
echo -e " $green 咦...发现新版本耶....正在拼命更新.......$none"
Expand All @@ -2918,9 +2930,9 @@ update_v2ray() {

unzip $v2ray_tmp_file -d "/tmp/v2ray/"
mkdir -p /usr/bin/v2ray
cp -f "/tmp/v2ray/v2ray-${v2ray_latest_ver}-linux-${v2ray_bit}/v2ray" "/usr/bin/v2ray/v2ray"
cp -f "/tmp/v2ray/v2ray" "/usr/bin/v2ray/v2ray"
chmod +x "/usr/bin/v2ray/v2ray"
cp -f "/tmp/v2ray/v2ray-${v2ray_latest_ver}-linux-${v2ray_bit}/v2ctl" "/usr/bin/v2ray/v2ctl"
cp -f "/tmp/v2ray/v2ctl" "/usr/bin/v2ray/v2ctl"
chmod +x "/usr/bin/v2ray/v2ctl"
# systemctl restart v2ray
# service v2ray restart >/dev/null 2>&1
Expand Down

0 comments on commit 2fd7b60

Please sign in to comment.