Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Jan 2005 14:49:19 -0600
From:      Eric F Crist <ecrist@secure-computing.net>
To:        Timothy Luoma <lists@tntluoma.com>
Cc:        FreeBSD-Questions Questions <freebsd-questions@freebsd.org>
Subject:   Re: my lame attempt at a shell script...
Message-ID:  <F0BE3E23-5DC8-11D9-B56F-000D9333E43C@secure-computing.net>
In-Reply-To: <6074EB8D-5DC6-11D9-89A5-000D93AD26C8@tntluoma.com>
References:  <06DDB71C-5DB4-11D9-B56F-000D9333E43C@secure-computing.net> <15416223037.20050103193803@hexren.net> <6074EB8D-5DC6-11D9-89A5-000D93AD26C8@tntluoma.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail-8--223375354
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII; format=flowed

On Jan 3, 2005, at 2:30 PM, Timothy Luoma wrote:

>
> On Jan 3, 2005, at 1:38 PM, Hexren wrote:
>
>> I am not that great at bash but look in /etc/rc.firewall for the line
>> where it says: ". /etc/defaults/rc.conf" I think this line includes
>> /etc/rc.conf into the running script and as code in rc.conf is
>> evaluated at the time it is included, all the variables defined in
>> rc.conf are created at that time in your script. (you do realize that
>> for example gateway_enable="YES" is an variable declaration with
>> initialization when read as shell script ?)
>
> Hexren is right, ". /some/file" does mean "include /some/file" 
> (sometimes called "source")
>
> #!/bin/sh
>
> . /etc/rc.conf
>
> if [ "$gateway_enable" = "YES" ]
> then
>         echo "yes, this machine is a gateway"
> else
>         echo "no, this is not a gateway"
> fi
>
> exit 0
>
> TjL

First off, let me thank you very much for the massive amount of 
information you've given me thus far.  Do me a favor and tell me if 
this syntax is correct:

#!/bin/sh

. /etc/rc.conf

if [ "$grog_firewall_enable" = "YES" ]
then
         echo "Firewall enabled."
elif [ "$grog_firewall_enable" = "NO" ]
then
         echo "Firewall disabled."
fi

exit 0

This seems to work when I try it at a command line.  There's one other 
question. How would I add the following line (please correct syntax):

elif [ "$grog_firewall_enable" <> "YES" or "NO" ]
then
		echo "Syntax error in /etc/rc.conf file. grog_firewall_enable must be 
YES or NO"
fi


Thanks again for all the help.
_______________________________________________________
Eric F Crist                  "I am so smart, S.M.R.T!"
Secure Computing Networks              -Homer J Simpson

--Apple-Mail-8--223375354
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iEYEARECAAYFAkHZr9AACgkQRAAY9knOW+qmVACeJyxNkDR27xF5BM7OLhuw6JAY
gOMAnR2q6d4rjHAzWcjSTXv9O1HATNqe
=jr20
-----END PGP SIGNATURE-----

--Apple-Mail-8--223375354--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F0BE3E23-5DC8-11D9-B56F-000D9333E43C>