summaryrefslogtreecommitdiffstats
path: root/dhcp_wizard/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'dhcp_wizard/scripts')
-rwxr-xr-xdhcp_wizard/scripts/check_range.sh83
-rwxr-xr-xdhcp_wizard/scripts/compute_range1.sh51
-rwxr-xr-xdhcp_wizard/scripts/compute_range2.sh51
-rw-r--r--dhcp_wizard/scripts/dhcpd.conf.default27
-rw-r--r--dhcp_wizard/scripts/dhcpd.patch13
-rwxr-xr-xdhcp_wizard/scripts/do_it_dhcp.sh124
6 files changed, 349 insertions, 0 deletions
diff --git a/dhcp_wizard/scripts/check_range.sh b/dhcp_wizard/scripts/check_range.sh
new file mode 100755
index 00000000..4f5de970
--- /dev/null
+++ b/dhcp_wizard/scripts/check_range.sh
@@ -0,0 +1,83 @@
+#!/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 <ln@mandrakesoft.com>
+# <corporate@mandrakesoft.com> http://www.mandrakesoft.com
+
+# script for wizard basic network configuration
+#
+# assuming :
+# - C class network, mask 255.255.255.0
+#
+# echo on stdout range of ip for DHCP subnet (second part of range)
+
+echo_debug "in $0"
+
+r1_trunc=${wiz_ip_range1%.*}
+r2_trunc=${wiz_ip_range2%.*}
+d1=${wiz_ip_range1##*.}
+d2=${wiz_ip_range2##*.}
+
+se=`get_var wiz_ip_server`
+
+s_trunc=${se%.*}
+ds=${se##*.}
+
+if [ -z "${r1_trunc}" ]; then
+ echo_debug "incorrect address range 1"
+ exit 1
+fi
+
+if [ -z "${r2_trunc}" ]; then
+ echo_debug "incorrect address range 2"
+ exit 1
+fi
+
+if [ "${s_trunc}" != "${r1_trunc}" -o "${s_trunc}" != "${r2_trunc}" ]; then
+ echo_debug "range not in network"
+ exit 1
+fi
+
+if [ -z "${d1}" -o -z "${d2}" ]; then
+ echo_debug "bad range"
+ exit 1
+fi
+
+if [ ${d1} -gt 254 -o ${d1} -lt 1 -o ${d2} -gt 254 -o ${d2} -lt 1 ]; then
+ echo_debug "bad range"
+ exit 1
+fi
+
+if [ ${d1} -gt ${d2} ]; then
+ echo_debug "bad range "
+ exit 1
+fi
+
+if [ ${ds} -ge ${d1} -a ${ds} -le ${d2} ]; then
+ echo_debug "server in range"
+ exit 1
+fi
+
+
+# should be ok
+exit 10
+
diff --git a/dhcp_wizard/scripts/compute_range1.sh b/dhcp_wizard/scripts/compute_range1.sh
new file mode 100755
index 00000000..8e1f89fb
--- /dev/null
+++ b/dhcp_wizard/scripts/compute_range1.sh
@@ -0,0 +1,51 @@
+#!/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 <ln@mandrakesoft.com>
+# <corporate@mandrakesoft.com> http://www.mandrakesoft.com
+
+# script for wizard basic network configuration
+#
+# assuming :
+# - C class network, mask 255.255.255.0
+#
+# echo on stdout range of ip for DHCP subnet (first part of range)
+
+#truncating addresses
+
+se=`get_var wiz_ip_server`
+
+s_trunc=${se%.*}
+d=${se##*.}
+
+if [ $d -le 64 ]; then
+ r=65
+elif [ $d -le 128 ]; then
+ r=129
+else
+ r=1
+fi
+
+echo "${s_trunc}.$r"
+
+exit 0
+
diff --git a/dhcp_wizard/scripts/compute_range2.sh b/dhcp_wizard/scripts/compute_range2.sh
new file mode 100755
index 00000000..3055a6e2
--- /dev/null
+++ b/dhcp_wizard/scripts/compute_range2.sh
@@ -0,0 +1,51 @@
+#!/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 <ln@mandrakesoft.com>
+# <corporate@mandrakesoft.com> http://www.mandrakesoft.com
+
+# script for wizard basic network configuration
+#
+# assuming :
+# - C class network, mask 255.255.255.0
+#
+# echo on stdout range of ip for DHCP subnet (second part of range)
+
+#truncating addresses
+se=`get_var wiz_ip_server`
+
+s_trunc=${se%.*}
+d=${se##*.}
+
+if [ $d -le 128 ]; then
+ r=254
+elif [ $d -gt 192 ]; then
+ r=192
+else
+ r=128
+fi
+
+
+echo "${s_trunc}.$r"
+
+exit 0
+
diff --git a/dhcp_wizard/scripts/dhcpd.conf.default b/dhcp_wizard/scripts/dhcpd.conf.default
new file mode 100644
index 00000000..c2135639
--- /dev/null
+++ b/dhcp_wizard/scripts/dhcpd.conf.default
@@ -0,0 +1,27 @@
+# default file for dhcpd
+# replace __ip__ by the IP adress of the server (same server for
+# all services in this config file)
+
+server-identifier __hname__;
+default-lease-time 36000;
+max-lease-time 144000;
+ddns-update-style ad-hoc;
+
+
+subnet __net__ netmask __mask__{
+ range __rng1__ __rng2__;
+ option domain-name "__dname__";
+ option domain-name-servers __ip__;
+ option nis-servers __ip__;
+ option lpr-servers __ip__;
+ option netbios-name-servers __ip__;
+ option routers __ip__;
+ option subnet-mask __mask__;
+ option time-servers __ip__;
+ ddns-updates on;
+ ddns-domainname "__dname__";
+ ddns-rev-domainname "in-addr.arpa";
+
+}
+
+
diff --git a/dhcp_wizard/scripts/dhcpd.patch b/dhcp_wizard/scripts/dhcpd.patch
new file mode 100644
index 00000000..45d84c4b
--- /dev/null
+++ b/dhcp_wizard/scripts/dhcpd.patch
@@ -0,0 +1,13 @@
+--- dhcpd.o Wed Mar 22 18:39:19 2000
++++ dhcpd Wed Mar 22 18:40:17 2000
+@@ -25,8 +25,9 @@
+ # # Note that this work around assumes only using eth0!!!
+ # echo -n "Adding local broadcast host route: "
+ # /sbin/route add -host 255.255.255.255 dev eth0
++ [ -f /etc/sysconfig/dhcpd ] && . /etc/sysconfig/dhcpd
+ echo -n "Starting dhcpd: "
+- daemon /usr/sbin/dhcpd
++ daemon /usr/sbin/dhcpd ${INTERFACES}
+ echo
+ touch /var/lock/subsys/dhcpd
+ ;;
diff --git a/dhcp_wizard/scripts/do_it_dhcp.sh b/dhcp_wizard/scripts/do_it_dhcp.sh
new file mode 100755
index 00000000..5141b8c0
--- /dev/null
+++ b/dhcp_wizard/scripts/do_it_dhcp.sh
@@ -0,0 +1,124 @@
+#!/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 <ln@mandrakesoft.com>
+# <corporate@mandrakesoft.com> 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
+
+
+