Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# =============================================================================
# expand_lvm.sh - Automatically expand LVM volumes on Ubuntu 24.04
# =============================================================================
# This script:
# 1. Detects unallocated disk space on physical volumes
# 2. Expands the partition table entry if needed
# 3. Resizes PVs, extends VGs, extends LVs, and resizes filesystems
#
# Usage: sudo bash expand_lvm.sh [OPTIONS]
@onyxhat
onyxhat / install_r8125.sh
Last active March 10, 2026 00:52
Minisforum MS-S1 Network Driver(s) Install
#!/usr/bin/env bash
# ============================================================
# RTL8125 / RTL8127 10GbE Network Driver Installer
# For Ubuntu 24.04 (Linux 6.8 kernel)
# ============================================================
set -e # Exit immediately on error
DRIVER_NAME="r8125"
DRIVER_VERSION="9.016.08"
@onyxhat
onyxhat / steam-headless-setup.sh
Created December 7, 2025 15:44
Setup Steam-Headless Directories
#!/usr/bin/env bash
# Load env vars (compatible with Komodo)
export $(cat .env | grep -vE '^#|^$|^USER_LOCALES' | xargs)
# Make directories (if not exists)
mkdir -p "${HOME_DIR}"
mkdir -p "${SHARED_SOCKETS_DIR}"/{home,.X11-unix,pulse}
mkdir -p "${GAMES_DIR}"
@onyxhat
onyxhat / Export-Terraformer.ps1
Created May 23, 2022 20:15
Terraformer Export Helper
[CmdletBinding()]
param (
[Parameter()]
[string]
$aws_profile = "VirtixProd",
[Parameter()]
[string[]]
$aws_region = @("us-east-2"),
@onyxhat
onyxhat / get_myip.php
Created March 10, 2019 04:59
simple PHP script to return client IP address
<?php
/**
* Ensures an ip address is both a valid IP and does not fall within
* a private network range.
*/
function validate_ip($ip) {
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) === false) {
return false;
}
return true;
@onyxhat
onyxhat / printenv.groovy
Created February 26, 2019 18:44 — forked from dbt4u/printenv.groovy
Jenkins Groovy to print all env-variables
def env = System.getenv()
env.each{
println it
}
Param (
[string]$VMName,
[int]$vCPU,
[int]$MemoryGB
)
$Settings = New-Object PsObject -Property @{
Name = $VMName
vCPU = $vCPU
MemoryStartupBytes = [int]$MemoryGB * 1GB
[string]$UserName = "myJenkinsUser"
[string]$Jenkins_Token = "myJenkinsUserApiKey"
[uri]$Build_URL = "http://jenkins.local/job/myAwesomeApp/latest/"
$Headers = @{
"Authorization" = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${UserName}:${Jenkins_Token}"))
}
$jobObj = Invoke-RestMethod -Headers $Headers -Uri "${Build_URL}/api/json"
$jobObj
@onyxhat
onyxhat / Create-LinuxVM.ps1
Created August 15, 2018 15:44
Hyper-V script to Automate creation of Linux VMs
$Settings = New-Object PsObject -Property @{
Name = Read-Host "VM Name"
vCPU = Read-Host "vCPU Count"
MemoryStartupBytes = [int]$(Read-Host "GB of RAM") * 1GB
ImgSrc = Read-Host "Source VHD Location"
}
$vmhost = Get-VMHost
if ((Get-VM -Name $Settings.Name -ErrorAction SilentlyContinue) -or (Test-Path -Path "$($vmhost.VirtualHardDiskPath)\$($Settings.Name).vhdx")) {
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

Is a useful one-liner which will give you the full directory name of the script no matter where it is being called from

These will work as long as the last component of the path used to find the script is not a symlink (directory links are OK). If you want to also resolve any links to the script itself, you need a multi-line solution:

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink