Skip to content

Instantly share code, notes, and snippets.

Avatar

andyforceno andyforceno

  • Connecticut, USA
View GitHub Profile
@andyforceno
andyforceno / insync-info.sh
Created Mar 19, 2020
insync-info.sh - Display recent activity and information about your Google Drive account via insyc-headless
View insync-info.sh
#! /bin/bash
echo
echo "------ Insync-headless Status ------"
echo
echo "Sync progress:"; insync-headless get_sync_progress
echo
echo "Actions required:"; insync-headless get_actions_required
echo
echo "Errors:"; insync-headless get_errors
@andyforceno
andyforceno / rdiffrm.sh
Created Dec 6, 2019
rdiffrm.sh - Recursively remove old rdiff-backup increments
View rdiffrm.sh
#! /bin/bash
# rdiffrm.sh - Recursively remove old rdiff-backup increments
# Deletes rdiff-backup increments specified in $REPO that are older than $INCDATE days
#
# by Andy Forceno <aforceno@pm.me>
#
# Increment age in days
INCDATE="90"
@andyforceno
andyforceno / spush.py
Last active Sep 17, 2020
Send push notifications to mobile devices using Simplepush API
View spush.py
#! /usr/bin/python3
# Send push notifications to your mobile device
# using the Simplepush API
#
# Usage: spush.py title body eventid
# Accepts input from stdin
# e.g. sudo tail /var/log/somelog.log | spush.py title eventid
# by Andy Forceno <aforceno@pm.me>
@andyforceno
andyforceno / plex-update.sh
Created Mar 16, 2019
Updates Plex media server running on Ubuntu
View plex-update.sh
#! /bin/bash
# Downloads and install the latest version of Plex (for Ubuntu) for your arch
# if the version available is newer than what is installed
#
#
# by Andy Forceno <aforceno@pm.me>
#
arch=$(uname -m)
@andyforceno
andyforceno / nginxfail.sh
Last active Dec 16, 2018
Returns daily or all forbidden or refused requests parsed from the Nginx error log
View nginxfail.sh
#! /bin/bash
case "$1" in
all)
sudo grep -E "forb|refuse" /var/log/nginx/error.log | awk '{ print $1 " " $2 " " $11 }' | grep -w '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | tr -d ','
# I also include a pipe to grep to remove all friendly IPs, something like:
# | grep -vE "192.168.1.*|$(curl -s ifconfig.co)|10.8.0.4"
;;
day)
sudo grep -E "forb|refuse" /var/log/nginx/error.log | awk '{ print $1 " " $2 " " $11 }' | grep -w '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | tr -d ',' | grep "$(date +%Y/%m/%d)"
@andyforceno
andyforceno / blockbygeo.sh
Last active Mar 19, 2020
Bash script that uses ipset and iptables to block countries
View blockbygeo.sh
#! /bin/bash
# blockbygeo.sh - Download country ipsets & add to iptables firewall rules
# By: Andy Forceno <aforceno@pm.me>
#
# Depends on: wget, ipset, iptables
IFS=$'\n'
action="$1"
country="$2"
@andyforceno
andyforceno / netdata-chip.md
Last active Aug 10, 2020
Turn your CHIP into a monitoring server with Netdata
View netdata-chip.md

This guide will cover installing and configuring netdata to turn your CHIP (or other Linux device) into a monitoring server. I will also review the steps needed to configure a "client" device that sends it's netdata metrics to CHIP. It's actually very easy to do, thanks to the fantastic job the Netdata developers did in making setup and configuration easy. Yes, the sheer number of configuration options is daunting, but getting netdata running on CHIP actually requires no configuration at all.

This guide will cover installing and configuring netdata to turn your CHIP into a monitoring server. Netdata monitors hardware, networking, applications (web servers, db servers, mail servers), as well as many other things, and visualizes the data in real-time on a web dashboard. I will also cover how to configure CHIP as a “server” that receives and makes accessible monitoring data from other Linux devices, or clients. Installing Netdata isn’t difficult, and to just get it running on CHIP requires no configuration.

T

@andyforceno
andyforceno / adisc.sh
Last active Apr 29, 2018
Bash script to automate archiving of optical discs
View adisc.sh
#! /bin/bash
#
# adisc - Optical Disc Auto-Transfer Tool - v0.9
# by Andy Forceno <aforceno@pm.me>
#
# This script loops until user intervention
# Iteratively creates directories, mounts each disc
# Uses rsync to copy disc contents to dir, unmounts disc
# Then prompts user to insert next disc
@andyforceno
andyforceno / wf.sh
Last active Apr 29, 2018
Bash script weather forecast via the Weather Underground API
View wf.sh
#! /bin/bash
#
# wf.sh - Weather forecasts in your terminal! - v1.0
# by Andy Foreceno <aforceno@pm.me>
#
# To use this script, you must register for the Weather Underground API:
# https://www.wunderground.com/weather/api/
# Obtain an API key and insert it here:
@andyforceno
andyforceno / lastfm-oauth.sh
Last active May 28, 2019
Last.fm authentication flow for the Bash shell
View lastfm-oauth.sh
#! /bin/bash
# Lastfm-oauth - v1.0 (build 20160326)
# A Last.fm OAuth helper script for Bash
#
# by Andy Forceno <aforceno@pm.me>
#
# Reporting of bugs/issues or general inquiries are encouraged
# If you found this helpful, let me know :-)
You can’t perform that action at this time.