From babb114b66d3bbdbba9faa69bb1fdbae49f20172 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 19 Jun 2015 13:25:51 +0200 Subject: update examples and add systemd unit --- Makefile | 7 ++++--- README.md | 13 ++++++++++--- desktop/journal-notify-crit-alert-emerg.desktop | 9 +++++++++ desktop/journal-notify-dhcpd.desktop | 9 +++++++++ desktop/journal-notify-sshd.desktop | 9 +++++++++ examples/journal-notify-crit-alert-emerg.desktop | 9 --------- examples/journal-notify-dhcpd.desktop | 9 --------- examples/journal-notify-sshd.desktop | 9 --------- execute/mail.sh | 3 +++ systemd/journal-notify-sshd.service | 9 +++++++++ 10 files changed, 53 insertions(+), 33 deletions(-) create mode 100755 desktop/journal-notify-crit-alert-emerg.desktop create mode 100755 desktop/journal-notify-dhcpd.desktop create mode 100755 desktop/journal-notify-sshd.desktop delete mode 100755 examples/journal-notify-crit-alert-emerg.desktop delete mode 100755 examples/journal-notify-dhcpd.desktop delete mode 100755 examples/journal-notify-sshd.desktop create mode 100644 systemd/journal-notify-sshd.service diff --git a/Makefile b/Makefile index 9230401..e3d117d 100644 --- a/Makefile +++ b/Makefile @@ -29,11 +29,12 @@ install: install-bin install-doc install-bin: journal-notify $(INSTALL) -D -m0755 journal-notify $(DESTDIR)/usr/bin/journal-notify - $(INSTALL) -D -m0755 examples/journal-notify-crit-alert-emerg.desktop $(DESTDIR)/usr/share/journal-notify/examples/journal-notify-crit-alert-emerg.desktop - $(INSTALL) -D -m0755 examples/journal-notify-dhcpd.desktop $(DESTDIR)/usr/share/journal-notify/examples/journal-notify-dhcpd.desktop - $(INSTALL) -D -m0755 examples/journal-notify-sshd.desktop $(DESTDIR)/usr/share/journal-notify/examples/journal-notify-sshd.desktop + $(INSTALL) -D -m0755 desktop/journal-notify-crit-alert-emerg.desktop $(DESTDIR)/usr/share/journal-notify/desktop/journal-notify-crit-alert-emerg.desktop + $(INSTALL) -D -m0755 desktop/journal-notify-dhcpd.desktop $(DESTDIR)/usr/share/journal-notify/desktop/journal-notify-dhcpd.desktop + $(INSTALL) -D -m0755 desktop/journal-notify-sshd.desktop $(DESTDIR)/usr/share/journal-notify/desktop/journal-notify-sshd.desktop $(INSTALL) -D -m0755 execute/echo.sh $(DESTDIR)/usr/share/journal-notify/execute/echo.sh $(INSTALL) -D -m0755 execute/mail.sh $(DESTDIR)/usr/share/journal-notify/execute/mail.sh + $(INSTALL) -D -m0755 systemd/journal-notify-sshd.service $(DESTDIR)/usr/share/journal-notify/systemd/journal-notify-sshd.service install-doc: README.html $(INSTALL) -D -m0644 README.md $(DESTDIR)/usr/share/doc/journal-notify/README.md diff --git a/README.md b/README.md index 52b97a7..96f3bec 100644 --- a/README.md +++ b/README.md @@ -77,10 +77,17 @@ your executable understands these options: * *-m*: message Additionally example desktop files are installed to -`/usr/share/journal-notify/examples`. You should copy them to +`/usr/share/journal-notify/desktop/`. You should copy them to `~/.config/autostart/` to enable autostart or create your own desktop files -there. Example execute scripts are installed to -`/usr/share/journal-notify/execute/`. +there. + +Example execute scripts are installed to `/usr/share/journal-notify/execute/`. +Review and update them before execution, for example you should replace the +mail address in `mail.sh` with your own one. + +Example systemd units are installed to `/usr/share/journal-notify/systemd/`. +To use them copy to `/etc/systemd/system/` and `systemctl enable`. Again, make +sure to change unit file and script for your needs! ### Upstream diff --git a/desktop/journal-notify-crit-alert-emerg.desktop b/desktop/journal-notify-crit-alert-emerg.desktop new file mode 100755 index 0000000..ddcd27f --- /dev/null +++ b/desktop/journal-notify-crit-alert-emerg.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=journal-notify-crit-alert-emerg +GenericName=Journal-Notify Critical, Alert & Emergency +Comment=Notify about log with priority Critical, Alert & Emergency +Exec=journal-notify -m PRIORITY=0 -m PRIORITY=1 -m PRIORITY=2 -i dialog-warning +StartupNotify=false +Terminal=false +Type=Application +Categories= diff --git a/desktop/journal-notify-dhcpd.desktop b/desktop/journal-notify-dhcpd.desktop new file mode 100755 index 0000000..f74b67a --- /dev/null +++ b/desktop/journal-notify-dhcpd.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=journal-notify-dhcpd +GenericName=Journal-Notify DHCPD +Comment=Notify about DHCP activities +Exec=journal-notify -m SYSLOG_IDENTIFIER=dhcpd -e -r "^DHCPN?ACK" -i network-wired +StartupNotify=false +Terminal=false +Type=Application +Categories= diff --git a/desktop/journal-notify-sshd.desktop b/desktop/journal-notify-sshd.desktop new file mode 100755 index 0000000..efedcbf --- /dev/null +++ b/desktop/journal-notify-sshd.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=journal-notify-sshd +GenericName=Journal-Notify SSHD +Comment=Notify about SSH activities +Exec=journal-notify -m SYSLOG_IDENTIFIER=sshd -e -r "^(error:|Accepted)" -i security-high +StartupNotify=false +Terminal=false +Type=Application +Categories= diff --git a/examples/journal-notify-crit-alert-emerg.desktop b/examples/journal-notify-crit-alert-emerg.desktop deleted file mode 100755 index ddcd27f..0000000 --- a/examples/journal-notify-crit-alert-emerg.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=journal-notify-crit-alert-emerg -GenericName=Journal-Notify Critical, Alert & Emergency -Comment=Notify about log with priority Critical, Alert & Emergency -Exec=journal-notify -m PRIORITY=0 -m PRIORITY=1 -m PRIORITY=2 -i dialog-warning -StartupNotify=false -Terminal=false -Type=Application -Categories= diff --git a/examples/journal-notify-dhcpd.desktop b/examples/journal-notify-dhcpd.desktop deleted file mode 100755 index f74b67a..0000000 --- a/examples/journal-notify-dhcpd.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=journal-notify-dhcpd -GenericName=Journal-Notify DHCPD -Comment=Notify about DHCP activities -Exec=journal-notify -m SYSLOG_IDENTIFIER=dhcpd -e -r "^DHCPN?ACK" -i network-wired -StartupNotify=false -Terminal=false -Type=Application -Categories= diff --git a/examples/journal-notify-sshd.desktop b/examples/journal-notify-sshd.desktop deleted file mode 100755 index efedcbf..0000000 --- a/examples/journal-notify-sshd.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=journal-notify-sshd -GenericName=Journal-Notify SSHD -Comment=Notify about SSH activities -Exec=journal-notify -m SYSLOG_IDENTIFIER=sshd -e -r "^(error:|Accepted)" -i security-high -StartupNotify=false -Terminal=false -Type=Application -Categories= diff --git a/execute/mail.sh b/execute/mail.sh index 2d757db..3b797c1 100755 --- a/execute/mail.sh +++ b/execute/mail.sh @@ -19,6 +19,9 @@ while getopts "i:p:m:" opt; do esac done +# WARNING: Do NOT use this unmodified! +# Please replace mail address with your own. + mail -s "[${PRIORITY}] ${IDENTIFIER}" mail@example.com <<< "${MESSAGE}" exit 0 diff --git a/systemd/journal-notify-sshd.service b/systemd/journal-notify-sshd.service new file mode 100644 index 0000000..772fbe2 --- /dev/null +++ b/systemd/journal-notify-sshd.service @@ -0,0 +1,9 @@ +[Unit] +Description=Notify about SSHD journal log entries + +[Service] +Type=simple +ExecStart=/usr/bin/journal-notify -m SYSLOG_IDENTIFIER=sshd -e -r "^(error:|Accepted)" -X /path/to/updated/execute/mail.sh + +[Install] +WantedBy=multi-user.target -- cgit v1.2.3-70-g09d2