diff options
author | Jordan K. Hubbard <jkh@FreeBSD.org> | 2001-03-13 06:42:12 +0000 |
---|---|---|
committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 2001-03-13 06:42:12 +0000 |
commit | 401e1ee5c1d36511773004e13d3a39b95da3299b (patch) | |
tree | 983bb4fae21d4d6a4b56c6fda5ece96ea8e00c3b /usr.sbin/sysinstall/config.c | |
parent | 02846353f96532797feef46c2a28b2eb32f03dcd (diff) | |
download | src-401e1ee5c1d36511773004e13d3a39b95da3299b.tar.gz src-401e1ee5c1d36511773004e13d3a39b95da3299b.zip |
Be a better rc.conf citizen and create an initial file which:
1. Has a time-stamp to show when it was created
2. Sorts and uniq's the output to only contain single instances of a
given setting. This doesn't mean you still can't have settings which
override one another, that's still possible since it's too much
trouble to do the redundancy checking here.
Requested by: lots of people
Notes
Notes:
svn path=/head/; revision=74201
Diffstat (limited to 'usr.sbin/sysinstall/config.c')
-rw-r--r-- | usr.sbin/sysinstall/config.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/usr.sbin/sysinstall/config.c b/usr.sbin/sysinstall/config.c index 3a5f9dfcf74c..7a651dc6db2c 100644 --- a/usr.sbin/sysinstall/config.c +++ b/usr.sbin/sysinstall/config.c @@ -44,6 +44,7 @@ #include <sys/stat.h> #include <unistd.h> #include <sys/mount.h> +#include <time.h> static Chunk *chunk_list[MAX_CHUNKS]; static int nchunks; @@ -378,6 +379,8 @@ configRC_conf(void) FILE *rcSite; Variable *v; int write_header; + time_t t_loc; + char *cp; static int did_marker = 0; write_header = !file_readable("/etc/rc.conf"); @@ -388,6 +391,8 @@ configRC_conf(void) fprintf(rcSite, "# This file now contains just the overrides from /etc/defaults/rc.conf\n"); fprintf(rcSite, "# please make all changes to this file.\n\n"); fprintf(rcSite, "# Enable network daemons for user convenience.\n"); + if ((t_loc = time(NULL)) != -1 && (cp = ctime(&t_loc))) + fprintf(rcSite, "# Created: %s", cp); } /* Now do variable substitutions */ @@ -402,6 +407,10 @@ configRC_conf(void) } } fclose(rcSite); + /* Tidy up the resulting file if it's late enough in the installation + for sort and uniq to be available */ + if (file_readable("/usr/bin/sort") && file_readable("/usr/bin/uniq")) + (void)vsystem("sort /etc/rc.conf | uniq > /etc/rc.conf.new && mv /etc/rc.conf.new /etc/rc.conf"); } int |