From owner-freebsd-questions@FreeBSD.ORG Wed Apr 12 20:16:22 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4552416A405 for ; Wed, 12 Apr 2006 20:16:22 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout4.cac.washington.edu (mxout4.cac.washington.edu [140.142.33.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id 00BF343D66 for ; Wed, 12 Apr 2006 20:16:18 +0000 (GMT) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.32.139]) by mxout4.cac.washington.edu (8.13.6+UW06.03/8.13.5+UW06.03) with ESMTP id k3CKGHW0024041 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 12 Apr 2006 13:16:18 -0700 X-Auth-Received: from [128.208.5.99] (nilakantha.cs.washington.edu [128.208.5.99]) (authenticated authid=youshi10) by smtp.washington.edu (8.13.6+UW06.03/8.13.6+UW06.03) with ESMTP id k3CKGHna004733 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Apr 2006 13:16:17 -0700 Message-ID: <443D6011.1040500@u.washington.edu> Date: Wed, 12 Apr 2006 13:16:17 -0700 From: Garrett Cooper User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' Subject: Re: Need /bin/sh script help X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Apr 2006 20:16:22 -0000 Garrett Cooper wrote: > Hello again all, > Just making a series of sh scripts to help automate updating and > whatnot of my fileserver (since I am trying to avoid having mistakes > occur with my system, and maybe help the community out a bit by > providing some decent means of updating their own machines), and I was > wondering if anyone could help me out with the following script I've > developing (the grep if statements are incorrect..): > > #!/bin/sh > # > > KC=""; > > cd /usr/src; > > if [ -n `grep -e s/KERNCONF=/ /etc/make.conf` ] # want to look for > KERNCONF in /etc/make.conf > then > echo "enter in the kernel conf file full pathname:"; > read KERNCONF; > KC="KERNCONF=$KERNCONF"; > fi > > if [ -n `grep -e s/NO_CLEAN=*yes*/ /etc/make.conf` ] // want to look > for NO_CLEAN in /etc/make.conf -- is this really necessary? > then > cd sys; > echo "cleaning sources" > make clean; > make cleandir; > cd ..; > fi > > echo "building kernel"; > make buildkernel $KC; > > echo "installing kernel"; > make installkernel $KC; > > echo "kernel compile complete. reboot to try new kernel"; > > TIA, > -Garrett > Thank you all for the replies and the advice. I still need to fix the grepping, but I hope that any and all problems will be resolved soon once I stick my mind to it. As for what worked and was changed, what didn't, and why I am doing this: What worked/was changed: -Removing C++ style comment. Lol. -Adding in a loop for read so the kernconf variable is not set to null. What didn't work: -Using make -V (it came up with nothing... oddly enough even though the manpage said it would work). -grep call when I didn't redirect stuff to stderr (suppose I should do that). Why I am doing this: If you're probably reading the mailing list from time to time, you'll have noticed I had some issues last week with cvsup and my system sources. I've basically come to the conclusion that the cause for my issue is the fact that I had a cron job which would update my system/kernel sources, as well as my ports, and my system/kernel sources were synced DURING a build, which lead to quite a few issues with the build and installworld, I discovered after rebooting the machine the next morning (no errors were encountered though, which was odd). So, in order to scratch the itch, persay, that exists with cvsup and building ports/compiling system stuff, I have created a script which does 'lock' a process, if noted correctly, with a 'semaphore lockfile'. Maybe a call to ps aux would be better, but I found that dealing with a lockfile system would be a much easier way to solve things. Todo Plan: Add an rc-script or something that will run in single-user mode which will help with mergemaster. People should be at the machine when doing this, and my scripts were originally designed so that a person could just run the script and it would do function X on a timed basis (say as a cron job). These scripts aren't meant to replace any resources; they're just here to help automate junk and ensure that things DO get done properly and things DO get updated, with less typing and command memorizing for the admin (I will properly annotate which chapters in the handbook to use and manpages to read for a more in depth reference of what the script does and how it does it). Furthermore, I plan on possibly coming out with a more up to date installcd setup that would have an 'admin pack' as I would call it, or apache, bind9, perl, mysql, ipfw, samba, etc, properly configured with a set of CGI pages that would help simplify system management for people (I am doing this as a project for the house/apt I'm living in since they need a NAT box with extras). So, that's what I have in mind. Questions, comments :) ? -Garrett