From owner-freebsd-current Sat Mar 24 17:49:28 2001 Delivered-To: freebsd-current@freebsd.org Received: from ns.internet.dk (ns.internet.dk [194.19.140.1]) by hub.freebsd.org (Postfix) with ESMTP id 9F74537B71B for ; Sat, 24 Mar 2001 17:49:22 -0800 (PST) (envelope-from leifn@neland.dk) Received: (from uucp@localhost) by ns.internet.dk (8.11.2/8.11.2) id f2P1nGn90762 for freebsd-current@freebsd.org.AVP; Sun, 25 Mar 2001 03:49:16 +0200 (CEST) (envelope-from leifn@neland.dk) Received: (from uucp@localhost) by ns.internet.dk (8.11.2/8.11.2) with UUCP id f2P1nFF90734 for freebsd-current@freebsd.org; Sun, 25 Mar 2001 03:49:15 +0200 (CEST) (envelope-from leifn@neland.dk) Received: from localhost (localhost [127.0.0.1]) by arnold.neland.dk (8.11.3/8.11.0) with ESMTP id f2P1mxR01951 for ; Sun, 25 Mar 2001 03:49:04 +0200 (CEST) (envelope-from leifn@neland.dk) Date: Sun, 25 Mar 2001 03:48:59 +0200 (CEST) From: Leif Neland To: freebsd-current@freebsd.org Subject: rc.conf duplicating defaults/rc.conf Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Once upon a time, before I knew better, I copied defaults/rc.conf to rc.conf and edited it to my needs. Therefore I had many lines in rc.conf which were unnessecary, because they just repeated the defaults. I have thrown together this script, which just outputs the needed lines in rc.conf. If VERBOSE is set, it also prints ##= Is default: Somelabel="somevalue" if rc.conf and defaults/rc.conf agree on the value of Somelabel ##- Default: Somelabel="defaultvalue" if rc.conf and defaults/rc.conf disagree on the value of Somelabel. Btw, why can't I run this as a bang-script? Typing ./defcheck just produces: awk: cmd. line 1: ./defcheck awk: cmd. line 1: ^ syntax error - - - - filename: defcheck #!/usr/bin/awk ######################################################## # # Quick hack to check if rc.conf unnessecary duplicate # lines in defaults/rc.conf # # Assume all lines are in format label="value" # # Prints lines in rc.conf which are not in defaults/rc.conf # If VERBOSE==1 below, also prints defaults. # # usage: # cd /etc; awk -f defcheck # # Other files in defaults may be checked: # cd /etc; awk -f defcheck -v CHECK=otherfile.conf # # Leif Neland # leif@neland.dk # 25.marts.2001 # BEGIN { if (CHECK=="") { CHECK="rc.conf" } VERBOSE=0; ### Read defaults into array DEFAULT="defaults/"CHECK; FS="#"; while (getline 0) { m=split($1,a,"\""); if (m==3) {linie[sprintf("%s\"%s\"",a[1],a[2])]=1; default[a[1]]=a[2];} } ###################################################### while (getline 0) { flag=1; m=split($1,a,"\""); if (m==3) {l=sprintf("%s\"%s\"",a[1],a[2]); if (l in linie) { if (VERBOSE) print "##= Is default: ",l; flag=0; } else { if (VERBOSE && a[1] in default) {print "##- Default "a[1]"\""default[a[1]]"\""}; } } if (flag) {print}; } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message