Skip to content

Instantly share code, notes, and snippets.

@plutocrat
plutocrat / dovecot_summary.sh
Last active September 14, 2021 06:22
Grabbing a few key stats from dovecot logs to replace the regular logwatch report
#!/bin/bash
# Future version might store stats in a flatfile DB and then show comparative values, eg +5%, -250%
TEMPFILE=/tmp/dc_temp.log
# Need to cat the last two logs to guarantee 24 hours of data: adjust according to your setup
# zcat -f will deal with uncompressed and gzipped alike
zcat -f /var/log/dovecot.log.1 /var/log/dovecot.log > $TEMPFILE
# Find start hour 24 hours ago. If no match, try 25 hours, 26 hours, etc up to 48 hours
@plutocrat
plutocrat / install-imapsync.sh
Created January 17, 2018 02:41
Install imapsync on Ubuntu 16.04
# Run these manually
# First install git and grab the imapsync code
apt install git
git clone https://github.com/imapsync/imapsync.git
# Install all dependencies
apt install automake build-essential libauthen-ntlm-perl libclass-load-perl libcrypt-openssl-rsa-perl libdata-uniqid-perl libdate-manip-perl libdigest-hmac-perl libdigest-md5-file-perl libdist-checkconflicts-perl libfile-copy-recursive-perl libio-tee-perl libjson-perl libmail-imapclient-perl libmodule-implementation-perl libmodule-runtime-perl libmodule-scandeps-perl libpackage-stash-perl libpackage-stash-xs-perl libpar-packer-perl libreadonly-perl libsys-meminfo-perl libterm-readkey-perl libtest-fatal-perl libtest-mock-guard-perl libtest-mockobject-perl libtest-pod-perl libtest-requires-perl libtry-tiny-perl libunicode-string-perl make makepasswd perl-doc rcs
# These ones didn't exist in my repos, so first try to install through apt
apt-get install libjson-webtoken-perl libjson-webtoken-crypt-rsa-perl
@plutocrat
plutocrat / streams.php
Last active January 8, 2018 03:05
Fixed /usr/share/php/php-gettext/streams.php file for annoying phpmyadmin + PHP7 errors
<?php
/*
Copyright (c) 2003, 2005, 2006, 2009 Danilo Segan <[email protected]>.
This amended version uses function __construct to get rid of errors
# Install:
cd /usr/share/php/php-gettext/
mv streams.php streams.orig.php
wget https://gist.githubusercontent.com/plutocrat/e6abc230924c17b1c2f54929de442882/raw/724d81bcdb8347ac4b12fff4f1674d9b096465ec/streams.php
*/
@plutocrat
plutocrat / aws-info.sh
Created December 15, 2017 05:36
Pull various useful info from AWS meta data interface
#!/bin/bash
OUTFILE=server-info.txt
NEWFILE=1
# Clear existing if NEWFILE set to 1
if [ "$NEWFILE" == "1" ]; then
echo "" > $OUTFILE
fi
@plutocrat
plutocrat / install_perftools.sh
Last active March 18, 2024 09:38
Grabs a few performance / info command line tools from around the web
#!/bin/bash
# wget -O install_perftools.sh https://gist.github.com/plutocrat/31d43d125ed64954fa2f575ccac40448/raw/ && chmod 700 install_perftools.sh
# Get mysqltuner
wget -O mysqltuner.pl https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
wget -O basic_passwords.txt https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt
wget -O vulnerabilities.csv https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv
chmod 700 mysqltuner.pl
sed -i 's/"skippassword" => 0,/"skippassword" => 1,/' mysqltuner.pl
@plutocrat
plutocrat / upload_clean.sh
Last active April 8, 2019 07:02
Wordpress Uploads Directory Cleanout
#!/bin/bash
# wget https://gist.githubusercontent.com/plutocrat/7636841e480f483a97c0d17568ac0ef1/raw/upload_clean.sh
# Dumps your database out, extracts image paths from it and compares it against a list of files from the filesystem
# Needs wp-cli to dump the database.
# Only works on Linuxy servers
# It will give you a chance to bail before it deletes anything.
# If it saves you a few hours, show your appreciation with bitcoin: 35Ws8qgKUCiVaca7vg5NWqkfQozPfzb4my
# Working Dir
WKDIR=zz_temp
@plutocrat
plutocrat / ssl-check-report.sh
Last active February 24, 2024 14:23
Bash Script to check SSL expiry dates and send a report
#!/bin/bash
# Requires openssl, bc, grep, sed, date, mutt, sort
## Edit these ##
# Space separated list of domains to check
DOMAINLIST="hp.com github.com google.com"
# Where to send the report
[email protected]
# Additional alert warning prepended if domain has less than this number of days before expiry
EXPIRYALERTDAYS=15
@plutocrat
plutocrat / log-squish.sh
Last active October 23, 2018 03:54
Quick script to remove Web Crawlers / Bots and other non-traffic from web logs
#!/bin/bash
## Set Variables
# Pass input file as a commandline argument, or set it here, and your output file
INFILE=$1
OUTFILE=./$1.squish
TMPFILE=./squish.tmp
# Lists of patterns to delete from logfiles. space separated. backslash before special characters
# LOCALTRAFFIC will be unique to your setup.