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; \
|
} >>/etc/motd; \
|
||||||
mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$((y / 1024))"; }); \
|
mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$((y / 1024))"; }); \
|
||||||
if command -v websocketd && [ "$mem" -ge 400 ]; then \
|
if command -v websocketd && [ "$mem" -ge 400 ]; then \
|
||||||
|
mkdir -p /tmp/web; \
|
||||||
|
echo 'Wrong Path' >/tmp/web/index.html; \
|
||||||
for _ in {1..10}; do \
|
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; \
|
break; \
|
||||||
fi; \
|
fi; \
|
||||||
sleep 5; \
|
sleep 5; \
|
||||||
done; \
|
done; \
|
||||||
run_as_service_with_screen websocketd --port "$web_port" --loglevel=fatal --staticdir=/tmp \
|
run_as_service_with_screen websocketd --port "$web_port" --loglevel=fatal --staticdir=/tmp/web \
|
||||||
sh -c "tail -fn+0 /var/log/syslog | tr '\r' '\n' | grep -Fiv -e password -e token" ; \
|
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; \
|
||||||
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 () {
|
ws.onopen = function () {
|
||||||
bufferMessage('WebSocket Connected.');
|
bufferMessage('WebSocket Connected.');
|
||||||
};
|
};
|
||||||
|
|||||||
+18
-5
@@ -732,6 +732,10 @@ assert_cpu_supports_x86_64_v3() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_http_log_url() {
|
||||||
|
echo "http://IP$([ "${web_port:-80}" = 80 ] || echo :$web_port)$web_path"
|
||||||
|
}
|
||||||
|
|
||||||
# 判断语言字符是否合法,允许全名和缩写
|
# 判断语言字符是否合法,允许全名和缩写
|
||||||
is_valid_lang_chars() {
|
is_valid_lang_chars() {
|
||||||
[[ "$1" =~ ^[A-Za-z_-]+$ ]]
|
[[ "$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
|
# 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 \
|
for key in confhome hold force_boot_mode force_cn force_old_windows_setup cloud_image main_disk \
|
||||||
elts deb_mirror \
|
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}
|
value=${!key}
|
||||||
if [ -n "$value" ]; then
|
if [ -n "$value" ]; then
|
||||||
is_need_quote "$value" &&
|
is_need_quote "$value" &&
|
||||||
@@ -4115,6 +4119,10 @@ get_ip_conf_cmd() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_need_web_viewer() {
|
||||||
|
! { [ "$distro" = netboot.xyz ] || is_alpine_live; }
|
||||||
|
}
|
||||||
|
|
||||||
mod_initrd_alpine() {
|
mod_initrd_alpine() {
|
||||||
# hack 1 v3.19 和之前的 virt 内核需添加 ipv6 模块
|
# hack 1 v3.19 和之前的 virt 内核需添加 ipv6 模块
|
||||||
if virt_dir=$(ls -d $initrd_dir/lib/modules/*-virt 2>/dev/null); then
|
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
|
mod_initrd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# web 路径
|
||||||
|
if is_need_web_viewer; then
|
||||||
|
web_path="/$(tr -dc "A-Za-z0-9" </dev/urandom | head -c8)"
|
||||||
|
fi
|
||||||
|
|
||||||
# 将内核/netboot.xyz.lkrn 放到正确的位置
|
# 将内核/netboot.xyz.lkrn 放到正确的位置
|
||||||
if false && is_need_boot_vmlinuz; then
|
if false && is_need_boot_vmlinuz; then
|
||||||
if is_in_windows; then
|
if is_in_windows; then
|
||||||
@@ -5350,7 +5363,7 @@ elif [ "$distro" = fnos ]; then
|
|||||||
echo "Password: $password"
|
echo "Password: $password"
|
||||||
fi
|
fi
|
||||||
echo "SSH Port: $ssh_port"
|
echo "SSH Port: $ssh_port"
|
||||||
echo "WEB Port: $web_port"
|
echo "WEB: $(get_http_log_url)"
|
||||||
|
|
||||||
info "After Install"
|
info "After Install"
|
||||||
|
|
||||||
@@ -5365,7 +5378,7 @@ elif [ "$distro" = windows ]; then
|
|||||||
echo "Username: $username"
|
echo "Username: $username"
|
||||||
echo "Password: $password"
|
echo "Password: $password"
|
||||||
echo "SSH Port: $ssh_port"
|
echo "SSH Port: $ssh_port"
|
||||||
echo "WEB Port: $web_port"
|
echo "WEB: $(get_http_log_url)"
|
||||||
|
|
||||||
info "After Install"
|
info "After Install"
|
||||||
if is_administrator_username "$username"; then
|
if is_administrator_username "$username"; then
|
||||||
@@ -5385,7 +5398,7 @@ elif [ "$distro" = dd ]; then
|
|||||||
echo "Password: $password"
|
echo "Password: $password"
|
||||||
fi
|
fi
|
||||||
echo "SSH Port: $ssh_port"
|
echo "SSH Port: $ssh_port"
|
||||||
echo "WEB Port: $web_port"
|
echo "WEB: $(get_http_log_url)"
|
||||||
|
|
||||||
info "After Install"
|
info "After Install"
|
||||||
if [ -n "$cloud_data" ]; then
|
if [ -n "$cloud_data" ]; then
|
||||||
@@ -5408,7 +5421,7 @@ else
|
|||||||
echo "Password: $password"
|
echo "Password: $password"
|
||||||
fi
|
fi
|
||||||
echo "SSH Port: $ssh_port"
|
echo "SSH Port: $ssh_port"
|
||||||
echo "WEB Port: $web_port"
|
echo "WEB: $(get_http_log_url)"
|
||||||
|
|
||||||
info "After Install"
|
info "After Install"
|
||||||
echo "Username: $username"
|
echo "Username: $username"
|
||||||
|
|||||||
@@ -425,13 +425,18 @@ setup_nginx() {
|
|||||||
|
|
||||||
setup_websocketd() {
|
setup_websocketd() {
|
||||||
apk add websocketd
|
apk add websocketd
|
||||||
wget $confhome/logviewer.html -O /tmp/index.html
|
|
||||||
apk add coreutils
|
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
|
killall -q websocketd || true
|
||||||
# websocketd 遇到 \n 才推送,因此要转换 \r 为 \n
|
# websocketd 遇到 \n 才推送,因此要转换 \r 为 \n
|
||||||
websocketd --port "$web_port" --loglevel=fatal --staticdir=/tmp \
|
websocketd --port "$web_port" --loglevel=fatal --staticdir=/tmp/web \
|
||||||
stdbuf -oL -eL sh -c "tail -fn+0 /reinstall.log | tr '\r' '\n' | grep -Fiv -e password -e token" &
|
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() {
|
get_approximate_ram_size() {
|
||||||
|
|||||||
Reference in New Issue
Block a user