Updated script descriptions
Updated email address in scripts Removed squidguard-blacklists.sh
This commit is contained in:
parent
bb95025e81
commit
2cda37ccc8
13
00logwatch
13
00logwatch
@ -1,18 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Script Name: 00logwatch
|
||||||
|
# Author: Matt McKinnon
|
||||||
|
# Date: 7th June 2016
|
||||||
|
# Description:
|
||||||
|
# This script will email a logwatch report
|
||||||
|
|
||||||
MAILTO="support@comprofix.com"
|
MAILTO="support@comprofix.com"
|
||||||
SMTP=mail.comprofix.com
|
SMTP=mail.comprofix.com
|
||||||
THISSERVER=`hostname --fqdn`
|
THISSERVER=$(hostname -f)
|
||||||
MAILFROM="$(hostname)@$(dnsdomainname)"
|
MAILFROM="$(hostname)@$(dnsdomainname)"
|
||||||
|
|
||||||
#Check if removed-but-not-purged
|
#Check if removed-but-not-purged
|
||||||
test -x /usr/share/logwatch/scripts/logwatch.pl || exit 0
|
test -x /usr/share/logwatch/scripts/logwatch.pl || exit 0
|
||||||
|
|
||||||
#execute
|
#execute
|
||||||
#/usr/sbin/logwatch --output mail
|
/usr/sbin/logwatch > /tmp/logwatch
|
||||||
/usr/sbin/logwatch
|
|
||||||
|
|
||||||
sendemail -o tls=no -s $SMTP -t $MAILTO -f "$THISSERVER <$MAILFROM>" -u "[$THISSERVER] Logwatch" -m "$(cat /tmp/logwatch)" -q
|
sendemail -o tls=no -s $SMTP -t $MAILTO -f "$THISSERVER <$MAILFROM>" -u "[$THISSERVER] Logwatch" -m "$(cat /tmp/logwatch)" -q
|
||||||
|
|
||||||
#Note: It's possible to force the recipient in above command
|
|
||||||
#Just pass --mailto address@a.com instead of --output mail
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Script Name: maint.sh
|
# Script Name: check_updates_deb
|
||||||
# Author Name: Keith Bawden
|
# Author Name: Matt McKinnon
|
||||||
# Date: Wed May 17 15:40:32 JST 2006
|
# Date: 7th June 2016
|
||||||
# Description: This script will:
|
# Description: For use on Debian Based Systems
|
||||||
|
# This script will:
|
||||||
# Clean up the local apt repository of retrieved packages (apt-get clean)
|
# Clean up the local apt repository of retrieved packages (apt-get clean)
|
||||||
# Resync the package index (apt-get update)
|
# Resync the package index (apt-get update)
|
||||||
# If called with AUTOUPDATE set to yes then updates will be downloaded and applied with no feed back (not recommended)
|
# If called with AUTOUPDATE set to yes then updates will be downloaded and applied with no feed back (not recommended)
|
||||||
@ -114,7 +115,7 @@ then
|
|||||||
apt-get -yqq upgrade > /dev/null
|
apt-get -yqq upgrade > /dev/null
|
||||||
check_return "apt-get -yq upgrade"
|
check_return "apt-get -yq upgrade"
|
||||||
else
|
else
|
||||||
PACKAGES_TO_BE_UPGRADED=`apt-get -Vs upgrade | perl -ne 'print if /upgraded:/ .. /upgraded,/'`
|
PACKAGES_TO_BE_UPGRADED=$(apt-get -Vs upgrade | perl -ne 'print if /upgraded:/ .. /upgraded,/')
|
||||||
apt-get -yqd upgrade > /dev/null
|
apt-get -yqd upgrade > /dev/null
|
||||||
check_return "apt-get -yqd upgrade"
|
check_return "apt-get -yqd upgrade"
|
||||||
fi
|
fi
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Script Name: check_updates_rpm.sh
|
# Script Name: check_updates_rpm
|
||||||
# Author Name: Keith Bawden
|
# Author Name: Matt McKinnon
|
||||||
# Modified by: Matthew McKinnon
|
# Date: 7th June 2016
|
||||||
# Date: Wed May 17 15:40:32 JST 2006
|
|
||||||
# Updated: Mon Nov 22, 2015
|
|
||||||
# Description: For use on rpm based distros ie CentOS, Red Hat, Fedora
|
# Description: For use on rpm based distros ie CentOS, Red Hat, Fedora
|
||||||
# This script will:
|
# This script will:
|
||||||
# Clean up the local rpm repository of retrieved packages (yum clean)
|
# Clean up the local rpm repository of retrieved packages (yum clean)
|
||||||
# Resync the package index (yum makecache)
|
# Resync the package index (yum makecache)
|
||||||
# If called with AUTOUPDATE set to yes then SECURITY updates will be downloaded and applied. (The package yum-plugin-security is required Install using
|
# If called with AUTOUPDATE set to yes then SECURITY updates will be downloaded and applied. (The package yum-plugin-security is required Install using
|
||||||
# yum install yum-plugin-security)
|
# yum install yum-plugin-security)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Make user configuration changes in this section
|
# Make user configuration changes in this section
|
||||||
#
|
#
|
||||||
|
|
||||||
MAILTO="matthew@ambient-it.com.au"
|
MAILTO="support@comprofix.com"
|
||||||
AUTOUPDATE="no"
|
AUTOUPDATE="no"
|
||||||
LOGFILE="/var/log/server_maint.log"
|
LOGFILE="/var/log/server_maint.log"
|
||||||
THISSERVER=`hostname --fqdn`
|
THISSERVER=$(hostname -f)
|
||||||
|
|
||||||
#
|
#
|
||||||
# End of user configuration section
|
# End of user configuration section
|
||||||
@ -49,12 +48,12 @@ stoplogging() {
|
|||||||
check_return() {
|
check_return() {
|
||||||
if [ "$?" -ne "0" ]
|
if [ "$?" -ne "0" ]
|
||||||
then
|
then
|
||||||
echo "`date` [ERROR] $1 failed to run" >> $LOGFILE
|
echo "$(date) [ERROR] $1 failed to run" >> $LOGFILE
|
||||||
send_error_email $1
|
send_error_email $1
|
||||||
stoplogging
|
stoplogging
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "`date` [SUCCESS] $1 ran without error" >> $LOGFILE
|
echo "$(date) [SUCCESS] $1 ran without error" >> $LOGFILE
|
||||||
}
|
}
|
||||||
|
|
||||||
send_error_email() {
|
send_error_email() {
|
||||||
@ -115,7 +114,7 @@ fi
|
|||||||
|
|
||||||
if [[ -z $PACKAGES_TO_BE_UPGRADED ]]
|
if [[ -z $PACKAGES_TO_BE_UPGRADED ]]
|
||||||
then
|
then
|
||||||
echo "`date` [MESSAGE] No packages need updating." >> $LOGFILE
|
echo "$(date) [MESSAGE] No packages need updating." >> $LOGFILE
|
||||||
else
|
else
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
|
28
dbbackup.sh
28
dbbackup.sh
@ -1,11 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
bakdate=$(date +%Y%m%d%H%M)
|
# Script Name: dbbackup
|
||||||
|
# Author: Matt McKinnon
|
||||||
|
# Date: 7th June 2016
|
||||||
|
# Description:
|
||||||
|
# This script will backup your mysql databases.
|
||||||
|
# Send an email report of databases that have been backed up.
|
||||||
|
# Rotate backups for 7 days
|
||||||
|
#
|
||||||
|
# NOTE:
|
||||||
|
# A user will need to be grated permissions on the databases
|
||||||
|
# Login to mysql with your root user.
|
||||||
|
#
|
||||||
|
# CREATE USER 'dbbackup'@'localhost' IDENTIFIED BY 'PASSWORD';
|
||||||
|
# GRANT LOCK TABLES, SELECT, SHOW VIEW, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER ON *.* TO 'backup'@'localhost';
|
||||||
|
|
||||||
|
SUBJECT="Database Backup Completed $BAKDATE"
|
||||||
|
MAILTO="support@comprofix.com"
|
||||||
|
BAKDATE=$(date +%Y%m%d)
|
||||||
DBUSER='dbbackup'
|
DBUSER='dbbackup'
|
||||||
DBPASS='EWFfP3GZsqr427Yj'
|
DBPASS='EWFfP3GZsqr427Yj'
|
||||||
BACKUPDIR='/BACKUP/db/'
|
BACKUPDIR='/BACKUP/db/'
|
||||||
|
|
||||||
|
|
||||||
rotate_backups() {
|
rotate_backups() {
|
||||||
find $BACKUPDIR -type f -mtime +7 -exec rm -frv {} \;
|
find $BACKUPDIR -type f -mtime +7 -exec rm -frv {} \;
|
||||||
|
|
||||||
@ -13,12 +28,15 @@ rotate_backups() {
|
|||||||
|
|
||||||
rotate_backups
|
rotate_backups
|
||||||
|
|
||||||
databases=`mysql --user=$DBUSER --password=$DBPASS -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
|
databases=$(mysql --user=$DBUSER --password=$DBPASS -e "SHOW DATABASES;" | tr -d "| " | grep -v Database)
|
||||||
|
|
||||||
for db in $databases; do
|
for db in $databases; do
|
||||||
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
|
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
|
||||||
echo "Dumping database: $db"
|
echo "Dumping database: $db" >> /tmp/dbbackup.msg
|
||||||
mysqldump --force --opt --user=$DBUSER --password=$DBPASS --databases $db > $BACKUPDIR/$db.`date +%Y%m%d`.sql
|
mysqldump --force --opt --user=$DBUSER --password=$DBPASS --databases $db > $BACKUPDIR/$db.$BAKDATE.sql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
cat /tmp/dbbackup.msg | mail -s "$SUBJECT" "$MAILTO"
|
||||||
|
rm -fr /tmp/dbbackup.msg
|
||||||
|
10
diskalert.sh
10
diskalert.sh
@ -1,8 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Script Name: diskalert
|
||||||
|
# Author: Matt McKinnon
|
||||||
|
# Date: 7th June 2016
|
||||||
|
# Description:
|
||||||
|
# This script will email when diskspace is high.
|
||||||
|
|
||||||
MAILTO="support@comprofix.com"
|
MAILTO="support@comprofix.com"
|
||||||
SMTP=mail.comprofix.com
|
SMTP=mail.comprofix.com
|
||||||
LOGFILE="/var/log/diskalert.log"
|
LOGFILE="/var/log/diskalert.log"
|
||||||
THISSERVER=`hostname --fqdn`
|
THISSERVER=$(hostname -f)
|
||||||
MAILFROM="$(hostname)@$(dnsdomainname)"
|
MAILFROM="$(hostname)@$(dnsdomainname)"
|
||||||
|
|
||||||
startlogging() {
|
startlogging() {
|
||||||
@ -53,7 +59,7 @@ See the logfile for more info: vim $LOGFILE
|
|||||||
|
|
||||||
Regards, " >/tmp/diskalertmail.msg
|
Regards, " >/tmp/diskalertmail.msg
|
||||||
|
|
||||||
cat /tmp/diskalertmail.msg | sendemail -o tls=no -s $SMTP -t $MAILTO -f "$THISSERVER <$MAILFROM>" -u "[$THISSERVER] is running out of disk space"
|
sendemail -o tls=no -s $SMTP -t $MAILTO -f "$THISSERVER <$MAILFROM>" -u "[$THISSERVER] is running out of disk space" -m "$(cat /tmp/diskalertmail.msg)"
|
||||||
echo "$(date) [MESSAGE] Running out of disk space email sent to $MAILTO" >> $LOGFILE
|
echo "$(date) [MESSAGE] Running out of disk space email sent to $MAILTO" >> $LOGFILE
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Script Name: mailQWatch
|
||||||
|
# Author: Matt McKinnon
|
||||||
|
# Date: 7th June 2016
|
||||||
|
# Description:
|
||||||
|
# This script will email a report mailq on postfix is high.
|
||||||
|
|
||||||
QUEUELIMIT=75
|
QUEUELIMIT=75
|
||||||
SUBJECT="Mail Queue on $HOST is currently $QUEUECOUNT"
|
SUBJECT="Mail Queue on $HOST is currently $QUEUECOUNT"
|
||||||
MAILTO="mmckinnon@comprofix.com"
|
MAILTO="support@comprofix.com"
|
||||||
|
|
||||||
HOST=$(/bin/hostname)
|
HOST=$(/bin/hostname)
|
||||||
POSTQUEUE=$(which postqueue)
|
POSTQUEUE=$(which postqueue)
|
||||||
|
12
rkhunter.sh
12
rkhunter.sh
@ -1,11 +1,15 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
# Script Name: rkhunter
|
||||||
|
# Author: Matt McKinnon
|
||||||
|
# Date: 7th June 2016
|
||||||
|
# Description:
|
||||||
|
# This script will email a logwatch report
|
||||||
MAILTO="support@comprofix.com"
|
MAILTO="support@comprofix.com"
|
||||||
SMTP=mail.comprofix.com
|
SMTP=mail.comprofix.com
|
||||||
THISSERVER=`hostname -f`
|
THISSERVER=$(hostname -f)
|
||||||
MAILFROM="support@comprofix.com"
|
MAILFROM="support@comprofix.com"
|
||||||
(
|
(
|
||||||
/usr/bin/rkhunter --versioncheck --nocolors
|
/usr/bin/rkhunter --versioncheck --nocolors
|
||||||
/usr/bin/rkhunter --update --nocolors
|
/usr/bin/rkhunter --update --nocolors
|
||||||
/usr/bin/rkhunter --cronjob --report-warnings-only --nocolors
|
/usr/bin/rkhunter --cronjob --report-warnings-only --nocolors
|
||||||
) | /usr/bin/sendemail -o tls=no -s $SMTP -t $MAILTO -f "$THISSERVER <$MAILTO>" -u "[rkhunter] Daily Log $THISSERVER" -q
|
) | /usr/bin/sendemail -o tls=no -s $SMTP -t $MAILTO -f "$THISSERVER <$MAILTO>" -u "[rkhunter] Daily Log $THISSERVER" -q
|
||||||
|
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# squidGuard blacklists - download & install script to
|
|
||||||
# download blacklists from Shalla Secure Services @
|
|
||||||
# http://squidguard.shalla.de/Downloads/shallalist.tar.gz
|
|
||||||
#
|
|
||||||
# created by Steve Olive - oz.ollie[at]gmail.com
|
|
||||||
# ver 0.8 20071204 15:05 GMT+10
|
|
||||||
# Creative Commons Attribution-Share Alike 3.0 License
|
|
||||||
# http://creativecommons.org/licenses/by-sa/3.0/
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# _________ ____ ____________ _______ ___________________
|
|
||||||
# ______ /__________ |/ /___ ____/________ ___ |__ ____/___ ____/
|
|
||||||
# _ __ / __ ___/__ / ______ \ ___ __ \__ /| |_ / __ __/
|
|
||||||
# / /_/ / _ / _ | ____/ / __ /_/ /_ ___ |/ /___ _ /___
|
|
||||||
# \__,_/ /_/ /_/|_| /_____/ _ .___/ /_/ |_|\____/ /_____/
|
|
||||||
# /_/ drxspace@gmail.com
|
|
||||||
#
|
|
||||||
|
|
||||||
ROOTLS=/tmp
|
|
||||||
cd ${ROOTLS} || { echo "Can't find root's squidGuard directory."; exit 1; }
|
|
||||||
|
|
||||||
SQUID=$(which squid3)
|
|
||||||
SQUIDGRD=$(which squidGuard)
|
|
||||||
|
|
||||||
[[ -f ${CONFFILE:="/etc/squidguard/squidGuard.conf"} ]] || { echo "Can't find squidGuard conf file."; exit 1; }
|
|
||||||
DATADIR=$(grep ^dbhome ${CONFFILE} | cut -d' ' -f2)
|
|
||||||
|
|
||||||
# download latest file - overwrite any existing file
|
|
||||||
echo 'Downloading new blacklists...'
|
|
||||||
wget -nv 'http://www.shallalist.de/Downloads/shallalist.tar.gz' -a /var/log/blacklists.log
|
|
||||||
|
|
||||||
# extract blacklists
|
|
||||||
tar -zxf shallalist.tar.gz
|
|
||||||
echo 'New lists downloaded and decompressed.'
|
|
||||||
|
|
||||||
# remove old database folders
|
|
||||||
test -d ${DATADIR} || mkdir -p ${DATADIR}
|
|
||||||
echo 'Removing old lists...'
|
|
||||||
rm -Rf ${DATADIR}/*
|
|
||||||
|
|
||||||
# copy downloaded blacklists to db home
|
|
||||||
echo 'Copying new lists...'
|
|
||||||
cp -R ${ROOTLS}/BL/* ${DATADIR}
|
|
||||||
|
|
||||||
# create my whitelist/blacklist directories and copy files
|
|
||||||
#mkdir -p ${DATADIR}/white ${DATADIR}/black
|
|
||||||
#cp -R ${ROOTLS}/white/* ${DATADIR}/white
|
|
||||||
#cp -R ${ROOTLS}/black/* ${DATADIR}/black
|
|
||||||
|
|
||||||
echo 'Changing ownership...'
|
|
||||||
chown -R proxy:proxy ${DATADIR}/../
|
|
||||||
find ${DATADIR} -type d | xargs chmod -R 2750
|
|
||||||
|
|
||||||
# This script performs a database rebuild for any blacklists listed in the default Squidguard config file `/etc/squid/squidGuard.conf'.
|
|
||||||
#/usr/sbin/update-squidguard -c
|
|
||||||
|
|
||||||
# build domains + urls db, then change ownership to squid user
|
|
||||||
echo 'Building database. Please wait...'
|
|
||||||
su - proxy -c "$SQUIDGRD -b -C all"
|
|
||||||
echo 'Database builds complete.'
|
|
||||||
|
|
||||||
$SQUID -k reconfigure
|
|
||||||
echo 'Squid Proxy Server reconfigured'
|
|
||||||
echo 'Cleaning space...'
|
|
||||||
rm -Rf ${ROOTLS}/BL
|
|
||||||
rm -f ${ROOTLS}/shallalist.tar.gz
|
|
||||||
|
|
||||||
echo "$(date +"%c") Blacklists updated ok." >> /var/log/blacklists.log
|
|
||||||
|
|
||||||
exit 0
|
|
Loading…
Reference in New Issue
Block a user