diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4a181d2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +version: 2 +updates: +- package-ecosystem: gomod + directory: "/entrypoint" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 + ignore: + - dependency-name: github.com/otiai10/copy + versions: + - 1.4.2 + - 1.5.1 +- package-ecosystem: docker + directory: "/" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7c20340 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,22 @@ +name: Build + +on: + push: + branches: + - master + pull_request: {} + +jobs: + build: + name: build + runs-on: ubuntu-latest + + steps: + - name: Checkout HEAD + uses: actions/checkout@v1 + + - name: Icinga 2 + run: git clone https://github.com/Icinga/icinga2.git + + - name: Build + run: ./build.bash ./icinga2 diff --git a/README.md b/README.md index 51a347a..e70a816 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,10 @@ To configure it, do one of the following: on which configuration files there are. * Provide environment variables as shown above. +To notify by e-mail, provide an [msmtp configuration] - either +by mounting the `/etc/msmtprc` file or by specifying the desired content +of `~icinga/.msmtprc` via the environment variable `MSMTPRC`. + ### Environment variables Most of the following variables correspond to @@ -107,7 +111,15 @@ git clone https://github.com/Icinga/icinga2.git ./build.bash ./icinga2 ``` +In order to run the script on macOS, [coreutils] must be installed: + +* Install [Homebrew] +* Run `brew install coreutils` + [Icinga 2]: https://github.com/Icinga/icinga2 [Docker]: https://www.docker.com [Icinga 2 configuration documentation]: https://icinga.com/docs/icinga2/latest/doc/04-configuration/ +[msmtp configuration]: https://wiki.archlinux.org/index.php/Msmtp [node setup command documentation]: https://icinga.com/docs/icinga2/latest/doc/06-distributed-monitoring/#node-setup +[Homebrew]: https://brew.sh/ +[coreutils]: https://formulae.brew.sh/formula/coreutils diff --git a/deps.Dockerfile b/deps.Dockerfile index 73734e4..2417ed1 100644 --- a/deps.Dockerfile +++ b/deps.Dockerfile @@ -59,7 +59,7 @@ RUN cd /check_postgres ;\ FROM debian:buster-slim -RUN ["/bin/bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y dumb-init libboost-{context,coroutine,date-time,filesystem,program-options,regex,system,thread}1.67 libedit2 libmariadb3 libmoosex-role-timer-perl libpq5 libssl1.1 mailutils monitoring-plugins openssh-client openssl postfix libcap2-bin; apt-get clean; rm -vrf /var/lib/apt/lists/*"] +RUN ["/bin/bash", "-exo", "pipefail", "-c", "apt-get update; DEBIAN_FRONTEND=noninteractive apt-get install --no-install-{recommends,suggests} -y ca-certificates curl dumb-init libboost-{context,coroutine,date-time,filesystem,program-options,regex,system,thread}1.67 libcap2-bin libedit2 libmariadb3 libmoosex-role-timer-perl libpq5 libssl1.1 mailutils monitoring-plugins msmtp{,-mta} openssh-client openssl; apt-get clean; rm -vrf /var/lib/apt/lists/*"] COPY --from=entrypoint /entrypoint/entrypoint /entrypoint diff --git a/entrypoint/go.mod b/entrypoint/go.mod index f099074..31dad30 100644 --- a/entrypoint/go.mod +++ b/entrypoint/go.mod @@ -3,6 +3,6 @@ module entrypoint go 1.14 require ( - github.com/otiai10/copy v1.4.0 + github.com/otiai10/copy v1.5.1 golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 ) diff --git a/entrypoint/go.sum b/entrypoint/go.sum index addf468..1d8db75 100644 --- a/entrypoint/go.sum +++ b/entrypoint/go.sum @@ -4,6 +4,10 @@ github.com/otiai10/copy v1.3.0 h1:Z0OIFgj8hyI18YVzgPXpp652vv0NggCGWaNKSPN9KU8= github.com/otiai10/copy v1.3.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= github.com/otiai10/copy v1.4.0 h1:S9XdWuTRJ54QDIrdbPEVl/1lMwF5xOjd5AvF9S866y8= github.com/otiai10/copy v1.4.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= +github.com/otiai10/copy v1.5.0 h1:SoXDGnlTUZoqB/wSuj/Y5L6T5i6iN4YRAcMCd+JnLNU= +github.com/otiai10/copy v1.5.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= +github.com/otiai10/copy v1.5.1 h1:a/cs2E1/1V0az8K5nblbl+ymEa4E11AfaOLMar8V34w= +github.com/otiai10/copy v1.5.1/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= diff --git a/entrypoint/main.go b/entrypoint/main.go index c4bb0da..77b50bd 100644 --- a/entrypoint/main.go +++ b/entrypoint/main.go @@ -19,6 +19,7 @@ import ( const ca = "/var/lib/icinga2/certs/ca.crt" const crtMode = 0640 +const mSmtpRc = "/var/lib/icinga2/.msmtprc" func main() { if err := entrypoint(); err != nil { @@ -122,6 +123,14 @@ func entrypoint() error { } } + if mSmtpCfg, ok := os.LookupEnv("MSMTPRC"); ok { + logf(info, "Writing %#v", mSmtpRc) + + if errWF := ioutil.WriteFile(mSmtpRc, []byte(mSmtpCfg), 0644); errWF != nil { + return errWF + } + } + command = append([]string{"dumb-init", "-c", "--"}, command...) }