setup.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # Setup of buildbot configuration. Package installation is being done by
  3. # Vagrantfile
  4. # Dependencies: buildbot, buildbot-slave, supervisor
  5. USER=$1
  6. CFG_PATH=$2
  7. DOCKER_PATH=$3
  8. BUILDBOT_PWD=$4
  9. IRC_PWD=$5
  10. IRC_CHANNEL=$6
  11. SMTP_USER=$7
  12. SMTP_PWD=$8
  13. EMAIL_RCP=$9
  14. REGISTRY_USER=${10}
  15. REGISTRY_PWD=${11}
  16. REGISTRY_BUCKET=${12}
  17. REGISTRY_ACCESS_KEY=${13}
  18. REGISTRY_SECRET_KEY=${14}
  19. BUILDBOT_PATH="/data/buildbot"
  20. SLAVE_NAME="buildworker"
  21. SLAVE_SOCKET="localhost:9989"
  22. export PATH="/bin:sbin:/usr/bin:/usr/sbin:/usr/local/bin"
  23. function run { su $USER -c "$1"; }
  24. # Exit if buildbot has already been installed
  25. [ -d "$BUILDBOT_PATH" ] && exit 0
  26. # Setup buildbot
  27. run "mkdir -p $BUILDBOT_PATH"
  28. cd $BUILDBOT_PATH
  29. run "buildbot create-master master"
  30. run "cp $CFG_PATH/master.cfg master"
  31. run "sed -i -E 's#(BUILDBOT_PWD = ).+#\1\"$BUILDBOT_PWD\"#' master/master.cfg"
  32. run "sed -i -E 's#(IRC_PWD = ).+#\1\"$IRC_PWD\"#' master/master.cfg"
  33. run "sed -i -E 's#(IRC_CHANNEL = ).+#\1\"$IRC_CHANNEL\"#' master/master.cfg"
  34. run "sed -i -E 's#(SMTP_USER = ).+#\1\"$SMTP_USER\"#' master/master.cfg"
  35. run "sed -i -E 's#(SMTP_PWD = ).+#\1\"$SMTP_PWD\"#' master/master.cfg"
  36. run "sed -i -E 's#(EMAIL_RCP = ).+#\1\"$EMAIL_RCP\"#' master/master.cfg"
  37. run "buildslave create-slave slave $SLAVE_SOCKET $SLAVE_NAME $BUILDBOT_PWD"
  38. run "echo 'export DOCKER_CREDS=\"$REGISTRY_USER:$REGISTRY_PWD\"' > $BUILDBOT_PATH/master/credentials.cfg"
  39. run "echo 'export S3_BUCKET=\"$REGISTRY_BUCKET\"' >> $BUILDBOT_PATH/master/credentials.cfg"
  40. run "echo 'export S3_ACCESS_KEY=\"$REGISTRY_ACCESS_KEY\"' >> $BUILDBOT_PATH/master/credentials.cfg"
  41. run "echo 'export S3_SECRET_KEY=\"$REGISTRY_SECRET_KEY\"' >> $BUILDBOT_PATH/master/credentials.cfg"
  42. # Patch github webstatus to capture pull requests
  43. cp $CFG_PATH/github.py /usr/local/lib/python2.7/dist-packages/buildbot/status/web/hooks
  44. # Allow buildbot subprocesses (docker tests) to properly run in containers,
  45. # in particular with docker -u
  46. run "sed -i 's/^umask = None/umask = 000/' slave/buildbot.tac"
  47. # Setup supervisor
  48. cp $CFG_PATH/buildbot.conf /etc/supervisor/conf.d/buildbot.conf
  49. sed -i -E "s/^chmod=0700.+/chmod=0770\nchown=root:$USER/" /etc/supervisor/supervisord.conf
  50. kill -HUP $(pgrep -f "/usr/bin/python /usr/bin/supervisord")