Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2e6683a44 | ||
|
|
c4f962d120 | ||
|
|
352aa78a8f | ||
|
|
0c105e5224 | ||
|
|
e5f1ba44c8 | ||
|
|
f0f67afbcb | ||
|
|
4e517797e1 | ||
|
|
5bc1b52721 | ||
|
|
b357808e99 | ||
|
|
90d8838e15 | ||
|
|
bcc5e0d4d0 | ||
|
|
2e7d079f65 | ||
|
|
da7762b0cf | ||
|
|
61edf87116 | ||
|
|
a567579ab2 | ||
|
|
3433a6d945 |
No files matched your search
@@ -15,9 +15,9 @@ thirdParty:
|
|||||||
- { upstream: docker.io/library/rabbitmq:4.3-management, acr: library/rabbitmq:4.3-management, pushed: true }
|
- { upstream: docker.io/library/rabbitmq:4.3-management, acr: library/rabbitmq:4.3-management, pushed: true }
|
||||||
# ── edge 单元 + audit broker 硬依赖 ──
|
# ── edge 单元 + audit broker 硬依赖 ──
|
||||||
- { upstream: docker.io/emqx/nanomq:0.25.2-2, acr: library/nanomq:0.25.2-2, pushed: true } # D2 已补推(2026-08-22)
|
- { upstream: docker.io/emqx/nanomq:0.25.2-2, acr: library/nanomq:0.25.2-2, pushed: true } # D2 已补推(2026-08-22)
|
||||||
# ── 工具类 ──
|
# ── 工具类(现场无组件直接依赖,备查;tag 以 ACR 实存为准,2026-08-22 盘点) ──
|
||||||
- { upstream: docker.io/library/busybox:latest, acr: library/busybox:latest, pushed: true }
|
- { upstream: docker.io/library/busybox:1.36, acr: library/busybox:1.36, pushed: true, optional: true }
|
||||||
- { upstream: docker.io/library/alpine:3, acr: library/alpine:3, pushed: true }
|
- { upstream: docker.io/library/alpine:3.19, acr: library/alpine:3.19, pushed: true, optional: true }
|
||||||
# ── 可选(客户默认不部署) ──
|
# ── 可选(客户默认不部署) ──
|
||||||
- { upstream: docker.io/emqx/mqttx-web:latest, acr: library/mqttx-web:latest, pushed: false, optional: true }
|
- { upstream: docker.io/emqx/mqttx-web:latest, acr: library/mqttx-web:latest, pushed: true, optional: true } # mxlexus 已部署(2026-08-22)
|
||||||
- { upstream: docker.io/library/mongo:7.0, acr: library/mongo:7.0, pushed: true, optional: true } # v2 audit 已去 mongo,存量备用
|
- { upstream: docker.io/library/mongo:7.0, acr: library/mongo:7.0, pushed: true, optional: true } # v2 audit 已去 mongo,存量备用
|
||||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
|||||||
name: mixingx-agent-unit
|
name: mixingx-agent-unit
|
||||||
description: "One MixingX agent unit release: agent backend, agent web, and agent PostgreSQL."
|
description: "One MixingX agent unit release: agent backend, agent web, and agent PostgreSQL."
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.0.3
|
||||||
appVersion: "1.0.1"
|
appVersion: "1.0.3"
|
||||||
@@ -6,6 +6,12 @@ Deploys one agent site as one Helm release:
|
|||||||
- `agent-web-<site>` frontend
|
- `agent-web-<site>` frontend
|
||||||
- `agent-<site>-postgres` StatefulSet and retained PVC
|
- `agent-<site>-postgres` StatefulSet and retained PVC
|
||||||
|
|
||||||
|
Agent PostgreSQL sessions set `idle_in_transaction_session_timeout` through the
|
||||||
|
connection string. The default is `60s`, configurable with
|
||||||
|
`sharedInfra.postgres.idleInTransactionSessionTimeout`. This is a database-side
|
||||||
|
safety net for leaked idle transactions and does not change database users,
|
||||||
|
passwords, roles, or the PostgreSQL StatefulSet credential model.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ stringData:
|
|||||||
ConnectionStrings__redis: "{{ .Values.sharedInfra.redis.host }}:{{ .Values.sharedInfra.redis.port }},password={{ .Values.sharedInfra.redis.password }}"
|
ConnectionStrings__redis: "{{ .Values.sharedInfra.redis.host }}:{{ .Values.sharedInfra.redis.port }},password={{ .Values.sharedInfra.redis.password }}"
|
||||||
REDIS_PASSWORD: "{{ .Values.sharedInfra.redis.password }}"
|
REDIS_PASSWORD: "{{ .Values.sharedInfra.redis.password }}"
|
||||||
REDIS_URI: "redis://:{{ .Values.sharedInfra.redis.password }}@{{ .Values.sharedInfra.redis.host }}:{{ .Values.sharedInfra.redis.port }}"
|
REDIS_URI: "redis://:{{ .Values.sharedInfra.redis.password }}@{{ .Values.sharedInfra.redis.host }}:{{ .Values.sharedInfra.redis.port }}"
|
||||||
ConnectionStrings__PostgreSQL: "Host={{ $pgHost }};Port={{ .Values.sharedInfra.postgres.port }};Username={{ .Values.sharedInfra.postgres.username }};Password={{ .Values.sharedInfra.postgres.password }};Database={{ $database }}"
|
ConnectionStrings__PostgreSQL: "Host={{ $pgHost }};Port={{ .Values.sharedInfra.postgres.port }};Username={{ .Values.sharedInfra.postgres.username }};Password={{ .Values.sharedInfra.postgres.password }};Database={{ $database }};Options=-c idle_in_transaction_session_timeout={{ .Values.sharedInfra.postgres.idleInTransactionSessionTimeout }}"
|
||||||
POSTGRESQL_PASSWORD: "{{ .Values.sharedInfra.postgres.password }}"
|
POSTGRESQL_PASSWORD: "{{ .Values.sharedInfra.postgres.password }}"
|
||||||
POSTGRESQL_URI: "postgresql://{{ .Values.sharedInfra.postgres.username }}:{{ .Values.sharedInfra.postgres.password }}@{{ $pgHost }}:{{ .Values.sharedInfra.postgres.port }}/{{ $database }}"
|
POSTGRESQL_URI: "postgresql://{{ .Values.sharedInfra.postgres.username }}:{{ .Values.sharedInfra.postgres.password }}@{{ $pgHost }}:{{ .Values.sharedInfra.postgres.port }}/{{ $database }}"
|
||||||
POSTGRESQL_DATABASENAME: "{{ $database }}"
|
POSTGRESQL_DATABASENAME: "{{ $database }}"
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ sharedInfra:
|
|||||||
username: postgres
|
username: postgres
|
||||||
password: "Admin12345"
|
password: "Admin12345"
|
||||||
port: 5432
|
port: 5432
|
||||||
|
idleInTransactionSessionTimeout: 60s
|
||||||
redis:
|
redis:
|
||||||
host: redis-service
|
host: redis-service
|
||||||
port: 6379
|
port: 6379
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
|||||||
name: mixingx-audit
|
name: mixingx-audit
|
||||||
description: MixingX audit service.
|
description: MixingX audit service.
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.0.3
|
||||||
appVersion: "1.0.1"
|
appVersion: "1.0.3"
|
||||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
|||||||
name: mixingx-edge-unit
|
name: mixingx-edge-unit
|
||||||
description: "One MixingX edge unit release with durable local revision storage."
|
description: "One MixingX edge unit release with durable local revision storage."
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.0.3
|
||||||
appVersion: "1.0.1"
|
appVersion: "1.0.3"
|
||||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
|||||||
name: mixingx-gateway
|
name: mixingx-gateway
|
||||||
description: MixingX gateway service, RBAC, and root ingress.
|
description: MixingX gateway service, RBAC, and root ingress.
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.0.3
|
||||||
appVersion: "1.0.1"
|
appVersion: "1.0.3"
|
||||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
|||||||
name: mixingx-infra
|
name: mixingx-infra
|
||||||
description: MixingX shared infrastructure services (Redis, MongoDB, RabbitMQ).
|
description: MixingX shared infrastructure services (Redis, MongoDB, RabbitMQ).
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.0.3
|
||||||
appVersion: "1.0.1"
|
appVersion: "1.0.3"
|
||||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
|||||||
name: mixingx-mqttx
|
name: mixingx-mqttx
|
||||||
description: MixingX MQTTX Web — 浏览器端 MQTT 客户端,用于监控/调试各 Edge 的 NanoMQ broker。
|
description: MixingX MQTTX Web — 浏览器端 MQTT 客户端,用于监控/调试各 Edge 的 NanoMQ broker。
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.0.3
|
||||||
appVersion: "1.0.1"
|
appVersion: "1.0.3"
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: mixingx-network-agent
|
||||||
|
description: "MixingX network console agent: 每节点常驻,提供主机网口(IP/掩码/网关/DNS)与 WiFi 的可视化配置 API。"
|
||||||
|
type: application
|
||||||
|
version: 1.0.3
|
||||||
|
appVersion: "1.0.3"
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: DaemonSet
|
||||||
|
metadata:
|
||||||
|
name: network-agent
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: mixingx
|
||||||
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
|
app.kubernetes.io/component: network-agent
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/component: network-agent
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/component: network-agent
|
||||||
|
annotations:
|
||||||
|
# 容器内 nmcli 通过 D-Bus 操作主机 NetworkManager,
|
||||||
|
# 需要 unconfined 才能通过 dbus-daemon 的 AppArmor 仲裁
|
||||||
|
container.apparmor.security.beta.kubernetes.io/network-agent: unconfined
|
||||||
|
spec:
|
||||||
|
# hostNetwork: IP 变更后 agent 在新 IP 上继续存活,负责回滚与 k3s 自愈;
|
||||||
|
# 前端弹窗直连 http://<节点IP>:9750 即命中该节点的 agent
|
||||||
|
hostNetwork: true
|
||||||
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
|
{{- if .Values.nodeName }}
|
||||||
|
nodeName: {{ .Values.nodeName }}
|
||||||
|
{{- else if .Values.nodeSelector }}
|
||||||
|
nodeSelector:
|
||||||
|
{{ toYaml .Values.nodeSelector | indent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
containers:
|
||||||
|
- name: network-agent
|
||||||
|
image: {{ .Values.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: {{ .Values.ports.http }}
|
||||||
|
protocol: TCP
|
||||||
|
env:
|
||||||
|
- name: TZ
|
||||||
|
value: {{ .Values.timezone | default "Asia/Shanghai" | quote }}
|
||||||
|
- name: ASPNETCORE_URLS
|
||||||
|
value: "http://0.0.0.0:{{ .Values.ports.http }}"
|
||||||
|
- name: AUTH_TOKEN
|
||||||
|
value: {{ .Values.authToken | quote }}
|
||||||
|
- name: CORS_ORIGINS
|
||||||
|
value: {{ .Values.corsOrigins | quote }}
|
||||||
|
- name: ROLLBACK_TIMEOUT_SECONDS
|
||||||
|
value: {{ .Values.rollbackTimeoutSeconds | quote }}
|
||||||
|
- name: K3S_RESTART_ON_IP_CHANGE
|
||||||
|
value: {{ .Values.k3sRestartOnIpChange | quote }}
|
||||||
|
securityContext:
|
||||||
|
# 只需 root + D-Bus socket,无需 privileged
|
||||||
|
# NET_ADMIN: 清除切换静态后残留的动态地址(ip addr del 需要此能力)
|
||||||
|
runAsUser: 0
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
capabilities:
|
||||||
|
add:
|
||||||
|
- NET_ADMIN
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/network/health
|
||||||
|
port: {{ .Values.ports.http }}
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
periodSeconds: 30
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 6
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/network/health
|
||||||
|
port: {{ .Values.ports.http }}
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 15
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 6
|
||||||
|
resources:
|
||||||
|
{{ toYaml .Values.resources | indent 12 }}
|
||||||
|
volumeMounts:
|
||||||
|
# 主机 system bus: nmcli 与 systemd 重启都走它
|
||||||
|
- name: dbus
|
||||||
|
mountPath: /run/dbus/system_bus_socket
|
||||||
|
- name: nm-run
|
||||||
|
mountPath: /run/NetworkManager
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: dbus
|
||||||
|
hostPath:
|
||||||
|
path: /run/dbus/system_bus_socket
|
||||||
|
type: Socket
|
||||||
|
- name: nm-run
|
||||||
|
hostPath:
|
||||||
|
path: /run/NetworkManager
|
||||||
|
type: DirectoryOrCreate
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Headless 诊断服务: DNS network-agent 返回各节点 agent 的全部地址。
|
||||||
|
# 注意: 每个 agent 只管理自己所在节点,不要用普通 ClusterIP Service 访问
|
||||||
|
# (会在节点间随机负载均衡导致操作到错误的主机)。前端弹窗始终直连节点 IP。
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: network-agent
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: mixingx
|
||||||
|
app.kubernetes.io/component: network-agent
|
||||||
|
spec:
|
||||||
|
clusterIP: None
|
||||||
|
selector:
|
||||||
|
app.kubernetes.io/component: network-agent
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: {{ .Values.ports.http }}
|
||||||
|
targetPort: http
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
registry: 192.168.1.105:8888/mixingx
|
||||||
|
timezone: Asia/Shanghai
|
||||||
|
|
||||||
|
image:
|
||||||
|
repository: network-agent
|
||||||
|
tag: latest
|
||||||
|
|
||||||
|
ports:
|
||||||
|
http: 9750
|
||||||
|
|
||||||
|
# 鉴权令牌:为空则不启用(仅限内网联调);生产环境必须配置,
|
||||||
|
# 前端弹窗请求头 Authorization: Bearer <token>
|
||||||
|
authToken: ""
|
||||||
|
|
||||||
|
# 前端弹窗的跨域来源,逗号分隔;* = 任意(联调)
|
||||||
|
corsOrigins: "*"
|
||||||
|
|
||||||
|
# 改静态 IP 后未确认自动回滚的窗口(秒)
|
||||||
|
rollbackTimeoutSeconds: 60
|
||||||
|
|
||||||
|
# 确认 IP 变更后自动重启本机 k3s/k3s-agent(flannel 重绑新 IP)
|
||||||
|
k3sRestartOnIpChange: true
|
||||||
|
|
||||||
|
# 只在指定节点部署(为空 = 每个节点一个,推荐)
|
||||||
|
nodeName: ""
|
||||||
|
nodeSelector: {}
|
||||||
|
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 50m
|
||||||
|
memory: 128Mi
|
||||||
|
limits:
|
||||||
|
cpu: 500m
|
||||||
|
memory: 256Mi
|
||||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
|||||||
name: mixingx-platform
|
name: mixingx-platform
|
||||||
description: MixingX central platform services without customer edge/agent instances.
|
description: MixingX central platform services without customer edge/agent instances.
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.0.3
|
||||||
appVersion: "1.0.1"
|
appVersion: "1.0.3"
|
||||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
|||||||
name: mixingx-protocol-server-unit
|
name: mixingx-protocol-server-unit
|
||||||
description: Deploy one MixingX edge protocol test server instance.
|
description: Deploy one MixingX edge protocol test server instance.
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.0.3
|
||||||
appVersion: "1.0.1"
|
appVersion: "1.0.3"
|
||||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
|||||||
name: mixingx-sso
|
name: mixingx-sso
|
||||||
description: MixingX SSO standalone release (backend, web, and PostgreSQL).
|
description: MixingX SSO standalone release (backend, web, and PostgreSQL).
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.0.3
|
||||||
appVersion: "1.0.1"
|
appVersion: "1.0.3"
|
||||||
@@ -2,5 +2,5 @@ apiVersion: v2
|
|||||||
name: mixingx-ultra
|
name: mixingx-ultra
|
||||||
description: "MixingX Ultra dashboard standalone release: ultra backend, ultra web, and ultra PostgreSQL."
|
description: "MixingX Ultra dashboard standalone release: ultra backend, ultra web, and ultra PostgreSQL."
|
||||||
type: application
|
type: application
|
||||||
version: 1.0.1
|
version: 1.0.3
|
||||||
appVersion: "1.0.1"
|
appVersion: "1.0.3"
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# ============================================================================
|
||||||
|
# provision-host.sh — MixingX network-agent 主机初始化 (Ubuntu Server 20.04+)
|
||||||
|
#
|
||||||
|
# 职责(幂等,可重复执行):
|
||||||
|
# 1. 安装并启动 NetworkManager(服务器版默认未装)
|
||||||
|
# 2. 读取主网口当前网络参数,预创建等值静态 NM 连接(切换前后地址不变,不断网)
|
||||||
|
# 3. 创建低优先级 DHCP 救援连接(静态配错时的主机侧兜底)
|
||||||
|
# 4. 禁用 cloud-init 网络管理,netplan renderer 切换为 NetworkManager
|
||||||
|
# 5. rfkill 解锁无线网卡
|
||||||
|
# 6. 安装 polkit 放行规则(容器内 root 调用 NM/systemd D-Bus)
|
||||||
|
#
|
||||||
|
# 用法: sudo bash provision-host.sh
|
||||||
|
# 回滚: sudo bash rollback-host.sh
|
||||||
|
# 备份: /var/backups/mixingx-netconsole/
|
||||||
|
# ============================================================================
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BACKUP_DIR=/var/backups/mixingx-netconsole
|
||||||
|
|
||||||
|
log() { echo -e "\033[32m[mixingx]\033[0m $*"; }
|
||||||
|
die() { echo -e "\033[31m[mixingx] 错误: $*\033[0m" >&2; exit 1; }
|
||||||
|
|
||||||
|
[[ $EUID -eq 0 ]] || die "请用 root 运行: sudo bash $0"
|
||||||
|
command -v ip >/dev/null 2>&1 || die "缺少 ip 命令"
|
||||||
|
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
|
||||||
|
# ── 1. 安装 NetworkManager ────────────────────────────────────────────────
|
||||||
|
if ! command -v nmcli >/dev/null 2>&1; then
|
||||||
|
log "安装 NetworkManager ..."
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y -qq network-manager
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 关闭 NM 自动建连(未配置网卡自动 DHCP),避免与现有 networkd 抢接口
|
||||||
|
mkdir -p /etc/NetworkManager/conf.d
|
||||||
|
cat > /etc/NetworkManager/conf.d/99-mixingx.conf <<'EOF'
|
||||||
|
[main]
|
||||||
|
no-auto-default=*
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl enable --now NetworkManager >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
# ── 2. 识别主网口并读取当前参数 ───────────────────────────────────────────
|
||||||
|
PRIMARY_IF=$(ip -4 route show default | awk '{print $5; exit}')
|
||||||
|
[[ -n "${PRIMARY_IF:-}" ]] || die "未找到默认路由网卡(主机当前无网络?)"
|
||||||
|
PRIMARY_TYPE=$(ip link show "$PRIMARY_IF" | grep -o 'link/[a-z]*' | head -1)
|
||||||
|
|
||||||
|
CUR_ADDR=$(ip -4 addr show dev "$PRIMARY_IF" | awk '/inet /{print $2; exit}') # x.x.x.x/前缀
|
||||||
|
CUR_GW=$(ip -4 route show default | awk '{print $3; exit}')
|
||||||
|
CUR_DNS4=$(grep -h '^nameserver' /run/systemd/resolve/resolv.conf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf 2>/dev/null \
|
||||||
|
| awk '{print $2}' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' | sort -u | tr '\n' ' ')
|
||||||
|
log "主网口 $PRIMARY_IF 当前: 地址=$CUR_ADDR 网关=$CUR_GW DNS4=${CUR_DNS4:-<无>}"
|
||||||
|
|
||||||
|
# ── 3. 救援连接(仅以太网主口;WiFi 主口跳过——救援 DHCP 对 WiFi 无意义) ────
|
||||||
|
if [[ "$PRIMARY_TYPE" == "ethernet"* ]]; then
|
||||||
|
if ! nmcli connection show "rescue-dhcp" >/dev/null 2>&1; then
|
||||||
|
log "创建救援 DHCP 连接 rescue-dhcp (autoconnect-priority -100)"
|
||||||
|
nmcli connection add type ethernet ifname "$PRIMARY_IF" con-name "rescue-dhcp" \
|
||||||
|
ipv4.method auto \
|
||||||
|
connection.autoconnect yes \
|
||||||
|
connection.autoconnect-priority -100 >/dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── 4. 全局切换 netplan renderer → NetworkManager ────────────────────────
|
||||||
|
# 不删除原 netplan 配置(ethernet/wifi 定义、SSID/PSK 原样保留),
|
||||||
|
# netplan 会把原有连接定义自动渲染为等值的 NM profiles,无缝接管
|
||||||
|
if [[ ! -f /etc/netplan/90-mixingx-nm.yaml ]]; then
|
||||||
|
log "备份原 netplan 配置 → $BACKUP_DIR/netplan/"
|
||||||
|
mkdir -p "$BACKUP_DIR/netplan"
|
||||||
|
cp -a /etc/netplan/*.yaml "$BACKUP_DIR/netplan/" 2>/dev/null || true
|
||||||
|
|
||||||
|
log "禁用 cloud-init 网络管理"
|
||||||
|
mkdir -p /etc/cloud/cloud.cfg.d
|
||||||
|
echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
|
||||||
|
|
||||||
|
log "写入全局 renderer=NetworkManager"
|
||||||
|
cat > /etc/netplan/90-mixingx-nm.yaml <<'EOF'
|
||||||
|
network:
|
||||||
|
version: 2
|
||||||
|
renderer: NetworkManager
|
||||||
|
EOF
|
||||||
|
chmod 600 /etc/netplan/90-mixingx-nm.yaml
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "应用 netplan (交给 NetworkManager 托管)..."
|
||||||
|
netplan apply
|
||||||
|
|
||||||
|
# ── 5. 无线解锁 + polkit 放行 ─────────────────────────────────────────────
|
||||||
|
rfkill unblock all 2>/dev/null || true
|
||||||
|
|
||||||
|
if command -v pkexec >/dev/null 2>&1 || dpkg -s policykit-1 >/dev/null 2>&1; then
|
||||||
|
mkdir -p /etc/polkit-1/localauthority/50-local.d
|
||||||
|
cat > /etc/polkit-1/localauthority/50-local.d/49-mixingx-network-agent.pkla <<'EOF'
|
||||||
|
[MixingX Network Agent]
|
||||||
|
Identity=unix-user:root
|
||||||
|
Action=org.freedesktop.NetworkManager.*;org.freedesktop.systemd1.*
|
||||||
|
ResultAny=yes
|
||||||
|
ResultInactive=yes
|
||||||
|
ResultActive=yes
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── 6. 校验 ───────────────────────────────────────────────────────────────
|
||||||
|
sleep 3
|
||||||
|
log "当前设备状态:"
|
||||||
|
nmcli -g DEVICE,TYPE,STATE,CONNECTION device status
|
||||||
|
log "主网口地址: $(ip -4 addr show dev "$PRIMARY_IF" | awk '/inet /{print $2}')"
|
||||||
|
log "完成。后续用 k3s 弹窗或 nmcli 管理;回滚执行 rollback-host.sh"
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# ============================================================================
|
||||||
|
# rollback-host.sh — provision-host.sh 的反向操作
|
||||||
|
#
|
||||||
|
# 职责:
|
||||||
|
# 1. 恢复原 netplan 配置(从 /var/backups/mixingx-netconsole/netplan/)
|
||||||
|
# 2. 恢复 cloud-init 网络管理
|
||||||
|
# 3. 停用 NetworkManager 托管(服务禁用,连接配置保留)
|
||||||
|
# 4. 移除 polkit 放行规则
|
||||||
|
#
|
||||||
|
# 用法: sudo bash rollback-host.sh
|
||||||
|
# ============================================================================
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BACKUP_DIR=/var/backups/mixingx-netconsole
|
||||||
|
|
||||||
|
log() { echo -e "\033[32m[mixingx]\033[0m $*"; }
|
||||||
|
die() { echo -e "\033[31m[mixingx] 错误: $*\033[0m" >&2; exit 1; }
|
||||||
|
|
||||||
|
[[ $EUID -eq 0 ]] || die "请用 root 运行: sudo bash $0"
|
||||||
|
|
||||||
|
# ── 1. 恢复 netplan ───────────────────────────────────────────────────────
|
||||||
|
if [[ -d "$BACKUP_DIR/netplan" ]] && ls "$BACKUP_DIR/netplan"/*.yaml >/dev/null 2>&1; then
|
||||||
|
log "恢复备份的 netplan 配置"
|
||||||
|
rm -f /etc/netplan/90-mixingx-nm.yaml
|
||||||
|
cp -a "$BACKUP_DIR/netplan"/*.yaml /etc/netplan/
|
||||||
|
else
|
||||||
|
log "无备份,仅移除 NM renderer 配置(回退到 renderer 默认)"
|
||||||
|
rm -f /etc/netplan/90-mixingx-nm.yaml
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── 2. 恢复 cloud-init 网络管理 ───────────────────────────────────────────
|
||||||
|
rm -f /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
|
||||||
|
|
||||||
|
log "应用恢复的 netplan ..."
|
||||||
|
netplan apply
|
||||||
|
|
||||||
|
# ── 3. 停用 NetworkManager ────────────────────────────────────────────────
|
||||||
|
log "停用并禁用 NetworkManager"
|
||||||
|
systemctl disable --now NetworkManager >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
# ── 4. 移除 polkit 规则 / NM 覆盖配置 ─────────────────────────────────────
|
||||||
|
rm -f /etc/polkit-1/localauthority/50-local.d/49-mixingx-network-agent.pkla
|
||||||
|
rm -f /etc/NetworkManager/conf.d/99-mixingx.conf
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
ip -4 addr show | awk '/inet /{print " " $2 " @ " $NF}'
|
||||||
|
log "回滚完成。NM 连接配置保留在 /etc/NetworkManager/system-connections/ (可手工清理)"
|
||||||
Reference in new issue
Block a user