26 lines
1.1 KiB
Bash
Executable File
26 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Bring up static networking inside unprivileged LXC 3501 (ccip-monitor) when eth0 stays DOWN.
|
|
# Run on the Proxmox node that hosts VMID 3501 (r630-02). Optional: @reboot cron on the host.
|
|
#
|
|
# After `pct reboot 3501` (or stop/start), eth0 may be DOWN until you run this script again —
|
|
# host @reboot cron does not run on container-only reboots.
|
|
#
|
|
# Usage (on r630-02 as root): /usr/local/sbin/pct-lxc-3501-net-up.sh
|
|
# Install: scp to r630-02 /usr/local/sbin/ && chmod +x
|
|
|
|
set -euo pipefail
|
|
VMID="${CCIP_MONITOR_VMID:-3501}"
|
|
IP="${CCIP_MONITOR_IP:-192.168.11.28/24}"
|
|
GW="${CCIP_MONITOR_GW:-192.168.11.1}"
|
|
BCAST="${CCIP_MONITOR_BCAST:-192.168.11.255}"
|
|
|
|
if ! pct status "$VMID" 2>/dev/null | grep -q running; then
|
|
exit 0
|
|
fi
|
|
|
|
pct exec "$VMID" -- ip link set eth0 up
|
|
pct exec "$VMID" -- ip addr replace "$IP" dev eth0 broadcast "$BCAST" 2>/dev/null || \
|
|
pct exec "$VMID" -- ip addr add "$IP" dev eth0 broadcast "$BCAST"
|
|
pct exec "$VMID" -- ip route replace default via "$GW" dev eth0 2>/dev/null || \
|
|
pct exec "$VMID" -- ip route add default via "$GW" dev eth0
|