-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·137 lines (115 loc) · 5.02 KB
/
entrypoint.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
trap stop SIGTERM SIGQUIT SIGINT SIGHUP ERR SIGKILL
stop () {
/usr/bin/watcher -c /data/watcher.ini stop
}
start () {
if [[ ! -d "/data" ]]; then
echo "Please mount a /data directory"
exit 0
elif [[ ! -e "/data/watcher.ini" ]]; then
echo "; ----------------------
; General Settings
; ----------------------
[DEFAULT]
; where to store output
logfile=/data/watcher.log
; where to save the PID file
pidfile=/data/watcher.pid
; working directory (default: '/')
working_directory=/data
; umask for the daemon. Take int value (default: 0)
umask=
; gid and uid to run the daemon. Take int values (default to current)
gid=
uid=
; ----------------------
; Job Setups
; ----------------------
;[job1]
; Directory or file to watch. Probably should be abs path.
;watch=/path/to/watcher/directory
; List of events to watch for.
; Supported events:
; 'access' - File was accessed (read) (*)
; 'attribute_change' - Metadata changed (permissions, timestamps, extended attributes, etc.) (*)
; 'write_close' - File opened for writing was closed (*)
; 'nowrite_close' - File not opened for writing was closed (*)
; 'create' - File/directory created in watched directory (*)
; 'delete' - File/directory deleted from watched directory (*)
; 'self_delete' - Watched file/directory was itself deleted
; 'modify' - File was modified (*)
; 'self_move' - Watched file/directory was itself moved
; 'move_from' - File moved out of watched directory (*)
; 'move_to' - File moved into watched directory (*)
; 'open' - File was opened (*)
; 'all' - Any of the above events are fired
; 'move' - A combination of 'move_from' and 'move_to'
; 'close' - A combination of 'write_close' and 'nowrite_close'
;
; When monitoring a directory, the events marked with an asterisk (*) above
; can occur for files in the directory, in which case the name field in the
; returned event data identifies the name of the file within the directory.
;events=create
; Comma separated list of excluded dir. Absolute path needed.
; If it is empty or absent (default) - no excluded dir is set.
;excluded=
; Comma separated list of the file extensions to the watch for.
; If it is empty or absent (default) - all extensions are watched.
;include_extensions=
; Comma separated list of file extensions to exclude from the watched files.
; If it is empty or absent (default) - no extensions are excluded.
;exclude_extensions=
; Regular expression to exclude files from the watched files by matching its name only (not full path)
; If it is empty or absent (default) - no files by name are excluded.
;exclude_re=~\$
; If it is true or absent (default), watcher will monitor directories recursively for changes
;recursive=true
; If it is true or absent (default), watcher will automatically watch new subdirectory
;autoadd=true
; The command to run. Can be any command. It's run as whatever user started watcher.
; The following wildards may be used inside command specification:
; \$\$ - dollar sign
; \$folder - watched root folder ('watch' param)
; \$watched - watched filesystem path (see above)
; \$filename - event-related file name
; \$tflags - event flags (textually)
; \$nflags - event flags (numerically)
; \$cookie - event cookie (integer used for matching move_from and move_to events, otherwise 0)
; \$job - a job (section) name
;command=subliminal \$filename -l en fr -p opensubtitles
; If it is true, watcher will run 'command' in async non-blocking manner,
; so several copies of 'command' can be executed simultaneously.
; It is set to false if absent by default.
;background=false
; If it is true or absent (default), watcher will log 'command' output (both stdout and stderr).
;log_output=true
; If 'log_output' is true - 'outfile' defines where to redirect 'command' output (both stdout and stderr).
; If it is empty or absent (default) output will be logged into daemon 'logfile'.
; \$job variable can be used here too
;outfile=/tmp/\$job.log
; The command to run when 'command' return code is equal to 0.
; Can be absent or empty.
; Warning: using this option can be a security hazard, as the
; specified command will be executed through the shell to have
; access to features such as shell pipes.
; The following wildards may be used inside command specification:
; \$output - output generated with 'command' (both stdout and stderr)
; \$job - a job (section) name
; \$host - hostname of the computer where watcher is running
;action_on_success=echo \$output | mutt -s \"watcher job \$job on \$host succeed\" root
; The command to run when 'command' return code is not equal to 0.
; Using is the same as 'action_on_success'.
;action_on_failure=echo \$output | mutt -s \"watcher job \$job on \$host failed\" root" > /data/watcher.ini.example
echo "Please edit the default 'watcher.ini.example' file to your need, rename it to "watcher.ini", and restart the container."
exit 0
else
echo "Starting watcher..."
/usr/bin/watcher -c /data/watcher.ini -v start
while [[ ! -e /data/watcher.log ]]; do
sleep 1
done
tail -f /data/watcher.log
fi
}
start