From cb037d9d914b49a4482c05b6b726e31ffa5877ad Mon Sep 17 00:00:00 2001 From: Victor LABORIE Date: Fri, 24 Feb 2017 14:35:56 +0100 Subject: [PATCH] tomcat-instance: send mail in shell script not in systemd unit --- tomcat-instance/files/tomcat.service | 1 - tomcat-instance/templates/bin/shutdown.sh | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tomcat-instance/files/tomcat.service b/tomcat-instance/files/tomcat.service index c54eb4be..0a5a22d9 100644 --- a/tomcat-instance/files/tomcat.service +++ b/tomcat-instance/files/tomcat.service @@ -9,7 +9,6 @@ EnvironmentFile=%h/conf/env UMask=0002 ExecStart=/usr/share/tomcat7/bin/startup.sh ExecStop=/usr/share/tomcat7/bin/shutdown.sh -ExecStopPost=/bin/sh -c date | /usr/bin/mail -s "%H/%u : Shutdown instance" %u Type=forking [Install] diff --git a/tomcat-instance/templates/bin/shutdown.sh b/tomcat-instance/templates/bin/shutdown.sh index 95544a5d..3daf3be6 100755 --- a/tomcat-instance/templates/bin/shutdown.sh +++ b/tomcat-instance/templates/bin/shutdown.sh @@ -2,3 +2,6 @@ # alias for compatibility sudo -iu {{ tomcat_instance_name }} systemctl --user stop tomcat +{% if tomcat_instance_mail is defined %} +/bin/sh -c date | /usr/bin/mail -s {{ inventory_hostname }}/{{ tomcat_instance_name }} : Shutdown instance {{ tomcat_instance_mail }} +{% endif %}