Your commit message
This commit is contained in:
2200
脚本参考/V2Ray-TLS+Web-setup.sh
Normal file
2200
脚本参考/V2Ray-TLS+Web-setup.sh
Normal file
File diff suppressed because it is too large
Load Diff
389
脚本参考/bbr.sh
Normal file
389
脚本参考/bbr.sh
Normal file
@@ -0,0 +1,389 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Auto install latest kernel for TCP BBR
|
||||
#
|
||||
# System Required: CentOS 6+, Debian7+, Ubuntu12+
|
||||
#
|
||||
# Copyright (C) 2016-2018 Teddysun <i@teddysun.com>
|
||||
#
|
||||
# URL: https://teddysun.com/489.html
|
||||
#
|
||||
|
||||
red='\033[0;31m'
|
||||
green='\033[0;32m'
|
||||
yellow='\033[0;33m'
|
||||
|
||||
plain='\033[0m'
|
||||
|
||||
cur_dir=$(pwd)
|
||||
|
||||
[[ $EUID -ne 0 ]] && echo -e "${red}Error:${plain} This script must be run as root!" && exit 1
|
||||
|
||||
[[ -d "/proc/vz" ]] && echo -e "${red}Error:${plain} Your VPS is based on OpenVZ, which is not supported." && exit 1
|
||||
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
release="centos"
|
||||
elif cat /etc/issue | grep -Eqi "debian"; then
|
||||
release="debian"
|
||||
elif cat /etc/issue | grep -Eqi "ubuntu"; then
|
||||
release="ubuntu"
|
||||
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
|
||||
release="centos"
|
||||
elif cat /proc/version | grep -Eqi "debian"; then
|
||||
release="debian"
|
||||
elif cat /proc/version | grep -Eqi "ubuntu"; then
|
||||
release="ubuntu"
|
||||
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
|
||||
release="centos"
|
||||
else
|
||||
release=""
|
||||
fi
|
||||
|
||||
is_digit(){
|
||||
local input=${1}
|
||||
if [[ "$input" =~ ^[0-9]+$ ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_64bit(){
|
||||
if [ $(getconf WORD_BIT) = '32' ] && [ $(getconf LONG_BIT) = '64' ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_valid_valname(){
|
||||
local val=${1}
|
||||
local new_val=$(eval echo $val | sed 's/[-.]/_/g')
|
||||
echo ${new_val}
|
||||
}
|
||||
|
||||
get_hint(){
|
||||
local val=${1}
|
||||
local new_val=$(get_valid_valname $val)
|
||||
eval echo "\$hint_${new_val}"
|
||||
}
|
||||
|
||||
#Display Memu
|
||||
display_menu(){
|
||||
local soft=${1}
|
||||
local default=${2}
|
||||
eval local arr=(\${${soft}_arr[@]})
|
||||
local default_prompt
|
||||
if [[ "$default" != "" ]]; then
|
||||
if [[ "$default" == "last" ]]; then
|
||||
default=${#arr[@]}
|
||||
fi
|
||||
default_prompt="(default ${arr[$default-1]})"
|
||||
fi
|
||||
local pick
|
||||
local hint
|
||||
local vname
|
||||
local prompt="which ${soft} you'd select ${default_prompt}: "
|
||||
|
||||
while :
|
||||
do
|
||||
echo -e "\n------------ ${soft} setting ------------\n"
|
||||
for ((i=1;i<=${#arr[@]};i++ )); do
|
||||
vname="$(get_valid_valname ${arr[$i-1]})"
|
||||
hint="$(get_hint $vname)"
|
||||
[[ "$hint" == "" ]] && hint="${arr[$i-1]}"
|
||||
echo -e "${green}${i}${plain}) $hint"
|
||||
done
|
||||
echo
|
||||
read -p "${prompt}" pick
|
||||
if [[ "$pick" == "" && "$default" != "" ]]; then
|
||||
pick=${default}
|
||||
break
|
||||
fi
|
||||
|
||||
if ! is_digit "$pick"; then
|
||||
prompt="Input error, please input a number"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "$pick" -lt 1 || "$pick" -gt ${#arr[@]} ]]; then
|
||||
prompt="Input error, please input a number between 1 and ${#arr[@]}: "
|
||||
continue
|
||||
fi
|
||||
|
||||
break
|
||||
done
|
||||
|
||||
eval ${soft}=${arr[$pick-1]}
|
||||
vname="$(get_valid_valname ${arr[$pick-1]})"
|
||||
hint="$(get_hint $vname)"
|
||||
[[ "$hint" == "" ]] && hint="${arr[$pick-1]}"
|
||||
echo -e "\nyour selection: $hint\n"
|
||||
}
|
||||
|
||||
version_ge(){
|
||||
test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"
|
||||
}
|
||||
|
||||
get_latest_version() {
|
||||
latest_version=($(wget -qO- https://kernel.ubuntu.com/~kernel-ppa/mainline/ | awk -F'\"v' '/v[4-9]./{print $2}' | cut -d/ -f1 | grep -v - | sort -V))
|
||||
|
||||
[ ${#latest_version[@]} -eq 0 ] && echo -e "${red}Error:${plain} Get latest kernel version failed." && exit 1
|
||||
|
||||
kernel_arr=()
|
||||
for i in ${latest_version[@]}; do
|
||||
if version_ge $i 4.14; then
|
||||
kernel_arr+=($i);
|
||||
fi
|
||||
done
|
||||
|
||||
display_menu kernel last
|
||||
|
||||
if [[ `getconf WORD_BIT` == "32" && `getconf LONG_BIT` == "64" ]]; then
|
||||
deb_name=$(wget -qO- https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/ | grep "linux-image" | grep "generic" | awk -F'\">' '/amd64.deb/{print $2}' | cut -d'<' -f1 | head -1)
|
||||
deb_kernel_url="https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/${deb_name}"
|
||||
deb_kernel_name="linux-image-${kernel}-amd64.deb"
|
||||
modules_deb_name=$(wget -qO- https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/ | grep "linux-modules" | grep "generic" | awk -F'\">' '/amd64.deb/{print $2}' | cut -d'<' -f1 | head -1)
|
||||
deb_kernel_modules_url="https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/${modules_deb_name}"
|
||||
deb_kernel_modules_name="linux-modules-${kernel}-amd64.deb"
|
||||
else
|
||||
deb_name=$(wget -qO- https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/ | grep "linux-image" | grep "generic" | awk -F'\">' '/i386.deb/{print $2}' | cut -d'<' -f1 | head -1)
|
||||
deb_kernel_url="https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/${deb_name}"
|
||||
deb_kernel_name="linux-image-${kernel}-i386.deb"
|
||||
modules_deb_name=$(wget -qO- https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/ | grep "linux-modules" | grep "generic" | awk -F'\">' '/i386.deb/{print $2}' | cut -d'<' -f1 | head -1)
|
||||
deb_kernel_modules_url="https://kernel.ubuntu.com/~kernel-ppa/mainline/v${kernel}/${modules_deb_name}"
|
||||
deb_kernel_modules_name="linux-modules-${kernel}-i386.deb"
|
||||
fi
|
||||
|
||||
[ -z ${deb_name} ] && echo -e "${red}Error:${plain} Getting Linux kernel binary package name failed, maybe kernel build failed. Please choose other one and try again." && exit 1
|
||||
}
|
||||
|
||||
get_opsy() {
|
||||
[ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
|
||||
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
|
||||
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
|
||||
}
|
||||
|
||||
opsy=$( get_opsy )
|
||||
arch=$( uname -m )
|
||||
lbit=$( getconf LONG_BIT )
|
||||
kern=$( uname -r )
|
||||
|
||||
get_char() {
|
||||
SAVEDSTTY=`stty -g`
|
||||
stty -echo
|
||||
stty cbreak
|
||||
dd if=/dev/tty bs=1 count=1 2> /dev/null
|
||||
stty -raw
|
||||
stty echo
|
||||
stty $SAVEDSTTY
|
||||
}
|
||||
|
||||
getversion() {
|
||||
if [[ -s /etc/redhat-release ]]; then
|
||||
grep -oE "[0-9.]+" /etc/redhat-release
|
||||
else
|
||||
grep -oE "[0-9.]+" /etc/issue
|
||||
fi
|
||||
}
|
||||
|
||||
centosversion() {
|
||||
if [ x"${release}" == x"centos" ]; then
|
||||
local code=$1
|
||||
local version="$(getversion)"
|
||||
local main_ver=${version%%.*}
|
||||
if [ "$main_ver" == "$code" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_bbr_status() {
|
||||
local param=$(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}')
|
||||
if [[ x"${param}" == x"bbr" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_kernel_version() {
|
||||
local kernel_version=$(uname -r | cut -d- -f1)
|
||||
if version_ge ${kernel_version} 4.9; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_elrepo() {
|
||||
|
||||
if centosversion 5; then
|
||||
echo -e "${red}Error:${plain} not supported CentOS 5."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
|
||||
|
||||
if centosversion 6; then
|
||||
rpm -Uvh https://www.elrepo.org/elrepo-release-6-9.el6.elrepo.noarch.rpm
|
||||
elif centosversion 7; then
|
||||
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/yum.repos.d/elrepo.repo ]; then
|
||||
echo -e "${red}Error:${plain} Install elrepo failed, please check it."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
sysctl_config() {
|
||||
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
|
||||
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
|
||||
echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf
|
||||
echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf
|
||||
sysctl -p >/dev/null 2>&1
|
||||
}
|
||||
|
||||
install_config() {
|
||||
if [[ x"${release}" == x"centos" ]]; then
|
||||
if centosversion 6; then
|
||||
if [ ! -f "/boot/grub/grub.conf" ]; then
|
||||
echo -e "${red}Error:${plain} /boot/grub/grub.conf not found, please check it."
|
||||
exit 1
|
||||
fi
|
||||
sed -i 's/^default=.*/default=0/g' /boot/grub/grub.conf
|
||||
elif centosversion 7; then
|
||||
if [ ! -f "/boot/grub2/grub.cfg" ]; then
|
||||
echo -e "${red}Error:${plain} /boot/grub2/grub.cfg not found, please check it."
|
||||
exit 1
|
||||
fi
|
||||
grub2-set-default 0
|
||||
fi
|
||||
elif [[ x"${release}" == x"debian" || x"${release}" == x"ubuntu" ]]; then
|
||||
/usr/sbin/update-grub
|
||||
fi
|
||||
}
|
||||
|
||||
reboot_os() {
|
||||
echo
|
||||
echo -e "${green}Info:${plain} The system needs to reboot."
|
||||
read -p "Do you want to restart system? [y/n]" is_reboot
|
||||
if [[ ${is_reboot} == "y" || ${is_reboot} == "Y" ]]; then
|
||||
reboot
|
||||
else
|
||||
echo -e "${green}Info:${plain} Reboot has been canceled..."
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
install_bbr() {
|
||||
check_bbr_status
|
||||
if [ $? -eq 0 ]; then
|
||||
echo
|
||||
echo -e "${green}Info:${plain} TCP BBR has already been installed. nothing to do..."
|
||||
exit 0
|
||||
fi
|
||||
check_kernel_version
|
||||
if [ $? -eq 0 ]; then
|
||||
echo
|
||||
echo -e "${green}Info:${plain} Your kernel version is greater than 4.9, directly setting TCP BBR..."
|
||||
sysctl_config
|
||||
echo -e "${green}Info:${plain} Setting TCP BBR completed..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ x"${release}" == x"centos" ]]; then
|
||||
install_elrepo
|
||||
[ ! "$(command -v yum-config-manager)" ] && yum install -y yum-utils > /dev/null 2>&1
|
||||
[ x"$(yum-config-manager elrepo-kernel | grep -w enabled | awk '{print $3}')" != x"True" ] && yum-config-manager --enable elrepo-kernel > /dev/null 2>&1
|
||||
if centosversion 6; then
|
||||
if is_64bit; then
|
||||
rpm_kernel_name="kernel-ml-4.18.20-1.el6.elrepo.x86_64.rpm"
|
||||
rpm_kernel_devel_name="kernel-ml-devel-4.18.20-1.el6.elrepo.x86_64.rpm"
|
||||
rpm_kernel_url_1="http://repos.lax.quadranet.com/elrepo/archive/kernel/el6/x86_64/RPMS/"
|
||||
else
|
||||
rpm_kernel_name="kernel-ml-4.18.20-1.el6.elrepo.i686.rpm"
|
||||
rpm_kernel_devel_name="kernel-ml-devel-4.18.20-1.el6.elrepo.i686.rpm"
|
||||
rpm_kernel_url_1="http://repos.lax.quadranet.com/elrepo/archive/kernel/el6/i386/RPMS/"
|
||||
fi
|
||||
rpm_kernel_url_2="https://dl.lamp.sh/files/"
|
||||
wget -c -t3 -T60 -O ${rpm_kernel_name} ${rpm_kernel_url_1}${rpm_kernel_name}
|
||||
if [ $? -ne 0 ]; then
|
||||
rm -rf ${rpm_kernel_name}
|
||||
wget -c -t3 -T60 -O ${rpm_kernel_name} ${rpm_kernel_url_2}${rpm_kernel_name}
|
||||
fi
|
||||
wget -c -t3 -T60 -O ${rpm_kernel_devel_name} ${rpm_kernel_url_1}${rpm_kernel_devel_name}
|
||||
if [ $? -ne 0 ]; then
|
||||
rm -rf ${rpm_kernel_devel_name}
|
||||
wget -c -t3 -T60 -O ${rpm_kernel_devel_name} ${rpm_kernel_url_2}${rpm_kernel_devel_name}
|
||||
fi
|
||||
if [ -f "${rpm_kernel_name}" ]; then
|
||||
rpm -ivh ${rpm_kernel_name}
|
||||
else
|
||||
echo -e "${red}Error:${plain} Download ${rpm_kernel_name} failed, please check it."
|
||||
exit 1
|
||||
fi
|
||||
if [ -f "${rpm_kernel_devel_name}" ]; then
|
||||
rpm -ivh ${rpm_kernel_devel_name}
|
||||
else
|
||||
echo -e "${red}Error:${plain} Download ${rpm_kernel_devel_name} failed, please check it."
|
||||
exit 1
|
||||
fi
|
||||
rm -f ${rpm_kernel_name} ${rpm_kernel_devel_name}
|
||||
elif centosversion 7; then
|
||||
yum -y install kernel-ml kernel-ml-devel
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${red}Error:${plain} Install latest kernel failed, please check it."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
elif [[ x"${release}" == x"debian" || x"${release}" == x"ubuntu" ]]; then
|
||||
[[ ! -e "/usr/bin/wget" ]] && apt-get -y update && apt-get -y install wget
|
||||
echo -e "${green}Info:${plain} Getting latest kernel version..."
|
||||
get_latest_version
|
||||
if [ -n ${modules_deb_name} ]; then
|
||||
wget -c -t3 -T60 -O ${deb_kernel_modules_name} ${deb_kernel_modules_url}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${red}Error:${plain} Download ${deb_kernel_modules_name} failed, please check it."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
wget -c -t3 -T60 -O ${deb_kernel_name} ${deb_kernel_url}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${red}Error:${plain} Download ${deb_kernel_name} failed, please check it."
|
||||
exit 1
|
||||
fi
|
||||
[ -f ${deb_kernel_modules_name} ] && dpkg -i ${deb_kernel_modules_name}
|
||||
dpkg -i ${deb_kernel_name}
|
||||
rm -f ${deb_kernel_name} ${deb_kernel_modules_name}
|
||||
else
|
||||
echo -e "${red}Error:${plain} OS is not be supported, please change to CentOS/Debian/Ubuntu and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install_config
|
||||
sysctl_config
|
||||
reboot_os
|
||||
}
|
||||
|
||||
|
||||
clear
|
||||
echo "---------- System Information ----------"
|
||||
echo " OS : $opsy"
|
||||
echo " Arch : $arch ($lbit Bit)"
|
||||
echo " Kernel : $kern"
|
||||
echo "----------------------------------------"
|
||||
echo " Auto install latest kernel for TCP BBR"
|
||||
echo
|
||||
echo " URL: https://teddysun.com/489.html"
|
||||
echo "----------------------------------------"
|
||||
echo
|
||||
echo "Press any key to start...or Press Ctrl+C to cancel"
|
||||
char=`get_char`
|
||||
|
||||
install_bbr 2>&1 | tee ${cur_dir}/install_bbr.log
|
||||
3088
脚本参考/kcptun-server.sh
Normal file
3088
脚本参考/kcptun-server.sh
Normal file
File diff suppressed because it is too large
Load Diff
130
脚本参考/multiDistributeInstallDocker.sh
Normal file
130
脚本参考/multiDistributeInstallDocker.sh
Normal file
@@ -0,0 +1,130 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
#########color code#############
|
||||
RED="31m" ## 姨妈红
|
||||
GREEN="32m" ## 水鸭青
|
||||
YELLOW="33m" ## 鸭屎黄
|
||||
BLUE="35m" ## 基佬紫
|
||||
BLUE="36m" ## 天依蓝
|
||||
|
||||
###############color echo func#################
|
||||
colorEcho(){
|
||||
echo -e "\033[${1}${@:2}\033[0m" 1>& 2
|
||||
}
|
||||
|
||||
check_root(){
|
||||
if [[ $EUID != 0 ]];then
|
||||
colorEcho ${RED} "当前非root账号(或没有root权限),无法继续操作,请更换root账号!"
|
||||
colorEcho ${YELLOW} "使用sudo -命令获取临时root权限(执行后可能会提示输入root密码)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
####### 获取系统版本及64位或32位信息
|
||||
check_sys() {
|
||||
# sys_bit=$(uname -m)
|
||||
# case $sys_bit in
|
||||
# i[36]86)
|
||||
# os_bit="32"
|
||||
# release="386"
|
||||
# ;;
|
||||
# x86_64)
|
||||
# os_bit="64"
|
||||
# release="amd64"
|
||||
# ;;
|
||||
# *armv6*)
|
||||
# os_bit="arm"
|
||||
# release="arm6"
|
||||
# ;;
|
||||
# *armv7*)
|
||||
# os_bit="arm"
|
||||
# release="arm7"
|
||||
# ;;
|
||||
# *aarch64* | *armv8*)
|
||||
# os_bit="arm64"
|
||||
# release="arm64"
|
||||
# ;;
|
||||
# *)
|
||||
# colorEcho ${RED} "
|
||||
# 哈哈……这个 辣鸡脚本 不支持你的系统。 (-_-) \n
|
||||
# 备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统
|
||||
# " && exit 1
|
||||
# ;;
|
||||
# esac
|
||||
## 判定Linux的发行版本
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
LinuxReleaseVersion="centos"
|
||||
elif cat /etc/issue | grep -Eqi "debian"; then
|
||||
LinuxReleaseVersion="debian"
|
||||
elif cat /etc/issue | grep -Eqi "ubuntu"; then
|
||||
LinuxReleaseVersion="ubuntu"
|
||||
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
|
||||
LinuxReleaseVersion="centos"
|
||||
elif cat /proc/version | grep -Eqi "debian"; then
|
||||
LinuxReleaseVersion="debian"
|
||||
elif cat /proc/version | grep -Eqi "ubuntu"; then
|
||||
LinuxReleaseVersion="ubuntu"
|
||||
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
|
||||
LinuxReleaseVersion="centos"
|
||||
else
|
||||
LinuxReleaseVersion=""
|
||||
fi
|
||||
|
||||
# 判断系统的包管理工具 apt, yum, or zypper
|
||||
getPackageManageTool() {
|
||||
if [[ -n $(command -v apt-get) ]]; then
|
||||
CMD_INSTALL="apt-get -y -qq install"
|
||||
CMD_UPDATE="apt-get -qq update"
|
||||
CMD_REMOVE="apt-get -y remove"
|
||||
elif [[ -n $(command -v yum) ]]; then
|
||||
CMD_INSTALL="yum -y -q install"
|
||||
CMD_UPDATE="yum -q makecache"
|
||||
CMD_REMOVE="yum -y remove"
|
||||
elif [[ -n $(command -v zypper) ]]; then
|
||||
CMD_INSTALL="zypper -y install"
|
||||
CMD_UPDATE="zypper ref"
|
||||
CMD_REMOVE="zypper -y remove"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# 检查系统包管理方式,更新包
|
||||
getPackageManageTool
|
||||
if [[ $? -eq 1 ]]; then
|
||||
colorEcho ${RED} "系统的包管理不是 APT or YUM, 请手动安装所需要的软件."
|
||||
return 1
|
||||
fi
|
||||
|
||||
### 更新程序引索
|
||||
if [[ $SOFTWARE_UPDATED -eq 0 ]]; then
|
||||
colorEcho ${BLUE} "正在更新软件包管理..."
|
||||
$CMD_UPDATE
|
||||
SOFTWARE_UPDATED=1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
## 安装所需要的程序,及依赖程序
|
||||
installDemandSoftwares() {
|
||||
for software in $@; do
|
||||
## 安装该软件
|
||||
if [[ -n $(command -v ${software}) ]]; then
|
||||
colorEcho ${GREEN} "${software}已经安装了...跳过..."
|
||||
else
|
||||
colorEcho ${BLUE} "正在安装 ${software}.."
|
||||
$CMD_INSTALL ${software}
|
||||
|
||||
## 判断该软件是否安装成功
|
||||
if [[ $? -ne 0 ]]; then
|
||||
colorEcho ${RED} "安装 ${software} 失败. 请手动安装该程序."
|
||||
return 1
|
||||
else
|
||||
colorEcho ${GREEN} "已经成功安装 ${software}."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
306
脚本参考/seafile-installer-71.sh
Normal file
306
脚本参考/seafile-installer-71.sh
Normal file
@@ -0,0 +1,306 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
|
||||
if [[ $HOME == "" ]]; then
|
||||
export HOME=/root
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------
|
||||
# Vars
|
||||
# -------------------------------------------
|
||||
SEAFILE_ADMIN=ice@qq.com
|
||||
SEAFILE_SERVER_USER=seafile
|
||||
SEAFILE_SERVER_HOME=/opt/seafile
|
||||
IP_OR_DOMAIN=127.0.0.1
|
||||
SEAFILE_VERSION=7.1.0
|
||||
TIME_ZONE=Asia/Shanghai
|
||||
|
||||
|
||||
FILE_SERVER_PACKAGE=seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
||||
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-server-${SEAFILE_VERSION}/
|
||||
|
||||
# -------------------------------------------
|
||||
# Additional requirements
|
||||
# -------------------------------------------
|
||||
# apt-get update
|
||||
|
||||
|
||||
# apt-get install -y python3 python3-setuptools python3-pip python3-ldap memcached openjdk-8-jre \
|
||||
# libmemcached-dev libreoffice-script-provider-python libreoffice pwgen curl nginx
|
||||
|
||||
# pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy psd-tools \
|
||||
# django-pylibmc django-simple-captcha
|
||||
|
||||
|
||||
service memcached start
|
||||
|
||||
rm /etc/nginx/sites-enabled/*
|
||||
|
||||
cp /root/seafile.conf /etc/nginx/sites-available/seafile.conf
|
||||
|
||||
ln -sf /etc/nginx/sites-available/seafile.conf /etc/nginx/sites-enabled/seafile.conf
|
||||
|
||||
service nginx restart
|
||||
|
||||
|
||||
# -------------------------------------------
|
||||
# MariaDB
|
||||
# -------------------------------------------
|
||||
if [[ -f "/root/.my.cnf" ]] ;
|
||||
then
|
||||
echo "MariaDB installed before, skip this part"
|
||||
SQLROOTPW=`sed -n 's/password=//p' /root/.my.cnf`
|
||||
else
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server
|
||||
service mysql restart
|
||||
|
||||
SQLROOTPW="phea8Mie"
|
||||
|
||||
mysqladmin -u root password $SQLROOTPW
|
||||
|
||||
cat > /root/.my.cnf <<EOF
|
||||
[client]
|
||||
user=root
|
||||
password=$SQLROOTPW
|
||||
EOF
|
||||
|
||||
chmod 600 /root/.my.cnf
|
||||
fi
|
||||
|
||||
# -------------------------------------------
|
||||
# Seafile
|
||||
# -------------------------------------------
|
||||
mkdir -p ${SEAFILE_SERVER_HOME}/installed
|
||||
cd ${SEAFILE_SERVER_HOME}
|
||||
cp /root/${FILE_SERVER_PACKAGE} .
|
||||
tar xzf ${FILE_SERVER_PACKAGE}
|
||||
|
||||
mv ${FILE_SERVER_PACKAGE} installed
|
||||
|
||||
# -------------------------------------------
|
||||
# Seafile DB
|
||||
# -------------------------------------------
|
||||
if [[ -f "/opt/seafile.my.cnf" ]] ;
|
||||
then
|
||||
echo "MariaDB installed before, skip this part"
|
||||
SQLSEAFILEPW=`sed -n 's/password=//p' /opt/seafile.my.cnf`
|
||||
else
|
||||
SQLSEAFILEPW="eiwae8Af"
|
||||
|
||||
cat > /opt/seafile.my.cnf <<EOF
|
||||
[client]
|
||||
user=seafile
|
||||
password=$SQLSEAFILEPW
|
||||
EOF
|
||||
|
||||
chmod 600 /opt/seafile.my.cnf
|
||||
fi
|
||||
|
||||
# -------------------------------------------
|
||||
# Add seafile user
|
||||
# -------------------------------------------
|
||||
useradd --system --comment "${SEAFILE_SERVER_USER}" ${SEAFILE_SERVER_USER} --home-dir ${SEAFILE_SERVER_HOME}
|
||||
|
||||
# -------------------------------------------
|
||||
# Go to /opt/seafile/seafile-pro-server-${SEAFILE_VERSION}
|
||||
# -------------------------------------------
|
||||
cd $INSTALLPATH
|
||||
|
||||
# -------------------------------------------
|
||||
# Vars - Don't touch these unless you really know what you are doing!
|
||||
# -------------------------------------------
|
||||
TOPDIR=$(dirname "${INSTALLPATH}")
|
||||
DEFAULT_CONF_DIR=${TOPDIR}/conf
|
||||
SEAFILE_DATA_DIR=${TOPDIR}/seafile-data
|
||||
DEST_SETTINGS_PY=${TOPDIR}/conf/seahub_settings.py
|
||||
|
||||
mkdir -p ${DEFAULT_CONF_DIR}
|
||||
|
||||
# -------------------------------------------
|
||||
# Create ccnet, seafile, seahub conf using setup script
|
||||
# -------------------------------------------
|
||||
|
||||
./setup-seafile-mysql.sh auto -u seafile -w ${SQLSEAFILEPW} -r ${SQLROOTPW}
|
||||
|
||||
# -------------------------------------------
|
||||
# Configure Seafile WebDAV Server(SeafDAV)
|
||||
# -------------------------------------------
|
||||
sed -i 's/enabled = .*/enabled = true/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||
sed -i 's/fastcgi = .*/fastcgi = true/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||
sed -i 's/share_name = .*/share_name = \/seafdav/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||
|
||||
# -------------------------------------------
|
||||
# Configuring seahub_settings.py
|
||||
# -------------------------------------------
|
||||
cat >> ${DEST_SETTINGS_PY} <<EOF
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
|
||||
'LOCATION': '127.0.0.1:11211',
|
||||
},
|
||||
'locmem': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
},
|
||||
}
|
||||
COMPRESS_CACHE_BACKEND = 'locmem'
|
||||
|
||||
# EMAIL_USE_TLS = False
|
||||
# EMAIL_HOST = 'localhost'
|
||||
# EMAIL_HOST_USER = ''
|
||||
# EMAIL_HOST_PASSWORD = ''
|
||||
# EMAIL_PORT = '25'
|
||||
# DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
||||
# SERVER_EMAIL = EMAIL_HOST_USER
|
||||
|
||||
TIME_ZONE = '${TIME_ZONE}'
|
||||
SITE_BASE = 'http://${IP_OR_DOMAIN}'
|
||||
SITE_NAME = 'Seafile Server'
|
||||
SITE_TITLE = 'Seafile Server'
|
||||
SITE_ROOT = '/'
|
||||
ENABLE_SIGNUP = False
|
||||
ACTIVATE_AFTER_REGISTRATION = False
|
||||
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True
|
||||
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True
|
||||
CLOUD_MODE = False
|
||||
FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
|
||||
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
|
||||
SESSION_SAVE_EVERY_REQUEST = False
|
||||
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
|
||||
|
||||
FILE_SERVER_ROOT = 'http://${IP_OR_DOMAIN}/seafhttp'
|
||||
EOF
|
||||
|
||||
|
||||
# -------------------------------------------
|
||||
# Backup check_init_admin.py befor applying changes
|
||||
# -------------------------------------------
|
||||
cp ${INSTALLPATH}/check_init_admin.py ${INSTALLPATH}/check_init_admin.py.backup
|
||||
|
||||
|
||||
# -------------------------------------------
|
||||
# Set admin credentials in check_init_admin.py
|
||||
# -------------------------------------------
|
||||
SEAFILE_ADMIN_PW=$(pwgen)
|
||||
eval "sed -i 's/= ask_admin_email()/= \"${SEAFILE_ADMIN}\"/' ${INSTALLPATH}/check_init_admin.py"
|
||||
eval "sed -i 's/= ask_admin_password()/= \"${SEAFILE_ADMIN_PW}\"/' ${INSTALLPATH}/check_init_admin.py"
|
||||
|
||||
# -------------------------------------------
|
||||
# Start and stop Seafile eco system. This generates the initial admin user.
|
||||
# -------------------------------------------
|
||||
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||
|
||||
su - seafile -c "${INSTALLPATH}/seafile.sh start"
|
||||
su - seafile -c "${INSTALLPATH}/seahub.sh start"
|
||||
wait # sleep for a while, otherwise seahub will not be stopped
|
||||
su - seafile -c "${INSTALLPATH}/seahub.sh stop"
|
||||
sleep 1
|
||||
su - seafile -c "${INSTALLPATH}/seafile.sh stop"
|
||||
sleep 1
|
||||
|
||||
# -------------------------------------------
|
||||
# Restore original check_init_admin.py
|
||||
# -------------------------------------------
|
||||
mv ${INSTALLPATH}/check_init_admin.py.backup ${INSTALLPATH}/check_init_admin.py
|
||||
|
||||
if is_pro; then
|
||||
PRO_PY=${INSTALLPATH}/pro/pro.py
|
||||
$PYTHON ${PRO_PY} setup --mysql --mysql_host=127.0.0.1 --mysql_port=3306 --mysql_user=seafile --mysql_password=${SQLSEAFILEPW} --mysql_db=seahub_db
|
||||
fi
|
||||
|
||||
# kill all process
|
||||
sleep 1
|
||||
pkill -9 -u seafile
|
||||
sleep 1
|
||||
|
||||
|
||||
# -------------------------------------------
|
||||
# Fix permissions
|
||||
# -------------------------------------------
|
||||
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||
if [[ -d /tmp/seafile-office-output/ ]]; then
|
||||
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R /tmp/seafile-office-output/
|
||||
fi
|
||||
|
||||
# -------------------------------------------
|
||||
# Start seafile server
|
||||
# -------------------------------------------
|
||||
echo "Starting productive Seafile server"
|
||||
service seafile-server start
|
||||
|
||||
|
||||
# -------------------------------------------
|
||||
# Final report
|
||||
# -------------------------------------------
|
||||
cat > ${TOPDIR}/aio_seafile-server.log<<EOF
|
||||
|
||||
Your Seafile server is installed
|
||||
-----------------------------------------------------------------
|
||||
|
||||
Server Address: http://${IP_OR_DOMAIN}
|
||||
|
||||
Seafile Admin: ${SEAFILE_ADMIN}
|
||||
Admin Password: ${SEAFILE_ADMIN_PW}
|
||||
|
||||
Seafile Data Dir: ${SEAFILE_DATA_DIR}
|
||||
|
||||
Seafile DB Credentials: Check /opt/seafile.my.cnf
|
||||
Root DB Credentials: Check /root/.my.cnf
|
||||
|
||||
This report is also saved to ${TOPDIR}/aio_seafile-server.log
|
||||
|
||||
|
||||
|
||||
Next you should manually complete the following steps
|
||||
-----------------------------------------------------------------
|
||||
|
||||
1) Log in to Seafile and configure your server domain via the system
|
||||
admin area if applicable.
|
||||
|
||||
2) If this server is behind a firewall, you need to ensure that
|
||||
tcp port 80 is open.
|
||||
|
||||
3) Seahub tries to send emails via the local server. Install and
|
||||
configure Postfix for this to work or
|
||||
check https://manual.seafile.com/config/sending_email.html
|
||||
for instructions on how to use an existing email account via SMTP.
|
||||
|
||||
|
||||
|
||||
|
||||
Optional steps
|
||||
-----------------------------------------------------------------
|
||||
|
||||
1) Check seahub_settings.py and customize it to fit your needs. Consult
|
||||
http://manual.seafile.com/config/seahub_settings_py.html for possible switches.
|
||||
|
||||
2) Setup NGINX with official SSL certificate.
|
||||
|
||||
3) Secure server with iptables based firewall. For instance: UFW or shorewall
|
||||
|
||||
4) Harden system with port knocking, fail2ban, etc.
|
||||
|
||||
5) Enable unattended installation of security updates. Check
|
||||
https://wiki.Ubuntu.org/UnattendedUpgrades for details.
|
||||
|
||||
6) Implement a backup routine for your Seafile server.
|
||||
|
||||
7) Update NGINX worker processes to reflect the number of CPU cores.
|
||||
|
||||
|
||||
|
||||
|
||||
Seafile support options
|
||||
-----------------------------------------------------------------
|
||||
|
||||
For free community support visit: https://bbs.seafile.com
|
||||
For paid commercial support visit: https://seafile.com
|
||||
|
||||
EOF
|
||||
|
||||
chmod 600 ${TOPDIR}/aio_seafile-server.log
|
||||
|
||||
clear
|
||||
|
||||
cat ${TOPDIR}/aio_seafile-server.log
|
||||
497
脚本参考/trojan-plus-by-atrandys.sh
Normal file
497
脚本参考/trojan-plus-by-atrandys.sh
Normal file
@@ -0,0 +1,497 @@
|
||||
#!/bin/bash
|
||||
function blue(){
|
||||
echo -e "\033[34m\033[01m$1\033[0m"
|
||||
}
|
||||
function green(){
|
||||
echo -e "\033[32m\033[01m$1\033[0m"
|
||||
}
|
||||
function red(){
|
||||
echo -e "\033[31m\033[01m$1\033[0m"
|
||||
}
|
||||
function version_lt(){
|
||||
test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1";
|
||||
}
|
||||
|
||||
source /etc/os-release
|
||||
RELEASE=$ID
|
||||
VERSION=$VERSION_ID
|
||||
if [ "$RELEASE" == "centos" ]; then
|
||||
release="centos"
|
||||
systemPackage="yum"
|
||||
elif [ "$RELEASE" == "debian" ]; then
|
||||
release="debian"
|
||||
systemPackage="apt-get"
|
||||
elif [ "$RELEASE" == "ubuntu" ]; then
|
||||
release="ubuntu"
|
||||
systemPackage="apt-get"
|
||||
fi
|
||||
systempwd="/etc/systemd/system/"
|
||||
|
||||
function install_trojan(){
|
||||
$systemPackage install -y nginx
|
||||
if [ ! -d "/etc/nginx/" ]; then
|
||||
red "nginx安装有问题,请使用卸载trojan后重新安装"
|
||||
exit 1
|
||||
fi
|
||||
cat > /etc/nginx/nginx.conf <<-EOF
|
||||
user root;
|
||||
worker_processes 1;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" '
|
||||
'\$status \$body_bytes_sent "\$http_referer" '
|
||||
'"\$http_user_agent" "\$http_x_forwarded_for"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
keepalive_timeout 120;
|
||||
client_max_body_size 20m;
|
||||
#gzip on;
|
||||
server {
|
||||
listen 80;
|
||||
server_name $your_domain;
|
||||
root /usr/share/nginx/html;
|
||||
index index.php index.html index.htm;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
systemctl restart nginx
|
||||
systemctl enable nginx
|
||||
sleep 3
|
||||
rm -rf /usr/share/nginx/html/*
|
||||
cd /usr/share/nginx/html/
|
||||
wget https://github.com/atrandys/trojan/raw/master/fakesite.zip >/dev/null 2>&1
|
||||
unzip fakesite.zip >/dev/null 2>&1
|
||||
sleep 5
|
||||
if [ ! -d "/usr/src" ]; then
|
||||
mkdir /usr/src
|
||||
fi
|
||||
if [ ! -d "/usr/src/trojan-cert" ]; then
|
||||
mkdir /usr/src/trojan-cert /usr/src/trojan-cli
|
||||
mkdir /usr/src/trojan-cert/$your_domain
|
||||
if [ ! -d "/usr/src/trojan-cert/$your_domain" ]; then
|
||||
red "不存在/usr/src/trojan-cert/$your_domain目录"
|
||||
exit 1
|
||||
fi
|
||||
curl https://get.acme.sh | sh
|
||||
~/.acme.sh/acme.sh --issue -d $your_domain --nginx
|
||||
if test -s /root/.acme.sh/$your_domain/fullchain.cer; then
|
||||
cert_success="1"
|
||||
fi
|
||||
elif [ -f "/usr/src/trojan-cert/$your_domain/fullchain.cer" ]; then
|
||||
cd /usr/src/trojan-cert/$your_domain
|
||||
create_time=`stat -c %Y fullchain.cer`
|
||||
now_time=`date +%s`
|
||||
minus=$(($now_time - $create_time ))
|
||||
if [ $minus -gt 5184000 ]; then
|
||||
curl https://get.acme.sh | sh
|
||||
~/.acme.sh/acme.sh --issue -d $your_domain --nginx
|
||||
if test -s /root/.acme.sh/$your_domain/fullchain.cer; then
|
||||
cert_success="1"
|
||||
fi
|
||||
else
|
||||
green "检测到域名$your_domain证书存在且未超过60天,无需重新申请"
|
||||
cert_success="1"
|
||||
fi
|
||||
else
|
||||
mkdir /usr/src/trojan-cert/$your_domain
|
||||
curl https://get.acme.sh | sh
|
||||
~/.acme.sh/acme.sh --issue -d $your_domain --nginx
|
||||
if test -s /root/.acme.sh/$your_domain/fullchain.cer; then
|
||||
cert_success="1"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$cert_success" == "1" ]; then
|
||||
#systemctl restart nginx
|
||||
mkdir /usr/src/trojan && cd /usr/src/trojan
|
||||
wget https://api.github.com/repos/atrandys/trojan-plus/releases/latest
|
||||
latest_version=`grep tag_name latest| awk -F '[:,"v]' '{print $6}'`
|
||||
rm -f latest
|
||||
green "开始下载最新版trojan amd64"
|
||||
wget https://github.com/atrandys/trojan-plus/releases/download/v${latest_version}/trojan
|
||||
chmod +x trojan
|
||||
green "请设置trojan密码,建议不要出现特殊字符"
|
||||
read -p "请输入密码 :" trojan_passwd
|
||||
#trojan_passwd=$(cat /dev/urandom | head -1 | md5sum | head -c 8)
|
||||
cat > /usr/src/trojan-cli/config.json <<-EOF
|
||||
{
|
||||
"run_type": "client",
|
||||
"local_addr": "127.0.0.1",
|
||||
"local_port": 1080,
|
||||
"remote_addr": "$your_domain",
|
||||
"remote_port": 443,
|
||||
"password": [
|
||||
"$trojan_passwd"
|
||||
],
|
||||
"log_level": 1,
|
||||
"ssl": {
|
||||
"verify": true,
|
||||
"verify_hostname": true,
|
||||
"cert": "",
|
||||
"cipher_tls13":"TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384",
|
||||
"sni": "",
|
||||
"alpn": [
|
||||
"http/1.1"
|
||||
],
|
||||
"reuse_session": true,
|
||||
"session_ticket": false,
|
||||
"curves": ""
|
||||
},
|
||||
"tcp": {
|
||||
"no_delay": true,
|
||||
"keep_alive": true,
|
||||
"fast_open": true,
|
||||
"fast_open_qlen": 20
|
||||
},
|
||||
"experimental":{
|
||||
"pipeline_num" : 10,
|
||||
"pipeline_ack_window" : 200
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cat > /usr/src/trojan/server.conf <<-EOF
|
||||
{
|
||||
"run_type": "server",
|
||||
"local_addr": "0.0.0.0",
|
||||
"local_port": 443,
|
||||
"remote_addr": "127.0.0.1",
|
||||
"remote_port": 80,
|
||||
"password": [
|
||||
"$trojan_passwd"
|
||||
],
|
||||
"log_level": 1,
|
||||
"ssl": {
|
||||
"cert": "/usr/src/trojan-cert/$your_domain/fullchain.cer",
|
||||
"key": "/usr/src/trojan-cert/$your_domain/private.key",
|
||||
"key_password": "",
|
||||
"cipher_tls13":"TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384",
|
||||
"prefer_server_cipher": true,
|
||||
"alpn": [
|
||||
"h2",
|
||||
"http/1.1"
|
||||
],
|
||||
"reuse_session": true,
|
||||
"session_ticket": false,
|
||||
"session_timeout": 600,
|
||||
"plain_http_response": "",
|
||||
"curves": "",
|
||||
"dhparam": ""
|
||||
},
|
||||
"tcp": {
|
||||
"no_delay": true,
|
||||
"keep_alive": true,
|
||||
"fast_open": true,
|
||||
"fast_open_qlen": 20
|
||||
},
|
||||
"experimental":{
|
||||
"pipeline_num" : 10,
|
||||
"pipeline_ack_window" : 200,
|
||||
"pipeline_proxy_icmp": true
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cat > ${systempwd}trojan.service <<-EOF
|
||||
[Unit]
|
||||
Description=trojan
|
||||
After=network.target network-online.target nss-lookup.target mysql.service mariadb.service mysqld.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
PIDFile=/usr/src/trojan/trojan.pid
|
||||
ExecStart=/usr/src/trojan/trojan -c "/usr/src/trojan/server.conf"
|
||||
ExecReload=/bin/kill -HUP \$MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=1s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
chmod +x ${systempwd}trojan.service
|
||||
systemctl enable trojan.service
|
||||
cd /root
|
||||
~/.acme.sh/acme.sh --installcert -d $your_domain \
|
||||
--key-file /usr/src/trojan-cert/$your_domain/private.key \
|
||||
--fullchain-file /usr/src/trojan-cert/$your_domain/fullchain.cer \
|
||||
--reloadcmd "systemctl restart trojan"
|
||||
echo
|
||||
echo
|
||||
green " 客户端配置文件"
|
||||
green "==========================================================================="
|
||||
cat /usr/src/trojan-cli/config.json
|
||||
green "==========================================================================="
|
||||
else
|
||||
red "==================================="
|
||||
red "https证书没有申请成功,本次安装失败"
|
||||
red "==================================="
|
||||
fi
|
||||
}
|
||||
function preinstall_check(){
|
||||
|
||||
nginx_status=`ps -aux | grep "nginx: worker" |grep -v "grep"`
|
||||
if [ -n "$nginx_status" ]; then
|
||||
systemctl stop nginx
|
||||
fi
|
||||
$systemPackage -y install net-tools socat >/dev/null 2>&1
|
||||
Port80=`netstat -tlpn | awk -F '[: ]+' '$1=="tcp"{print $5}' | grep -w 80`
|
||||
Port443=`netstat -tlpn | awk -F '[: ]+' '$1=="tcp"{print $5}' | grep -w 443`
|
||||
if [ -n "$Port80" ]; then
|
||||
process80=`netstat -tlpn | awk -F '[: ]+' '$5=="80"{print $9}'`
|
||||
red "==========================================================="
|
||||
red "检测到80端口被占用,占用进程为:${process80},本次安装结束"
|
||||
red "==========================================================="
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$Port443" ]; then
|
||||
process443=`netstat -tlpn | awk -F '[: ]+' '$5=="443"{print $9}'`
|
||||
red "============================================================="
|
||||
red "检测到443端口被占用,占用进程为:${process443},本次安装结束"
|
||||
red "============================================================="
|
||||
exit 1
|
||||
fi
|
||||
if [ -f "/etc/selinux/config" ]; then
|
||||
CHECK=$(grep SELINUX= /etc/selinux/config | grep -v "#")
|
||||
if [ "$CHECK" == "SELINUX=enforcing" ]; then
|
||||
green "$(date +"%Y-%m-%d %H:%M:%S") - SELinux状态非disabled,关闭SELinux."
|
||||
setenforce 0
|
||||
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
|
||||
#loggreen "SELinux is not disabled, add port 80/443 to SELinux rules."
|
||||
#loggreen "==== Install semanage"
|
||||
#logcmd "yum install -y policycoreutils-python"
|
||||
#semanage port -a -t http_port_t -p tcp 80
|
||||
#semanage port -a -t http_port_t -p tcp 443
|
||||
#semanage port -a -t http_port_t -p tcp 37212
|
||||
#semanage port -a -t http_port_t -p tcp 37213
|
||||
elif [ "$CHECK" == "SELINUX=permissive" ]; then
|
||||
green "$(date +"%Y-%m-%d %H:%M:%S") - SELinux状态非disabled,关闭SELinux."
|
||||
setenforce 0
|
||||
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
|
||||
fi
|
||||
fi
|
||||
if [ "$release" == "centos" ]; then
|
||||
if [ -n "$(grep ' 6\.' /etc/redhat-release)" ] ;then
|
||||
red "==============="
|
||||
red "当前系统不受支持"
|
||||
red "==============="
|
||||
exit
|
||||
fi
|
||||
if [ -n "$(grep ' 5\.' /etc/redhat-release)" ] ;then
|
||||
red "==============="
|
||||
red "当前系统不受支持"
|
||||
red "==============="
|
||||
exit
|
||||
fi
|
||||
firewall_status=`systemctl status firewalld | grep "Active: active"`
|
||||
if [ -n "$firewall_status" ]; then
|
||||
green "检测到firewalld开启状态,添加放行80/443端口规则"
|
||||
firewall-cmd --zone=public --add-port=80/tcp --permanent
|
||||
firewall-cmd --zone=public --add-port=443/tcp --permanent
|
||||
firewall-cmd --reload
|
||||
fi
|
||||
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm --force --nodeps
|
||||
elif [ "$release" == "ubuntu" ]; then
|
||||
if [ -n "$(grep ' 14\.' /etc/os-release)" ] ;then
|
||||
red "==============="
|
||||
red "当前系统不受支持"
|
||||
red "==============="
|
||||
exit
|
||||
fi
|
||||
if [ -n "$(grep ' 12\.' /etc/os-release)" ] ;then
|
||||
red "==============="
|
||||
red "当前系统不受支持"
|
||||
red "==============="
|
||||
exit
|
||||
fi
|
||||
ufw_status=`systemctl status ufw | grep "Active: active"`
|
||||
if [ -n "$ufw_status" ]; then
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
ufw reload
|
||||
fi
|
||||
apt-get update
|
||||
elif [ "$release" == "debian" ]; then
|
||||
ufw_status=`systemctl status ufw | grep "Active: active"`
|
||||
if [ -n "$ufw_status" ]; then
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
ufw reload
|
||||
fi
|
||||
apt-get update
|
||||
fi
|
||||
$systemPackage -y install wget unzip zip curl tar >/dev/null 2>&1
|
||||
green "======================="
|
||||
blue "请输入绑定到本VPS的域名"
|
||||
green "======================="
|
||||
read your_domain
|
||||
real_addr=`ping ${your_domain} -c 1 | sed '1{s/[^(]*(//;s/).*//;q}'`
|
||||
local_addr=`curl ipv4.icanhazip.com`
|
||||
if [ $real_addr == $local_addr ] ; then
|
||||
green "=========================================="
|
||||
green " 域名解析正常,开始安装trojan"
|
||||
green "=========================================="
|
||||
sleep 1s
|
||||
install_trojan
|
||||
else
|
||||
red "===================================="
|
||||
red "域名解析地址与本VPS IP地址不一致"
|
||||
red "若你确认解析成功你可强制脚本继续运行"
|
||||
red "===================================="
|
||||
read -p "是否强制运行 ?请输入 [Y/n] :" yn
|
||||
[ -z "${yn}" ] && yn="y"
|
||||
if [[ $yn == [Yy] ]]; then
|
||||
green "强制继续运行脚本"
|
||||
sleep 1s
|
||||
install_trojan
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function repair_cert(){
|
||||
systemctl stop nginx
|
||||
#iptables -I INPUT -p tcp --dport 80 -j ACCEPT
|
||||
#iptables -I INPUT -p tcp --dport 443 -j ACCEPT
|
||||
Port80=`netstat -tlpn | awk -F '[: ]+' '$1=="tcp"{print $5}' | grep -w 80`
|
||||
if [ -n "$Port80" ]; then
|
||||
process80=`netstat -tlpn | awk -F '[: ]+' '$5=="80"{print $9}'`
|
||||
red "==========================================================="
|
||||
red "检测到80端口被占用,占用进程为:${process80},本次安装结束"
|
||||
red "==========================================================="
|
||||
exit 1
|
||||
fi
|
||||
green "============================"
|
||||
blue "请输入绑定到本VPS的域名"
|
||||
blue "务必与之前失败使用的域名一致"
|
||||
green "============================"
|
||||
read your_domain
|
||||
real_addr=`ping ${your_domain} -c 1 | sed '1{s/[^(]*(//;s/).*//;q}'`
|
||||
local_addr=`curl ipv4.icanhazip.com`
|
||||
if [ $real_addr == $local_addr ] ; then
|
||||
~/.acme.sh/acme.sh --issue -d $your_domain --standalone
|
||||
~/.acme.sh/acme.sh --installcert -d $your_domain \
|
||||
--key-file /usr/src/trojan-cert/$your_domain/private.key \
|
||||
--fullchain-file /usr/src/trojan-cert/$your_domain/fullchain.cer \
|
||||
--reloadcmd "systemctl restart trojan"
|
||||
if test -s /usr/src/trojan-cert/$your_domain/fullchain.cer; then
|
||||
green "证书申请成功"
|
||||
systemctl restart trojan
|
||||
systemctl start nginx
|
||||
else
|
||||
red "申请证书失败"
|
||||
fi
|
||||
else
|
||||
red "================================"
|
||||
red "域名解析地址与本VPS IP地址不一致"
|
||||
red "本次安装失败,请确保域名解析正常"
|
||||
red "================================"
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_trojan(){
|
||||
red "================================"
|
||||
red "即将卸载trojan"
|
||||
red "同时卸载安装的nginx"
|
||||
red "================================"
|
||||
systemctl stop trojan
|
||||
systemctl disable trojan
|
||||
systemctl stop nginx
|
||||
systemctl disable nginx
|
||||
rm -f ${systempwd}trojan.service
|
||||
if [ "$release" == "centos" ]; then
|
||||
yum remove -y nginx
|
||||
else
|
||||
apt-get -y autoremove nginx
|
||||
apt-get -y --purge remove nginx
|
||||
apt-get -y autoremove && apt-get -y autoclean
|
||||
find / | grep nginx | sudo xargs rm -rf
|
||||
fi
|
||||
rm -rf /usr/src/trojan/
|
||||
rm -rf /usr/src/trojan-cli/
|
||||
rm -rf /usr/share/nginx/html/*
|
||||
rm -rf /etc/nginx/
|
||||
rm -rf /root/.acme.sh/
|
||||
green "=============="
|
||||
green "trojan删除完毕"
|
||||
green "=============="
|
||||
}
|
||||
|
||||
function update_trojan(){
|
||||
/usr/src/trojan/trojan -v 2>trojan.tmp
|
||||
curr_version=`cat trojan.tmp | grep "trojan" | awk '{print $4}'`
|
||||
wget https://api.github.com/repos/atrandys/trojan-plus/releases/latest
|
||||
latest_version=`grep tag_name latest| awk -F '[:,"v]' '{print $6}'`
|
||||
rm -f latest
|
||||
rm -f trojan.tmp
|
||||
if version_lt "$curr_version" "$latest_version"; then
|
||||
green "当前版本$curr_version,最新版本$latest_version,开始升级……"
|
||||
mkdir trojan_update_temp && cd trojan_update_temp
|
||||
wget https://github.com/atrandys/trojan-plus/releases/download/v${latest_version}/trojan
|
||||
chmod +x trojan
|
||||
\cp ./trojan /usr/src/trojan/
|
||||
cd .. && rm -rf trojan_update_temp
|
||||
systemctl restart trojan
|
||||
/usr/src/trojan/trojan -v 2>trojan.tmp
|
||||
green "服务端trojan升级完成,当前版本:`cat trojan.tmp | grep "trojan" | awk '{print $4}'`"
|
||||
rm -f trojan.tmp
|
||||
else
|
||||
green "当前版本$curr_version,最新版本$latest_version,无需升级"
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
start_menu(){
|
||||
clear
|
||||
green " =================================================="
|
||||
green " 描述: 一键安装Trojan plus "
|
||||
green " 系统: centos7+/debian9+/ubuntu16.04+"
|
||||
green " 作者: atrandys www.atrandys.com "
|
||||
echo
|
||||
red " *1. 不要在任何生产环境使用此脚本,若数据丢失后果自负"
|
||||
red " *2. 若80和443端口被占用会导致安装失败"
|
||||
red " *3. 若脚本安装失败,请先执行脚本中卸载trojan后重试"
|
||||
green " =================================================="
|
||||
echo
|
||||
green " 1. 安装Trojan plus"
|
||||
red " 2. 卸载Trojan plus"
|
||||
green " 3. 升级Trojan plus"
|
||||
green " 4. 修复证书"
|
||||
blue " 0. 退出脚本"
|
||||
echo
|
||||
read -p "请输入数字 :" num
|
||||
case "$num" in
|
||||
1)
|
||||
preinstall_check
|
||||
;;
|
||||
2)
|
||||
remove_trojan
|
||||
;;
|
||||
3)
|
||||
update_trojan
|
||||
;;
|
||||
4)
|
||||
repair_cert
|
||||
;;
|
||||
0)
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
clear
|
||||
red "请输入正确数字"
|
||||
sleep 1s
|
||||
start_menu
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
start_menu
|
||||
1422
脚本参考/warp-p3trex
Normal file
1422
脚本参考/warp-p3trex
Normal file
File diff suppressed because it is too large
Load Diff
744
脚本参考/xray-install.sh
Normal file
744
脚本参考/xray-install.sh
Normal file
@@ -0,0 +1,744 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#====================================================
|
||||
# System Request:Debian 9+/Ubuntu 18.04+/Centos 7+
|
||||
# Author: wulabing
|
||||
# Dscription: Xray onekey Management
|
||||
# email: admin@wulabing.com
|
||||
#====================================================
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
stty erase ^?
|
||||
|
||||
cd "$(
|
||||
cd "$(dirname "$0")" || exit
|
||||
pwd
|
||||
)" || exit
|
||||
|
||||
# 字体颜色配置
|
||||
Green="\033[32m"
|
||||
Red="\033[31m"
|
||||
Yellow="\033[33m"
|
||||
Blue="\033[36m"
|
||||
Font="\033[0m"
|
||||
GreenBG="\033[42;37m"
|
||||
RedBG="\033[41;37m"
|
||||
OK="${Green}[OK]${Font}"
|
||||
ERROR="${Red}[ERROR]${Font}"
|
||||
|
||||
# 变量
|
||||
shell_version="1.3.7"
|
||||
github_branch="main"
|
||||
xray_conf_dir="/usr/local/etc/xray"
|
||||
website_dir="/www/xray_web/"
|
||||
xray_access_log="/var/log/xray/access.log"
|
||||
xray_error_log="/var/log/xray/error.log"
|
||||
cert_dir="/usr/local/etc/xray"
|
||||
domain_tmp_dir="/usr/local/etc/xray"
|
||||
cert_group="nobody"
|
||||
random_num=$((RANDOM % 12 + 4))
|
||||
|
||||
VERSION=$(echo "${VERSION}" | awk -F "[()]" '{print $2}')
|
||||
WS_PATH="/$(head -n 10 /dev/urandom | md5sum | head -c ${random_num})/"
|
||||
|
||||
function shell_mode_check() {
|
||||
if [ -f ${xray_conf_dir}/config.json ]; then
|
||||
if [ "$(grep -c "wsSettings" ${xray_conf_dir}/config.json)" -ge 1 ]; then
|
||||
shell_mode="ws"
|
||||
else
|
||||
shell_mode="tcp"
|
||||
fi
|
||||
else
|
||||
shell_mode="None"
|
||||
fi
|
||||
}
|
||||
function print_ok() {
|
||||
echo -e "${OK} ${Blue} $1 ${Font}"
|
||||
}
|
||||
|
||||
function print_error() {
|
||||
echo -e "${ERROR} ${RedBG} $1 ${Font}"
|
||||
}
|
||||
|
||||
function is_root() {
|
||||
if [[ 0 == "$UID" ]]; then
|
||||
print_ok "当前用户是 root 用户,开始安装流程"
|
||||
else
|
||||
print_error "当前用户不是 root 用户,请切换到 root 用户后重新执行脚本"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
judge() {
|
||||
if [[ 0 -eq $? ]]; then
|
||||
print_ok "$1 完成"
|
||||
sleep 1
|
||||
else
|
||||
print_error "$1 失败"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function system_check() {
|
||||
source '/etc/os-release'
|
||||
|
||||
if [[ "${ID}" == "centos" && ${VERSION_ID} -ge 7 ]]; then
|
||||
print_ok "当前系统为 Centos ${VERSION_ID} ${VERSION}"
|
||||
INS="yum install -y"
|
||||
wget -N -P /etc/yum.repos.d/ https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/basic/nginx.repo
|
||||
elif [[ "${ID}" == "ol" ]]; then
|
||||
print_ok "当前系统为 Oracle Linux ${VERSION_ID} ${VERSION}"
|
||||
INS="yum install -y"
|
||||
wget -N -P /etc/yum.repos.d/ https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/basic/nginx.repo
|
||||
elif [[ "${ID}" == "debian" && ${VERSION_ID} -ge 9 ]]; then
|
||||
print_ok "当前系统为 Debian ${VERSION_ID} ${VERSION}"
|
||||
INS="apt install -y"
|
||||
# 清除可能的遗留问题
|
||||
rm -f /etc/apt/sources.list.d/nginx.list
|
||||
$INS lsb-release gnupg2
|
||||
|
||||
echo "deb http://nginx.org/packages/debian $(lsb_release -cs) nginx" >/etc/apt/sources.list.d/nginx.list
|
||||
curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add -
|
||||
|
||||
apt update
|
||||
elif [[ "${ID}" == "ubuntu" && $(echo "${VERSION_ID}" | cut -d '.' -f1) -ge 18 ]]; then
|
||||
print_ok "当前系统为 Ubuntu ${VERSION_ID} ${UBUNTU_CODENAME}"
|
||||
INS="apt install -y"
|
||||
# 清除可能的遗留问题
|
||||
rm -f /etc/apt/sources.list.d/nginx.list
|
||||
$INS lsb-release gnupg2
|
||||
|
||||
echo "deb http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" >/etc/apt/sources.list.d/nginx.list
|
||||
curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add -
|
||||
apt update
|
||||
else
|
||||
print_error "当前系统为 ${ID} ${VERSION_ID} 不在支持的系统列表内"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $(grep "nogroup" /etc/group) ]]; then
|
||||
cert_group="nogroup"
|
||||
fi
|
||||
|
||||
$INS dbus
|
||||
|
||||
# 关闭各类防火墙
|
||||
systemctl stop firewalld
|
||||
systemctl disable firewalld
|
||||
systemctl stop nftables
|
||||
systemctl disable nftables
|
||||
systemctl stop ufw
|
||||
systemctl disable ufw
|
||||
}
|
||||
|
||||
function nginx_install() {
|
||||
if ! command -v nginx >/dev/null 2>&1; then
|
||||
${INS} nginx
|
||||
judge "Nginx 安装"
|
||||
else
|
||||
print_ok "Nginx 已存在"
|
||||
${INS} nginx
|
||||
fi
|
||||
# 遗留问题处理
|
||||
mkdir -p /etc/nginx/conf.d >/dev/null 2>&1
|
||||
}
|
||||
function dependency_install() {
|
||||
${INS} wget lsof tar
|
||||
judge "安装 wget lsof tar"
|
||||
|
||||
if [[ "${ID}" == "centos" || "${ID}" == "ol" ]]; then
|
||||
${INS} crontabs
|
||||
else
|
||||
${INS} cron
|
||||
fi
|
||||
judge "安装 crontab"
|
||||
|
||||
if [[ "${ID}" == "centos" || "${ID}" == "ol" ]]; then
|
||||
touch /var/spool/cron/root && chmod 600 /var/spool/cron/root
|
||||
systemctl start crond && systemctl enable crond
|
||||
else
|
||||
touch /var/spool/cron/crontabs/root && chmod 600 /var/spool/cron/crontabs/root
|
||||
systemctl start cron && systemctl enable cron
|
||||
|
||||
fi
|
||||
judge "crontab 自启动配置 "
|
||||
|
||||
${INS} unzip
|
||||
judge "安装 unzip"
|
||||
|
||||
${INS} curl
|
||||
judge "安装 curl"
|
||||
|
||||
# upgrade systemd
|
||||
${INS} systemd
|
||||
judge "安装/升级 systemd"
|
||||
|
||||
# Nginx 后置 无需编译 不再需要
|
||||
# if [[ "${ID}" == "centos" || "${ID}" == "ol" ]]; then
|
||||
# yum -y groupinstall "Development tools"
|
||||
# else
|
||||
# ${INS} build-essential
|
||||
# fi
|
||||
# judge "编译工具包 安装"
|
||||
|
||||
if [[ "${ID}" == "centos" ]]; then
|
||||
${INS} pcre pcre-devel zlib-devel epel-release openssl openssl-devel
|
||||
elif [[ "${ID}" == "ol" ]]; then
|
||||
${INS} pcre pcre-devel zlib-devel openssl openssl-devel
|
||||
# Oracle Linux 不同日期版本的 VERSION_ID 比较乱 直接暴力处理
|
||||
yum-config-manager --enable ol7_developer_EPEL >/dev/null 2>&1
|
||||
yum-config-manager --enable ol8_developer_EPEL >/dev/null 2>&1
|
||||
else
|
||||
${INS} libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev
|
||||
fi
|
||||
|
||||
${INS} jq
|
||||
|
||||
if ! command -v jq; then
|
||||
wget -P /usr/bin https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/binary/jq && chmod +x /usr/bin/jq
|
||||
judge "安装 jq"
|
||||
fi
|
||||
|
||||
# 防止部分系统xray的默认bin目录缺失
|
||||
mkdir /usr/local/bin >/dev/null 2>&1
|
||||
}
|
||||
|
||||
function basic_optimization() {
|
||||
# 最大文件打开数
|
||||
sed -i '/^\*\ *soft\ *nofile\ *[[:digit:]]*/d' /etc/security/limits.conf
|
||||
sed -i '/^\*\ *hard\ *nofile\ *[[:digit:]]*/d' /etc/security/limits.conf
|
||||
echo '* soft nofile 65536' >>/etc/security/limits.conf
|
||||
echo '* hard nofile 65536' >>/etc/security/limits.conf
|
||||
|
||||
# 关闭 Selinux
|
||||
if [[ "${ID}" == "centos" || "${ID}" == "ol" ]]; then
|
||||
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
|
||||
setenforce 0
|
||||
fi
|
||||
}
|
||||
function domain_check() {
|
||||
read -rp "请输入你的域名信息(eg: www.wulabing.com):" domain
|
||||
domain_ip=$(ping "${domain}" -c 1 | sed '1{s/[^(]*(//;s/).*//;q}')
|
||||
print_ok "正在获取 IP 地址信息,请耐心等待"
|
||||
local_ip=$(curl -4L api64.ipify.org)
|
||||
echo -e "域名通过 DNS 解析的 IP 地址:${domain_ip}"
|
||||
echo -e "本机公网 IP 地址: ${local_ip}"
|
||||
sleep 2
|
||||
if [[ ${domain_ip} == "${local_ip}" ]]; then
|
||||
print_ok "域名通过 DNS 解析的 IP 地址与 本机 IP 地址匹配"
|
||||
sleep 2
|
||||
else
|
||||
print_error "请确保域名添加了正确的 A 记录,否则将无法正常使用 xray"
|
||||
print_error "域名通过 DNS 解析的 IP 地址与 本机 IP 地址不匹配,是否继续安装?(y/n)" && read -r install
|
||||
case $install in
|
||||
[yY][eE][sS] | [yY])
|
||||
print_ok "继续安装"
|
||||
sleep 2
|
||||
;;
|
||||
*)
|
||||
print_error "安装终止"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
function port_exist_check() {
|
||||
if [[ 0 -eq $(lsof -i:"$1" | grep -i -c "listen") ]]; then
|
||||
print_ok "$1 端口未被占用"
|
||||
sleep 1
|
||||
else
|
||||
print_error "检测到 $1 端口被占用,以下为 $1 端口占用信息"
|
||||
lsof -i:"$1"
|
||||
print_error "5s 后将尝试自动 kill 占用进程"
|
||||
sleep 5
|
||||
lsof -i:"$1" | awk '{print $2}' | grep -v "PID" | xargs kill -9
|
||||
print_ok "kill 完成"
|
||||
sleep 1
|
||||
fi
|
||||
}
|
||||
function update_sh() {
|
||||
ol_version=$(curl -L -s https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/install.sh | grep "shell_version=" | head -1 | awk -F '=|"' '{print $3}')
|
||||
if [[ "$shell_version" != "$(echo -e "$shell_version\n$ol_version" | sort -rV | head -1)" ]]; then
|
||||
print_ok "存在新版本,是否更新 [Y/N]?"
|
||||
read -r update_confirm
|
||||
case $update_confirm in
|
||||
[yY][eE][sS] | [yY])
|
||||
wget -N --no-check-certificate https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/install.sh
|
||||
print_ok "更新完成"
|
||||
print_ok "您可以通过 bash $0 执行本程序"
|
||||
exit 0
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
else
|
||||
print_ok "当前版本为最新版本"
|
||||
print_ok "您可以通过 bash $0 执行本程序"
|
||||
fi
|
||||
}
|
||||
|
||||
function xray_tmp_config_file_check_and_use() {
|
||||
if [[ -s ${xray_conf_dir}/config_tmp.json ]]; then
|
||||
mv -f ${xray_conf_dir}/config_tmp.json ${xray_conf_dir}/config.json
|
||||
else
|
||||
print_error "xray 配置文件修改异常"
|
||||
fi
|
||||
}
|
||||
|
||||
function modify_UUID() {
|
||||
[ -z "$UUID" ] && UUID=$(cat /proc/sys/kernel/random/uuid)
|
||||
cat ${xray_conf_dir}/config.json | jq 'setpath(["inbounds",0,"settings","clients",0,"id"];"'${UUID}'")' >${xray_conf_dir}/config_tmp.json
|
||||
xray_tmp_config_file_check_and_use
|
||||
judge "Xray TCP UUID 修改"
|
||||
}
|
||||
|
||||
function modify_UUID_ws() {
|
||||
cat ${xray_conf_dir}/config.json | jq 'setpath(["inbounds",1,"settings","clients",0,"id"];"'${UUID}'")' >${xray_conf_dir}/config_tmp.json
|
||||
xray_tmp_config_file_check_and_use
|
||||
judge "Xray ws UUID 修改"
|
||||
}
|
||||
|
||||
function modify_fallback_ws() {
|
||||
cat ${xray_conf_dir}/config.json | jq 'setpath(["inbounds",0,"settings","fallbacks",2,"path"];"'${WS_PATH}'")' >${xray_conf_dir}/config_tmp.json
|
||||
xray_tmp_config_file_check_and_use
|
||||
judge "Xray fallback_ws 修改"
|
||||
}
|
||||
|
||||
function modify_ws() {
|
||||
cat ${xray_conf_dir}/config.json | jq 'setpath(["inbounds",1,"streamSettings","wsSettings","path"];"'${WS_PATH}'")' >${xray_conf_dir}/config_tmp.json
|
||||
xray_tmp_config_file_check_and_use
|
||||
judge "Xray ws 修改"
|
||||
}
|
||||
|
||||
function configure_nginx() {
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.conf"
|
||||
cd /etc/nginx/conf.d/ && rm -f ${domain}.conf && wget -O ${domain}.conf https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/config/web.conf
|
||||
sed -i "s/xxx/${domain}/g" ${nginx_conf}
|
||||
judge "Nginx config modify"
|
||||
|
||||
systemctl restart nginx
|
||||
}
|
||||
|
||||
function modify_port() {
|
||||
read -rp "请输入端口号(默认:443):" PORT
|
||||
[ -z "$PORT" ] && PORT="443"
|
||||
if [[ $PORT -le 0 ]] || [[ $PORT -gt 65535 ]]; then
|
||||
print_error "请输入 0-65535 之间的值"
|
||||
exit 1
|
||||
fi
|
||||
port_exist_check $PORT
|
||||
cat ${xray_conf_dir}/config.json | jq 'setpath(["inbounds",0,"port"];'${PORT}')' >${xray_conf_dir}/config_tmp.json
|
||||
xray_tmp_config_file_check_and_use
|
||||
judge "Xray 端口 修改"
|
||||
}
|
||||
|
||||
function configure_xray() {
|
||||
cd /usr/local/etc/xray && rm -f config.json && wget -O config.json https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/config/xray_xtls-rprx-direct.json
|
||||
modify_UUID
|
||||
modify_port
|
||||
}
|
||||
|
||||
function configure_xray_ws() {
|
||||
cd /usr/local/etc/xray && rm -f config.json && wget -O config.json https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/config/xray_tls_ws_mix-rprx-direct.json
|
||||
modify_UUID
|
||||
modify_UUID_ws
|
||||
modify_port
|
||||
modify_fallback_ws
|
||||
modify_ws
|
||||
}
|
||||
|
||||
function xray_install() {
|
||||
print_ok "安装 Xray"
|
||||
curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh | bash -s -- install
|
||||
judge "Xray 安装"
|
||||
|
||||
# 用于生成 Xray 的导入链接
|
||||
echo $domain >$domain_tmp_dir/domain
|
||||
judge "域名记录"
|
||||
}
|
||||
|
||||
function ssl_install() {
|
||||
# 使用 Nginx 配合签发 无需安装相关依赖
|
||||
# if [[ "${ID}" == "centos" || "${ID}" == "ol" ]]; then
|
||||
# ${INS} socat nc
|
||||
# else
|
||||
# ${INS} socat netcat
|
||||
# fi
|
||||
# judge "安装 SSL 证书生成脚本依赖"
|
||||
|
||||
curl -L get.acme.sh | bash
|
||||
judge "安装 SSL 证书生成脚本"
|
||||
}
|
||||
|
||||
function acme() {
|
||||
"$HOME"/.acme.sh/acme.sh --set-default-ca --server letsencrypt
|
||||
|
||||
sed -i "6s/^/#/" "$nginx_conf"
|
||||
sed -i "6a\\\troot $website_dir;" "$nginx_conf"
|
||||
systemctl restart nginx
|
||||
|
||||
if "$HOME"/.acme.sh/acme.sh --issue -d "${domain}" --webroot "$website_dir" -k ec-256 --force; then
|
||||
print_ok "SSL 证书生成成功"
|
||||
sleep 2
|
||||
if "$HOME"/.acme.sh/acme.sh --installcert -d "${domain}" --fullchainpath /ssl/xray.crt --keypath /ssl/xray.key --reloadcmd "systemctl restart xray" --ecc --force; then
|
||||
print_ok "SSL 证书配置成功"
|
||||
sleep 2
|
||||
fi
|
||||
else
|
||||
print_error "SSL 证书生成失败"
|
||||
rm -rf "$HOME/.acme.sh/${domain}_ecc"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sed -i "7d" "$nginx_conf"
|
||||
sed -i "6s/#//" "$nginx_conf"
|
||||
}
|
||||
|
||||
function ssl_judge_and_install() {
|
||||
|
||||
mkdir -p /ssl >/dev/null 2>&1
|
||||
if [[ -f "/ssl/xray.key" || -f "/ssl/xray.crt" ]]; then
|
||||
print_ok "/ssl 目录下证书文件已存在"
|
||||
print_ok "是否删除 /ssl 目录下的证书文件 [Y/N]?"
|
||||
read -r ssl_delete
|
||||
case $ssl_delete in
|
||||
[yY][eE][sS] | [yY])
|
||||
rm -rf /ssl/*
|
||||
print_ok "已删除"
|
||||
;;
|
||||
*) ;;
|
||||
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ -f "/ssl/xray.key" || -f "/ssl/xray.crt" ]]; then
|
||||
echo "证书文件已存在"
|
||||
elif [[ -f "$HOME/.acme.sh/${domain}_ecc/${domain}.key" && -f "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" ]]; then
|
||||
echo "证书文件已存在"
|
||||
"$HOME"/.acme.sh/acme.sh --installcert -d "${domain}" --fullchainpath /ssl/xray.crt --keypath /ssl/xray.key --ecc
|
||||
judge "证书应用"
|
||||
else
|
||||
mkdir /ssl
|
||||
cp -a $cert_dir/self_signed_cert.pem /ssl/xray.crt
|
||||
cp -a $cert_dir/self_signed_key.pem /ssl/xray.key
|
||||
ssl_install
|
||||
acme
|
||||
fi
|
||||
|
||||
# Xray 默认以 nobody 用户运行,证书权限适配
|
||||
chown -R nobody.$cert_group /ssl/*
|
||||
}
|
||||
|
||||
function generate_certificate() {
|
||||
signedcert=$(xray tls cert -domain="$local_ip" -name="$local_ip" -org="$local_ip" -expire=87600h)
|
||||
echo $signedcert | jq '.certificate[]' | sed 's/\"//g' | tee $cert_dir/self_signed_cert.pem
|
||||
echo $signedcert | jq '.key[]' | sed 's/\"//g' >$cert_dir/self_signed_key.pem
|
||||
openssl x509 -in $cert_dir/self_signed_cert.pem -noout || 'print_error "生成自签名证书失败" && exit 1'
|
||||
print_ok "生成自签名证书成功"
|
||||
chown nobody.$cert_group $cert_dir/self_signed_cert.pem
|
||||
chown nobody.$cert_group $cert_dir/self_signed_key.pem
|
||||
}
|
||||
|
||||
function configure_web() {
|
||||
rm -rf /www/xray_web
|
||||
mkdir -p /www/xray_web
|
||||
wget -O web.tar.gz https://raw.githubusercontent.com/wulabing/Xray_onekey/main/basic/web.tar.gz
|
||||
tar xzf web.tar.gz -C /www/xray_web
|
||||
judge "站点伪装"
|
||||
rm -f web.tar.gz
|
||||
}
|
||||
|
||||
function xray_uninstall() {
|
||||
curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh | bash -s -- remove --purge
|
||||
rm -rf $website_dir
|
||||
print_ok "是否卸载nginx [Y/N]?"
|
||||
read -r uninstall_nginx
|
||||
case $uninstall_nginx in
|
||||
[yY][eE][sS] | [yY])
|
||||
if [[ "${ID}" == "centos" || "${ID}" == "ol" ]]; then
|
||||
yum remove nginx -y
|
||||
else
|
||||
apt purge nginx -y
|
||||
fi
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
print_ok "是否卸载acme.sh [Y/N]?"
|
||||
read -r uninstall_acme
|
||||
case $uninstall_acme in
|
||||
[yY][eE][sS] | [yY])
|
||||
/root/.acme.sh/acme.sh --uninstall
|
||||
rm -rf /root/.acme.sh
|
||||
rm -rf /ssl/
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
print_ok "卸载完成"
|
||||
exit 0
|
||||
}
|
||||
|
||||
function restart_all() {
|
||||
systemctl restart nginx
|
||||
judge "Nginx 启动"
|
||||
systemctl restart xray
|
||||
judge "Xray 启动"
|
||||
}
|
||||
|
||||
function vless_xtls-rprx-direct_link() {
|
||||
UUID=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].settings.clients[0].id | tr -d '"')
|
||||
PORT=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].port)
|
||||
FLOW=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].settings.clients[0].flow | tr -d '"')
|
||||
DOMAIN=$(cat ${domain_tmp_dir}/domain)
|
||||
|
||||
print_ok "URL 链接(VLESS + TCP + TLS)"
|
||||
print_ok "vless://$UUID@$DOMAIN:$PORT?security=tls&flow=$FLOW#TLS_wulabing-$DOMAIN"
|
||||
|
||||
print_ok "URL 链接(VLESS + TCP + XTLS)"
|
||||
print_ok "vless://$UUID@$DOMAIN:$PORT?security=xtls&flow=$FLOW#XTLS_wulabing-$DOMAIN"
|
||||
print_ok "-------------------------------------------------"
|
||||
print_ok "URL 二维码(VLESS + TCP + TLS)(请在浏览器中访问)"
|
||||
print_ok "https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless://$UUID@$DOMAIN:$PORT?security=tls%26flow=$FLOW%23TLS_wulabing-$DOMAIN"
|
||||
|
||||
print_ok "URL 二维码(VLESS + TCP + XTLS)(请在浏览器中访问)"
|
||||
print_ok "https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless://$UUID@$DOMAIN:$PORT?security=xtls%26flow=$FLOW%23XTLS_wulabing-$DOMAIN"
|
||||
}
|
||||
|
||||
function vless_xtls-rprx-direct_information() {
|
||||
UUID=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].settings.clients[0].id | tr -d '"')
|
||||
PORT=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].port)
|
||||
FLOW=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].settings.clients[0].flow | tr -d '"')
|
||||
DOMAIN=$(cat ${domain_tmp_dir}/domain)
|
||||
|
||||
echo -e "${Red} Xray 配置信息 ${Font}"
|
||||
echo -e "${Red} 地址(address):${Font} $DOMAIN"
|
||||
echo -e "${Red} 端口(port):${Font} $PORT"
|
||||
echo -e "${Red} 用户 ID(UUID):${Font} $UUID"
|
||||
echo -e "${Red} 流控(flow):${Font} $FLOW"
|
||||
echo -e "${Red} 加密方式(security):${Font} none "
|
||||
echo -e "${Red} 传输协议(network):${Font} tcp "
|
||||
echo -e "${Red} 伪装类型(type):${Font} none "
|
||||
echo -e "${Red} 底层传输安全:${Font} xtls 或 tls"
|
||||
}
|
||||
|
||||
function ws_information() {
|
||||
UUID=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].settings.clients[0].id | tr -d '"')
|
||||
PORT=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].port)
|
||||
FLOW=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].settings.clients[0].flow | tr -d '"')
|
||||
WS_PATH=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].settings.fallbacks[2].path | tr -d '"')
|
||||
DOMAIN=$(cat ${domain_tmp_dir}/domain)
|
||||
|
||||
echo -e "${Red} Xray 配置信息 ${Font}"
|
||||
echo -e "${Red} 地址(address):${Font} $DOMAIN"
|
||||
echo -e "${Red} 端口(port):${Font} $PORT"
|
||||
echo -e "${Red} 用户 ID(UUID):${Font} $UUID"
|
||||
echo -e "${Red} 加密方式(security):${Font} none "
|
||||
echo -e "${Red} 传输协议(network):${Font} ws "
|
||||
echo -e "${Red} 伪装类型(type):${Font} none "
|
||||
echo -e "${Red} 路径(path):${Font} $WS_PATH "
|
||||
echo -e "${Red} 底层传输安全:${Font} tls "
|
||||
}
|
||||
|
||||
function ws_link() {
|
||||
UUID=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].settings.clients[0].id | tr -d '"')
|
||||
PORT=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].port)
|
||||
FLOW=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].settings.clients[0].flow | tr -d '"')
|
||||
WS_PATH=$(cat ${xray_conf_dir}/config.json | jq .inbounds[0].settings.fallbacks[2].path | tr -d '"')
|
||||
WS_PATH_WITHOUT_SLASH=$(echo $WS_PATH | tr -d '/')
|
||||
DOMAIN=$(cat ${domain_tmp_dir}/domain)
|
||||
|
||||
print_ok "URL 链接(VLESS + TCP + TLS)"
|
||||
print_ok "vless://$UUID@$DOMAIN:$PORT?security=tls#TLS_wulabing-$DOMAIN"
|
||||
|
||||
print_ok "URL 链接(VLESS + TCP + XTLS)"
|
||||
print_ok "vless://$UUID@$DOMAIN:$PORT?security=xtls&flow=$FLOW#XTLS_wulabing-$DOMAIN"
|
||||
|
||||
print_ok "URL 链接(VLESS + WebSocket + TLS)"
|
||||
print_ok "vless://$UUID@$DOMAIN:$PORT?type=ws&security=tls&path=%2f${WS_PATH_WITHOUT_SLASH}%2f#WS_TLS_wulabing-$DOMAIN"
|
||||
print_ok "-------------------------------------------------"
|
||||
print_ok "URL 二维码(VLESS + TCP + TLS)(请在浏览器中访问)"
|
||||
print_ok "https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless://$UUID@$DOMAIN:$PORT?security=tls%23TLS_wulabing-$DOMAIN"
|
||||
|
||||
print_ok "URL 二维码(VLESS + TCP + XTLS)(请在浏览器中访问)"
|
||||
print_ok "https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless://$UUID@$DOMAIN:$PORT?security=xtls%26flow=$FLOW%23XTLS_wulabing-$DOMAIN"
|
||||
|
||||
print_ok "URL 二维码(VLESS + WebSocket + TLS)(请在浏览器中访问)"
|
||||
print_ok "https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless://$UUID@$DOMAIN:$PORT?type=ws%26security=tls%26path=%2f${WS_PATH_WITHOUT_SLASH}%2f%23WS_TLS_wulabing-$DOMAIN"
|
||||
}
|
||||
|
||||
function basic_information() {
|
||||
print_ok "VLESS+TCP+XTLS+Nginx 安装成功"
|
||||
vless_xtls-rprx-direct_information
|
||||
vless_xtls-rprx-direct_link
|
||||
}
|
||||
|
||||
function basic_ws_information() {
|
||||
print_ok "VLESS+TCP+TLS+Nginx with WebSocket 混合模式 安装成功"
|
||||
ws_information
|
||||
print_ok "————————————————————————"
|
||||
vless_xtls-rprx-direct_information
|
||||
ws_link
|
||||
}
|
||||
|
||||
function show_access_log() {
|
||||
[ -f ${xray_access_log} ] && tail -f ${xray_access_log} || echo -e "${RedBG}log文件不存在${Font}"
|
||||
}
|
||||
|
||||
function show_error_log() {
|
||||
[ -f ${xray_error_log} ] && tail -f ${xray_error_log} || echo -e "${RedBG}log文件不存在${Font}"
|
||||
}
|
||||
|
||||
function bbr_boost_sh() {
|
||||
[ -f "tcp.sh" ] && rm -rf ./tcp.sh
|
||||
wget -N --no-check-certificate "https://raw.githubusercontent.com/ylx2016/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
|
||||
}
|
||||
|
||||
function mtproxy_sh() {
|
||||
wget -N --no-check-certificate "https://github.com/wulabing/mtp/raw/master/mtproxy.sh" && chmod +x mtproxy.sh && bash mtproxy.sh
|
||||
}
|
||||
|
||||
function install_xray() {
|
||||
is_root
|
||||
system_check
|
||||
dependency_install
|
||||
basic_optimization
|
||||
domain_check
|
||||
port_exist_check 80
|
||||
xray_install
|
||||
configure_xray
|
||||
nginx_install
|
||||
configure_nginx
|
||||
configure_web
|
||||
generate_certificate
|
||||
ssl_judge_and_install
|
||||
restart_all
|
||||
basic_information
|
||||
}
|
||||
function install_xray_ws() {
|
||||
is_root
|
||||
system_check
|
||||
dependency_install
|
||||
basic_optimization
|
||||
domain_check
|
||||
port_exist_check 80
|
||||
xray_install
|
||||
configure_xray_ws
|
||||
nginx_install
|
||||
configure_nginx
|
||||
configure_web
|
||||
generate_certificate
|
||||
ssl_judge_and_install
|
||||
restart_all
|
||||
basic_ws_information
|
||||
}
|
||||
menu() {
|
||||
update_sh
|
||||
shell_mode_check
|
||||
echo -e "\t Xray 安装管理脚本 ${Red}[${shell_version}]${Font}"
|
||||
echo -e "\t---authored by wulabing---"
|
||||
echo -e "\thttps://github.com/wulabing\n"
|
||||
|
||||
echo -e "当前已安装版本:${shell_mode}"
|
||||
echo -e "—————————————— 安装向导 ——————————————"""
|
||||
echo -e "${Green}0.${Font} 升级 脚本"
|
||||
echo -e "${Green}1.${Font} 安装 Xray (VLESS + TCP + XTLS / TLS + Nginx)"
|
||||
echo -e "${Green}2.${Font} 安装 Xray (VLESS + TCP + XTLS / TLS + Nginx 及 VLESS + TCP + TLS + Nginx + WebSocket 回落并存模式)"
|
||||
echo -e "—————————————— 配置变更 ——————————————"
|
||||
echo -e "${Green}11.${Font} 变更 UUID"
|
||||
echo -e "${Green}13.${Font} 变更 连接端口"
|
||||
echo -e "${Green}14.${Font} 变更 WebSocket PATH"
|
||||
echo -e "—————————————— 查看信息 ——————————————"
|
||||
echo -e "${Green}21.${Font} 查看 实时访问日志"
|
||||
echo -e "${Green}22.${Font} 查看 实时错误日志"
|
||||
echo -e "${Green}23.${Font} 查看 Xray 配置链接"
|
||||
# echo -e "${Green}23.${Font} 查看 V2Ray 配置信息"
|
||||
echo -e "—————————————— 其他选项 ——————————————"
|
||||
echo -e "${Green}31.${Font} 安装 4 合 1 BBR、锐速安装脚本"
|
||||
echo -e "${Yellow}32.${Font} 安装 MTproxy(不推荐使用,请相关用户关闭或卸载)"
|
||||
echo -e "${Green}33.${Font} 卸载 Xray"
|
||||
echo -e "${Green}34.${Font} 更新 Xray-core"
|
||||
echo -e "${Green}35.${Font} 安装 Xray-core 测试版(Pre)"
|
||||
echo -e "${Green}36.${Font} 手动更新SSL证书"
|
||||
echo -e "${Green}40.${Font} 退出"
|
||||
read -rp "请输入数字:" menu_num
|
||||
case $menu_num in
|
||||
0)
|
||||
update_sh
|
||||
;;
|
||||
1)
|
||||
install_xray
|
||||
;;
|
||||
2)
|
||||
install_xray_ws
|
||||
;;
|
||||
11)
|
||||
read -rp "请输入UUID:" UUID
|
||||
if [[ ${shell_mode} == "tcp" ]]; then
|
||||
modify_UUID
|
||||
elif [[ ${shell_mode} == "ws" ]]; then
|
||||
modify_UUID
|
||||
modify_UUID_ws
|
||||
fi
|
||||
restart_all
|
||||
;;
|
||||
13)
|
||||
modify_port
|
||||
restart_all
|
||||
;;
|
||||
14)
|
||||
if [[ ${shell_mode} == "ws" ]]; then
|
||||
read -rp "请输入路径(示例:/wulabing/ 要求两侧都包含/):" WS_PATH
|
||||
modify_fallback_ws
|
||||
modify_ws
|
||||
restart_all
|
||||
else
|
||||
print_error "当前模式不是Websocket模式"
|
||||
fi
|
||||
;;
|
||||
21)
|
||||
tail -f $xray_access_log
|
||||
;;
|
||||
22)
|
||||
tail -f $xray_error_log
|
||||
;;
|
||||
23)
|
||||
if [[ -f $xray_conf_dir/config.json ]]; then
|
||||
if [[ ${shell_mode} == "tcp" ]]; then
|
||||
basic_information
|
||||
elif [[ ${shell_mode} == "ws" ]]; then
|
||||
basic_ws_information
|
||||
fi
|
||||
else
|
||||
print_error "xray 配置文件不存在"
|
||||
fi
|
||||
;;
|
||||
31)
|
||||
bbr_boost_sh
|
||||
;;
|
||||
32)
|
||||
mtproxy_sh
|
||||
;;
|
||||
33)
|
||||
source '/etc/os-release'
|
||||
xray_uninstall
|
||||
;;
|
||||
34)
|
||||
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" - install
|
||||
restart_all
|
||||
;;
|
||||
35)
|
||||
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" - install --beta
|
||||
restart_all
|
||||
;;
|
||||
36)
|
||||
"/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh"
|
||||
restart_all
|
||||
;;
|
||||
40)
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
print_error "请输入正确的数字"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
menu "$@"
|
||||
Reference in New Issue
Block a user