Set up separate log files for different services

This commit is contained in:
Andris Reinman 2020-03-16 12:54:47 +02:00
parent c3a11035dc
commit b8d0b51685
No known key found for this signature in database
GPG key ID: 5388A30A31834D83
17 changed files with 59 additions and 1 deletions

32
setup/00_install_global_functions_variables.sh Normal file → Executable file
View file

@ -253,3 +253,35 @@ sudo $SYSTEMCTL_PATH restart $1 || echo \"Failed restarting service\"" > "/var/o
chmod +x "/var/opt/$1.git/hooks/update"
}
export -f hook_script_bower
function log_script {
SERVICE_NAME=$1
# Ensure required files and permissions
echo "d /var/log/${SERVICE_NAME} 0750 syslog adm" > /etc/tmpfiles.d/${SERVICE_NAME}-log.conf
# Redirect MongoDB log output from syslog to mongodb log file
echo "if ( \$programname startswith \"$SERVICE_NAME\" ) then {
action(type=\"omfile\" file=\"/var/log/${SERVICE_NAME}/${SERVICE_NAME}.log\")
stop
}" > /etc/rsyslog.d/25-${SERVICE_NAME}.conf
# Setup log rotate
echo "/var/log/${SERVICE_NAME}/${SERVICE_NAME}.log {
daily
ifempty
missingok
rotate 7
compress
create 640 syslog adm
su root root
sharedscripts
postrotate
systemctl kill --signal=SIGHUP --kill-who=main rsyslog.service 2>/dev/null || true
endscript
}" > /etc/logrotate.d/${SERVICE_NAME}
}
export -f log_script

0
setup/01_install_commits.sh Normal file → Executable file
View file

0
setup/02_install_prerequisites.sh Normal file → Executable file
View file

0
setup/03_install_check_running_services.sh Normal file → Executable file
View file

0
setup/04_install_import_keys.sh Normal file → Executable file
View file

0
setup/05_install_packages.sh Normal file → Executable file
View file

0
setup/06_install_enable_services.sh Normal file → Executable file
View file

4
setup/07_install_wildduck.sh Normal file → Executable file
View file

@ -60,6 +60,10 @@ npm install --unsafe-perm --production
chown -R deploy:deploy /var/opt/wildduck.git
chown -R deploy:deploy /opt/wildduck
echo "d /opt/wildduck 0755 deploy deploy
d /etc/wildduck 0755 wildduck wildduck" > /etc/tmpfiles.d/zone-mta.conf
log_script "wildduck-server"
echo "[Unit]
Description=WildDuck Mail Server
Conflicts=cyrus.service dovecot.service

4
setup/08_install_haraka.sh Normal file → Executable file
View file

@ -101,6 +101,10 @@ error=false' > config/clamd.ini
cp plugins/wildduck/config/wildduck.yaml config/wildduck.yaml
sed -i -e "s/secret value/$SRS_SECRET/g" config/wildduck.yaml
# Ensure required files and permissions
echo "d /opt/haraka 0755 deploy deploy" > /etc/tmpfiles.d/haraka.conf
log_script "haraka"
echo '[Unit]
Description=Haraka MX Server
After=mongod.service redis.service

6
setup/09_install_zone_mta.sh Normal file → Executable file
View file

@ -111,6 +111,12 @@ npm install --unsafe-perm --production
chown -R deploy:deploy /var/opt/zone-mta.git
chown -R deploy:deploy /var/opt/zonemta-wildduck.git
chown -R deploy:deploy /opt/zone-mta
chown -R wildduck:wildduck /etc/zone-mta
# Ensure required files and permissions
echo "d /opt/zone-mta 0755 deploy deploy
d /etc/zone-mta 0755 wildduck wildduck" > /etc/tmpfiles.d/zone-mta.conf
log_script "zone-mta"
echo '[Unit]
Description=Zone Mail Transport Agent

4
setup/10_install_wildduck_webmail.sh Normal file → Executable file
View file

@ -43,6 +43,10 @@ chown -R deploy:deploy /opt/wildduck-webmail
HOME=/home/deploy sudo -u deploy npm install
HOME=/home/deploy sudo -u deploy npm run bowerdeps
echo "d /opt/wildduck-webmail 0755 deploy deploy" > /etc/tmpfiles.d/zone-mta.conf
log_script "wildduck-www"
echo '[Unit]
Description=Wildduck Webmail
After=wildduck.service

0
setup/11_install_nginx.sh Normal file → Executable file
View file

0
setup/12_install_ufw_rules.sh Normal file → Executable file
View file

0
setup/13_install_ssl_certs.sh Normal file → Executable file
View file

6
setup/14_install_start_services.sh Normal file → Executable file
View file

@ -4,6 +4,12 @@ OURNAME=14_install_start_services.sh
echo -e "\n-- Executing ${ORANGE}${OURNAME}${NC} subscript --"
# Run tmpfiles definitions to ensure required directories/files
systemd-tmpfiles --create --remove
# Restart rsyslog for the changes to take effect
systemctl restart rsyslog
# update reload script for future updates
echo "#!/bin/bash
$SYSTEMCTL_PATH reload nginx

0
setup/15_install_deploy.sh Normal file → Executable file
View file

4
setup/get_install.sh Normal file → Executable file
View file

@ -1,7 +1,9 @@
#! /bin/bash
BRANCH="${1:-master}"
# This script downloads all the installation files.
BASEURL="https://raw.githubusercontent.com/nodemailer/wildduck/master/setup/"
BASEURL="https://raw.githubusercontent.com/nodemailer/wildduck/$BRANCH/setup/"
## declare an array
declare -a arr=(