MySQL Backup 1.2 (MySQL 5.5+)

In the previous versions of this script you’ve had to leave the backup user password in the script, however MySQL 5.5 and above come with mysql_config_editor which allows you to store connection details in an ancryptedl file (~/.mylogin.cnf) which mysql/mysqldump/mysqladmin can use with the “–login-path=” option. For basic usage run the following, the –password prompts … [Read more…]

Forcing a specific video mode, Centos 7

At the grub prompt, edit the line for the specific kernel and at the end of the line add: video=800×600-24 for 800 x 600 resolution with 24 bit colour. To make this permanent: Edit /etc/default/grub and add the video= to the end of GRUB_CMDLINE_LINUX line. # grub2-mkconfig -o /boot/grub2/grub.cfg This will force the video mode … [Read more…]

MySQL Backup 1.1

This is an update to the earlier MySQL backup script, with this version I’ve added the code that (assuming your backup user has sufficient rights) allows the script to get a list of all the databases on the server, exclude the MySQL internal ones and use this as the list of databases to backup. This … [Read more…]

Blocking By Country

There are times when you’ll want to limit access and block whole countries. Why? Because there are times when it’s necessary. Here’s a script that builds a script…. It downloads the IP ranges from www.ipdeny.com, works through a list of two letter country codes to create a bash script that will: Delete an existing iptables … [Read more…]

“Fixing” troublesome filenames.

Windows has a number of reserved characters that aren’t allowed in file/folder names: ◦The following reserved characters: ◾< (less than) ◾> (greater than) ◾: (colon) ◾” (double quote) ◾/ (forward slash) ◾\ (backslash) ◾| (vertical bar or pipe) ◾? (question mark) ◾* (asterisk) I’d also advise against the use of curly braces {} The following … [Read more…]

“Nesting” Variables in bash

Many thanks to “Gavin Smith” on stackoverflow.com for the first part of this tip. Expressions like ${${a}} do not work. To work around it, you can use eval: b=value a=b eval aval=\$$a echo $aval Output is value Thanks for the tip Gavin! Ok, so why would you want to? For me, I needed to test … [Read more…]

Fail2Ban Behind A Proxy/Load Balancer

Problem You’ve users that you want to ban / block from your web servers using Fail2Ban but your web servers are behind a proxy so all traffic appears to be coming from the proxy server IP/Interface. Ideally you should have learning rules on your proxy or load balancer where you can automatically filter/rate/take actions, but … [Read more…]

Checking SSL Expiry Dates From The Command Line

This is a simple way to check your sites SSL certificate expiry date from the command line. I’ll probably expand the script to work with lists and to send alerts if under XX days are remaining, but for now it just works with ./ssl_exp.sh your.domain.name #!/bin/bash DOMAIN=$1 EXPIRES=$(echo | openssl s_client -connect ${DOMAIN}:443 2>/dev/null | … [Read more…]