I'm writing a System V init script for a custom application. I'm basically just reverse engineering an existing script. I have a question on the Postfix init script on RHEL AS 3.0. I'm just using Postfix as an example, a lot of them do the same thing. I know Perl scripting much better than bash scripting.
In the line "/usr/bin/postfix start 2>/dev/null 1>&2 && success || failure", what does the "&& success || failure" mean? I know that && means to only execute if the previous command was successful and I know that || means "or", but whats with the 'success' and 'failure'? They aren't system commands or anything.
At the end where it says...
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
echo
return $RETVAL
...they are saying "if the return value is 0, then create the file /var/lock/subsys/postfix". Why do they create this file? It doesn't seem to serve any purpose. Also, it then says "echo" on a line by itself, and then "return $RETVAL". What is the purpose of that?
Thanks,
Chris
Code:
start() {
# Start daemons.
echo -n "Starting postfix: "
/usr/sbin/postalias /etc/postfix/aliases
/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
echo
return $RETVAL
}
In the line "/usr/bin/postfix start 2>/dev/null 1>&2 && success || failure", what does the "&& success || failure" mean? I know that && means to only execute if the previous command was successful and I know that || means "or", but whats with the 'success' and 'failure'? They aren't system commands or anything.
At the end where it says...
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
echo
return $RETVAL
...they are saying "if the return value is 0, then create the file /var/lock/subsys/postfix". Why do they create this file? It doesn't seem to serve any purpose. Also, it then says "echo" on a line by itself, and then "return $RETVAL". What is the purpose of that?
Thanks,
Chris