Skip to content

Instantly share code, notes, and snippets.

View sophieforceno's full-sized avatar

sophiejane sophieforceno

  • Connecticut, USA
View GitHub Profile
@sophieforceno
sophieforceno / net-adapt.sh
Last active December 11, 2021 23:40
A Bash script that enables/disables network adapters depending on connectivity
#! /bin/bash
# net-adapt v0.9 (build 110915)
#
# Enables and disables WIFI device depending on ethernet connectivity
# by Sophie Forceno
#
# Distributed under an "I-don't-care-what-you-do-with-this" license
while true
@sophieforceno
sophieforceno / dispd.sh
Last active December 11, 2021 23:40
A Bash script that switches between two displays depending on display connectivity
#! /bin/bash
# dispd: Display Switcher daemon v1.0-(092015)
# by Sophie Forceno
#
# dispd will enable and make active one of two displays depending on which is plugged in
# Currently, allows you to switch between native laptop display and external HDMI monitor
# Execute 'dispd &' to run in background
# Then, plug/unplug your external display and watch the magic happen!
#
@sophieforceno
sophieforceno / gdrive-oauth.sh
Last active December 11, 2021 23:39
Google Drive API OAuth 2.0 for the Bash shell
#! /bin/bash
# gdrive-oauth v1.1 (build 20170321)
# A Bash helper script for Drive API authentication
# by Sophie Forceno
#
# Distributed under the MIT license:
# https://opensource.org/licenses/MIT
# To obtain client_id & secret:
@sophieforceno
sophieforceno / lastfm-oauth.sh
Last active December 11, 2021 23:39
Last.fm authentication flow for the Bash shell
#! /bin/bash
# Lastfm-oauth - v1.0 (build 20160326)
# A Last.fm OAuth helper script for Bash
#
# by Sophie Forceno
#
# Reporting of bugs/issues or general inquiries are encouraged
# If you found this helpful, let me know :-)
@sophieforceno
sophieforceno / wf.sh
Last active December 11, 2021 23:38
Bash script weather forecast via the Weather Underground API
#! /bin/bash
#
# wf.sh - Weather forecasts in your terminal! - v1.0
# by Sophie Forceno
#
# 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:
@sophieforceno
sophieforceno / adisc.sh
Last active December 11, 2021 23:38
Bash script to automate archiving of optical discs
#! /bin/bash
#
# adisc - Optical Disc Auto-Transfer Tool - v0.9
# by Sophie Forceno
#
# 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
@sophieforceno
sophieforceno / netdata-chip.md
Last active August 10, 2020 18:48
Turn your CHIP into a monitoring server with Netdata

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

@sophieforceno
sophieforceno / blockbygeo.sh
Last active December 11, 2021 23:37
Bash script that uses ipset and iptables to block countries
#! /bin/bash
# blockbygeo.sh - Download country ipsets & add to iptables firewall rules
# By: Sophie Forceno
#
# Depends on: wget, ipset, iptables
IFS=$'\n'
action="$1"
country="$2"
@sophieforceno
sophieforceno / nginxfail.sh
Last active January 10, 2022 23:16
Returns daily or all forbidden or refused requests parsed from the Nginx error log
#! /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)"
@sophieforceno
sophieforceno / plex-update.sh
Last active December 11, 2021 23:37
Updates Plex media server running on Ubuntu
#! /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 Sophie Forceno
#
arch=$(uname -m)