SRCS+= configure.c client.c
SRCS+= ${SRC_IF} ${SRC_SOCKET}
+CONFIG= ${SYSCONFDIR}/dhcpcd.conf
+SCRIPTDIR= ${PREFIX}/libexec
+SCRIPT= ${SCRIPTDIR}/dhcpcd.sh
+HOOKDIR= ${SCRIPTDIR}/dhcpcd.hook.d
+
BINDIR= ${PREFIX}/sbin
-SYSCONFDIR?= ${PREFIX}/etc/dhcpcd
+SYSCONFDIR?= ${PREFIX}/etc
MAN= dhcpcd.conf.5 dhcpcd.8 dhcpcd.sh.8
CLEANFILES= dhcpcd.conf.5 dhcpcd.8 dhcpcd.sh.8
SCRIPTS= dhcpcd.sh
-SCRIPTSDIR= ${SYSCONFDIR}
+SCRIPTSDIR= ${SCRIPTDIR}
CLEANFILES+= dhcpcd.sh
FILES= dhcpcd.conf
FILESDIR= ${SYSCONFDIR}
-CPPFLAGS+= -DSYSCONFDIR=\"${SYSCONFDIR}\"
CPPFLAGS+= -DDBDIR=\"${DBDIR}\"
+CPPFLAGS+= -DCONFIG=\"${CONFIG}\"
+CPPFLAGS+= -DSCRIPT=\"${SCRIPT}\"
LDADD+= ${LIBRT}
SUBDIRS= hook.d
.SUFFIXES: .in .sh.in
+SED_DBDIR= -e 's:@DBDIR@:${DBDIR}:g'
+SED_HOOKDIR= -e 's:@HOOKDIR@:${HOOKDIR}:g'
+SED_SCRIPT= -e 's:@SCRIPT@:${SCRIPT}:g'
+SED_SYS= -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
+
.in:
- ${SED} 's:@SYSCONFDIR@:${SYSCONFDIR}:g; s:@DBDIR@:${DBDIR}:g' $< > $@
+ ${SED} ${SED_DBDIR} ${SED_HOOKDIR} ${SED_SCRIPT} ${SED_SYS} $< > $@
.sh.in.sh:
- ${SED} 's:@SYSCONFDIR@:${SYSCONFDIR}:g' $< > $@
+ ${SED} ${SED_HOOKDIR} ${SED_SCRIPT} ${SED_SYS} $< > $@
MK= mk
include ${MK}/prog.mk
Hooks
-----
-We provide example exit hooks for looking up the hostname in DNS,
-NTP (www.ntp.org) and ypbind (Linux).
-There are not installed by default as they are platform dependant.
+Not all the hooks in hook.d are installed by default.
+By default we install 01-test.sh, 10-resolv.conf.sh and 15-hostname.sh.
+To add more simply add them in the HOOKSCRIPTS variable.
+make HOOKSCRIPTS=50-ntp.sh install
Compatibility
/* If we already have a DUID then use it as it's never supposed
* to change once we have one even if the interfaces do */
- if ((f = fopen(DUIDFILE, "r"))) {
+ if ((f = fopen(DUID, "r"))) {
while ((get_line(&buffer, &len, f))) {
line = buffer;
while ((option = strsep(&line, " \t")))
}
/* No file? OK, lets make one based on our interface */
- if (!(f = fopen(DUIDFILE, "w")))
+ if (!(f = fopen(DUID, "w")))
return 0;
type = htons(1); /* DUI-D-LLT */
/* Failed to write the duid? scrub it, we cannot use it */
if (x < 1) {
len = 0;
- unlink(DUIDFILE);
+ unlink(DUID);
}
return len;
#ifndef SYSCONFDIR
# define SYSCONFDIR "/etc/" PACKAGE
#endif
+#ifndef LIBEXECDIR
+# define LIBEXECDIR "/libexec"
+#endif
#ifndef RUNDIR
# define RUNDIR "/var/run"
#endif
# define DBDIR "/var/db"
#endif
-#ifndef CONFIGFILE
-# define CONFIGFILE SYSCONFDIR "/" PACKAGE ".conf"
+#ifndef CONFIG
+# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
#endif
#ifndef SCRIPT
-# define SCRIPT SYSCONFDIR "/" PACKAGE ".sh"
+# define SCRIPT LIBEXECDIR "/" PACKAGE ".sh"
#endif
-#ifndef DUIDFILE
-# define DUIDFILE SYSCONFDIR "/" PACKAGE ".duid"
+#ifndef DUID
+# define DUID SYSCONFDIR "/" PACKAGE ".duid"
#endif
#ifndef LEASEFILE
# define LEASEFILE DBDIR "/" PACKAGE "-%s.lease"
option.
.Ss Hooking into DHCP events
.Nm
-will run @SYSCONFDIR@/dhcpcd.sh, or the script specified by the
+will run @SCRIPT@, or the script specified by the
.Fl c , -script
option. This script will configure
.Pa /etc/resolv.conf
Request the DHCP
.Ar option
variable for use in
-.Pa @SYSCONFDIR@/dhcpcd.sh .
+.Pa @SCRIPT@ .
.It Fl n , -renew
Notifies an existing
.Nm
any options other than those to configure the interface and routing.
.It Fl T, -test
On receipt of discover messages we just call
-.Pa @SYSCONFDIR@/dhcpcd.sh
+.Pa @SCRIPT@
with the reason of TEST which echo's the DHCP variables found in the message
to the console. The interface configuration isn't touched and neither are any
configuration files.
Linux Socket Filter, or LPF device on Linux based systems.
.Sh FILES
.Bl -ohang
-.It Pa @SYSCONFDIR@/dhcpcd.sh
+.It Pa @SCRIPT@
Bourne shell script that is run when we configure or deconfigure an interface.
.It Pa @SYSCONFDIR@/dhcpcd.duid
Text file that holds the DUID used to identify the host.
/* If the duid file exists, then enable duid by default
* This means we don't break existing clients that easily :) */
# ifdef ENABLE_DUID
- if ((f = fopen(DUIDFILE, "r"))) {
+ if ((f = fopen(DUID, "r"))) {
options->options |= DHCPCD_DUID;
fclose(f);
}
}
/* Parse our options file */
- f = fopen(cf ? cf : CONFIGFILE, "r");
+ f = fopen(cf ? cf : CONFIG, "r");
if (f) {
r = 1;
while ((get_line(&buffer, &len, f))) {
goto abort;
} else {
if (errno != ENOENT || cf) {
- logger(LOG_ERR, "fopen `%s': %s", cf ? cf : CONFIGFILE,
+ logger(LOG_ERR, "fopen `%s': %s", cf ? cf : CONFIG,
strerror(errno));
goto abort;
}
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 12, 2008
+.Dd May 20, 2008
.Dt DHCPCD.CONF 5 SMM
.Sh NAME
.Nm dhcpcd.conf
.Xr dhcpcd.sh 8
or the numerical value. You can specify more seperated by commas, spaces or
more option lines.
+.It Ic script Ar script
+Use
+.Ar script
+instead of the default
+.Pa @SCRIPT@ .
.It Ic timeout Ar seconds
The default timeout for waiting for a DHCP response is 20 seconds which may
be too long or too short and can be changed here.
When
.Nm
runs, it loads
-.Pa @SYSCONFDIR@/dhcpcd-hook
+.Pa @SYSCONFDIR@/dhcpcd.hook
and any scripts found in
-.Pa @SYSCONFDIR@/dhcpcd-hook.d
+.Pa @HOOKDIR@
in a lexical order.
.Sh SEE ALSO
.Xr dhcpcd 8
mv -f "$1"-pre."${interface}" "$1"
}
+# We source each script into this one so that scripts run earlier can
+# remove variables from the environment so later scripts don't see them.
+# Thus, the user can create their dhcpcd.hook script to configure
+# /etc/resolv.conf how they want and stop the system scripts ever updating it.
for hook in \
- @SYSCONFDIR@/dhcpcd-hook \
- @SYSCONFDIR@/dhcpcd-hook.d/* \
+ @SYSCONFDIR@/dhcpcd.hook \
+ @HOOKDIR@/*
do
- if [ -f "${x}" ]; then
- . "${x}"
+ if [ -f "${hook}" ]; then
+ . "${hook}"
fi
done
-SYSCONFDIR?= /etc/dhcpcd
-
+SCRIPTDIR?= ${PREFIX}/libexec
+HOOKDIR?= ${SCRIPTDIR}/dhcpcd.hook.d
SYSTEMSCRIPTS= 01-test.sh 10-resolv.conf.sh 15-hostname.sh
SCRIPTS= ${SYSTEMSCRIPTS} ${HOOKSCRIPTS}
-SCRIPTSDIR= ${SYSCONFDIR}/hook.d
+SCRIPTSDIR= ${HOOKDIR}
MK= ../mk
include ${MK}/scripts.mk
# rules to install manpages
# Copyright 2008 Roy Marples <roy@marples.name>
-MANPREFIX?= /usr/share
+_MANPREFIX_SH= if [ -n "${PREFIX}" ]; then echo "${PREFIX}"; else echo "/usr/share"; fi
+_MANPREFIX!= ${_MANPREFIX_SH}
+MANPREFIX?= ${_MANPREFIX}$(shell ${_MANPREFIX_SH})
+
MANDIR?= ${MANPREFIX}/man/man
MANMODE?= 0444
_proginstall: ${PROG}
${INSTALL} -d ${DESTDIR}${BINDIR}
${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${BINDIR}
- ${INSTALL} -d ${DESTDIR}${INFODIR}
+ ${INSTALL} -d ${DESTDIR}${DBDIR}
include ${MK}/depend.mk
include ${MK}/files.mk
SCRIPTSDIR?= ${BINDIR}
SCRIPTSMODE?= ${BINMODE}
-_scriptsinstall:
+_scriptsinstall: ${SCRIPTS}
${INSTALL} -d ${DESTDIR}${SCRIPTSDIR}
${INSTALL} -m ${SCRIPTSMODE} ${SCRIPTS} ${DESTDIR}${SCRIPTSDIR}