Date: Sun, 25 Mar 2001 03:48:59 +0200 (CEST) From: Leif Neland <leifn@neland.dk> To: freebsd-current@freebsd.org Subject: rc.conf duplicating defaults/rc.conf Message-ID: <Pine.BSF.4.21.0103250337020.1899-100000@arnold.neland.dk>
next in thread | raw e-mail | index | archive | help
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 <DEFAULT >0) { m=split($1,a,"\""); if (m==3) {linie[sprintf("%s\"%s\"",a[1],a[2])]=1; default[a[1]]=a[2];} } ###################################################### while (getline <CHECK >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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0103250337020.1899-100000>