mirror of
https://github.com/bin456789/reinstall.git
synced 2026-10-03 22:17:46 +08:00
core: 日志网址使用随机路径
This commit is contained in:
+5
-3
@@ -188,14 +188,16 @@ d-i preseed/early_command string true; \
|
||||
} >>/etc/motd; \
|
||||
mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$((y / 1024))"; }); \
|
||||
if command -v websocketd && [ "$mem" -ge 400 ]; then \
|
||||
mkdir -p /tmp/web; \
|
||||
echo 'Wrong Path' >/tmp/web/index.html; \
|
||||
for _ in {1..10}; do \
|
||||
if wget "$confhome/logviewer.html" -O /tmp/index.html; then \
|
||||
if wget "$confhome/logviewer.html" -O /tmp/web$web_path; then \
|
||||
break; \
|
||||
fi; \
|
||||
sleep 5; \
|
||||
done; \
|
||||
run_as_service_with_screen websocketd --port "$web_port" --loglevel=fatal --staticdir=/tmp \
|
||||
sh -c "tail -fn+0 /var/log/syslog | tr '\r' '\n' | grep -Fiv -e password -e token" ; \
|
||||
run_as_service_with_screen websocketd --port "$web_port" --loglevel=fatal --staticdir=/tmp/web \
|
||||
sh -c "if [ \"\$PATH_INFO\" = \"$web_path\" ]; then tail -fn+0 /var/log/syslog | tr '\r' '\n' | grep -Fiv -e password -e token; fi" ; \
|
||||
fi; \
|
||||
fi; \
|
||||
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
var ws = new ReconnectingWebSocket('ws://' + location.host + '/');
|
||||
var ws = new ReconnectingWebSocket(window.location.href.replace(/^http/, 'ws'));
|
||||
ws.onopen = function () {
|
||||
bufferMessage('WebSocket Connected.');
|
||||
};
|
||||
|
||||
+18
-5
@@ -732,6 +732,10 @@ assert_cpu_supports_x86_64_v3() {
|
||||
fi
|
||||
}
|
||||
|
||||
get_http_log_url() {
|
||||
echo "http://IP$([ "${web_port:-80}" = 80 ] || echo :$web_port)$web_path"
|
||||
}
|
||||
|
||||
# 判断语言字符是否合法,允许全名和缩写
|
||||
is_valid_lang_chars() {
|
||||
[[ "$1" =~ ^[A-Za-z_-]+$ ]]
|
||||
@@ -3505,7 +3509,7 @@ build_extra_cmdline() {
|
||||
# https://salsa.debian.org/installer-team/rootskel/-/blob/master/src/lib/debian-installer-startup.d/S02module-params?ref_type=heads
|
||||
for key in confhome hold force_boot_mode force_cn force_old_windows_setup cloud_image main_disk \
|
||||
elts deb_mirror \
|
||||
username ssh_port rdp_port web_port allow_ping; do
|
||||
username ssh_port rdp_port web_port web_path allow_ping; do
|
||||
value=${!key}
|
||||
if [ -n "$value" ]; then
|
||||
is_need_quote "$value" &&
|
||||
@@ -4115,6 +4119,10 @@ get_ip_conf_cmd() {
|
||||
fi
|
||||
}
|
||||
|
||||
is_need_web_viewer() {
|
||||
! { [ "$distro" = netboot.xyz ] || is_alpine_live; }
|
||||
}
|
||||
|
||||
mod_initrd_alpine() {
|
||||
# hack 1 v3.19 和之前的 virt 内核需添加 ipv6 模块
|
||||
if virt_dir=$(ls -d $initrd_dir/lib/modules/*-virt 2>/dev/null); then
|
||||
@@ -5139,6 +5147,11 @@ if [ "$nextos_distro" = alpine ] || is_distro_like_debian "$nextos_distro"; then
|
||||
mod_initrd
|
||||
fi
|
||||
|
||||
# web 路径
|
||||
if is_need_web_viewer; then
|
||||
web_path="/$(tr -dc "A-Za-z0-9" </dev/urandom | head -c8)"
|
||||
fi
|
||||
|
||||
# 将内核/netboot.xyz.lkrn 放到正确的位置
|
||||
if false && is_need_boot_vmlinuz; then
|
||||
if is_in_windows; then
|
||||
@@ -5350,7 +5363,7 @@ elif [ "$distro" = fnos ]; then
|
||||
echo "Password: $password"
|
||||
fi
|
||||
echo "SSH Port: $ssh_port"
|
||||
echo "WEB Port: $web_port"
|
||||
echo "WEB: $(get_http_log_url)"
|
||||
|
||||
info "After Install"
|
||||
|
||||
@@ -5365,7 +5378,7 @@ elif [ "$distro" = windows ]; then
|
||||
echo "Username: $username"
|
||||
echo "Password: $password"
|
||||
echo "SSH Port: $ssh_port"
|
||||
echo "WEB Port: $web_port"
|
||||
echo "WEB: $(get_http_log_url)"
|
||||
|
||||
info "After Install"
|
||||
if is_administrator_username "$username"; then
|
||||
@@ -5385,7 +5398,7 @@ elif [ "$distro" = dd ]; then
|
||||
echo "Password: $password"
|
||||
fi
|
||||
echo "SSH Port: $ssh_port"
|
||||
echo "WEB Port: $web_port"
|
||||
echo "WEB: $(get_http_log_url)"
|
||||
|
||||
info "After Install"
|
||||
if [ -n "$cloud_data" ]; then
|
||||
@@ -5408,7 +5421,7 @@ else
|
||||
echo "Password: $password"
|
||||
fi
|
||||
echo "SSH Port: $ssh_port"
|
||||
echo "WEB Port: $web_port"
|
||||
echo "WEB: $(get_http_log_url)"
|
||||
|
||||
info "After Install"
|
||||
echo "Username: $username"
|
||||
|
||||
@@ -425,13 +425,18 @@ setup_nginx() {
|
||||
|
||||
setup_websocketd() {
|
||||
apk add websocketd
|
||||
wget $confhome/logviewer.html -O /tmp/index.html
|
||||
apk add coreutils
|
||||
|
||||
mkdir -p /tmp/web
|
||||
echo 'Wrong Path' >/tmp/web/index.html
|
||||
# shellcheck disable=SC2154
|
||||
wget $confhome/logviewer.html -O /tmp/web$web_path
|
||||
|
||||
killall -q websocketd || true
|
||||
# websocketd 遇到 \n 才推送,因此要转换 \r 为 \n
|
||||
websocketd --port "$web_port" --loglevel=fatal --staticdir=/tmp \
|
||||
stdbuf -oL -eL sh -c "tail -fn+0 /reinstall.log | tr '\r' '\n' | grep -Fiv -e password -e token" &
|
||||
websocketd --port "$web_port" --loglevel=fatal --staticdir=/tmp/web \
|
||||
stdbuf -oL -eL \
|
||||
sh -c "if [ \"\$PATH_INFO\" = \"$web_path\" ]; then tail -fn+0 /reinstall.log | tr '\r' '\n' | grep -Fiv -e password -e token; fi" &
|
||||
}
|
||||
|
||||
get_approximate_ram_size() {
|
||||
|
||||
Reference in New Issue
Block a user