Skip to content

Commit d9e6056

Browse files
committed
fix:修复一些隐藏的恶性BUG
1 parent 6d97ce9 commit d9e6056

12 files changed

Lines changed: 58 additions & 28 deletions

extra_scripts/build_wds_image.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# from
33
# https://github.com/oneclickvirt/docker
4-
# 2024.03.12
4+
# 2026.02.28
55

66
cd /root >/dev/null 2>&1
77
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
@@ -42,6 +42,7 @@ count=$(sudo egrep -c '(vmx|svm)' /proc/cpuinfo)
4242
if [[ -z $count ]] || [[ $count -le 0 ]]; then
4343
_yellow "Virtualization is not supported, exit the program."
4444
_yellow "虚拟化不支持,退出程序。"
45+
exit 1
4546
fi
4647

4748
windows_version="${1:-10}"

extra_scripts/check-dns.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#from https://github.com/oneclickvirt/docker
3-
# 2025.05.23
3+
# 2026.02.28
44
set -e
55

66
DNS_SERVERS_IPV4=(
@@ -92,7 +92,7 @@ write_resolv_conf() {
9292
for dns in "${DNS_SERVERS_IPV6[@]}"; do
9393
echo "nameserver $dns"
9494
done
95-
} >>/etc/resolv.conf
95+
} >/etc/resolv.conf
9696
echo "/etc/resolv.conf 更新完成"
9797
}
9898

@@ -147,5 +147,5 @@ else
147147
fi
148148
sleep 3
149149
if grep -q "vmbr0" "/etc/network/interfaces"; then
150-
resolvconf -a vmbr0 < ${RESOLV_CONF}
150+
resolvconf -a vmbr0 < /etc/resolv.conf
151151
fi

extra_scripts/guacamole.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# from
33
# https://github.com/oneclickvirt/docker
4-
# 2024.03.12
4+
# 2026.02.28
55

66
cd /root >/dev/null 2>&1
77
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
@@ -55,7 +55,7 @@ check_ipv4() {
5555
break
5656
fi
5757
done
58-
! curl -s4m8 $IP_API | grep -q '\.' && red " ERROR:The host must have IPv4. " && exit 1
58+
! curl -s4m8 $IP_API | grep -q '\.' && _red " ERROR:The host must have IPv4. " && exit 1
5959
IPV4=$(curl -s4m8 "$IP_API")
6060
}
6161

scripts/create_android.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# from
33
# https://github.com/oneclickvirt/docker
4-
# 2025.11.05
4+
# 2026.02.28
55

66
cd /root >/dev/null 2>&1
77
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
@@ -27,7 +27,7 @@ if [ ! -d /usr/local/bin ]; then
2727
mkdir -p /usr/local/bin
2828
fi
2929
export NVM_DIR="$HOME/.nvm"
30-
source "$NVM_DIR/nvm.sh"
30+
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
3131
REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch" "alpine")
3232
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch" "Alpine")
3333
PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy" "apk update")
@@ -93,14 +93,17 @@ if [[ "$(echo -e "$current_kernel_version\n$target_kernel_version" | sort -V | h
9393
else
9494
echo "当前内核版本 $current_kernel_version 小于 $target_kernel_version,请自行升级系统"
9595
fi
96-
if ! dpkg -S linux-modules-extra-${current_kernel_version} >/dev/null 2>&1; then
97-
${PACKAGE_INSTALL[int]} linux-modules-extra-${current_kernel_version}
98-
fi
9996
modprobe binder_linux devices="binder,hwbinder,vndbinder"
10097
modprobe ashmem_linux
10198
if [ ! -d /usr/local/bin ]; then
10299
mkdir -p /usr/local/bin
103100
fi
101+
# 仅在 Debian/Ubuntu 系(有 dpkg)时检查并安装内核模块包
102+
if command -v dpkg >/dev/null 2>&1; then
103+
if ! dpkg -S linux-modules-extra-${current_kernel_version} >/dev/null 2>&1; then
104+
${PACKAGE_INSTALL[int]} linux-modules-extra-${current_kernel_version}
105+
fi
106+
fi
104107
if ! command -v npm >/dev/null 2>&1; then
105108
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
106109
export NVM_DIR="$HOME/.nvm"

scripts/create_docker.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# from
33
# https://github.com/oneclickvirt/docker
4-
# 2025.08.24
4+
# 2026.02.28
55

66
# cd /root
77
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
@@ -46,7 +46,7 @@ pre_check() {
4646
chmod 777 ssh_sh.sh
4747
dos2unix ssh_sh.sh
4848
fi
49-
if [ ! -f buildone.sh ]; then
49+
if [ ! -f onedocker.sh ]; then
5050
curl -L https://raw.githubusercontent.com/oneclickvirt/docker/main/scripts/onedocker.sh -o onedocker.sh
5151
chmod 777 onedocker.sh
5252
dos2unix onedocker.sh

scripts/dockerinstall.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# from
33
# https://github.com/oneclickvirt/docker
4-
# 2025.11.05
4+
# 2026.02.28
55

66
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
77
_green() { echo -e "\033[32m\033[01m$@\033[0m"; }
@@ -116,6 +116,17 @@ setup_docker_btrfs_loop() {
116116
elif command -v rc-service >/dev/null 2>&1 && rc-service docker status >/dev/null 2>&1; then
117117
rc-service docker stop
118118
fi
119+
# 若 loop 文件已存在且已挂载,则跳过格式化以避免损坏已有数据
120+
if [ -f "$loop_file" ] && losetup -j "$loop_file" 2>/dev/null | grep -q "$loop_file"; then
121+
_green "Loop file $loop_file already exists and is attached, skipping creation."
122+
loop_device=$(losetup -j "$loop_file" | cut -d: -f1)
123+
mkdir -p "$mount_point"
124+
mount "$loop_device" "$mount_point" 2>/dev/null || true
125+
echo "$loop_device" > /usr/local/bin/docker_loop_device
126+
echo "$loop_file" > /usr/local/bin/docker_loop_file
127+
echo "$mount_point" > /usr/local/bin/docker_mount_point
128+
return
129+
fi
119130
if [ -d "$mount_point" ] && [ "$(ls -A $mount_point 2>/dev/null)" ]; then
120131
_yellow "Backing up existing Docker data..."
121132
mv "$mount_point" "${mount_point}.backup.$(date +%Y%m%d-%H%M%S)"
@@ -340,7 +351,8 @@ is_private_ipv6() {
340351
if [[ $address == 2002:* ]]; then
341352
temp="8"
342353
fi
343-
if [[ $address == 2001:* ]]; then
354+
# 仅匹配 Teredo 隧道地址 2001:0000::/32,不影响其他合法公网 2001: 地址
355+
if [[ $address == 2001:0000:* || $address == 2001:0:* ]]; then
344356
temp="9"
345357
fi
346358
if [ "$temp" -gt 0 ]; then

scripts/oneandroid.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# from
33
# https://github.com/oneclickvirt/docker
4-
# 2025.11.05
4+
# 2026.02.28
55

66
cd /root >/dev/null 2>&1
77
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
@@ -60,6 +60,17 @@ check_nginx() {
6060
fi
6161
}
6262

63+
check_dig() {
64+
if ! command -v dig >/dev/null 2>&1; then
65+
_green "Installing dig (dnsutils/bind-utils)..."
66+
if command -v apt-get >/dev/null 2>&1; then
67+
${PACKAGE_INSTALL[int]} dnsutils
68+
elif command -v yum >/dev/null 2>&1 || command -v dnf >/dev/null 2>&1; then
69+
${PACKAGE_INSTALL[int]} bind-utils
70+
fi
71+
fi
72+
}
73+
6374
build_reverse_proxy() {
6475
_green "Build reverse proxy."
6576
_green "Do you want to bind a URL? (yes/no): "
@@ -140,6 +151,7 @@ if ! command -v docker >/dev/null 2>&1; then
140151
fi
141152
check_ipv4
142153
check_nginx
154+
check_dig
143155
rm -rf /root/android/data
144156
# rm -rf /root/scrcpy_web/data
145157
if [ ! -d "/root/android/data" ]; then

scripts/onechromium.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# from
33
# https://github.com/oneclickvirt/docker
4-
# 2025.11.05
4+
# 2026.02.28
55

66
cd /root >/dev/null 2>&1
77
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
@@ -52,7 +52,7 @@ check_ipv4() {
5252
break
5353
fi
5454
done
55-
! curl -s4m8 $IP_API | grep -q '\.' && red " ERROR:The host must have IPv4. " && exit 1
55+
! curl -s4m8 $IP_API | grep -q '\.' && _red " ERROR:The host must have IPv4. " && exit 1
5656
IPV4=$(curl -s4m8 "$IP_API")
5757
}
5858

scripts/onefirefox.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# from
33
# https://github.com/oneclickvirt/docker
4-
# 2025.11.05
4+
# 2026.02.28
55

66
cd /root >/dev/null 2>&1
77
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
@@ -52,7 +52,7 @@ check_ipv4() {
5252
break
5353
fi
5454
done
55-
! curl -s4m8 $IP_API | grep -q '\.' && red " ERROR:The host must have IPv4. " && exit 1
55+
! curl -s4m8 $IP_API | grep -q '\.' && _red " ERROR:The host must have IPv4. " && exit 1
5656
IPV4=$(curl -s4m8 "$IP_API")
5757
}
5858

scripts/onerustdesk.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# from
33
# https://github.com/oneclickvirt/docker
4-
# 2025.11.05
4+
# 2026.02.28
55

66
cd /root >/dev/null 2>&1
77
_red() { echo -e "\033[31m\033[01m$@\033[0m"; }
@@ -49,7 +49,7 @@ check_ipv4() {
4949
break
5050
fi
5151
done
52-
! curl -s4m8 $IP_API | grep -q '\.' && red " ERROR:The host must have IPv4. " && exit 1
52+
! curl -s4m8 $IP_API | grep -q '\.' && _red " ERROR:The host must have IPv4. " && exit 1
5353
IPV4=$(curl -s4m8 "$IP_API")
5454
}
5555

@@ -84,6 +84,7 @@ iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
8484
iptables -A INPUT -p tcp --match multiport --sports 21115:21119 --dport 21115:21119 -j ACCEPT
8585
iptables -A INPUT -p tcp --dport 8000 -j ACCEPT
8686
iptables -A INPUT -p udp --dport 21116 -j ACCEPT
87-
iptables-save >/etc/iptables/rules.v4
8887
${PACKAGE_INSTALL[int]} iptables-persistent
88+
mkdir -p /etc/iptables
89+
iptables-save >/etc/iptables/rules.v4
8990
service netfilter-persistent restart

0 commit comments

Comments
 (0)