Refactor: Remove static interfaces file, use dynamic generation in start script
This commit is contained in:
@@ -11,7 +11,6 @@ RUN apt-get update && apt-get install -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 2. Copy your static network configuration
|
||||
COPY interfaces /etc/network/interfaces
|
||||
|
||||
# 3. Copy the master startup script
|
||||
COPY start_network.sh /start_network.sh
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 192.168.0.115/24
|
||||
gateway 192.168.0.1
|
||||
@@ -1,17 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "--- Custom Network Init ---"
|
||||
# --- CONFIGURATION ---
|
||||
# Use Env Vars if provided, otherwise use these defaults
|
||||
IP=${STATIC_IP:-"192.168.0.115/24"}
|
||||
GW=${STATIC_GW:-"192.168.0.1"}
|
||||
DNS=${STATIC_DNS:-"192.168.0.113"}
|
||||
|
||||
# 1. Set DNS (Replace with your specific DNS IP)
|
||||
echo "nameserver 192.168.0.113" > /etc/resolv.conf
|
||||
echo "--- Network Init ---"
|
||||
echo "Using IP: $IP"
|
||||
echo "Using Gateway: $GW"
|
||||
echo "Using DNS: $DNS"
|
||||
|
||||
# 2. Sleep to allow Proxmox NIC to attach
|
||||
# 1. Generate Network Config
|
||||
cat <<EOF > /etc/network/interfaces
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address $IP
|
||||
gateway $GW
|
||||
EOF
|
||||
|
||||
# 2. Set DNS
|
||||
echo "nameserver $DNS" > /etc/resolv.conf
|
||||
|
||||
# 3. Wait for Hardware & Start Network
|
||||
sleep 5
|
||||
|
||||
# 3. Force Network Up
|
||||
/sbin/ifup --force eth0
|
||||
|
||||
# 4. Launch the original container application
|
||||
# (We point to the original entrypoint we found earlier: /app/entrypoint.sh)
|
||||
# 4. Launch App
|
||||
echo "--- Starting Application ---"
|
||||
exec /app/entrypoint.sh "$@"
|
||||
|
||||
Reference in New Issue
Block a user