Skip to content

Instantly share code, notes, and snippets.

@jtmoon79
jtmoon79 / wireguard-site-to-site.sh
Last active September 29, 2024 20:59
Wireguard Site to Site generator
#!/usr/bin/env bash
#
# https://gist.github.com/jtmoon79/c951f81f621bb87ddb60836245aca4ff
#
# Script to generate a site-to-site Wireguard IPv4 VPN tunnel
# configuration files, and commands for systemd services.
# This script only covers a narrow scope of possible networking arrangements.
# It may not perfectly fit the user's needs, but it may provide the user with
# a working example that they can modify for their needs.
#
@hololeap
hololeap / btrfs-balance.bash
Last active October 2, 2021 20:33
Script to conditionally run `btrfs balance`, suitable as a cron job
#!/bin/bash
allocated_threshold="95" # Don't run balance if less than this much is allocated (percentage)
fs="/"
# The limit (in chunks) is set to be:
# 75% of unused allocated data (in GiB), rounded up to nearest integer
# This may need to be adjusted depending on the setup
balance_awk_formula='{printf("-dlimit=%d\n",($1 - $2) * 0.75 + 1)}'
@eatnumber1
eatnumber1 / renameat2.c
Last active August 18, 2024 22:47
Command-line tool to call renameat2(2)
/*
* Copyright (c) 2023 Russell Harmon
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@dansimau
dansimau / ping-csv.sh
Created December 23, 2011 11:01
Ping a host and output each reply in CSV format
#!/bin/bash
#
# Do a ping and output results as CSV.
#
# [email protected]
# 2011-12-23
#
if [ $# -lt 1 ]; then
echo "Usage: $0 [--add-timestamp] <ping host>"