A possibly working admin email thing

This commit is contained in:
Asaf Gartner 2021-09-04 21:21:11 +03:00
parent ed53d71b16
commit 39efde5369
6 changed files with 30 additions and 0 deletions

5
server/adminmailer.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
/home/hmn/hmn/adminmailer/adminmailer "[$1] Status changed" <<ERRMAIL
$(service "$1" status)
ERRMAIL

View File

@ -28,6 +28,7 @@ LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
OnFailure=status-email@%n.service
[Install]
WantedBy=multi-user.target

View File

@ -10,6 +10,7 @@ ExecStart=/home/hmn/hmn/cinera/start.sh
ExecStop=/home/hmn/hmn/cinera/stop.sh
PIDFile=/home/hmn/hmn/cinera/data/cinera.pid
Restart=always
OnFailure=status-email@%n.service
[Install]
WantedBy=multi-user.target

View File

@ -8,6 +8,7 @@ Group=hmn
ExecStart=/home/hmn/bin/hmn
Restart=always
TimeoutStopSec=15
OnFailure=status-email@%n.service
[Install]
WantedBy=multi-user.target

View File

@ -199,14 +199,18 @@ if [ $checkpoint -lt 100 ]; then
cp /home/hmn/hmn/server/caddy.service /etc/systemd/system/caddy.service
cp /home/hmn/hmn/server/hmn.service /etc/systemd/system/hmn.service
cp /home/hmn/hmn/server/cinera.service /etc/systemd/system/cinera.service
cp /home/hmn/hmn/server/status-email@.service /etc/systemd/system/status-email@.service
chmod 644 /etc/systemd/system/caddy.service
chmod 644 /etc/systemd/system/hmn.service
chmod 644 /etc/systemd/system/cinera.service
chmod 644 /etc/systemd/system/status-email@.service
cp /home/hmn/hmn/server/logrotate /etc/logrotate.d/hmn
cp /home/hmn/hmn/src/config/config.go.example /home/hmn/hmn/src/config/config.go
cp /home/hmn/hmn/server/hmn.conf.example /home/hmn/hmn/server/hmn.conf
cp /home/hmn/hmn/server/deploy.conf.example /home/hmn/hmn/server/deploy.conf
cp /home/hmn/hmn/adminmailer/config.go.example /home/hmn/hmn/adminmailer/config.go
cp /home/hmn/hmn/cinera/cinera.conf.sample /home/hmn/hmn/cinera/cinera.conf
chown hmn:hmn /home/hmn/hmn/src/config/config.go
chown hmn:hmn /home/hmn/hmn/server/hmn.conf
@ -303,6 +307,16 @@ ${BLUE_BOLD}s3cmd${RESET}: /home/hmn/.s3cfg
Add the DigitalOcean Spaces credentials, and ensure that the bucket info is correct.
${BLUE_BOLD}Admin mailer${RESET}: /home/hmn/hmn/adminmailer/config.go
First make sure you have Go on your path:
source ~/.bashrc
Fill in the config file and build the mailer:
cd /home/hmn/hmn/adminmailer
go build .
${BLUE_BOLD}===== Next steps =====${RESET}

View File

@ -0,0 +1,8 @@
[Unit]
Description=Status email for %i
[Service]
Type=oneshot
ExecStart=/home/hmn/hmn/server/adminmailer.sh %i
User=root
Group=systemd-journal