Skip to content

Instantly share code, notes, and snippets.

View ripsnortntear's full-sized avatar

ripsnort ntear ripsnortntear

View GitHub Profile
@ripsnortntear
ripsnortntear / jails.sh
Created March 31, 2025 06:26
This script checks and displays the status of all Fail2Ban jails on the system by iterating through the list of active jails and retrieving their individual statuses.
#!/bin/bash
# Check the status of all Fail2Ban jails
for jail in $(sudo fail2ban-client status | grep 'Jail list:' | cut -d ':' -f 2 | tr -d ' ' | tr ',' ' '); do
sudo fail2ban-client status "$jail"
echo ""
done
@ripsnortntear
ripsnortntear / create_pfx.sh
Created March 31, 2025 06:26
This script converts an SSL certificate and its private key into a PFX file format, specifying output paths and a password for the PFX file.
#!/bin/bash
# Define paths
CERT_PATH="/path/to/cert.pem"
KEY_PATH="/path/to/key.pem"
PFX_PATH="/path/to/output.pfx"
PFX_PASSWORD="your_password" # Set a password for the PFX file
# Create the PFX file
openssl pkcs12 -export -out "$PFX_PATH" -inkey "$KEY_PATH" -in "$CERT_PATH" -passout pass:"$PFX_PASSWORD"
@ripsnortntear
ripsnortntear / create_email_user.sh
Created March 31, 2025 06:24
This script creates a new email user, sets up their Maildir structure, assigns them to the appropriate groups, and prompts for a password, ensuring the user is configured for email services.
#!/bin/bash
# Function to display usage
usage() {
echo "Usage: $0"
echo "This script creates a new email user and sets up the necessary directories and groups."
}
# Check if the script is run as root
if [ "$EUID" -ne 0 ]; then
@ripsnortntear
ripsnortntear / cloudflare_ip_update.sh
Created March 31, 2025 06:22
This script retrieves the current public IP address and updates the corresponding A records in Cloudflare DNS if they differ, using the Cloudflare API and the jq tool for JSON processing.
#!/bin/bash
# Access the environment variables
api_token="CLOUDFLARE_API_TOKEN"
zone_name="FQDN"
# Function to get the current public IP address
get_public_ip() {
curl -s -X GET https://ifconfig.co
}
@ripsnortntear
ripsnortntear / backup_and_restore.sh
Created March 31, 2025 06:18
This Bash script is designed for creating and restoring backups of specified directories on a Unix-like system.
#!/bin/bash
# Define backup and restore directories
BACKUP_DIR="/mnt/storage" # Change this to your desired backup location
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
MAX_SIZE=250M # Maximum size of each archive part (250 MB)
DIRECTORIES=(
"/etc"
"/var"
"/home"
@ripsnortntear
ripsnortntear / Zip_to_CHD_w_cue_support.sh
Created July 27, 2024 18:42
Zip to CHD w cue support.sh
#!/bin/bash
start_time=$(date +%s)
# Set the directory containing the zip files to the current working directory
zip_dir=$PWD
# Define a function to process files
process_files() {
# Process CUE, ISO, and BIN files
for file in *; do