On Jan 3, 2005, at 4:34 PM, Erik Norgaard wrote:

Eric F Crist wrote:

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

I don't know if you're on 5.x, nor whether you use ipfw, ipfilter or pf - I wrote a replacement for ipfilter as I got dizzy trying to maintain a too long ruleset so I wanted to split it into multiple files.


On 5.x things get a lot simpler. In /etc/rc.d there are plenty of scripts to look at - don't look at rc.firewall.

[lots of good info snipped]

Finally, don't use bash, use /bin/sh and nothing else, you don't know if bash is available when your script run.

Regarding your script, which I got deleted from this mail (sorry), I think there is an error:

> if [ "$grog_firewall_enable" = "YES" ]

this "=" is assignment and will always evaulate to true. You want

if [ "$grog_firewall_enable" -eq "YES" ]

I'm not sure if "==" works, but always be careful you're not using asignment in if-statements.

either "-eq" or "=" will work in /bin/sh scripts. Assignment is done like this


foo=bar

so you have to be careful about quotes and spacing. (Learning PHP was hard because there you DO have to use == and not =

Eric - see 'man test' for the proper ways to do greater-than, less-than, greater-or-equal, etc in sh

TjL

ps - re: this quote:

On Jan 3, 2005, at 4:34 PM, Erik Norgaard wrote:

rc.subr also contains a "checkyesno" function answering your question above - however, it is normal to check "[Yy][Ee][Ss]" and treat everything else as a no. After all, what are you gonna do if you only accept "yes" or "no" but some one typed "yeah right"? You must have a default action.

Yeah, I had a Comp. Sci professor who always typed his name in whenever we wrote a program that asked for user input, so if you were expecting a Y|y|n|N and got "cupper" he wanted to know what you planned to do with that.


_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to