Browse Source

added utils, perhaps these should go into a debian-installer library

removed much from TODO
create dirs as necessary
install menutest into DEBIAN (fixed it's return value too)
cleaned up templates, took some phrases from etherconf
cleaned up overall flow
handle missing data better
moved functions around a bit so no need for protos (that's why the diff is unreadable)

r295
master
David Whedon 23 years ago
parent
commit
7df46069a1
  1. 11
      Makefile
  2. 12
      TODO
  3. 7
      debian/changelog
  4. 10
      debian/control
  5. 2
      debian/menutest-common
  6. 42
      debian/netcfg-common.templates
  7. 46
      debian/netcfg-dhcp.templates
  8. 71
      debian/netcfg-static.templates
  9. 4
      debian/rules
  10. 975
      netcfg.c
  11. 52
      utils.c
  12. 7
      utils.h

11
Makefile

@ -2,7 +2,6 @@ ifndef PROGS
PROGS=netcfg-dhcp netcfg-static
endif
INCS=-I../cdebconf/src/
LDOPTS=-L../cdebconf/src -ldebconf
PREFIX=$(DESTDIR)/usr/
@ -18,15 +17,15 @@ install:
$(foreach PROG, $(PROGS), \
-cp $(PROG) debian/$(PROG).postinst)
netcfg-dhcp: netcfg.c
$(CC) $(CFLAGS) -DDHCP netcfg.c -o $@ $(INCS) $(LDOPTS)
netcfg-dhcp: netcfg.c utils.o
$(CC) $(CFLAGS) -DDHCP netcfg.c utils.o -o $@ $(INCS) $(LDOPTS)
$(STRIP) $@
size $@
netcfg-static: netcfg.c
$(CC) $(CFLAGS) -DSTATIC netcfg.c -o $@ $(INCS) $(LDOPTS)
netcfg-static: netcfg.c utils.o
$(CC) $(CFLAGS) -DSTATIC netcfg.c utils.o -o $@ $(INCS) $(LDOPTS)
$(STRIP) $@
size $@
clean:
rm -f netcfg-*
rm -f netcfg-* *.o

12
TODO

@ -1,14 +1,4 @@
* put in checks so the user can't enter data that is clearly invalid (perhaps this will be done through debconf.
* fall back to safe defaults if the user doesn't enter a particular value (ex. gateway)
* do other sorts of network configurations (pcmcia, ppp)
* inderstand the target_path() thing, and do it properly
* what do we do differently if it is a CD filesystem?
* decide what numbers you will actually present the user with for confirmation (you have overkill now)
* fix the note about what the user should do if we don't find any network interfaces. Since I don't now know what the flow of the installer is going to be I can't suggest what they should do, I've got the test in there from the old installer now.
* currently we get an internal error if the user has lots of network interfaces, find a better way of handling that.
* etherconf has some good descriptive text, perhaps I want to use it in place of the existing text.
* when the real dhcpcd installs itself we want to make sure it doesn't destroy our nice working configuration, how to do that?
* dhcp and static config udebs share a fair amount of code, perhaps a shared library? They also share templates, need to make a netcfg-shared udeb?
* /etc/dhcpc needs to be created, udpkg isn't creating it for me right now
* get the /proc filesystem working
* strdup all the dotted quads rather than playing with num2dot etc. all the time
* dhcp and static udebs share a fair amount, perhaps that can be fixed.

7
debian/changelog

@ -1,3 +1,10 @@
netcfg (0.3) unstable; urgency=low
* cleaned up much, now it plays well with main-menu and
actually configures the network.
-- David Whedon <dwhedon@gordian.com> Sat, 30 Dec 2000 23:01:09 -0800
netcfg (0.2) unstable; urgency=low
* dhcp and static config now in two separate udebs

10
debian/control

@ -7,7 +7,7 @@ Standards-Version: 3.1.1
Package: netcfg-dhcp
Architecture: any
Depends: cdebconf-udeb | cdebconf , dhcpcd-udeb | dhcpcd, netcfg-common
Depends: ${shlibs:Depends}, cdebconf-udeb, dhcpcd-udeb
Provides: configured-network
XBC-Installer-Menu-Item: 2
Description: Configure the network via DHCP
@ -19,7 +19,7 @@ Description: Configure the network via DHCP
Package: netcfg-static
Architecture: any
Depends: cdebconf-udeb | cdebconf, netcfg-common
Depends: ${shlibs:Depends}, cdebconf-udeb
Provides: configured-network
XBC-Installer-Menu-Item: 2
Description: Configure a static network
@ -27,9 +27,3 @@ Description: Configure a static network
able to configure a static network. If you don't know this information, you
should ask you system administrator.
Package: netcfg-common
Architecture: any
Depends:
Provides: configured-network
Description: Share resources between static and dhcp netcfg.
This package contains templates that are shared between netcfg-dhcp and netcfg-static.

2
debian/menutest → debian/menutest-common

@ -1,7 +1,7 @@
#!/bin/sh
if [ -z "`/sbin/ifconfig -a`" ] ; then
exit 1
exit 0
else
exit -1
fi

42
debian/netcfg-common.templates

@ -1,17 +1,51 @@
Template: netcfg/no_interfaces
Template: netcfg/get_domain
Type: string
Description: Choose the domain name.
The domain name is the part of your Internet address to the right
of your host name. It is often something that ends in .com, .net,
.edu, or .org. If you are setting up a home network, you can make
something up, but make sure you use the same domain name on all
your computers.
Template: netcfg/get_nameservers
Type: string
Description: please enter a network interface.
No network interfaces were found.
Description: Choose the DNS Server Addresses
Please enter the IP addresses (not host names) of up to 3 name servers,
separated by spaces. Do not use commas. The servers will be queried in the
order in which you enter them. If you don't want to use any name servers just
leave this field blank.
Template: netcfg/choose_interface
Type: select
Choices: ${ifchoices}
Description: Choose an interface.
The following interfaces were detected. Choose the type of your primary
network interface that you will need for installing Debian (via NFS or HTTP).
network interface that you will need for installing the Debian system (via NFS or HTTP).
Template: netcfg/error_cfg
Type: note
Description: An error occured.
Something went wrong when I tried to activate your network.
Template: netcfg/get_hostname
Type: string
Default: debian
Description: Enter the system's hostname.
The hostname is a single word that identifies your system to the
network. If you don't know what your hostname should be, consult
your network administrator. If you are setting up your own home
network, you can make something up here.
Template: netcfg/error
Type: note
Description: An error occured and I cannot continue.
Feel free to retry. The output of some commands is logged in /var/log/debian-installer.log.
Template: netcfg/no_interfaces
Type: note
Description: No interfaces were detected.
No network interfaces were found. That means that the installation system
was unable to find a network device. If you do have a network card, then it
is possible that the module for it hasn't been selected yet. Go back to
'Configure Network Hardware'.

46
debian/netcfg-dhcp.templates

@ -6,39 +6,17 @@ Description: What is your dhcp hostname?
If you are a cable modem user, you might often need to specify an
account number here. Otherwise, you can just leave this blank.
Template: netcfg/no_interfaces
Type: string
Description: please enter a network interface.
No network interfaces were found. That means that the installation system
was unable to find a network device. If you do have a network card, then it
is possible that the module for it hasn't been selected yet. Go back to the
'Configure Device Driver Modules' menu and load the required kernel modules
first. If your only network connection is PPP, don't worry -- you will be
asked if you want PPP later in the process.
Template: netcfg/get_hostname
Type: string
Default: debian
Description: Enter the system's hostname.
The hostname is a single word that identifies your system to the
network. If you don't know what your hostname should be, consult
your network administrator. If you are setting up your own home
network, you can make something up here.
Template: netcfg/choose_interface
Type: select
Choices: ${ifchoices}
Description: Choose an interface.
The following interfaces were detected. Choose the type of your primary
network interface that you will need for installing Debian (via NFS or HTTP).
Template: netcfg/confirm_dhcp
Type: boolean
Default: true
Description: Is this information correct?
interface = ${interface}
hostname = ${hostname}
domain = ${domain}
dhcp hostname = ${dhcp_hostname}
nameservers = ${nameservers}
Template: netcfg/error_cfg
Template: netcfg/do_dhcp
Type: note
Description: An error occured.
Something went wrong when I tried to activate your network.
Template: netcfg/no_interfaces
Type: string
Description: please enter a network interface.
No network interfaces were found.
Description: I will now configure the network.
This may take some time. It shouldn't take more than a minute or two.

71
debian/netcfg-static.templates

@ -1,28 +1,21 @@
Template: netcfg/get_domain
Type: string
Description: Choose the domain name.
The domain name is the part of your Internet address to the right
of your host name. It is often something that ends in .com, .net,
.edu, or .org. If you are setting up a home network, you can make
something up, but make sure you use the same domain name on all
your computers.
Template: netcfg/get_ipaddress
Type: string
Description: What is the IP address of this system?
The ipaddress identifies you system to other computer on the network. If you don't
know your ipaddress you should ask your system administrator.
Description: IP address?
The IP address is unique to your computer and consists of four
numbers separated by periods. If you don't know what to use here,
consult your network administrator.
Template: netcfg/get_netmask
Type: string
Description: What is your netmask?
The netmask is used to determine what ipaddresses are valid on this network. This allows
your computer to determine whether or not it needs to send packets destined for a particular
ipaddress to a gateway.
Description: Netmask?
The netmask is used to determine which machines are local to your
network. Consult your network administrator if you do not know the
value. The netmask should be entered as four numbers separated by
periods.
Template: netcfg/get_gateway
Type: string
Description: What is your IP gateway address?
Description: Gateway?
This is an IP address (four numbers separated by periods) that
indicates the gateway router, also known as the default router. All
traffic that goes outside your LAN (for instance, to the Internet) is
@ -36,15 +29,7 @@ Type: note
Description: The gateway you entered is unreachable.
You may have made an error entering your ipaddress, netmask and/or gateway.
Template: netcfg/get_nameservers
Type: string
Description: Choose the DNS Server Addresses
Please enter the IP addresses (not host names) of up to 3 name servers,
separated by spaces. Do not use commas. The servers will be queried in the
order in which you enter them. If you don't want to use any name servers just
leave this field blank.
Template: netcfg/confirm_static_cfg
Template: netcfg/confirm_static
Type: boolean
Default: true
Description: Is this configuration correct?
@ -53,37 +38,5 @@ Description: Is this configuration correct?
domain = ${domain}
ipaddress = ${ipaddress}
netmask = ${netmask}
network = ${network}
broadcast = ${broadcast}
gateway = ${gateway}
primary DNS = ${primary_DNS}
secondary DNS = ${secondary_DNS}
tertiary DNS = ${tertiary_DNS}
Template: netcfg/get_hostname
Type: string
Default: debian
Description:
The hostname is a single word that identifies your system to the
network. If you don't know what your hostname should be, consult
your network administrator. If you are setting up your own home
network, you can make something up here. Don't enter your full
domain name here; you'll be asked for that next.
Template: netcfg/no_interfaces
Type: string
Description: please enter a network interface.
No network interfaces were found.
Template: netcfg/choose_interface
Type: select
Choices: ${ifchoices}
Description: Choose an interface.
The following interfaces were detected. Choose the type of your primary
network interface that you will need for installing Debian (via NFS or HTTP).
Template: netcfg/error_cfg
Type: note
Description: An error occured.
Something went wrong when I tried to activate your network.
nameservers = ${nameservers}

4
debian/rules

@ -62,6 +62,10 @@ binary-arch: build install
dh_testdir
dh_testroot
dh_installdebconf
cat debian/netcfg-common.templates >> debian/netcfg-static/DEBIAN/templates
cat debian/netcfg-common.templates >> debian/netcfg-dhcp/DEBIAN/templates
cp debian/menutest-common debian/netcfg-dhcp/DEBIAN/menutest
cp debian/menutest-common debian/netcfg-static/DEBIAN/menutest
# dh_installdocs
# dh_installchangelogs
# dh_link

975
netcfg.c

File diff suppressed because it is too large

52
utils.c

@ -0,0 +1,52 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define EXECLOG_FILE "/var/log/debian-installer.log"
#define MAXLINE 512
#define DEBUG
int
execlog (const char *incmd)
{
FILE *logfile, *output;
char cmd[strlen (incmd) + 6];
char line[MAXLINE];
strcpy (cmd, incmd);
if ((logfile = fopen (EXECLOG_FILE, "a")) == NULL)
{
perror ("execlog: fopen");
return system (cmd);
}
/* FIXME: this can cause the shell command if there's redirection
already in the passed string */
strcat (cmd, " 2>&1");
fprintf (logfile, "---- executing '%s' ----\n", cmd);
output = popen (cmd, "r");
while (fgets (line, MAXLINE, output) != NULL)
{
fprintf (logfile, "%s", line);
}
fprintf (logfile, "---- finished '%s' ----\n", cmd);
fclose (logfile);
/* FIXME we aren't getting the return value from the actual command
executed, not sure how to do that cleanly */
return (pclose (output));
}
int
check_dir (const char *dirname)
{
struct stat check;
if (stat (dirname, &check) == -1)
return -1;
else
return S_ISDIR (check.st_mode);
}

7
utils.h

@ -0,0 +1,7 @@
#ifndef __DEBIAN_INSTALLER_H__
#define __DEBIAN_INSTALLER_H__
int execlog(char *);
int check_dir(char *);
#endif /* __DEBIAN_INSTALLER_H__ */
Loading…
Cancel
Save