you could try something like this:
Xvfb :1 -screen 0 800x800x24 &
# saves the PID of the Xvfb process so we can kill it when we're doen with afni
x11DisplayPID=$!
x11DisplayArgument="-display :1.0"
## then you can run afni like this
## replace $otherCommandsGoHere with the other commands you want afni to run
afni $x11DisplayArgument $otherCommandsGoHere
if [[ -n $displayPID ]] ; then
kill $x11DisplayPID
fi