This commit is contained in:
yunshu
2025-01-15 15:44:59 +08:00
committed by paniy
parent 35f49dfd39
commit aa857d380e
8 changed files with 1218 additions and 783 deletions
+97
View File
@@ -0,0 +1,97 @@
name: Update Translations
on:
push:
paths:
- 'install.sh'
- 'fail2ban_manager.sh'
- 'file_manager.sh'
- 'translate.py'
branches:
- main
jobs:
update-translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Restore translation cache
id: cache-translations
uses: actions/cache@v3
with:
path: po/cache_*.json
key: ${{ runner.os }}-translations-${{ hashFiles('po/*.po') }}
restore-keys: |
${{ runner.os }}-translations-
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gettext python3 python3-pip
pip3 install googletrans-py
- name: Setup directories
run: |
mkdir -p po
mkdir -p languages/{en,fa,ru,zh_CN}/LC_MESSAGES
- name: Extract strings from all scripts
run: |
touch po/POTFILES.in
for script in install.sh auto_update.sh fail2ban_manager.sh file_manager.sh; do
echo "$script" >> po/POTFILES.in
done
xgettext \
--files-from=po/POTFILES.in \
--from-code=UTF-8 \
--language=Shell \
--keyword=gettext \
--package-name=xray_install \
--package-version=1.0 \
--msgid-bugs-address=https://github.com/hello-yunshu/Xray_bash_onekey/issues \
--copyright-holder="yunshu" \
--output=po/xray_install.pot
- name: Update/Create PO files
run: |
for lang in zh_CN en fa ru; do
if [ ! -f po/$lang.po ]; then
msginit --no-translator --locale=$lang --input=po/xray_install.pot --output=po/$lang.po
else
msgmerge --update --backup=none po/$lang.po po/xray_install.pot
fi
done
- name: Auto translate
run: python3 translate.py
- name: Save translation cache
if: always()
uses: actions/cache/save@v3
with:
path: po/cache_*.json
key: ${{ runner.os }}-translations-${{ hashFiles('po/*.po') }}
- name: Compile MO files
run: |
for lang in zh_CN en fa ru; do
msgfmt -o languages/${lang}/LC_MESSAGES/xray_install.mo po/${lang}.po
done
- name: Create version file
run: |
TIMESTAMP=$(date +%s)
for lang in zh_CN en fa ru; do
echo "$TIMESTAMP" > languages/${lang}/LC_MESSAGES/version
done
- name: Commit changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add po/ languages/
git commit -m "Update translations for all languages [$(date +%Y-%m-%d)]" || echo "No changes to commit"
git push
+2 -2
View File
@@ -1,9 +1,9 @@
# Xray 支持 Reality / VLESS WebSocket/gRPC+TLS 协议 + Nginx 的一键安装脚本
[简体中文](README.md) | [English](languages/en/README.md)
[![GitHub stars](https://img.shields.io/github/stars/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/stargazers) [![GitHub forks](https://img.shields.io/github/forks/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/network) [![GitHub issues](https://img.shields.io/github/issues/hello-yunshu/Xray_bash_onekey)](https://github.com/hello-yunshu/Xray_bash_onekey/issues)
> 感谢 JetBrains 提供的非商业开源软件开发授权
> Thanks for non-commercial open source development authorization by JetBrains
## 使用说明
+51 -22
View File
@@ -2,8 +2,11 @@
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
VERSION="1.0.0"
idleleo_dir="/etc/idleleo"
nginx_dir="/etc/nginx"
local_bin="/usr/local"
nginx_dir="${local_bin}/nginx"
xray_conf_dir="${idleleo_conf_dir}/xray"
xray_conf="${xray_conf_dir}/config.json"
log_dir="${idleleo_dir}/logs"
@@ -15,18 +18,18 @@ info_extraction_all=$(jq -rc . ${xray_qr_config_file})
[[ ! -d "${log_dir}" ]] && mkdir -p ${log_dir}
if [[ -f "${running_file}" ]]; then
echo "上个自动更新程序仍在运行! 检查于: $(date '+%Y-%m-%d %H:%M') 建议手动排错!" >>${log_file}
echo "Previous auto update process is still running! Checked at: $(date '+%Y-%m-%d %H:%M') Manual troubleshooting recommended!" >>${log_file}
exit 1
else
touch ${running_file}
fi
[[ -f "${log_file}" ]] && rm -rf ${log_file}
echo "更新时间: $(date '+%Y-%m-%d %H:%M')" >${log_file}
echo "Update time: $(date '+%Y-%m-%d %H:%M')" >${log_file}
check_online_version() {
echo ${get_versions_all} | jq -rc ".$1"
[[ 0 -ne $? ]] && echo "在线版本检测失败, 请稍后再试!" >>${log_file} && exit 1
[[ 0 -ne $? ]] && echo "Online version check failed, please try again later!" >>${log_file} && exit 1
}
info_extraction() {
@@ -34,42 +37,68 @@ info_extraction() {
}
shell_online_version="$(check_online_version shell_online_version)"
xray_online_version="$(check_online_version xray_tested_version)"
nginx_online_version="$(check_online_version nginx_online_version)"
openssl_online_version="$(check_online_version openssl_online_version)"
jemalloc_online_version="$(check_online_version jemalloc_tested_version)"
xray_online_version="$(check_online_version xray_online_version)"
nginx_online_version="$(check_online_version nginx_build_version)"
if [[ -f ${xray_qr_config_file} ]]; then
if [[ $(info_extraction shell_version) == null ]] || [[ $(info_extraction shell_version) != ${shell_online_version} ]]; then
bash idleleo -u auto_update
[[ 0 -ne $? ]] && echo "脚本 更新失败!" >>${log_file} && exit 1
echo "脚本 更新成功!" >>${log_file}
[[ 0 -ne $? ]] && echo "Script update failed!" >>${log_file} && exit 1
echo "Script updated successfully!" >>${log_file}
add_shell_version=$(jq -r ". += {\"shell_version\": \"${shell_online_version}\"}" ${xray_qr_config_file})
echo "${add_shell_version}" | jq . >${xray_qr_config_file}
else
echo "脚本 最新版!" >>${log_file}
echo "Script is up to date!" >>${log_file}
fi
if [[ $(info_extraction nginx_version) == null ]] || [[ ! -f "${nginx_dir}/sbin/nginx" ]]; then
echo "Nginx 未安装!"
elif [[ ${nginx_online_version} != $(info_extraction nginx_version) ]] || [[ ${openssl_online_version} != $(info_extraction openssl_version) ]] || [[ ${jemalloc_online_version} != $(info_extraction jemalloc_version) ]]; then
if [[ $(info_extraction nginx_build_version) == null ]] || [[ ! -f "${nginx_dir}/sbin/nginx" ]]; then
echo "Nginx not installed!"
elif [[ ${nginx_online_version} != $(info_extraction nginx_build_version) ]]; then
bash idleleo -n auto_update
[[ 0 -ne $? ]] && echo "Nginx 更新失败!" >>${log_file} && exit 1
echo "Nginx 更新成功!" >>${log_file}
[[ 0 -ne $? ]] && echo "Nginx update failed!" >>${log_file} && exit 1
echo "Nginx updated successfully!" >>${log_file}
else
echo "Nginx 最新版!" >>${log_file}
echo "Nginx is up to date!" >>${log_file}
fi
if [[ -f ${xray_qr_config_file} ]] && [[ -f ${xray_conf} ]] && [[ -f /usr/local/bin/xray ]]; then
if [[ $(info_extraction xray_version) == null ]]; then
echo "Xray 版本未知 无法自动更新" >>${log_file}
echo "Xray version unknown, cannot auto update" >>${log_file}
elif [[ ${xray_online_version} != $(info_extraction xray_version) ]]; then
bash idleleo -x auto_update
[[ 0 -ne $? ]] && echo "Xray 更新失败!" >>${log_file} && exit 1
echo "Xray 更新成功!" >>${log_file}
[[ 0 -ne $? ]] && echo "Xray update failed!" >>${log_file} && exit 1
echo "Xray updated successfully!" >>${log_file}
elif [[ ${xray_online_version} == $(info_extraction xray_version) ]]; then
echo "Xray 最新版!" >>${log_file}
echo "Xray is up to date!" >>${log_file}
fi
else
echo "Xray 未安装!" >>${log_file}
echo "Xray not installed!" >>${log_file}
fi
fi
rm -rf ${running_file}
check_update() {
temp_file="/tmp/temp_script.sh"
if ! curl -s -o "$temp_file" "https://github.com/hello-yunshu/Xray_bash_onekey/raw/refs/heads/main/auto_update.sh"; then
echo "Failed to download remote script" >>${log_file}
return 1
}
remote_version=$(grep "^VERSION=" "$temp_file" | cut -d'"' -f2)
if [ -z "$remote_version" ]; then
echo "Unable to get remote version number" >>${log_file}
return 1
}
if [ "$VERSION" != "$remote_version" ]; then
echo "New version found: $remote_version" >>${log_file}
cp "$temp_file" "$0"
chmod +x "$0"
rm -f "$temp_file"
exec "$0" "$@"
fi
rm -f "$temp_file"
return 0
}
check_update
+52 -52
View File
@@ -1,19 +1,19 @@
#!/bin/bash
# 定义当前版本号
mf_SCRIPT_VERSION="1.0.8"
mf_SCRIPT_VERSION="1.0.9"
mf_main_menu() {
check_system
echo -e "\n"
log_echo "${GreenBG} 设置 Fail2ban 用于防止暴力破解, 请选择: ${Font}"
log_echo "1. ${Green}安装 Fail2ban${Font}"
log_echo "2. ${Green}管理 Fail2ban${Font}"
log_echo "3. ${Green}卸载 Fail2ban${Font}"
log_echo "4. ${Green}查看 Fail2ban 状态${Font}"
log_echo "5. ${Green}退出${Font}"
read -rp "请输入: " fail2ban_fq
log_echo "${GreenBG} $(gettext "设置 Fail2ban 用于防止暴力破解, 请选择:") ${Font}"
log_echo "1. ${Green}$(gettext "安装") Fail2ban${Font}"
log_echo "2. ${Green}$(gettext "管理") Fail2ban${Font}"
log_echo "3. ${Green}$(gettext "卸载") Fail2ban${Font}"
log_echo "4. ${Green}$(gettext "查看") Fail2ban $(gettext "状态")${Font}"
log_echo "5. ${Green}$(gettext "退出")${Font}"
read -rp "$(gettext "请输入:")" fail2ban_fq
[[ -z "${fail2ban_fq}" ]] && fail2ban_fq=1
case $fail2ban_fq in
@@ -24,18 +24,18 @@ mf_main_menu() {
5) source "${idleleo}" ;;
*)
echo -e "\n"
log_echo "${Error} ${RedBG} 无效的选择 请重试 ${Font}"
log_echo "${Error} ${RedBG} $(gettext "无效的选择 请重试") ${Font}"
;;
esac
}
mf_install_fail2ban() {
if command -v fail2ban-client &> /dev/null; then
log_echo "${OK} ${Green} Fail2ban 已经安装, 跳过安装步骤 ${Font}"
log_echo "${OK} ${Green} $(gettext "Fail2ban 已经安装, 跳过安装步骤") ${Font}"
else
pkg_install "fail2ban"
mf_configure_fail2ban
judge "Fail2ban 安装"
judge "Fail2ban $(gettext "安装")"
source "${idleleo}"
fi
}
@@ -49,7 +49,7 @@ mf_configure_fail2ban() {
# 检查 Nginx 是否安装
if [[ ${tls_mode} == "TLS" || ${reality_add_nginx} == "on" ]]; then
if [[ ! -f "${nginx_dir}/sbin/nginx" ]]; then
log_echo "${Warning} ${YellowBG} Nginx 未安装, 请先安装 Nginx ${Font}"
log_echo "${Warning} ${YellowBG} $(gettext "Nginx 未安装, 请先安装 Nginx") ${Font}"
return
fi
fi
@@ -73,7 +73,7 @@ mf_configure_fail2ban() {
fi
systemctl daemon-reload
systemctl restart fail2ban
judge "Fail2ban 配置"
judge "Fail2ban $(gettext "配置")"
}
mf_create_nginx_no_host_filter() {
@@ -89,18 +89,18 @@ EOF
mf_manage_fail2ban() {
if ! command -v fail2ban-client &> /dev/null; then
log_echo "${Error} ${RedBG} Fail2ban 未安装, 请先安装 Fail2ban ${Font}"
log_echo "${Error} ${RedBG} $(gettext "Fail2ban 未安装, 请先安装 Fail2ban") ${Font}"
return
fi
echo -e "\n"
log_echo "${Green} 请选择 Fail2ban 操作: ${Font}"
echo "1. 启动 Fail2ban"
echo "2. 重启 Fail2ban"
echo "3. 停止 Fail2ban"
echo "4. 添加自定义规则"
echo "5. 返回"
read_optimize "请输入: " mf_action 1
log_echo "${Green} $(gettext "请选择 Fail2ban 操作:") ${Font}"
echo "1. $(gettext "启动") Fail2ban"
echo "2. $(gettext "重启") Fail2ban"
echo "3. $(gettext "停止") Fail2ban"
echo "4. $(gettext "添加自定义规则")"
echo "5. $(gettext "返回")"
read_optimize "$(gettext "请输入:")" mf_action 1
case $mf_action in
1)
mf_start_enable_fail2ban
@@ -119,7 +119,7 @@ mf_manage_fail2ban() {
5) mf_main_menu ;;
*)
echo -e "\n"
log_echo "${Error} ${RedBG} 无效的选择 请重试 ${Font}"
log_echo "${Error} ${RedBG} $(gettext "无效的选择 请重试") ${Font}"
mf_manage_fail2ban
;;
esac
@@ -132,31 +132,31 @@ mf_add_custom_rule() {
local max_retry
local ban_time
read_optimize "请输入新的 Jail 名称: " "jail_name" NULL
read_optimize "请输入 Filter 名称: " "filter_name" NULL
read_optimize "请输入日志路径: " "log_path" NULL
read_optimize "请输入最大重试次数 (默认 5): " "max_retry" 5 1 99 "最大重试次数必须在 1 到 99 之间"
read_optimize "请输入封禁时间 (秒, 默认 604800 秒): " "ban_time" 604800 1 8640000 "封禁时间必须在 1 到 8640000 秒之间"
read_optimize "$(gettext "请输入新的 Jail 名称:")" "jail_name" NULL
read_optimize "$(gettext "请输入 Filter 名称:")" "filter_name" NULL
read_optimize "$(gettext "请输入日志路径:")" "log_path" NULL
read_optimize "$(gettext "请输入最大重试次数 (默认 5):")" "max_retry" 5 1 99 "$(gettext "最大重试次数必须在 1 到 99 之间")"
read_optimize "$(gettext "请输入封禁时间 (秒, 默认 604800 秒):")" "ban_time" 604800 1 8640000 "$(gettext "封禁时间必须在 1 到 8640000 秒之间")"
if grep -q "\[$jail_name\]" /etc/fail2ban/jail.local; then
log_echo "${Warning} ${YellowBG} Jail '$jail_name' 已存在 ${Font}"
log_echo "${Warning} ${YellowBG} $(gettext "Jail") '$jail_name' $(gettext "已存在") ${Font}"
return
fi
echo -e "[$jail_name]\nenabled = true\nfilter = $filter_name\nlogpath = $log_path\nmaxretry = $max_retry\nbantime = $ban_time\n" >> /etc/fail2ban/jail.local
log_echo "${OK} ${GreenBG} 自定义规则添加成功 ${Font}"
log_echo "${OK} ${GreenBG} $(gettext "自定义规则添加成功") ${Font}"
systemctl daemon-reload
systemctl restart fail2ban
judge "Fail2ban 重启以应用新规则"
judge "Fail2ban $(gettext "重启以应用新规则")"
}
mf_start_enable_fail2ban() {
systemctl daemon-reload
systemctl start fail2ban
systemctl enable fail2ban
judge "Fail2ban 启动"
timeout "清空屏幕!"
judge "Fail2ban $(gettext "启动")"
timeout "$(gettext "清空屏幕!")"
clear
}
@@ -168,8 +168,8 @@ mf_uninstall_fail2ban() {
if [[ -f "/etc/fail2ban/filter.d/nginx-no-host.conf" ]]; then
rm -rf /etc/fail2ban/filter.d/nginx-no-host.conf
fi
judge "Fail2ban 卸载"
timeout "清空屏幕!"
judge "Fail2ban $(gettext "卸载")"
timeout "$(gettext "清空屏幕!")"
clear
source "${idleleo}"
}
@@ -177,39 +177,39 @@ mf_uninstall_fail2ban() {
mf_stop_disable_fail2ban() {
systemctl stop fail2ban
systemctl disable fail2ban
log_echo "${OK} ${GreenBG} Fail2ban 停止成功 ${Font}"
timeout "清空屏幕!"
log_echo "${OK} ${GreenBG} $(gettext "Fail2ban 停止成功") ${Font}"
timeout "$(gettext "清空屏幕!")"
clear
}
mf_restart_fail2ban() {
systemctl daemon-reload
systemctl restart fail2ban
judge "Fail2ban 重启"
timeout "清空屏幕!"
judge "Fail2ban $(gettext "重启")"
timeout "$(gettext "清空屏幕!")"
clear
}
mf_display_fail2ban_status() {
if ! command -v fail2ban-client &> /dev/null; then
log_echo "${Error} ${RedBG} Fail2ban 未安装, 请先安装 Fail2ban ${Font}"
log_echo "${Error} ${RedBG} $(gettext "Fail2ban 未安装, 请先安装 Fail2ban") ${Font}"
return
fi
log_echo "${GreenBG} Fail2ban 总体状态: ${Font}"
log_echo "${GreenBG} $(gettext "Fail2ban 总体状态:") ${Font}"
fail2ban-client status
echo -e "\n"
log_echo "${Green} 默认启用的 Jail 状态: ${Font}"
log_echo "${Green} $(gettext "默认启用的 Jail 状态:") ${Font}"
echo "----------------------------------------"
log_echo "${Green} SSH 封锁情况: ${Font}"
log_echo "${Green} $(gettext "SSH 封锁情况:") ${Font}"
fail2ban-client status sshd
if [[ ${tls_mode} == "TLS" || ${reality_add_nginx} == "on" ]]; then
log_echo "${Green} Fail2ban Nginx 封锁情况: ${Font}"
log_echo "${Green} $(gettext "Fail2ban Nginx 封锁情况:") ${Font}"
fail2ban-client status nginx-badbots
fail2ban-client status nginx-botsearch
if [[ ${reality_add_nginx} == "on" ]]; then
log_echo "${Green} Fail2ban Nginx No Host 封锁情况: ${Font}"
log_echo "${Green} $(gettext "Fail2ban Nginx No Host 封锁情况:") ${Font}"
fail2ban-client status nginx-no-host
fi
fi
@@ -223,31 +223,31 @@ mf_check_for_updates() {
# 直接使用 curl 下载远程版本信息
latest_version=$(curl -s "$mf_remote_url" | grep 'mf_SCRIPT_VERSION=' | head -n 1 | sed 's/mf_SCRIPT_VERSION="//; s/"//')
if [ -n "$latest_version" ] && [ "$latest_version" != "$mf_SCRIPT_VERSION" ]; then
log_echo "${Warning} ${YellowBG} 新版本可用: $latest_version 当前版本: $mf_SCRIPT_VERSION ${Font}"
log_echo "${Warning} ${YellowBG} 请访问 https://github.com/hello-yunshu/Xray_bash_onekey 查看更新说明 ${Font}"
log_echo "${Warning} ${YellowBG} $(gettext "新版本可用:") $latest_version $(gettext "当前版本:") $mf_SCRIPT_VERSION ${Font}"
log_echo "${Warning} ${YellowBG} $(gettext "请访问 https://github.com/hello-yunshu/Xray_bash_onekey 查看更新说明") ${Font}"
log_echo "${GreenBG} 是否要下载并安装新版本 [Y/${Red}N${Font}${GreenBG}]? ${Font}"
log_echo "${GreenBG} $(gettext "是否要下载并安装新版本") [Y/${Red}N${Font}${GreenBG}]? ${Font}"
read -r update_choice
case $update_choice in
[yY][eE][sS] | [yY])
log_echo "${Info} ${Green} 正在下载新版本... ${Font}"
log_echo "${Info} ${Green} $(gettext "正在下载新版本...") ${Font}"
curl -sL "$mf_remote_url" -o "${idleleo_dir}/fail2ban_manager.sh"
if [ $? -eq 0 ]; then
chmod +x "${idleleo_dir}/fail2ban_manager.sh"
log_echo "${OK} ${Green} 下载完成,正在重新运行脚本... ${Font}"
log_echo "${OK} ${Green} $(gettext "下载完成,正在重新运行脚本...") ${Font}"
bash "${idleleo}" --set-fail2ban
else
echo -e "\n"
log_echo "${Error} ${RedBG} 下载失败,请手动下载并安装新版本 ${Font}"
log_echo "${Error} ${RedBG} $(gettext "下载失败,请手动下载并安装新版本") ${Font}"
fi
;;
*)
log_echo "${OK} ${Green} 跳过更新 ${Font}"
log_echo "${OK} ${Green} $(gettext "跳过更新") ${Font}"
;;
esac
else
log_echo "${OK} ${Green} 当前已经是最新版本: $mf_SCRIPT_VERSION ${Font}"
log_echo "${OK} ${Green} $(gettext "当前已经是最新版本:") $mf_SCRIPT_VERSION ${Font}"
fi
}
+45 -45
View File
@@ -1,11 +1,11 @@
#!/bin/bash
# 定义当前版本号
fm_SCRIPT_VERSION="1.0.8"
fm_SCRIPT_VERSION="1.0.9"
# 检查是否提供了扩展名参数
if [ -z "$1" ]; then
echo "用法: $0 <文件扩展名> [<目录路径>]"
echo "$(gettext "用法:")" $0 $(gettext "<文件扩展名> [<目录路径>]")
exit 1
fi
@@ -15,7 +15,7 @@ fm_WORKDIR="${2:-$(pwd)}"
# 检查目录是否存在
if [ ! -d "$fm_WORKDIR" ]; then
echo -e "\n"
log_echo "${Error} ${RedBG} 目录 $fm_WORKDIR 不存在 请检查路径 ${Font}"
log_echo "${Error} ${RedBG} $(gettext "目录") $fm_WORKDIR $(gettext "不存在 请检查路径") ${Font}"
exit 1
fi
@@ -28,7 +28,7 @@ cd "$fm_WORKDIR"
# 函数: 列出当前目录下所有指定扩展名的文件
fm_list_files() {
local max_length
log_echo "${GreenBG} 列出所有 .$fm_EXTENSION 文件 ${Font}"
log_echo "${GreenBG} $(gettext "列出所有") .$fm_EXTENSION $(gettext "文件") ${Font}"
# 设置 dotglob 选项,使通配符 * 包括以点开头的文件
shopt -s dotglob
@@ -37,7 +37,7 @@ fm_list_files() {
files=(*.$fm_EXTENSION)
if [ ${#files[@]} -eq 0 ]; then
log_echo "${Warning} ${YellowBG} 没有找到 .$fm_EXTENSION 文件 ${Font}"
log_echo "${Warning} ${YellowBG} $(gettext "没有找到") .$fm_EXTENSION $(gettext "文件") ${Font}"
return 1
else
# 计算最大文件名长度
@@ -61,13 +61,13 @@ fm_list_files() {
printf "%-${total_width}s\n" "$(printf '%*s' "$total_width" | tr ' ' '-')"
# 居中文本
local header_text="文件名"
local header_text="$(gettext "文件名")"
local header_length=${#header_text}
local padding=$(( (total_width - header_length - 4) / 2 ))
local left_padding=$(( padding - 4 )) # 加上序号列的宽度
local right_padding=$(( padding - 4 ))
printf "| %-4s | %-${left_padding}s%-${header_length}s%-${right_padding}s |\n" "序号" "" "$header_text" ""
printf "| %-4s | %-${left_padding}s%-${header_length}s%-${right_padding}s |\n" "$(gettext "序号")" "" "$header_text" ""
printf "%-${total_width}s\n" "$(printf '%*s' "$total_width" | tr ' ' '-')"
@@ -90,16 +90,16 @@ fm_create_servername_file() {
local url
fm_list_files
echo -e "\n"
log_echo "${Green} 请输入网址 (例如 hey.run)"
log_echo "${Green} 不要包含 http:// 或 https:// 开头 ${Font}"
read_optimize "请输入: " url
log_echo "${Green} $(gettext "请输入网址 (例如 hey.run)")"
log_echo "${Green} $(gettext "不要包含 http:// 或 https:// 开头") ${Font}"
read_optimize "$(gettext "请输入:")" url
if [[ $url =~ ^(http|https):// ]]; then
echo -e "\n"
log_echo "${Error} ${RedBG} 网址不能包含 http:// 或 https:// 开头 ${Font}"
log_echo "${Error} ${RedBG} $(gettext "网址不能包含 http:// 或 https:// 开头") ${Font}"
return
fi
echo "${url} reality;" > "${url}.serverNames"
log_echo "${OK} ${GreenBG} 文件 ${url}.serverNames 已创建 ${Font}"
log_echo "${OK} ${GreenBG} $(gettext "文件") ${url}.serverNames $(gettext "已创建") ${Font}"
fm_restart_nginx_and_check_status
fm_list_files
}
@@ -108,17 +108,17 @@ fm_create_servername_file() {
fm_create_ws_or_grpc_server_file() {
local host port weight content firewall_set_fq
fm_list_files
read_optimize "请输入主机 (host): " host
read_optimize "请输入端口 (port): " port "" 1 65535
read_optimize "请输入权重 (0~100 默认值 50): " weight "50" 0 100
read_optimize "$(gettext "请输入主机 (host):")" host
read_optimize "$(gettext "请输入端口 (port):")" port "" 1 65535
read_optimize "$(gettext "请输入权重 (0~100 默认值 50):")" weight "50" 0 100
content="server ${host}:${port} weight=${weight} max_fails=2 fail_timeout=10;"
echo "$content" > "${host}.${fm_EXTENSION}"
log_echo "${OK} ${GreenBG} 文件 ${host}.${fm_EXTENSION} 已创建 ${Font}"
log_echo "${OK} ${GreenBG} $(gettext "文件") ${host}.${fm_EXTENSION} $(gettext "已创建") ${Font}"
# 询问是否需要修改防火墙
echo -e "\n"
log_echo "${GreenBG} 是否需要设置防火墙 [Y/${Red}N${Font}${GreenBG}]? ${Font}"
log_echo "${GreenBG} $(gettext "是否需要设置防火墙") [Y/${Red}N${Font}${GreenBG}]? ${Font}"
read -r firewall_set_fq
case $firewall_set_fq in
[yY][eE][sS] | [yY])
@@ -132,19 +132,19 @@ fm_create_ws_or_grpc_server_file() {
iptables -I INPUT -p udp --dport ${port} -j ACCEPT
iptables -I OUTPUT -p tcp --sport ${port} -j ACCEPT
iptables -I OUTPUT -p udp --sport ${port} -j ACCEPT
log_echo "${OK} ${GreenBG} 防火墙 追加 完成 ${Font}"
log_echo "${OK} ${GreenBG} $(gettext "防火墙 追加 完成") ${Font}"
if [[ "${ID}" == "centos" && ${VERSION_ID} -ge 7 ]]; then
service iptables save
service iptables restart
log_echo "${OK} ${GreenBG} 防火墙 重启 完成 ${Font}"
log_echo "${OK} ${GreenBG} $(gettext "防火墙 重启 完成") ${Font}"
else
netfilter-persistent save
systemctl restart iptables
log_echo "${OK} ${GreenBG} 防火墙 重启 完成 ${Font}"
log_echo "${OK} ${GreenBG} $(gettext "防火墙 重启 完成") ${Font}"
fi
;;
*)
log_echo "${OK} ${GreenBG} 跳过防火墙设置 ${Font}"
log_echo "${OK} ${GreenBG} $(gettext "跳过防火墙设置") ${Font}"
;;
esac
fm_restart_nginx_and_check_status
@@ -156,17 +156,17 @@ fm_edit_file() {
fm_list_files
local num_files=${#files[@]}
local choice
read_optimize "请输入要编辑的文件编号 (1-$num_files): " choice "" 1 "$num_files"
read_optimize "$(gettext "请输入要编辑的文件编号") (1-$num_files): " choice "" 1 "$num_files"
local filename="${files[$((choice - 1))]}"
# 检查 vim 是否安装
if ! command -v vim &> /dev/null; then
log_echo "${Warning} ${YellowBG} vim 未安装 正在尝试安装 ${Font}"
log_echo "${Warning} ${YellowBG} $(gettext "vim 未安装 正在尝试安装") ${Font}"
pkg_install vim
fi
vim "$filename"
log_echo "${OK} ${GreenBG} 文件 $filename 已编辑 ${Font}"
log_echo "${OK} ${GreenBG} $(gettext "文件") $filename $(gettext "已编辑") ${Font}"
fm_restart_nginx_and_check_status
}
@@ -178,12 +178,12 @@ fm_delete_file() {
local num_files=${#files[@]}
local choice
read_optimize "请输入要删除的文件编号 (1-$num_files): " choice "" 1 "$num_files"
read_optimize "$(gettext "请输入要删除的文件编号") (1-$num_files): " choice "" 1 "$num_files"
local filename="${files[$((choice - 1))]}"
rm "$filename"
log_echo "${OK} ${GreenBG} 文件 $filename 已删除 ${Font}"
log_echo "${OK} ${GreenBG} $(gettext "文件") $filename $(gettext "已删除") ${Font}"
fm_restart_nginx_and_check_status
fm_list_files
}
@@ -199,7 +199,7 @@ fm_create_file() {
;;
*)
echo -e "\n"
log_echo "${Error} ${RedBG} 不支持的文件扩展名 $fm_EXTENSION ${Font}"
log_echo "${Error} ${RedBG} $(gettext "不支持的文件扩展名") $fm_EXTENSION ${Font}"
;;
esac
}
@@ -209,14 +209,14 @@ fm_main_menu() {
fm_list_files
while true; do
echo
log_echo "${GreenBG} 主菜单 ${Font}"
log_echo "1 ${Green}列出所有 $fm_EXTENSION 文件${Font}"
log_echo "2 ${Green}创建一个新的 $fm_EXTENSION 文件${Font}"
log_echo "3 ${Green}编辑一个已存在的 $fm_EXTENSION 文件${Font}"
log_echo "4 ${Green}删除一个已存在的 $fm_EXTENSION 文件${Font}"
log_echo "5 ${Green}退出${Font}"
log_echo "${GreenBG} $(gettext "主菜单") ${Font}"
log_echo "1 ${Green}$(gettext "列出所有") $fm_EXTENSION $(gettext "文件")${Font}"
log_echo "2 ${Green}$(gettext "创建一个新的") $fm_EXTENSION $(gettext "文件")${Font}"
log_echo "3 ${Green}$(gettext "编辑一个已存在的") $fm_EXTENSION $(gettext "文件")${Font}"
log_echo "4 ${Green}$(gettext "删除一个已存在的") $fm_EXTENSION $(gettext "文件")${Font}"
log_echo "5 ${Green}$(gettext "退出")${Font}"
local choice
read_optimize "请选择一个选项: " choice "" 1 5
read_optimize "$(gettext "请选择一个选项:")" choice "" 1 5
case $choice in
1) fm_list_files ;;
@@ -226,7 +226,7 @@ fm_main_menu() {
5) source "$idleleo" ;;
*)
echo -e "\n"
log_echo "${Error} ${RedBG} 无效选项 请重试 ${Font}"
log_echo "${Error} ${RedBG} $(gettext "无效选项 请重试") ${Font}"
;;
esac
done
@@ -239,31 +239,31 @@ fm_check_for_updates() {
# 直接使用 curl 下载远程版本信息
latest_version=$(curl -s "$fm_remote_url" | grep 'fm_SCRIPT_VERSION=' | head -n 1 | sed 's/fm_SCRIPT_VERSION="//; s/"//')
if [ -n "$latest_version" ] && [ "$latest_version" != "$fm_SCRIPT_VERSION" ]; then
log_echo "${Warning} ${YellowBG} 新版本可用: $latest_version 当前版本: $fm_SCRIPT_VERSION ${Font}"
log_echo "${Warning} ${YellowBG} 请访问 https://github.com/hello-yunshu/Xray_bash_onekey 查看更新说明 ${Font}"
log_echo "${Warning} ${YellowBG} $(gettext "新版本可用:") $latest_version $(gettext "当前版本:") $fm_SCRIPT_VERSION ${Font}"
log_echo "${Warning} ${YellowBG} $(gettext "请访问 https://github.com/hello-yunshu/Xray_bash_onekey 查看更新说明") ${Font}"
log_echo "${GreenBG} 是否要下载并安装新版本 [Y/${Red}N${Font}${GreenBG}]? ${Font}"
log_echo "${GreenBG} $(gettext "是否要下载并安装新版本") [Y/${Red}N${Font}${GreenBG}]? ${Font}"
read -r update_choice
case $update_choice in
[yY][eE][sS] | [yY])
log_echo "${Info} ${Green} 正在下载新版本... ${Font}"
log_echo "${Info} ${Green} $(gettext "正在下载新版本...") ${Font}"
curl -sL "$fm_remote_url" -o "${idleleo_dir}/file_manager.sh"
if [ $? -eq 0 ]; then
chmod +x "${idleleo_dir}/file_manager.sh"
log_echo "${OK} ${Green} 下载完成,正在重新运行脚本... ${Font}"
log_echo "${OK} ${Green} $(gettext "下载完成,正在重新运行脚本...") ${Font}"
bash "${idleleo}" --add-servernames
else
echo -e "\n"
log_echo "${Error} ${RedBG} 下载失败,请手动下载并安装新版本 ${Font}"
log_echo "${Error} ${RedBG} $(gettext "下载失败,请手动下载并安装新版本") ${Font}"
fi
;;
*)
log_echo "${OK} ${Green} 跳过更新 ${Font}"
log_echo "${OK} ${Green} $(gettext "跳过更新") ${Font}"
;;
esac
else
log_echo "${OK} ${Green} 当前已经是最新版本: $fm_SCRIPT_VERSION ${Font}"
log_echo "${OK} ${Green} $(gettext "当前已经是最新版本:") $fm_SCRIPT_VERSION ${Font}"
fi
}
@@ -272,10 +272,10 @@ fm_restart_nginx_and_check_status() {
systemctl restart nginx
if systemctl is-active --quiet nginx; then
echo -e "\n"
log_echo "${OK} ${GreenBG} Nginx 重启成功 ${Font}"
log_echo "${OK} ${GreenBG} $(gettext "Nginx 重启成功") ${Font}"
else
echo -e "\n"
log_echo "${Error} ${RedBG} Nginx 重启失败 请检查配置文件是否有误 ${Font}"
log_echo "${Error} ${RedBG} $(gettext "Nginx 重启失败 请检查配置文件是否有误") ${Font}"
fm_edit_file
fi
fi
+793 -662
View File
File diff suppressed because it is too large Load Diff
+104
View File
@@ -0,0 +1,104 @@
# One-click Installation Script for Xray with Reality / VLESS WebSocket/gRPC+TLS Protocol + Nginx
[简体中文](README.md) | [English](languages/en/README.md)
[![GitHub stars](https://img.shields.io/github/stars/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/stargazers) [![GitHub forks](https://img.shields.io/github/forks/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/network) [![GitHub issues](https://img.shields.io/github/issues/hello-yunshu/Xray_bash_onekey)](https://github.com/hello-yunshu/Xray_bash_onekey/issues)
> Thanks for non-commercial open source development authorization by JetBrains
## Instructions
* You can directly enter the command: `idleleo` to manage the script.
* It is recommended to use Nginx frontend for Reality, which can be installed in the script.
* It is recommended to enable fail2ban, which can be installed in the script.
* Using the sharing link [proposal](https://github.com/XTLS/Xray-core/issues/91) (beta) from [@DuckSoft](https://github.com/DuckSoft), supporting Qv2ray, V2rayN, V2rayNG.
* Using the proposal from [XTLS](https://github.com/XTLS/Xray-core/issues/158) project, following the [UUIDv5](https://tools.ietf.org/html/rfc4122#section-4.3) standard, custom strings can be mapped to VLESS UUID.
* Reality installation instructions: [Setting up Xray Reality Protocol Server](https://hey.run/archives/da-jian-xray-reality-xie-yi-fu-wu-qi).
* Risks of Reality protocol: [Risks of Xray Reality Protocol](https://hey.run/archives/reality-xie-yi-de-feng-xian).
* Accelerating server using Reality protocol: [Accelerating Server Using Reality Protocol "Vulnerability"](https://hey.run/archives/li-yong-reality-xie-yi-lou-dong-jia-su-fu-wu-qi).
* Added load balancing configuration, tutorial: [XRay Advanced Usage Setting up Backend Server Load Balancing](https://hey.run/archives/xrayjin-jie-wan-fa---da-jian-hou-duan-fu-wu-qi-fu-zai-jun-heng).
* Added gRPC protocol support, details can be found at: [Xray Advanced Usage Using gRPC Protocol](https://hey.run/archives/xrayjin-jie-wan-fa---shi-yong-grpcxie-yi).
## Telegram Group
* Telegram chat group: <https://t.me/idleleo_chat>
## Preparation
* Prepare a server running outside mainland China with a public IP.
* For Reality protocol installation, find a domain name that meets Xray requirements.
* For TLS version installation, prepare a domain name and add the A record.
* Read [Xray official documentation](https://xtls.github.io) to understand Reality TLS WebSocket gRPC and Xray related information, understand Reality target domain requirements.
* **Install curl**, Centos users run: `yum install -y curl`; Debian/Ubuntu users run: `apt install -y curl`.
## Installation Method
Copy and run:
``` bash
bash <(curl -Ss https://www.idleleo.com/install.sh)
```
## Notes
* If you don't understand the specific meaning of each setting in the script, except for required items, please use the default values provided by the script (press Enter all the way).
* Cloudflare users please enable CDN function after installation is complete.
* Using this script requires Linux basics and experience, understanding of computer network knowledge, and basic computer operations.
* Currently supports Debian 9+ / Ubuntu 18.04+ / Centos7+. Some Centos templates may have difficult compilation issues, it is recommended to switch to other system templates when encountering compilation problems.
* The author provides limited support, as they are too inexperienced.
* The sharing link is an experimental version, future changes are possible, please confirm client support yourself.
* Custom string mapping to UUIDv5 requires client support.
## Acknowledgments
* This script is derived from <https://github.com/wulabing/V2Ray_ws-tls_bash_onekey> Thanks to wulabing
* TCP acceleration script project in this script references <https://github.com/ylx2016/Linux-NetSpeed> Thanks to ylx2016
## Certificate
If you already have the certificate files for your domain name, you can name the crt and key files as xray.crt and xray.key and place them in the /etc/idleleo/cert directory (create the directory if it doesn't exist), please note the certificate file permissions and validity period, custom certificates need to be renewed manually after expiration.
The script supports automatic generation of Let's Encrypted certificates, valid for 3 months, theoretically supporting automatic renewal.
## View Client Configuration
`cat /etc/idleleo/xray_info.txt`
## Xray Introduction
* Xray is an excellent open-source network proxy tool that can help you enjoy the internet smoothly, currently supporting Windows, Mac, Android, IOS, Linux and other operating systems.
* This script is a one-click complete configuration script. After all processes run normally, you can directly set up the client according to the output results.
* Please note: We still strongly recommend that you fully understand the entire program's workflow and principles.
## Recommend Setting Up Single Proxy on Single Server
* This script installs the latest version of Xray core by default.
* It is recommended to use the default port 443 as the connection port.
* The disguise content can be replaced as needed.
## Other Notes
* Recommended to use this script in a clean environment. If you are a beginner, please do not use Centos system.
* Please do not apply this program to production environment before confirming this script is actually usable.
* This program depends on Nginx to implement related functions. Users who have installed Nginx using [LNMP](https://lnmp.org) or other similar Nginx scripts should pay special attention, using this script may cause unpredictable errors.
* Centos system users please allow program-related ports (default: 80, 443) in the firewall in advance.
## Start Method
Start Xray: `systemctl start xray`
Stop Xray: `systemctl stop xray`
Start Nginx: `systemctl start nginx`
Stop Nginx: `systemctl stop nginx`
## Related Directories
Xray server configuration: `/etc/idleleo/conf/xray/config.json`
Nginx directory: `/usr/local/nginx`
Certificate files: `/etc/idleleo/cert/xray.key` and `/etc/idleleo/cert/xray.crt` please note certificate permission settings
Configuration information files etc: `/etc/idleleo`
+74
View File
@@ -0,0 +1,74 @@
import re
import time
import json
import os
from googletrans import Translator, LANGUAGES
def load_translation_cache(cache_file):
if os.path.exists(cache_file):
with open(cache_file, 'r', encoding='utf-8') as f:
return json.load(f)
return {}
def save_translation_cache(cache_file, translations):
with open(cache_file, 'w', encoding='utf-8') as f:
json.dump(translations, f, ensure_ascii=False, indent=2)
def translate_po_file(input_file, output_file, target_lang):
cache_file = f'po/cache_{target_lang}.json'
translations = load_translation_cache(cache_file)
# 使用最新的 Translator,并设置更可靠的服务 URL
translator = Translator(service_urls=['translate.google.com'])
with open(input_file, 'r', encoding='utf-8') as f:
content = f.read()
pattern = r'msgid "(.*?)"\nmsgstr ""'
matches = re.finditer(pattern, content)
updated = False
for match in matches:
chinese_text = match.group(1)
if chinese_text and any('\u4e00' <= char <= '\u9fff' for char in chinese_text):
if chinese_text in translations:
translated_text = translations[chinese_text]
print(f"Using cached translation [{target_lang}]: {chinese_text} -> {translated_text}")
else:
try:
# 增加重试机制
max_retries = 3
for attempt in range(max_retries):
try:
time.sleep(2) # 增加延迟以避免请求过快
translation = translator.translate(chinese_text, src='zh-cn', dest=target_lang)
translated_text = translation.text
translations[chinese_text] = translated_text
updated = True
print(f"New translation [{target_lang}]: {chinese_text} -> {translated_text}")
break
except Exception as e:
if attempt == max_retries - 1:
raise e
print(f"Retry {attempt + 1}/{max_retries} for: {chinese_text}")
time.sleep(5) # 重试前等待更长时间
except Exception as e:
print(f"Translation failed for: {chinese_text}")
print(f"Error: {e}")
continue
content = content.replace(
f'msgid "{chinese_text}"\nmsgstr ""',
f'msgid "{chinese_text}"\nmsgstr "{translated_text}"'
)
if updated:
save_translation_cache(cache_file, translations)
with open(output_file, 'w', encoding='utf-8') as f:
f.write(content)
if __name__ == '__main__':
for lang, code in [('en', 'en'), ('fa', 'fa'), ('ru', 'ru')]:
print(f"\nTranslating to {lang}...")
translate_po_file(f'po/{lang}.po', f'po/{lang}.po', code)