Captain Hook is a webhook server running flask-gitea-webserver #blackbeard https://pages.charlesreid1.com/b-captain-hook

push-b-captain-hook-master 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env python
  2. from datetime import datetime
  3. """
  4. Captain Hook Webhook:
  5. Captain Hook Self-Updater
  6. This is a Captain Hook webhook that operates
  7. on Captain Hook itself. This webhook places
  8. a trigger file in the following directory:
  9. /tmp/triggers
  10. On the host machine (blackbeard), a script
  11. will detect this and run a task hard-coded
  12. into Captain Hook's Canary.
  13. """
  14. repo = "b-captain-hook"
  15. org = "bots"
  16. branch = "master"
  17. action = 'push'
  18. name = '%s'%(repo)
  19. git_url = 'https://git.charlesreid1.com/%s/%s.git'%(org,repo)
  20. logfile = '/tmp/{action}-{name}-{branch}.log'.format(action=action,
  21. name=name,
  22. branch=branch)
  23. with open(logfile,'w') as f:
  24. f.write("\n")
  25. f.write("-"*40)
  26. f.write(datetime.now().strftime("%Y-%m-%d_%H-%M-%S"))
  27. f.write("\n")
  28. import subprocess
  29. import os
  30. # ------------------
  31. # this one is pretty easy:
  32. # we just touch the file
  33. #
  34. # /tmp/triggers/push-b-captain-hook-master
  35. #
  36. # /tmp/triggers is mounted to the
  37. # same location on the host dir.
  38. fname = '/tmp/triggers/push-b-captain-hook-master'
  39. f.write("About to touch the file: %s\n"%(fname))
  40. with open(fname, 'w') as triggerfile:
  41. triggerfile.write('SANTAMONICA')