Need /bin/sh script help
Garrett Cooper
youshi10 at u.washington.edu
Wed Apr 12 20:16:22 UTC 2006
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
More information about the freebsd-questions
mailing list