Advertisement
stronk7

Untitled

Oct 21st, 2021
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Don't stop on error
  4. set +e
  5.  
  6. # Move to base directory
  7. pushd "$(git rev-parse --show-toplevel)" > /dev/null
  8.  
  9. # Calculate path to config.yml file
  10. pathtoconfig=$(php -r 'define("CLI_SCRIPT", true);
  11. include "config.php";
  12. include("lib/behat/classes/behat_command.php");
  13. echo behat_command::get_behat_dir();')/behat.yml
  14.  
  15. # Add quotes back to show the complete command
  16. forcequoted="[[:space:]]|[&,]"
  17. quoted=
  18. for i in "$@"
  19. do
  20. if [[ ${i} =~ ${forcequoted} ]]; then
  21. i=\'${i}\'
  22. fi
  23. quoted="${quoted} ${i}"
  24. done
  25.  
  26. # no password is required because (sudo visudo) has, AFTER the admin entries!:
  27. # (or also in a /etc/sudoers.d/stronk7_as_www file, to make it persistent - else it's gone on every upgrade)
  28. # stronk7 ALL=(_www) NOPASSWD: ALL
  29. # (allow to run everything as _www without password to stronk7)
  30.  
  31. # Run behat passing all params straight to it
  32. echo
  33. echo "Command: vendor/bin/behat --config ${pathtoconfig} ${quoted}"
  34. echo
  35. sudo -u _www vendor/bin/behat --config "${pathtoconfig}" "$@"
  36. status=$?
  37.  
  38. # Move back to original directory
  39. popd > /dev/null
  40. exit $status
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement