mirror of
				https://github.com/mail-in-a-box/mailinabox.git
				synced 2025-10-30 18:50:53 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			58 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| 
 | |
| #
 | |
| # this adds the logwatch tool to the system (see,
 | |
| # https://ubuntu.com/server/docs/logwatch) and executes it as part of
 | |
| # normal status checks with it's output attached to daily status
 | |
| # checks emails
 | |
| #
 | |
| # created: 2022-11-03
 | |
| # author: downtownallday
 | |
| # removal: run `local/logwatch.sh remove`, then delete symbolic link
 | |
| #          (`rm local/logwatch.sh`)
 | |
| 
 | |
| . /etc/mailinabox.conf
 | |
| . setup/functions.sh
 | |
| 
 | |
| logwatch_remove() {
 | |
|     remove_hook_handler "logwatch-hooks.py"
 | |
|     hide_output apt-get purge logwatch -y
 | |
| }
 | |
| 
 | |
| logwatch_install() {
 | |
|     echo "Installing logwatch"
 | |
|     apt_install logwatch
 | |
|     # remove cron entry added by logwatch installer, which emails daily
 | |
|     rm -f /etc/cron.daily/00logwatch
 | |
|     mkdir -p /var/cache/logwatch
 | |
| 
 | |
|     # settings in the logwatch.conf file become defaults when running
 | |
|     # the cli /usr/sbin/logwatch (cli arguments override the conf
 | |
|     # file)
 | |
|     local settings=(
 | |
|         "MailTo=administrator@$PRIMARY_HOSTNAME"
 | |
|         "MailFrom=\"$PRIMARY_HOSTNAME\" <administrator@$PRIMARY_HOSTNAME>"
 | |
|     )
 | |
|         
 | |
|     if [ ! -e /etc/logwatch/conf/logwatch.conf ]; then
 | |
|         cp /usr/share/logwatch/default.conf/logwatch.conf /etc/logwatch/conf/
 | |
|         settings+=(
 | |
|             "Output=mail"
 | |
|             "Format=html"
 | |
|             "Service=All"
 | |
|             "Detail=Low"
 | |
|         )
 | |
|     fi
 | |
| 
 | |
|     tools/editconf.py /etc/logwatch/conf/logwatch.conf -case-insensitive "${settings[@]}"    
 | |
|     install_hook_handler "setup/mods.available/hooks/logwatch-hooks.py"
 | |
| }
 | |
| 
 | |
| 
 | |
| if [ "${1:-}" = "remove" ]; then
 | |
|     logwatch_remove
 | |
| else
 | |
|     logwatch_install
 | |
| fi
 | |
| 
 |