sdelrio / rpi-hostap

Transform your PI into a Wireless Router (DHCP and WPA2 already insisde)
76 stars 65 forks source link

dhcpd.conf mapping #19

Closed cwong-archy closed 10 months ago

cwong-archy commented 10 months ago

is this repo still being developed? or these issues still being monitored?

wondering if we can map the dhcpd.conf file via volumes: instead of hardcoding in the startup script -

echo "Configuring DHCP server .."

cat > "/etc/dhcpd.conf" <<EOF
option domain-name-servers ${PRI_DNS}, ${SEC_DNS};
option subnet-mask 255.255.255.0;
option routers ${AP_ADDR};
subnet ${SUBNET} netmask 255.255.255.0 {
  range ${SUBNET::-1}100 ${SUBNET::-1}200;
}
EOF

i would like to do this -

    volumes:
      - './isc-dhcp-server/etc-dhcp/dhcpd.conf:/etc/dhcpd.conf'
cwong-archy commented 10 months ago

i tested it out locally and it works -

-cat > "/etc/dhcpd.conf" <<EOF
+if [[ ! -f /etc/dhcpd.conf ]]; then
+    cat > "/etc/dhcpd.conf" <<EOF
 option domain-name-servers ${PRI_DNS}, ${SEC_DNS};
 option subnet-mask 255.255.255.0;
 option routers ${AP_ADDR};
@@ -111,9 +112,10 @@ subnet ${SUBNET} netmask 255.255.255.0 {
   range ${SUBNET::-1}100 ${SUBNET::-1}200;
 }
 EOF
+fi

with my docker-compose.yml -

---
version: '3.8'

services:
  hostap:
    build: ./rpi-hostap
    container_name: hostap
    # image: sdelrio/rpi-hostap:latest
...
sdelrio commented 10 months ago

You can do with volume as you wrote, or create your own Dockerfile, include this image as a base one and add your own dhcdp.conf