How can I check for root privileges with an Ant build script? I tried doing it with the shellscript task like
<shellscript shell="bash">
if [[ `whoami` != 'root' ]]; then
echo "You need to be root to install ooplss";
exit 1
fi
</shellscript>
But this won’t stop the execution of the script.
Any other ideas?
The shellscript task is an extension of the exec task. You should be able to specify
failonerrorto make the build process fail if the script fails:It should however be possible to do without a shell script; the following is untested: