Skip to content

Instantly share code, notes, and snippets.

@U039b
U039b / fail2ban_report.sh
Last active April 11, 2023 06:38
Fail2Ban mail report
#!/bin/bash
# Weekly Fail2Ban Report
# Be sure to sudo chmod +x script_name.sh to make it executable
# Original script from https://www.mopar4life.com/fail2ban-weekly-report-script/
FAIL2BAN_PATH="/var/log/fail2ban*"
LOGFILE="/var/log/custom_fail2ban_report_$(date +%m%d%Y).log"
MAILTOADDRESS="your@domain.tld"
SUBJECT="$HOSTNAME Weekly Fail2Ban Report"
@lukechilds
lukechilds / get_latest_release.sh
Created August 9, 2016 19:43
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@irazasyed
irazasyed / manage-etc-hosts.sh
Created March 7, 2015 09:16
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/bin/sh
# PATH TO YOUR HOSTS FILE
ETC_HOSTS=/etc/hosts
# DEFAULT IP FOR HOSTNAME
IP="127.0.0.1"
# Hostname to add/remove.
HOSTNAME=$1
#!/bin/bash
## Obserivum Client Setup Script
## v.0.5 - 12/15/13 - nunim@sonicboxes.com
## Tested on Debian 6/7 & Ubuntu 12.04+ - CentOS 5.8/6.4
## Useage: ./observium-client.sh <Community> <Contact Email>
## check if root
if [ $(whoami) != "root" ]; then
echo "You need to run this script as root."
echo "Use 'sudo ./observium-client.sh' then enter your password when pro mpted."
exit 1
anonymous
anonymous / Observium Client Setup Script
Created April 13, 2014 00:33
Sets up client for Observium. (Created by nunim@sonicboxes.com)
#!/bin/bash
## Obserivum Client Setup Script
## v.0.5 - 12/15/13 - nunim@sonicboxes.com
## Tested on Debian 6/7 & Ubuntu 12.04+ - CentOS 5.8/6.4
## Useage: ./observium-client.sh <Community> <Contact Email>
## check if root
if [ $(whoami) != "root" ]; then
echo "You need to run this script as root."
echo "Use 'sudo ./observium-client.sh' then enter your password when pro mpted."
exit 1
@bmarston
bmarston / InitialDbMigrationCommand.php
Created May 8, 2013 16:23
Let's say you're starting a new Yii project and you've already created the database schema for it using something like phpMyAdmin or MySQL Workbench. Now you want to create an initial database migration so you can put the schema under version control, but you don't want to manually write the Yii code to create the tables, indexes, and foreign ke…
<?php
class InitialDbMigrationCommand extends CConsoleCommand
{
public function run($args) {
$schema = $args[0];
$tables = Yii::app()->db->schema->getTables($schema);
$addForeignKeys = '';
$dropForeignKeys = '';
@rcoh
rcoh / sshupdate.py
Created February 3, 2013 22:57
Automatically update your SSH config to allow ssh-ing into EC2 instances by their name. Works on Linux and Mac OS X.
import os
import subprocess
import boto.ec2
import itertools
AWS_KEY = os.getenv('AWS_ACCESS_KEY')
AWS_SECRET = os.getenv('AWS_SECRET_KEY')
# Tweak as necessary for your infrastructure
regions = ['us-east-1', 'us-west-1', 'eu-west-1']
@asimzeeshan
asimzeeshan / fix_locales.sh
Created October 31, 2012 11:53
[FIX] perl: warning: Setting locale failed
#!/bin/bash
# Fix the notorious problem that shows the following
#
# --------------------------------------------------------
# perl: warning: Setting locale failed.
# perl: warning: Please check that your locale settings:
# LANGUAGE = (unset),
# LC_ALL = (unset),
# LANG = "en_US.utf8"
# are supported and installed on your system.
# Recursively add a .gitignore file to all directories
# in the working directory which are empty and don't
# start with a dot. Helpful for tracking empty dirs
# in a git repository.
find . -type d -regex ``./[^.].*'' -empty -exec touch {}"/.gitignore" \;