-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
37 lines (33 loc) · 1.06 KB
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
#
# Script options (exit script on command fail).
#
set -e
CURL_OPTIONS_DEFAULT=
SIGNAL_DEFAULT="SIGHUP"
INOTIFY_EVENTS_DEFAULT="create,delete,modify,move"
INOTIFY_OPTONS_DEFAULT='--monitor --exclude=*.sw[px]'
#
# Display settings on standard out.
#
echo "inotify settings"
echo "================"
echo
echo " Container: ${CONTAINER}"
echo " Volumes: ${VOLUMES}"
echo " Curl_Options: ${CURL_OPTIONS:=${CURL_OPTIONS_DEFAULT}}"
echo " Signal: ${SIGNAL:=${SIGNAL_DEFAULT}}"
echo " Inotify_Events: ${INOTIFY_EVENTS:=${INOTIFY_EVENTS_DEFAULT}}"
echo " Inotify_Options: ${INOTIFY_OPTONS:=${INOTIFY_OPTONS_DEFAULT}}"
echo
#
# Inotify part.
#
echo "[Starting inotifywait...]"
inotifywait -e ${INOTIFY_EVENTS} ${INOTIFY_OPTONS} "${VOLUMES}" | \
while read -r notifies;
do
echo "$notifies"
echo "notify received, sent signal ${SIGNAL} to container ${CONTAINER}"
curl ${CURL_OPTIONS} -X POST --unix-socket /var/run/docker.sock http:/containers/${CONTAINER}/kill?signal=${SIGNAL} > /dev/stdout 2> /dev/stderr
done