From 401e1ee5c1d36511773004e13d3a39b95da3299b Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Tue, 13 Mar 2001 06:42:12 +0000 Subject: 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 --- usr.sbin/sade/config.c | 9 +++++++++ usr.sbin/sysinstall/config.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c index 3a5f9dfcf74c..7a651dc6db2c 100644 --- a/usr.sbin/sade/config.c +++ b/usr.sbin/sade/config.c @@ -44,6 +44,7 @@ #include #include #include +#include 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 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 #include #include +#include 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 -- cgit v1.3