#!/bin/bash # # Wizard # # Copyright (C) 2000 Mandrakesoft. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # See file LICENSE for further informations on licensing terms. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # Authors: Jerome Dumonteil, Maurizio De Cecco, Enzo Maggi # icons: Helene Durosini # http://www.mandrakesoft.com # script for wizard network configuration # # install default dhcpd configuration for dhcp server # assuming all dependencies are ok echo_debug "in $0" cfg_file=/etc/sysconfig/mdk_serv # loading var wiz_device=`get_var wiz_device` echo_debug "wiz_device=$wiz_device" wiz_host_name=`get_var wiz_host_name` echo_debug "wiz_host_name=$wiz_host_name" wiz_ip_net=`get_var wiz_ip_net` echo_debug "wiz_ip_net=$wiz_ip_net" wiz_ip_netmask=`get_var wiz_ip_netmask` echo_debug "wiz_ip_netmask=$wiz_ip_netmask" wiz_domain_name=`get_var wiz_domain_name` echo_debug "wiz_domain_name=$wiz_domain_name" wiz_ip_server=`get_var wiz_ip_server` echo_debug "=wiz_ip_server=$wiz_ip_server" echo_debug "wiz_ip_range1 is $wiz_ip_range1" echo_debug "wiz_ip_range2 is $wiz_ip_range2" chg_val ${cfg_file} wiz_ip_range1 "${wiz_ip_range1}" s chg_val ${cfg_file} wiz_ip_range2 "${wiz_ip_range2}" s # patch to rewrite when got new file about dhcp with INTERFACES value # currently, I put the device to configure as dhcp server # in /etc/sysconfig/dhcpd # ok, the new init.d/dhcp is not as wanted, still need a patch #[ -f /etc/sysconfig/dhcpd ] && cp -f /etc/sysconfig/dhcpd /var/tmp/wiz_bck/orig/dhcpd bck_file /etc/sysconfig/dhcpd echo "INTERFACES=${wiz_device}" > /etc/sysconfig/dhcpd # ok, the new init.d/dhcp is not as wanted, still need a patch # now patching /etc/rc.d/init.d/dhcpd if needed if [ -z "`grep INTERFACES /etc/rc.d/init.d/dhcpd`" ]; then echo_debug "now patching etc/rc.d/init.d/dhcpd" bck_file /etc/rc.d/init.d/dhcpd cat /etc/rc.d/init.d/dhcpd.mdk_orig.1 \ |sed -e '/daemon \/usr\/sbin\/dhcpd/{ i \ if [ -f /etc/sysconfig/dhcpd ]; then\ . /etc/sysconfig/dhcpd\ DEV=$INTERFACES\ fi }' > /etc/rc.d/init.d/dhcpd #old version patch /etc/rc.d/init.d/dhcpd < ${CWD}/scripts/dhcpd.patch fi # dhcpd.conf bck_file /etc/dhcpd.conf echo_debug "now putting dhcpd config file" cat ${CWD}/scripts/dhcpd.conf.default \ |sed "s|__hname__|${wiz_host_name}|g" \ |sed "s|__net__|${wiz_ip_net}|g" \ |sed "s|__ip__|${wiz_ip_server}|g" \ |sed "s|__mask__|${wiz_ip_netmask}|g" \ |sed "s|__rng1__|${wiz_ip_range1}|g" \ |sed "s|__rng2__|${wiz_ip_range2}|g" \ |sed "s|__dname__|${wiz_domain_name}|g" \ > /etc/dhcpd.conf touch /var/dhcpd/dhcpd.leases # modifying webmin config echo_debug "modifying webmin config" file="/etc/webmin/dhcpd/config" if [ -f ${file} ]; then chg_val ${file} lease_file "/var/dhcpd/dhcpd.leases" chg_val ${file} interfaces "${wiz_device}" fi # this part of script to be played at the very end echo_debug "restarting services" /etc/rc.d/init.d/dhcpd restart # all is ok exit 10