Skip to content
Snippets Groups Projects
Commit 52ebf7d3 authored by Erick Hitter's avatar Erick Hitter
Browse files

Switch to pure systemd

parent bca3aa0b
No related branches found
No related tags found
No related merge requests found
......@@ -9,8 +9,9 @@ Pipe logs to Mattermost or Slack webhooks
# Installation
1. `git clone https://git.ethitter.com/debian/eth-log-alerting.git /usr/local/eth-log-alerting`
2. `cp /usr/local/eth-log-alerting/init.sh /etc/init.d/eth_log_alerting`
2. `cp /usr/local/eth-log-alerting/systemd.service /etc/systemd/system/eth_log_alerting.service`
3. `cp /usr/local/eth-log-alerting/defaults /etc/default/eth_log_alerting`
4. Edit `/etc/default/eth_log_alerting`
5. `sudo update-rc.d eth_log_alerting defaults`
6. `/etc/init.d/eth_log_alerting start`
5. `systemctl daemon-reload`
6. `systemctl enable eth_log_alerting.service`
6. `systemctl start eth_log_alerting.service`
#!/bin/sh
### BEGIN INIT INFO
# Provides: eth_log_alerting
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Log entry alerting
### END INIT INFO
set -e
. /lib/lsb/init-functions
DAEMON="/usr/local/eth-log-alerting/pipe.sh"
NAME="eth_log_alerting"
DESC="log alerting"
DAEMON_OPTIONS=
PID="/run/$NAME.pid"
# Check if DAEMON binary exist
[ -f $DAEMON ] || exit 0
[ -f "/etc/default/$NAME" ] && . /etc/default/$NAME
daemon_not_configured () {
if [ "$1" != "stop" ]
then
log_daemon_msg "Configuration required! Update /etc/default/$NAME"
exit 0
fi
}
config_checks () {
# Check that log is configured
if [ -z "$DAEMON_OPTIONS" ]
then
daemon_not_configured "$1"
fi
}
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
config_checks "$1"
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $DAEMON_OPTIONS 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
if start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet --pidfile $PID 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
restart)
log_daemon_msg "Restarting $DESC" "$NAME"
start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet --pidfile $PID 1>/dev/null
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $DAEMON_OPTIONS 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
status)
status_of_proc -p $PID $DAEMON $NAME
;;
*)
log_action_msg "Usage: /etc/init.d/$NAME {start|stop|restart|status}"
;;
esac
exit 0
#!/bin/sh
DAEMON="/usr/local/eth-log-alerting/pipe.sh"
NAME="eth_log_alerting"
# Check if DAEMON binary exist
[ -f $DAEMON ] || exit 0
# Check if config exists
if [ -f "/etc/default/$NAME" ]
then
. /etc/default/$NAME
else
exit 0
fi
# On with it!
$DAEMON $DAEMON_OPTIONS
[Unit]
After=network.target
[Service]
ExecStart=/usr/local/eth-log-alerting/service.sh
[Install]
WantedBy=default.target
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment