#------------------------------------------------------------------------------ # /etc/rc.d/rc390.dns_dhcp - start dns and dhcp # # Creation: 2007-02-03 lanspezi # Last Update: $Id$ #------------------------------------------------------------------------------ # # setting user.group and rights for additional config-files of dnsmasq # -------------------------------------------------------------------- if [ -d /etc/dnsmasq.d ] then chown dns.dns /etc/dnsmasq.d/* chmod 600 /etc/dnsmasq.d/* chown dns.dns /etc/dnsmasq.d chmod 700 /etc/dnsmasq.d fi if [ "$OPT_DNS" = "yes" ] then dnsmasq_msg='DNS' check_rdns "-REMOVE" if [ "$OPT_HTTPD" = "yes" ] then log_info "add DNS info to webgui" httpd-menu.sh add status_dns.cgi DNS '$_MT_stat' status fi begin_script DNS "configure firewall for DNS service ..." conf_firewall_dns end_script fi if [ "$OPT_DHCP" = "yes" ] then begin_script DHCP "configure firewall for DHCP service ..." case $DHCP_TYPE in isc-dhcpd) . /etc/rc.d/helper-dhcp_isc.sh while read ifname do case $iflist in *$ifname*) # ignore it, its already there ;; *) iflist="$iflist $ifname" ;; esac done < /var/run/dhcpd.iflist dhcpdoptions="-q -cf /etc/dhcpd.conf -lf /var/run/iscdhcpd.leases -pf /var/run/dhcpd.pid $iflist" if [ ! -f $DHCP_LEASES_DIR/iscdhcpd.leases ] then > $DHCP_LEASES_DIR/iscdhcpd.leases fi cp $DHCP_LEASES_DIR/iscdhcpd.leases /var/run/ ln -s /srv/www/admin/status_dhcp-isc-dhcpd.cgi /srv/www/admin/status_dhcp.cgi ;; dnsmasq) if [ "$dnsmasq_msg" ]; then dnsmasq_msg="$dnsmasq_msg and DHCP" else dnsmasq_msg=DHCP fi . /etc/rc.d/helper-dhcp_dnsmasq.sh ln -s /srv/www/admin/status_dhcp-dnsmasq.cgi /srv/www/admin/status_dhcp.cgi ;; *) log_error "$DHCP_TYPE not supported" ;; esac conf_firewall_dhcp end_script if [ "$OPT_HTTPD" = "yes" ] then log_info "add DHCP info to webgui" httpd-menu.sh add status_dhcp.cgi DHCP '$_MT_stat' status fi echo "DHCP_LEASES_DIR=\"$DHCP_LEASES_DIR\"" > /var/run/dhcp_leases_dir fi # start services # -------------- case ${OPT_DNS}_${OPT_DHCP}_${DHCP_TYPE} in yes_yes_dnsmasq | no_yes_dnsmasq | yes_no_*) begin_script DNS_DHCP "start dnsmasq as $dnsmasq_msg server ..." mkdir /var/run/dnsmasq chown dns.dns /var/run/dnsmasq dnsmasq || log_error "dnsmasq not started!" end_script ;; yes_yes_isc-dhcpd) begin_script DNS_DHCP "start dnsmasq as DNS and isc-dhcpd as DHCP server ..." mkdir /var/run/dnsmasq chown dns.dns /var/run/dnsmasq dnsmasq || log_error "dnsmasq not started!" dhcpd $dhcpdoptions || log_error "isc-dhcpd not started!" end_script ;; no_yes_isc-dhcpd) begin_script DNS_DHCP "start isc-dhcpd as DHCP server ..." dhcpd $dhcpdoptions || log_error "isc-dhcpd not started!" end_script ;; *) log_info "no DNS and DHCP server selected (${OPT_DNS}_${OPT_DHCP}_${DHCP_TYPE}) ..." ;; esac case $OPT_DHCPRELAY in yes) begin_script DHCRELAY "starting dhcprelay ..." idx=1 interfaces="" while [ $idx -le $DHCPRELAY_IF_N ] do eval iface='$DHCPRELAY_IF_'$idx get_count INPUT ins_rule filter INPUT "prot:udp if:$iface:any 68 67 ACCEPT" $res "dhcprelay access" interfaces=$interfaces' -i '$iface idx=`expr $idx + 1` done dhcrelay $interfaces $DHCPRELAY_SERVER end_script ;; esac