Skip to content

Instantly share code, notes, and snippets.

View charlieporth1's full-sized avatar

Charles Porth charlieporth1

View GitHub Profile
@charlieporth1
charlieporth1 / Raspberry Pi Zero SD CARD Ethernet USB gadget Setup bash script
Last active September 1, 2021 00:00
Raspberry Pi Zero SD CARD Ethernet USB gadget Setup bash script
#!/bin/bash
# Change this to your needs. I happen to be on a Macbook Pro
DRIVE_DIR=/Volumes
BOOT_DIR=boot
SD_CARD_DIR=$DRIVE_DIR/$BOOT_DIR
touch $SD_CARD_DIR/ssh
echo "dtoverlay=dwc2" | tee -a $SD_CARD_DIR/config.txt
@charlieporth1
charlieporth1 / AdjustableCreateSwapFile
Last active February 24, 2023 01:50
Adjustable swap file creation and turn on script
#!/bin/bash
# round $1 to $2 decimal places
SWAP_FILE_SIZE_INPUT="${1:-8192}"
SWAP_FILE_LOCATION="${2:-/swapfile}"
round() {
printf "%.${2:-0}f" "$1"
}
ROOT_STORAGE_STATS=`df -h | grep root`
FREE_SPACE=`df -h | grep root | awk '{print $4}'`
MEM_COUNT=$(round `grep MemTotal /proc/meminfo | awk '{print $2 / 1024}'` 0)
@charlieporth1
charlieporth1 / LightenSystemDebian.sh
Last active June 19, 2022 00:23
Lightten Ubuntu for a lighter system
#!/usr/bin/env bash
sudo apt-get purge -y btrfs-progs && sudo update-initramfs -uk all
IMPORTANT_PKGS="network\|dhcp\|avahi\|"
X11_PKGS="x11\|xauth"
DESKTOP_PKGS="xorg\|xserver|desktop\|unity\|xserver\|gnome\|wallpaper\|icon\|lxde\|lxdm\|light-dm\|lightdm\|gdm\|kdm\|kde\|xfce\|lfce"
PRINTER_PKGS="cupsd\|cups-browsed\|accountsservice\|printer\|cups"
UNNEEDED_CLI_PKGS="man-db\|mouse\|wacom\|wayland\|spreadsheet"
AUDIO_PKGS="pulseaudio\|bluetooth\|alsa\|sound\|audio"
@charlieporth1
charlieporth1 / dhcp_ip_disconnect.sh
Last active November 29, 2021 17:02
DHCP Static IP Disconnect fix
#!/usr/bin/env bash
count=3
timeout=12
router=your.router.ip.here
test_ip=1.1.1.1
test_dns=one.one.one.one
sysctl -w net.ipv6.conf.all.forwarding=1
sysctl -w net.ipv4.ip_forward=1
@charlieporth1
charlieporth1 / APT-Fix.sh
Created November 29, 2021 16:54
Simple apt lock & fix for Ubuntu
#!/bin/bash
if [[ -f /var/lib/dpkg/lock ]]; then
rm /var/lib/apt/lists/lock
rm /var/cache/apt/archives/lock
rm /var/lib/dpkg/lock*
fi
yes | sudo dpkg --configure -a
yes | apt -y --fix-broken install
@charlieporth1
charlieporth1 / WireGuard-site-to-site.md
Created December 19, 2021 14:30
Accessing a subnet that is behind a WireGuard client using a site-to-site setup

WireGuard Site-to-Site

Accessing a subnet that is behind a WireGuard client using a site-to-site setup

Problem Summary

We want to access a local subnet remotely, but it is behind a NAT firewall and we can't setup port forwarding. Outgoing connections work, but all incoming connections get DROPPED by the ISP's routing policy.

Solution Summary

@charlieporth1
charlieporth1 / NFTTables_or_IPTables_switcher_Ubuntu_and_Debian.sh
Last active March 26, 2024 02:02
NFTTables or IPTables switcher Ubuntu & Debian
#!/bin/bash
which_tables=$1
timeout_time=180
function set_iptables() {
arg=$1
table=$2
find -L /usr/sbin -name 'iptables*' -type l -exec rm -rf {} \;
find -L /usr/sbin -name 'ip6tables*' -type l -exec rm -rf {} \;
echo 0 | update-alternatives $arg iptables /usr/sbin/iptables-$table
#!/usr/bin/env bash
apt_out_file=/etc/apt/sources.list.d/apt-fast.list
export CPU_CORE_COUNT=`cat /proc/stat | grep cpu | grep -E 'cpu[0-9]+' | wc -l`
export DEBIAN_FRONTEND=noninteractive
export OS_ID=$(cat /etc/os-release | grep -E ^ID= | awk -F= '{print $2}' | awk '{print $1=$1}')
if [[ $OS_ID = ubuntu ]]; then
export VERSION_CODENAME=$(cat /etc/os-release | grep VERSION_CODENAME | awk -F= '{print $2}' | awk '{print $1=$1}')
else
export VERSION_CODENAME=focal
export OS_ID=ubuntu
#!/usr/bin/env bash
export DEBIAN_FRONTEND=noninteractive
export OS_ID=$(cat /etc/os-release | grep -E ^ID= | awk -F= '{print $2}' | awk '{print $1=$1}')
export VERSION_CODENAME=$(cat /etc/os-release | grep VERSION_CODENAME | awk -F= '{print $2}' | awk '{print $1=$1}')
dpkg --add-architecture i386
apt-get update
apt-get install -y ca-certificates apt-transport-https curl wget
@charlieporth1
charlieporth1 / adlists.list
Last active November 1, 2023 15:48
Pi-Hole Adlist
blocklist.site/app/dl/ads
http://hostsfile.mine.nu/hosts0.txt
http://jasonhill.co.uk/pfsense/ytadblock.txt
http://malwaredomains.lehigh.edu/files/domains.txt
http://mirror1.malwaredomains.com/files/justdomains
http://pgl.yoyo.org/adservers/serverlist.php
http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts;showintro=0
http://pilotfiber.dl.sourceforge.net/project/adzhosts/HOSTS.txt
http://private-lists.whisky.software/txt_lists/ctp-lists/china-blacklist.list
http://private-lists.whisky.software/txt_lists/ctp-lists/vulnerability-blacklist.list