This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
# This script check netstat connected IPs with more than $limit connections | |
# If connections continues 5 minutes after, IP will be added to iptables with DROP | |
# Execute as cron every 5 minutes | |
# */5 * * * * /root/shells/ddos-detect.sh >> /root/logs/ddos-detect.log 2>> /root/logs/ddos-detect.err | |
echo "" | |
echo "Start at: `date "+%Y-%m-%d %H:%M:%S"`" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ------------------------------------- | |
# Script to do incremental rsync backups | |
# from a central backup server | |
# | |
# This script is freely distributed under the GPL | |
# ------------------------------------- | |
# ------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Cron installation: | |
# 30 05 * * * /root/scripts/raspberry-pi-backup.sh >> /root/logs/raspberry-pi-backup.log 2>&1 | |
# Configuration | |
external="/backup" # Check if external storage is mounted | |
folder="$external/raspi" # Base backup folder | |
dev="/dev/mmcblk0" # Device to backup | |
days=10 # Delete backups older than X days |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install: Download and add execution permissions | |
# | |
# Usage: ./add-keys-to-servers "current-private-key-to-connect" "new-private-key-to-add" "servers.list" | |
# | |
# First parameter must be the current available key to connect to servers | |
# Second parameter must be the new key to add to servers | |
# Third parameter must be the servers list (One line for server with format: hostname,port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# crontab -e | |
# * * * * * /root/scripts/hdd-wakeup.sh >> /root/logs/hdd-wakeup.log 2>&1 | |
devices=$(mount -l | grep -o '/dev/sd[a-z][0-9]') | |
if [ "$devices" == "" ]; then | |
echo "$(date "+%Y-%m-%d %H:%M:%S") No HDD mounted" | |
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ------------------------------------- | |
# Databases backup with X days storage history | |
# | |
# User executing this script must have FULL permissions | |
# to mysql and mysqldump | |
# | |
# Use $HOME/.my.cnf to store MySQL auth | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## User installation: | |
# | |
# 1) Append to user file ~/.bashrc | |
# | |
# Wide System installation: | |
# | |
# 1) Create /etc/bash.bashrc.d folder | |
# 2) Paste this file into /etc/bash.bashrc.d/custom.sh file | |
# 3) Append ". /etc/bash.bashrc.d/custom.sh" at end of /etc/bash.bashrc file | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add goaccess repository | |
echo "deb http://deb.goaccess.io/ xenial main" > /etc/apt/sources.list.d/goaccess.list | |
# Add repository keys | |
gpg --keyserver keyserver.ubuntu.com --recv-key 742483B7B222C443 | |
gpg -a --export 742483B7B222C443 | apt-key add - | |
# Update apt | |
apt-get update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ------------------------------------- | |
# Script to do incremental rsync backups | |
# into a local computer | |
# | |
# This script is freely distributed under the GPL | |
# ------------------------------------- |