-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·51 lines (40 loc) · 1.46 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -euo pipefail
OS="$(uname -s)"
BASE_URL="https://github.com/v2fly/v2ray-core/releases"
FILENAME="v2ray-linux-64.zip"
# Get config vars from stdin
read -p "Remote uuid: " REMOTE_UUID
read -p "Remote host address: " REMOTE_HOST_ADDRESS
read -p "Remote port: " REMOTE_PORT
read -p "Remote ws path: " REMOTE_WS_PATH
export REMOTE_UUID REMOTE_HOST_ADDRESS REMOTE_PORT REMOTE_WS_PATH
# Install requirements
printf "| Install dependencies and requirements |"
sudo apt update \
&& sudo apt install unzip --no-install-recommends -y
# Download latest v2ray version
VERSION="v5.16.1"
[ ${OS} == "Linux" ] && printf "| Downloading v2ray version ${VERSION}... |\n"
curl -LOJs "${BASE_URL}/download/${VERSION}/${FILENAME}"
# Unzip downloaded file
(
printf "| Create v2ray dir |\n" \
&& mkdir v2ray \
&& mv ${FILENAME} v2ray \
&& cd v2ray \
&& printf "| Unzip v2ray file |\n" \
&& unzip -qq ${FILENAME}
)
# Create /usr/local/v2ray/ for need files
sudo mkdir -p /usr/local/etc/v2ray/
# Move files to their locations
sudo cat config.json.template | envsubst > config.json \
&& sudo mv config.json /usr/local/etc/v2ray/config.json
sudo mv v2ray/v2ray /usr/local/bin/v2ray
IPV4_ADDRESS="$(hostname -I | cut -d ' ' -f1)"
export IPV4_ADDRESS
cat v2ray.service.template | envsubst > v2ray.service
sudo mv v2ray.service /etc/systemd/system/v2ray.service \
&& sudo systemctl daemon-reload
printf "| Congrats! You can start using your vpn with sudo systemctl start command |\n"