mirror of https://github.com/XTLS/Xray-install
feat: install Xray-core
parent
1bc4e215d8
commit
58e083aa65
14
README.md
14
README.md
|
@ -1,4 +1,4 @@
|
|||
# alpinelinux-install-v2ray
|
||||
# alpinelinux-install-xray
|
||||
|
||||
## 依賴軟體
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
|||
## 下載
|
||||
|
||||
```
|
||||
$ curl -O https://raw.githubusercontent.com/v2fly/alpinelinux-install-v2ray/master/install-release.sh
|
||||
$ curl -O https://raw.githubusercontent.com/XTLS/alpinelinux-install-xray/main/install-release.sh
|
||||
```
|
||||
|
||||
## 使用
|
||||
|
@ -25,29 +25,29 @@ $ curl -O https://raw.githubusercontent.com/v2fly/alpinelinux-install-v2ray/mast
|
|||
### 啟用
|
||||
|
||||
```
|
||||
# rc-update add v2ray
|
||||
# rc-update add xray
|
||||
```
|
||||
|
||||
### 禁用
|
||||
|
||||
```
|
||||
# rc-update del v2ray
|
||||
# rc-update del xray
|
||||
```
|
||||
|
||||
### 啟動
|
||||
|
||||
```
|
||||
# rc-service v2ray start
|
||||
# rc-service xray start
|
||||
```
|
||||
|
||||
### 關閉
|
||||
|
||||
```
|
||||
# rc-service v2ray stop
|
||||
# rc-service xray stop
|
||||
```
|
||||
|
||||
### 重啟
|
||||
|
||||
```
|
||||
# rc-service v2ray restart
|
||||
# rc-service xray restart
|
||||
```
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
name="V2Ray"
|
||||
description="A platform for building proxies to bypass network restrictions"
|
||||
name="Xray"
|
||||
description="The best v2ray-core, with XTLS support"
|
||||
description_checkconfig="Test configuration file"
|
||||
|
||||
: ${env:="V2RAY_LOCATION_ASSET=/usr/local/lib/v2ray/"}
|
||||
: ${confdir:="/usr/local/etc/v2ray/"}
|
||||
: ${env:="XRAY_LOCATION_ASSET=/usr/local/lib/xray/"}
|
||||
: ${confdir:="/usr/local/etc/xray/"}
|
||||
|
||||
command="/usr/local/bin/v2ray"
|
||||
command_args="-confdir $confdir"
|
||||
command="/usr/local/bin/xray"
|
||||
command_args="run -confdir $confdir"
|
||||
command_user="nobody"
|
||||
|
||||
pidfile="/run/v2ray.pid"
|
||||
pidfile="/run/xray.pid"
|
||||
command_background="yes"
|
||||
|
||||
extra_commands="checkconfig"
|
||||
|
@ -26,7 +26,7 @@ checkconfig() {
|
|||
return 1
|
||||
fi
|
||||
export $env
|
||||
$command -test $command_args
|
||||
$command $command_args -test
|
||||
}
|
||||
|
||||
start_pre() {
|
|
@ -55,8 +55,8 @@ case "$(arch -s)" in
|
|||
esac
|
||||
|
||||
TMP_DIRECTORY="$(mktemp -d)/"
|
||||
ZIP_FILE="${TMP_DIRECTORY}v2ray-linux-$MACHINE.zip"
|
||||
DOWNLOAD_LINK="https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-linux-$MACHINE.zip"
|
||||
ZIP_FILE="${TMP_DIRECTORY}Xray-linux-$MACHINE.zip"
|
||||
DOWNLOAD_LINK="https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-$MACHINE.zip"
|
||||
|
||||
install_software() {
|
||||
if [[ -n "$(command -v curl)" ]]; then
|
||||
|
@ -73,7 +73,7 @@ install_software() {
|
|||
fi
|
||||
}
|
||||
|
||||
download_v2ray() {
|
||||
download_xray() {
|
||||
curl -L -H 'Cache-Control: no-cache' -o "$ZIP_FILE" "$DOWNLOAD_LINK" -#
|
||||
if [ "$?" -ne '0' ]; then
|
||||
echo 'error: Download failed! Please check your network or try again.'
|
||||
|
@ -86,7 +86,7 @@ download_v2ray() {
|
|||
fi
|
||||
}
|
||||
|
||||
verification_v2ray() {
|
||||
verification_xray() {
|
||||
for LISTSUM in 'md5' 'sha1' 'sha256' 'sha512'; do
|
||||
SUM="$(${LISTSUM}sum $ZIP_FILE | sed 's/ .*//')"
|
||||
CHECKSUM="$(grep $(echo $LISTSUM | tr [:lower:] [:upper:]) $ZIP_FILE.dgst | uniq | sed 's/.* //')"
|
||||
|
@ -102,27 +102,26 @@ decompression() {
|
|||
}
|
||||
|
||||
is_it_running() {
|
||||
V2RAY_RUNNING='0'
|
||||
if [ -n "$(pgrep v2ray)" ]; then
|
||||
rc-service v2ray stop
|
||||
V2RAY_RUNNING='1'
|
||||
XRAY_RUNNING='0'
|
||||
if [ -n "$(pgrep xray)" ]; then
|
||||
rc-service xray stop
|
||||
XRAY_RUNNING='1'
|
||||
fi
|
||||
}
|
||||
|
||||
install_v2ray() {
|
||||
install -m 755 "${TMP_DIRECTORY}v2ray" "/usr/local/bin/v2ray"
|
||||
install -m 755 "${TMP_DIRECTORY}v2ctl" "/usr/local/bin/v2ctl"
|
||||
install -d /usr/local/lib/v2ray/
|
||||
install -m 755 "${TMP_DIRECTORY}geoip.dat" "/usr/local/lib/v2ray/geoip.dat"
|
||||
install -m 755 "${TMP_DIRECTORY}geosite.dat" "/usr/local/lib/v2ray/geosite.dat"
|
||||
install_xray() {
|
||||
install -m 755 "${TMP_DIRECTORY}xray" "/usr/local/bin/xray"
|
||||
install -d /usr/local/lib/xray/
|
||||
install -m 755 "${TMP_DIRECTORY}geoip.dat" "/usr/local/lib/xray/geoip.dat"
|
||||
install -m 755 "${TMP_DIRECTORY}geosite.dat" "/usr/local/lib/xray/geosite.dat"
|
||||
}
|
||||
|
||||
install_confdir() {
|
||||
CONFDIR='0'
|
||||
if [ ! -d '/usr/local/etc/v2ray/' ]; then
|
||||
install -d /usr/local/etc/v2ray/
|
||||
if [ ! -d '/usr/local/etc/xray/' ]; then
|
||||
install -d /usr/local/etc/xray/
|
||||
for BASE in 00_log 01_api 02_dns 03_routing 04_policy 05_inbounds 06_outbounds 07_transport 08_stats 09_reverse; do
|
||||
echo '{}' > "/usr/local/etc/v2ray/$BASE.json"
|
||||
echo '{}' > "/usr/local/etc/xray/$BASE.json"
|
||||
done
|
||||
CONFDIR='1'
|
||||
fi
|
||||
|
@ -130,70 +129,69 @@ install_confdir() {
|
|||
|
||||
install_log() {
|
||||
LOG='0'
|
||||
if [ ! -d '/var/log/v2ray/' ]; then
|
||||
install -d -o nobody -g nobody /var/log/v2ray/
|
||||
install -m 600 -o nobody -g nobody /dev/null /var/log/v2ray/access.log
|
||||
install -m 600 -o nobody -g nobody /dev/null /var/log/v2ray/error.log
|
||||
if [ ! -d '/var/log/xray/' ]; then
|
||||
install -d -o nobody -g nobody /var/log/xray/
|
||||
install -m 600 -o nobody -g nobody /dev/null /var/log/xray/access.log
|
||||
install -m 600 -o nobody -g nobody /dev/null /var/log/xray/error.log
|
||||
LOG='1'
|
||||
fi
|
||||
}
|
||||
|
||||
install_startup_service_file() {
|
||||
OPENRC='0'
|
||||
if [ ! -f '/etc/init.d/v2ray' ]; then
|
||||
if [ ! -f '/etc/init.d/xray' ]; then
|
||||
mkdir "${TMP_DIRECTORY}init.d/"
|
||||
curl -o "${TMP_DIRECTORY}init.d/v2ray" https://raw.githubusercontent.workers.dev/v2fly/alpinelinux-install-v2ray/master/init.d/v2ray -s
|
||||
curl -o "${TMP_DIRECTORY}init.d/xray" https://raw.githubusercontent.com/XTLS/alpinelinux-install-xray/main/init.d/xray -s
|
||||
if [ "$?" -ne '0' ]; then
|
||||
echo 'error: Failed to start service file download! Please check your network or try again.'
|
||||
exit 1
|
||||
fi
|
||||
install -m 755 "${TMP_DIRECTORY}init.d/v2ray" /etc/init.d/v2ray
|
||||
install -m 755 "${TMP_DIRECTORY}init.d/xray" /etc/init.d/xray
|
||||
OPENRC='1'
|
||||
fi
|
||||
}
|
||||
|
||||
information() {
|
||||
echo 'installed: /usr/local/bin/v2ray'
|
||||
echo 'installed: /usr/local/bin/v2ctl'
|
||||
echo 'installed: /usr/local/lib/v2ray/geoip.dat'
|
||||
echo 'installed: /usr/local/lib/v2ray/geosite.dat'
|
||||
echo 'installed: /usr/local/bin/xray'
|
||||
echo 'installed: /usr/local/lib/xray/geoip.dat'
|
||||
echo 'installed: /usr/local/lib/xray/geosite.dat'
|
||||
if [ "$CONFDIR" -eq '1' ]; then
|
||||
echo 'installed: /usr/local/etc/v2ray/00_log.json'
|
||||
echo 'installed: /usr/local/etc/v2ray/01_api.json'
|
||||
echo 'installed: /usr/local/etc/v2ray/02_dns.json'
|
||||
echo 'installed: /usr/local/etc/v2ray/03_routing.json'
|
||||
echo 'installed: /usr/local/etc/v2ray/04_policy.json'
|
||||
echo 'installed: /usr/local/etc/v2ray/05_inbounds.json'
|
||||
echo 'installed: /usr/local/etc/v2ray/06_outbounds.json'
|
||||
echo 'installed: /usr/local/etc/v2ray/07_transport.json'
|
||||
echo 'installed: /usr/local/etc/v2ray/08_stats.json'
|
||||
echo 'installed: /usr/local/etc/v2ray/09_reverse.json'
|
||||
echo 'installed: /usr/local/etc/xray/00_log.json'
|
||||
echo 'installed: /usr/local/etc/xray/01_api.json'
|
||||
echo 'installed: /usr/local/etc/xray/02_dns.json'
|
||||
echo 'installed: /usr/local/etc/xray/03_routing.json'
|
||||
echo 'installed: /usr/local/etc/xray/04_policy.json'
|
||||
echo 'installed: /usr/local/etc/xray/05_inbounds.json'
|
||||
echo 'installed: /usr/local/etc/xray/06_outbounds.json'
|
||||
echo 'installed: /usr/local/etc/xray/07_transport.json'
|
||||
echo 'installed: /usr/local/etc/xray/08_stats.json'
|
||||
echo 'installed: /usr/local/etc/xray/09_reverse.json'
|
||||
fi
|
||||
if [ "$LOG" -eq '1' ]; then
|
||||
echo 'installed: /var/log/v2ray/'
|
||||
echo 'installed: /var/log/xray/'
|
||||
fi
|
||||
if [ "$OPENRC" -eq '1' ]; then
|
||||
echo 'installed: /etc/init.d/v2ray'
|
||||
echo 'installed: /etc/init.d/xray'
|
||||
fi
|
||||
rm -r "$TMP_DIRECTORY"
|
||||
echo "removed: $TMP_DIRECTORY"
|
||||
echo "You may need to execute a command to remove dependent software: apk del curl unzip"
|
||||
if [ "$V2RAY_RUNNING" -eq '1' ]; then
|
||||
rc-service v2ray start
|
||||
if [ "$XRAY_RUNNING" -eq '1' ]; then
|
||||
rc-service xray start
|
||||
else
|
||||
echo 'Please execute the command: rc-update add v2ray; rc-service v2ray start'
|
||||
echo 'Please execute the command: rc-update add xray; rc-service xray start'
|
||||
fi
|
||||
echo "info: V2Ray is installed."
|
||||
echo "info: Xray is installed."
|
||||
}
|
||||
|
||||
main() {
|
||||
install_software
|
||||
install_software
|
||||
download_v2ray
|
||||
verification_v2ray
|
||||
download_xray
|
||||
verification_xray
|
||||
decompression
|
||||
is_it_running
|
||||
install_v2ray
|
||||
install_xray
|
||||
install_confdir
|
||||
install_log
|
||||
install_startup_service_file
|
||||
|
|
Loading…
Reference in New Issue