entrypoint.sh

Fri, 01 May 2020 15:27:45 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 01 May 2020 15:27:45 +0100
changeset 0
e6c11dadd985
permissions
-rwxr-xr-x

Initial commit

0
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 #!/bin/bash
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 trap 'kill %1;' SIGTERM
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 log() {
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 echo "$(date +"%F %R"): $@"
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 }
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 run_certwatch() {
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 log "Executing checks at $(date +"%F %R")..."
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 /usr/local/bin/certwatch.sh
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 case "$?" in
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 0) log "PASS: All checks passed" ;;
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 2) log "FAIL: One or more checks failed" ;;
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 *) log "ERROR: There was an error executing the checks" ;;
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 esac
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 }
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 log "Hello and welcome to certwatch!"
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 (
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 run_certwatch;
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 while sleep 86400; do
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 run_certwatch;
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 done;
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 ) &
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 wait %1
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 log "Exiting..."
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32
e6c11dadd985 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 exit 0;

mercurial