Browse Source

transform captain hook canary scripts to templates

master
Charles Reid 6 years ago
parent
commit
c3b5db300f
  1. 12
      scripts/captain-hook-canary.service.j2
  2. 47
      scripts/captain_hook_canary.sh.j2

12
scripts/captain-hook-canary.service.j2

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
[Unit]
Description=captain hook canary script
Requires=dockerpod-webhooks.service
After=dockerpod-webhooks.service
[Service]
Restart=always
ExecStart={{ webhooks_install_dir }}/scripts/captain_hook_canary.sh
ExecStop=/usr/bin/pgrep -f captain_hook_canary | /usr/bin/xargs /bin/kill
[Install]
WantedBy=default.target

47
scripts/captain_hook_canary.sh.j2

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
#!/bin/bash
: '
Captain Hook Canary Script (Template)
Note: this needs an associated systemd service.
See the services directory of the dotfiles repo.
This is a canary script for connecting
the Captain Hook container to the host
machine, and triggering tasks on the
host machine with webhooks.
The Captain Hook container mounts the
following host directory inside the
container (same location for host/container):
/tmp/triggers/
When a webhook in Captain Hook wants to
trigger an event on the host (blackbeard),
it puts a file in /tmp/triggers/.
Meanwhile, on the host, this script checks
every 10 seconds for trigger files.
Each webhook can create its own trigger file,
and this script processes each trigger differently.
'
while true
do
# bootstrap-pull captain hook
if [ -f "/tmp/triggers/push-b-captain-hook-master" ]; then
echo "CAPTAIN HOOK'S CANARY:"
echo "Running trigger to update Captain Hook on the host machine (user charles)"
sudo -H -u charles python {{ webhooks_install_dir }}/scripts/captain_hook_pull_host.py
echo "All done."
rm -f "/tmp/triggers/push-b-captain-hook-master"
touch /tmp/canary-yup-host-works
fi
sleep 10;
done
Loading…
Cancel
Save