feat(脚本): 完善日志功能

pull/534/merge
mack-a 2021-04-08 17:53:19 +08:00
parent fc25c80dad
commit ac62857933
1 changed files with 51 additions and 60 deletions

View File

@ -74,10 +74,7 @@ initVar() {
# 选择的个性化安装方式 # 选择的个性化安装方式
selectCustomInstallType= selectCustomInstallType=
# v2ray-core配置文件的路径 # v2ray-core、xray-core配置文件的路径
configPath=
# xray-core配置文件的路径
configPath= configPath=
# 配置文件的path # 配置文件的path
@ -1432,7 +1429,7 @@ initV2RayConfig() {
cat <<EOF >/etc/v2ray-agent/v2ray/conf/00_log.json cat <<EOF >/etc/v2ray-agent/v2ray/conf/00_log.json
{ {
"log": { "log": {
"error": "/etc/v2ray-agent/v2ray/v2ray_error.log", "error": "/etc/v2ray-agent/v2ray/error.log",
"loglevel": "warning" "loglevel": "warning"
} }
} }
@ -1731,7 +1728,7 @@ initXrayConfig() {
cat <<EOF >/etc/v2ray-agent/xray/conf/00_log.json cat <<EOF >/etc/v2ray-agent/xray/conf/00_log.json
{ {
"log": { "log": {
"error": "/etc/v2ray-agent/xray/xray_error.log", "error": "/etc/v2ray-agent/xray/error.log",
"loglevel": "warning" "loglevel": "warning"
} }
} }
@ -2274,7 +2271,7 @@ updateNginxBlog() {
changeCorePort() { changeCorePort() {
read -r -p "请输入要更换的端口号:" newPort read -r -p "请输入要更换的端口号:" newPort
if [[ -n "${newPort}" ]]; then if [[ -n "${newPort}" ]]; then
vlessTcpResult=$(jq -r ".inbounds[0].port=${newPort}" ${configPath}/02_VLESS_TCP_inbounds.json) vlessTcpResult=$(jq -r ".inbounds[0].port=${newPort}" ${configPath}02_VLESS_TCP_inbounds.json)
echo "${vlessTcpResult}" | jq . >${configPath}02_VLESS_TCP_inbounds.json echo "${vlessTcpResult}" | jq . >${configPath}02_VLESS_TCP_inbounds.json
reloadCore reloadCore
fi fi
@ -2637,64 +2634,58 @@ bbrInstall() {
# 查看、检查日志 # 查看、检查日志
checkLog() { checkLog() {
if [[ -z ${configPath} ]]; then
echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容"
fi
echoContent skyBlue "\n功能 $1/${totalProgress} : 查看日志" echoContent skyBlue "\n功能 $1/${totalProgress} : 查看日志"
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
local coreType= echoContent yellow "# 建议仅调试打开access日志\n"
if [[ "${coreInstallType}" == "1" ]]; then echoContent yellow "1.打开access日志"
coreType=xray/xray echoContent yellow "2.关闭access日志"
echoContent yellow "3.监听access日志"
elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then echoContent yellow "4.监听error日志"
coreType=v2ray/v2ray echoContent yellow "5.清空日志"
else
echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容"
menu
exit 0
fi
echoContent skyBlue "-------------------------V2Ray/Xray--------------------------------"
echoContent yellow "1.查看error日志"
echoContent yellow "2.监听error日志"
echoContent yellow "3.清空日志"
echoContent skyBlue "-----------------------Trojan-Go------------------------------"
echoContent yellow "4.查看Trojan-Go日志"
echoContent yellow "5.监听Trojan-GO日志"
echoContent yellow "6.清空Trojan-GO日志"
echoContent skyBlue "-------------------------Nginx--------------------------------"
echoContent yellow "7.查看Nginx日志"
echoContent yellow "8.清空Nginx日志"
echoContent red "==============================================================" echoContent red "=============================================================="
read -r -p "请选择:" selectLogType read -r -p "请选择:" selectAccessLogType
case ${selectLogType} in local configPathLog=${configPath//conf\//}
case ${selectAccessLogType} in
1) 1)
cat /etc/v2ray-agent/xray/xray_error.log cat <<EOF >${configPath}00_log.json
{
"log": {
"access":"${configPathLog}access.log",
"error": "${configPathLog}error.log",
"loglevel": "warning"
}
}
EOF
reloadCore
;; ;;
2) 2)
tail -f /etc/v2ray-agent/xray/xray_error.log cat <<EOF >${configPath}00_log.json
{
"log": {
"error": "${configPathLog}error.log",
"loglevel": "warning"
}
}
EOF
reloadCore
;; ;;
3) 3)
echo '' >/etc/v2ray-agent/xray/xray_error.log tail -f ${configPathLog}access.log
echoContent green " ---> 清空完毕"
;; ;;
4) 4)
cat /etc/v2ray-agent/trojan/trojan.log tail -f ${configPathLog}error.log
;; ;;
5) 5)
tail -f /etc/v2ray-agent/trojan/trojan.log echo >${configPathLog}access.log
;; echo >${configPathLog}error.log
6)
echo '' >/etc/v2ray-agent/trojan/trojan.log
echoContent green " ---> 清空完毕"
;;
7)
cat /var/log/nginx/access.log
;;
8)
echo '' >/var/log/nginx/access.log
;; ;;
esac esac
sleep 1
menu
} }
# 脚本快捷方式 # 脚本快捷方式
@ -2857,7 +2848,7 @@ dokodemoDoorUnblockNetflix() {
setDokodemoDoorUnblockNetflixOutbounds() { setDokodemoDoorUnblockNetflixOutbounds() {
read -r -p "请输入解锁Netflix vps的IP:" setIP read -r -p "请输入解锁Netflix vps的IP:" setIP
if [[ -n "${setIP}" ]]; then if [[ -n "${setIP}" ]]; then
cat <<EOF >${configPath}/10_ipv4_outbounds.json cat <<EOF >${configPath}10_ipv4_outbounds.json
{ {
"outbounds": [ "outbounds": [
{ {
@ -2886,7 +2877,7 @@ setDokodemoDoorUnblockNetflixOutbounds() {
] ]
} }
EOF EOF
cat <<EOF >${configPath}/09_routing.json cat <<EOF >${configPath}09_routing.json
{ {
"routing": { "routing": {
"domainStrategy": "AsIs", "domainStrategy": "AsIs",
@ -2925,7 +2916,7 @@ EOF
setDokodemoDoorUnblockNetflixInbounds() { setDokodemoDoorUnblockNetflixInbounds() {
read -r -p "请输入允许访问该解锁Netflix vps的IP:" setIP read -r -p "请输入允许访问该解锁Netflix vps的IP:" setIP
if [[ -n "${setIP}" ]]; then if [[ -n "${setIP}" ]]; then
cat <<EOF >${configPath}/01_netflix_inbounds.json cat <<EOF >${configPath}01_netflix_inbounds.json
{ {
"inbounds": [ "inbounds": [
{ {
@ -2968,7 +2959,7 @@ setDokodemoDoorUnblockNetflixInbounds() {
} }
EOF EOF
cat <<EOF >${configPath}/09_routing.json cat <<EOF >${configPath}09_routing.json
{ {
"routing": { "routing": {
"rules": [ "rules": [
@ -2996,7 +2987,7 @@ EOF
# 移除任意门解锁Netflix # 移除任意门解锁Netflix
removeDokodemoDoorUnblockNetflix() { removeDokodemoDoorUnblockNetflix() {
cat <<EOF >${configPath}/10_ipv4_outbounds.json cat <<EOF >${configPath}10_ipv4_outbounds.json
{ {
"outbounds": [ "outbounds": [
{ {
@ -3010,7 +3001,7 @@ removeDokodemoDoorUnblockNetflix() {
} }
EOF EOF
rm -rf ${configPath}/09_routing.json rm -rf ${configPath}09_routing.json
reloadCore reloadCore
echoContent green " ---> 卸载成功" echoContent green " ---> 卸载成功"
@ -3078,7 +3069,7 @@ dnsUnlockNetflix() {
setUnlockDNS() { setUnlockDNS() {
read -r -p "请输入解锁Netflix的DNS:" setDNS read -r -p "请输入解锁Netflix的DNS:" setDNS
if [[ -n ${setDNS} ]]; then if [[ -n ${setDNS} ]]; then
cat <<EOF >${configPath}/11_dns.json cat <<EOF >${configPath}11_dns.json
{ {
"dns": { "dns": {
"servers": [ "servers": [
@ -3121,7 +3112,7 @@ EOF
# 移除Netflix解锁 # 移除Netflix解锁
removeUnlockDNS() { removeUnlockDNS() {
cat <<EOF >${configPath}/11_dns.json cat <<EOF >${configPath}11_dns.json
{ {
"dns": { "dns": {
"servers": [ "servers": [
@ -3556,7 +3547,7 @@ menu() {
cd "$HOME" || exit cd "$HOME" || exit
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent green "作者mack-a" echoContent green "作者mack-a"
echoContent green "当前版本v2.4.10" echoContent green "当前版本v2.4.11"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent" echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:七合一共存脚本" echoContent green "描述:七合一共存脚本"
showInstallStatus showInstallStatus