mirror of
https://github.com/kenzok8/small-package
synced 2025-01-08 11:17:34 +08:00
update 2023-06-18 16:20:52
This commit is contained in:
parent
468c555d3c
commit
4bead6a29d
@ -14,6 +14,7 @@ o.rmempty = false
|
||||
o = s:option(Value, "port", translate("Port"))
|
||||
o.datatype = "and(port,min(1))"
|
||||
o.rmempty = false
|
||||
o.default = "5244"
|
||||
|
||||
o = s:option(Flag, "log", translate("Enable Logs"))
|
||||
o.default = 1
|
||||
@ -33,6 +34,9 @@ o:depends("ssl", "1")
|
||||
o = s:option(Flag, "allow_wan", translate("Allow Access From Internet"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "site_url", translate("Site URL"), translate("When the web is reverse proxied to a subdirectory, this option must be filled out to ensure proper functioning of the web. Do not include '/' at the end of the URL"))
|
||||
o.datatype = "string"
|
||||
|
||||
o = s:option(Value, "max_connections", translate("Max Connections"), translate("0 is unlimited, It is recommend to set a low number of concurrency (10-20) for poor performance device"))
|
||||
o.datatype = "and(uinteger,min(0))"
|
||||
o.default = "0"
|
||||
|
@ -84,3 +84,9 @@ msgstr "最大并发连接数"
|
||||
|
||||
msgid "0 is unlimited, It is recommend to set a low number of concurrency (10-20) for poor performance device"
|
||||
msgstr "默认0不限制,低性能设备建议设置较低的并发数(10-20)"
|
||||
|
||||
msgid "Site URL"
|
||||
msgstr "站点 URL"
|
||||
|
||||
msgid "When the web is reverse proxied to a subdirectory, this option must be filled out to ensure proper functioning of the web. Do not include '/' at the end of the URL"
|
||||
msgstr "Web 被反向代理到二级目录时,必须填写该选项以确保 Web 正常工作。URL 结尾请勿携带 '/'"
|
||||
|
@ -5,3 +5,4 @@ config alist
|
||||
option 'ssl' '0'
|
||||
option 'token_expires_in' '48'
|
||||
option 'max_connections' '0'
|
||||
option 'site_url' ''
|
||||
|
@ -9,6 +9,7 @@ get_config() {
|
||||
config_get_bool enabled $1 enabled 1
|
||||
config_get port $1 port 5244
|
||||
config_get log $1 log 1
|
||||
config_get site_url $1 site_url ""
|
||||
config_get temp_dir $1 temp_dir "/tmp/alist"
|
||||
config_get ssl $1 ssl 0
|
||||
config_get ssl_cert $1 ssl_cert ""
|
||||
@ -61,7 +62,7 @@ start_service() {
|
||||
set_firewall
|
||||
cat /dev/null > $temp_dir/alist.log
|
||||
cat > $CONFIG_DIR/config.json <<EOF
|
||||
{"force":false,"address":"$listen_addr","port":$port,"cdn":"","jwt_secret":"","token_expires_in":$token_expires_in,"database":{"type":"sqlite3","host":"","port":0,"user":"","password":"","name":"","db_file":"/etc/alist/data.db","table_prefix":"x_","ssl_mode":""},"scheme":{"https":$SSL,"cert_file":"$ssl_cert","key_file":"$ssl_key"},"temp_dir":"$temp_dir","log":{"enable":$LOG,"name":"$temp_dir/alist.log","max_size":10,"max_backups":5,"max_age":28,"compress":false},"max_connections":$max_connections}
|
||||
{"force":false,"address":"$listen_addr","port":$port,"https_port":$port,"site_url":"$site_url","cdn":"","jwt_secret":"","token_expires_in":$token_expires_in,"database":{"type":"sqlite3","host":"","port":0,"user":"","password":"","name":"","db_file":"/etc/alist/data.db","table_prefix":"x_","ssl_mode":""},"scheme":{"disable_http":$SSL,"https":$SSL,"cert_file":"$ssl_cert","key_file":"$ssl_key"},"temp_dir":"$temp_dir","log":{"enable":$LOG,"name":"$temp_dir/alist.log","max_size":10,"max_backups":5,"max_age":28,"compress":false},"max_connections":$max_connections}
|
||||
EOF
|
||||
procd_open_instance alist
|
||||
procd_set_param command $PROG
|
||||
|
@ -799,7 +799,7 @@ msgstr "宿主机 SSH 端口"
|
||||
|
||||
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:73
|
||||
msgid "The default SSH port is 22. If you have a custom port, please fill in the custom SSH port.<br/>Please make sure you have set up key-based login, otherwise it may cause script errors.<br/>Install the sensors command on PVE by searching on the internet.<br/>Example for key-based login (modify the address and port number accordingly):<br/>opkg update # Update package list<br/>opkg install openssh-client openssh-keygen # Install openssh client<br/>echo -e \"\\n\" | ssh-keygen -t rsa # Generate key file (no passphrase)<br/>pve_host=`uci get wechatpush.config.server_host` || pve_host=\"10.0.0.3\" # Read the PVE host address from the configuration file, If not saved, please fill in by yourself.<br/>pve_port=`uci get wechatpush.config.server_port` || pve_host=\"22\" # Read the PVE host SSH port number from the configuration file, If not saved, please fill in by yourself.<br/>ssh root@${pve_host} -p ${pve_port} \"tee -a ~/.ssh/id_rso.pub\" < ~/.ssh/id_rso.pub # Transfer public key to PVE<br/>ssh root@${pve_host} -p ${pve_port} \"cat ~/.ssh/id_rso.pub >> ~/.ssh/authorized_keys\" # Write public key to PVE<br/>ssh -i /root/.ssh/id_rsa root@${pve_host} -p ${pve_port} sensors # To avoid script errors during the initial connection, please use a private key to connect to PVE and test the temperature command for its proper functioning.<br/>For users who frequently flash firmware, please add /root/.ssh/ to the backup list to avoid duplicate operations."
|
||||
msgstr "SSH 端口默认为 22,如有自定义,请填写自定义 SSH 端口<br/>请确认已经设置好密钥登陆,否则会引起脚本无法运行等错误!<br/>PVE 安装 sensors 命令自行百度<br/>密钥登陆例(自行修改地址与端口号):<br/>opkg update #更新列表<br/>opkg install openssh-client openssh-keygen #安装openssh客户端<br/>echo -e \"\\n\" | ssh-keygen -t rsa # 生成密钥文件(空密码)<br/>pve_host=`uci get serverchan.serverchan.server_host` || pve_host=\"10.0.0.3\" # 读取配置文件中的 pve 主机地址,如果未保存设置,请自行填写 <br/>pve_port=`uci get serverchan.serverchan.server_port` || pve_host=\"22\" # 读取配置文件中的 pve 主机 ssh 端口号,如果未保存设置,请自行填写 <br/>ssh root@${pve_host} -p ${pve_port} \"tee -a ~/.ssh/id_rso.pub\" < ~/.ssh/id_rso.pub # 传送公钥到 PVE<br/>ssh root@${pve_host} -p ${pve_port} \"cat ~/.ssh/id_rso.pub >> ~/.ssh/authorized_keys\" # 写入公钥到 PVE<br/>ssh -i /root/.ssh/id_rsa root@${pve_host} -p ${pve_port} sensors # 因首次连接时需要确认,为避免脚本错误,请使用私钥连接 PVE 并测试温度命令是否正常运行。<br/>刷机党自行将 /root/.ssh/ 加入备份列表,避免重复操作"
|
||||
msgstr "SSH 端口默认为 22,如有自定义,请填写自定义 SSH 端口<br/>请确认已经设置好密钥登陆,否则会引起脚本无法运行等错误!<br/>PVE 安装 sensors 命令自行百度<br/>密钥登陆例(自行修改地址与端口号):<br/>opkg update #更新列表<br/>opkg install openssh-client openssh-keygen #安装openssh客户端<br/>echo -e \"\\n\" | ssh-keygen -t rsa # 生成密钥文件(空密码)<br/>pve_host=`uci get wechatpush.config.server_host` || pve_host=\"10.0.0.3\" # 读取配置文件中的 pve 主机地址,如果未保存设置,请自行填写 <br/>pve_port=`uci get wechatpush.config.server_port` || pve_host=\"22\" # 读取配置文件中的 pve 主机 ssh 端口号,如果未保存设置,请自行填写 <br/>ssh root@${pve_host} -p ${pve_port} \"tee -a ~/.ssh/id_rso.pub\" < ~/.ssh/id_rso.pub # 传送公钥到 PVE<br/>ssh root@${pve_host} -p ${pve_port} \"cat ~/.ssh/id_rso.pub >> ~/.ssh/authorized_keys\" # 写入公钥到 PVE<br/>ssh -i /root/.ssh/id_rsa root@${pve_host} -p ${pve_port} sensors # 因首次连接时需要确认,为避免脚本错误,请使用私钥连接 PVE 并测试温度命令是否正常运行。<br/>刷机党自行将 /root/.ssh/ 加入备份列表,避免重复操作"
|
||||
|
||||
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:76
|
||||
msgid "Test temperature command"
|
||||
|
@ -57,7 +57,7 @@ function read_config(){
|
||||
done
|
||||
( opkg list-installed|grep -w -q ^firewall4 ) && nftables_version="true"
|
||||
dir="/tmp/wechatpush/" && mkdir -p ${dir} && mkdir -p ${dir}/client
|
||||
tempjsonpath="/tmp/wechatpush/temp.json"
|
||||
tempjsonpath="${dir}temp.json"
|
||||
ip_blacklist_path="/usr/share/wechatpush/api/ip_blacklist"
|
||||
oui_base="${dir}oui_base.txt"
|
||||
debuglevel=`echo "$debuglevel"` && [ -z "$debuglevel" ] && logfile="/dev/null" || logfile="${dir}wechatpush.log"
|
||||
@ -80,7 +80,7 @@ function read_config(){
|
||||
[ -z "$login_ip_white_timeout" ] && login_ip_white_timeout="600"
|
||||
[ "$iw_version" ] && wlan_interface=`iw dev 2>/dev/null|grep Interface|awk '{print $2}'` >/dev/null 2>&1
|
||||
[ -z "$server_port" ] && server_port="22"
|
||||
output_dir="/tmp/wechatpush/json_output"
|
||||
output_dir="${dir}json_output"
|
||||
mkdir -p "$output_dir"
|
||||
if ( echo "$lite_enable"|grep -q "content" ); then
|
||||
str_title_start="" && str_title_end="" && str_splitline="" && str_linefeed="" && str_tab=""
|
||||
@ -372,7 +372,7 @@ function soc_temp(){
|
||||
# AMD
|
||||
local sensor_field2='["zenpower-pci-00c3"]["Tctl"]["temp1_input"]'
|
||||
local sensor_field3='["k10temp-pci-00c3"]["Tctl"]["temp1_input"]'
|
||||
eval "${1}sensors -j 2>/dev/null" | jq -r "
|
||||
eval "${1} sensors -j 2>/dev/null" | jq -r "
|
||||
if .${sensor_field1} != null then
|
||||
.${sensor_field1}
|
||||
elif .${sensor_field2} != null then
|
||||
@ -385,7 +385,7 @@ function soc_temp(){
|
||||
"
|
||||
}
|
||||
|
||||
[ ! -z "$server_host" ] && ssh_command="ssh -o StrictHostKeyChecking=yes -o BatchMode=yes -i /root/.ssh/id_rsa root@${server_host} -p ${server_port} "
|
||||
[ ! -z "$server_host" ] && ssh_command="ssh -o StrictHostKeyChecking=yes -o BatchMode=yes -i /root/.ssh/id_rsa root@${server_host} -p ${server_port}"
|
||||
temperature=$(getsensors "$ssh_command" 2>/dev/null)
|
||||
# 通用(只能取最高温度,不一定是 CPU,特殊设备自行修改)
|
||||
# 将 grep °C 改为温度所在行的特别字符串,如 grep Core 0 等,就可以指定设备了
|
||||
@ -633,8 +633,8 @@ function cron(){
|
||||
|
||||
# 重置流量
|
||||
if [ ! -z "$reset_regularly" ] && [ "$reset_regularly" -eq "1" ]; then
|
||||
crontab -l 2>/dev/null > conf && echo -e "0 0 * * * rm /tmp/wechatpush/usage.db >/dev/null 2>&1" >> conf && crontab conf && rm -f conf >/dev/null 2>&1
|
||||
crontab -l 2>/dev/null > conf && echo -e "0 0 * * * rm /tmp/wechatpush/usage6.db >/dev/null 2>&1" >> conf && crontab conf && rm -f conf >/dev/null 2>&1
|
||||
crontab -l 2>/dev/null > conf && echo -e "0 0 * * * rm ${dir}usage.db >/dev/null 2>&1" >> conf && crontab conf && rm -f conf >/dev/null 2>&1
|
||||
crontab -l 2>/dev/null > conf && echo -e "0 0 * * * rm ${dir}usage6.db >/dev/null 2>&1" >> conf && crontab conf && rm -f conf >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# 定时发送
|
||||
@ -1087,6 +1087,69 @@ function cputop(){
|
||||
[ ! -z "$1" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!警报!!】 CPU 占用前三: ${logtop}" >> ${logfile}
|
||||
}
|
||||
|
||||
# 检测硬盘状态
|
||||
function get_disk() {
|
||||
mkdir -p "${dir}disk_info"
|
||||
local_disk_names=()
|
||||
pve_disk_names=()
|
||||
|
||||
# 查询硬盘名
|
||||
local_disk_names=($(df -h | grep "/dev/sd" | awk '{print $1}' | sed 's/.*\///' | sort -u))
|
||||
if [ ! -z "$server_host" ]; then
|
||||
ssh_command="ssh -o StrictHostKeyChecking=yes -o BatchMode=yes -i /root/.ssh/id_rsa root@${server_host} -p ${server_port}"
|
||||
pve_disk_names=($(eval ${ssh_command} lsblk | awk '$NF=="disk" {print $1}' | sort -u))
|
||||
fi
|
||||
all_disk_names=("${local_disk_names[@]}" "${pve_disk_names[@]}")
|
||||
|
||||
for tmp_name in "${all_disk_names[@]}"; do
|
||||
if [[ ${pve_disk_names[@]} =~ ${tmp_name} ]]; then
|
||||
ssh_command="ssh -o StrictHostKeyChecking=yes -o BatchMode=yes -i /root/.ssh/id_rsa root@${server_host} -p ${server_port}"
|
||||
disk_type="(pve)"
|
||||
fi
|
||||
|
||||
# 手上的硬盘不能休眠,不确定命令是否会唤醒硬盘,每天只运行一次
|
||||
last_disk_time=$(date -r "${dir}disk_info/${tmp_name}" +%s 2>/dev/null) || last_disk_time=0
|
||||
|
||||
if [ $(( $(date +%s) - $last_disk_time )) -gt 86400 ]; then
|
||||
${ssh_command} smartctl -i -n standby "/dev/${tmp_name}" | grep "STANDBY" && {
|
||||
echo "STANDBY" > "${dir}disk_info/${tmp_name}"
|
||||
} || \
|
||||
${ssh_command} smartctl -i -n standby "/dev/${tmp_name}" | grep "No such device\|Unknown USB bridge" | grep "STANDBY" && {
|
||||
continue
|
||||
} || \
|
||||
${ssh_command} smartctl -a -j /dev/${tmp_name} > ${dir}disk_info/${tmp_name}
|
||||
fi
|
||||
|
||||
# 硬盘状态
|
||||
if [ -f "${dir}disk_info/${tmp_name}" ] && ( ! cat "${dir}disk_info/${tmp_name}" | grep -q -v "STANDBY" ); then
|
||||
printf "\n${str_title_start} 硬盘名称:${tmp_name}${disk_type}${str_title_end}\n${str_tab}硬盘休眠中" >> "$output_dir/get_disk"
|
||||
elif [ -f "${dir}disk_info/${tmp_name}" ]; then
|
||||
printf "\n${str_title_start} 硬盘名称:${tmp_name}${disk_type}${str_title_end}" >> "$output_dir/get_disk"
|
||||
# 硬盘错误
|
||||
disk_err=$(jq -r .ata_smart_error_log.summary.count ${dir}disk_info/${tmp_name})
|
||||
[[ -n $disk_err && $disk_err != null && $disk_err != 0 ]] && printf "\n${str_tab}硬盘错误:${disk_err}" >> "$output_dir/get_disk"
|
||||
# 自检错误
|
||||
disk_test_err=$(jq -r .ata_smart_self_test_log.standard.error_count_total ${dir}disk_info/${tmp_name})
|
||||
[[ -n $disk_test_err && $disk_test_err != null && $disk_test_err != 0 ]] && printf "\n${str_tab}自检错误:${disk_test_err}" >> "$output_dir/get_disk"
|
||||
# 0E 错误
|
||||
disk_0e_err=$(jq -r .nvme_smart_health_information_log.media_errors ${dir}disk_info/${tmp_name})
|
||||
[[ -n $disk_0e_err && $disk_0e_err != null && $disk_0e_err != 0 ]] && printf "\n${str_tab}0E 错误:${disk_0e_err}" >> "$output_dir/get_disk"
|
||||
# 硬盘温度
|
||||
disk_temp=$(jq -r .temperature.current ${dir}disk_info/${tmp_name})
|
||||
[[ -n $disk_temp && $disk_temp != null && $disk_temp != 0 ]] && printf "\n${str_tab}硬盘温度:${disk_temp}℃" >> "$output_dir/get_disk"
|
||||
# 通电时间
|
||||
disk_time=$(jq -r .power_on_time.hours ${dir}disk_info/${tmp_name})
|
||||
[[ -n $disk_time && $disk_time != null ]] && printf "\n${str_tab}通电时间:${disk_time}h" >> "$output_dir/get_disk"
|
||||
# 使用空间
|
||||
disk_use=$(df -h | grep -w "^/dev/${tmp_name}" | awk '{print $5}' | sort -u)
|
||||
[ -n "$disk_use" ] && [ -n "${disk_use// }" ] && printf "\n${str_tab}使用空间:${disk_use}%%" >> "$output_dir/get_disk"
|
||||
# 使用寿命
|
||||
disk_health=$(jq -r .nvme_smart_health_information_log.percentage_used ${dir}disk_info/${tmp_name})
|
||||
[[ -n $disk_health && $disk_health != null ]] && printf "\n${str_tab}使用寿命:${disk_health}%%" >> "$output_dir/get_disk"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 查询 IP 归属地
|
||||
function get_ip_attribution(){
|
||||
ip="$1"
|
||||
@ -1375,7 +1438,7 @@ function send(){
|
||||
echo "`date "+%Y-%m-%d %H:%M:%S"` 【定时数据】创建定时任务" >> ${logfile}
|
||||
disturb;local send_disturb=$?
|
||||
get_config "send_title" "send_notification"
|
||||
|
||||
|
||||
cpuload=`getcpu`
|
||||
service_status=$(ubus call service list '{"name": "wechatpush"}' | grep -o '"running": true')
|
||||
[ -z "$1" ] && ( echo "$send_notification"|grep -q "client_list" ) && > ${dir}send_enable.lock && [ -z "$service_status" ] && first &
|
||||
@ -1387,7 +1450,7 @@ function send(){
|
||||
systeminfo_enable="1"
|
||||
fi
|
||||
[ -z "$1" ] && ( echo "$send_notification"|grep -q "router_temp" ) && soc_temp > "$output_dir/cputemp" &
|
||||
|
||||
|
||||
if [ -z "$1" ] && ( echo "$send_notification"|grep -q "wan_info" ); then
|
||||
getip wanipv4 > "$output_dir/send_wanIP" &
|
||||
getip hostipv4|jq -r '.IP' > "$output_dir/send_hostIP" &
|
||||
@ -1400,9 +1463,12 @@ function send(){
|
||||
getinterfaceuptime > "$output_dir/interfaceuptime" &
|
||||
fi
|
||||
|
||||
#[ -z "$1" ] && ( echo "$send_notification"|grep -q "disk_info" ) && get_disk &
|
||||
[ -z "$1" ] && get_disk &
|
||||
|
||||
[ -z "$send_title" ] && send_title="路由状态:"
|
||||
[ ! -z "$1" ] && send_title="发送测试:" && send_content="${str_splitline}${str_title_start}内容1${str_title_end}${str_linefeed}${str_tab}设备1${str_linefeed}${str_tab}设备2${str_splitline}${str_title_start}内容2${str_title_end}${str_linefeed}${str_tab}设备3${str_linefeed}${str_tab}设备4"
|
||||
|
||||
|
||||
wait_and_cat
|
||||
if [ -n "$systeminfo_enable" ]; then
|
||||
[[ $Qwai -eq 200 || $Qwai -eq 301 || $Qwai -eq 302 ]] && Qwai_status="已连通!" || Qwai_status="已断开!"
|
||||
@ -1419,6 +1485,11 @@ function send(){
|
||||
[ -z "$cputemp" ] && send_content="${send_content}${str_splitline}${str_title_start} 设备温度${str_title_end}${str_linefeed}${str_tab}无法获取设备温度"
|
||||
fi
|
||||
|
||||
#if [ -z "$1" ] && ( echo "$send_notification"|grep -q "disk_info" ); then
|
||||
if [ -z "$1" ]; then
|
||||
send_content="${send_content}${get_disk}"
|
||||
fi
|
||||
|
||||
if [ -n "$waninfo_enable" ]; then
|
||||
send_content="${send_content}${str_splitline}${str_title_start} WAN 口信息${str_title_end}${str_linefeed}${str_tab}接口 IPv4:${send_wanIP}"
|
||||
send_content="${send_content}${str_linefeed}${str_tab}外网 IPv4:${send_hostIP}"
|
||||
@ -1596,6 +1667,9 @@ while [ "$enable" -eq "1" ]; do
|
||||
# CPU 检测
|
||||
[ ! -f "${dir}send_enable.lock" ] && cpu_load
|
||||
|
||||
# 硬盘检测
|
||||
[ ! -f "${dir}send_enable.lock" ] && get_disk
|
||||
|
||||
# 异常流量检测
|
||||
[ ! -f "${dir}send_enable.lock" ] && get_client_usage
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user