This is a set of very specific scripts for my home servers:
- "Starálfur" (NAS, DNS Sinkhole #1, Plex Server)
- "Sæglópur" (VPN, Security)
- "Smáskífa" (Headless Plexamp & AirPlay Client, DNS Sinkhole #2, soon-to-be ASD-B flight tracker)
Maybe they'll inspire you and your scripts. I'm just hosting them here for versioning
backup.sh- Backup directories of interest as
tarfiles or compressed.7zarchives - Configurable compression level
- Automated daily runs with
cron - Downtime is minimized to mere minutes by first copying directories then working on said copies
- Only one param (compression level). The script takes care of the rest
- e.g.
backup 9for max compression (7z mx=9)
- e.g.
- Temporarily reenables Intel's Turbo Boost (see
toggle_turbo_boost.shbelow) for faster compression
- Backup directories of interest as
restore_plex.sh- Restore Plex Media Server config from a timestamped snapshot
- Stops PMS service, deletes current PMS appdata directory, writes snapshot to it, restores permissions, removes instance-specific cache files, then restarts PMS
- Only one param (datetime / snapshot name) required
bad_blocks.sh- Script to detect bad blocks on given storage device
- Optional param:
drive - If no params are given, the script will list attached storage devices and prompt the user to enter a device name
- No need to include
/dev/in the name for either parameter. Just use the storage device or partition name (e.g.sda)
- Optional param:
- Script to detect bad blocks on given storage device
bench.sh- Benchmarks attached storage devices
- Optional param:
drive- If no params are given, the script will list attached storage devices and prompt the user to enter a device name
- No need to include
/dev/in the name for either parameter. Just use the storage device or partition name (e.g.sda)
hdd_smart.sh- Script to query SMART data for given storage device
- Optional param:
drive - If no params are given, the script will list attached storage devices and prompt the user to enter a device name
- No need to include
/dev/in the name for either parameter. Just use the storage device or partition name (e.g.sda)
- Optional param:
- Script to query SMART data for given storage device
temps.sh- Shows formatted temperature data for CPU and attached storage devices
- No params
toggle_turbo_boost.sh- Enables, disables, or toggles Intel's Turbo Boost tech to reduce wattage
- I got a good deal on a K-series i5 chip, but this is a server and it doesn't need high clocks
- Automatically toggles off with
cronwith each reboot - Optional param:
desired_state- Disable:
turbo disable/turbo d/turbo 0 - Enable:
turbo enable/turbo e,turbo 1 - Toggle:
turbo toggle/turbo t/turbo 2 - Report:
turbo report/turbo r,turbo 3 - If no params are given, the script reports the current turbo boost status
- Disable:
- Enables, disables, or toggles Intel's Turbo Boost tech to reduce wattage
geoip.sh- Returns IP geolocation information. Useful for determining VPN status
- Detail flags
f: return full report on IPr: return IP region- None: defaults to
f
wireguard_namespace.sh- Creates "physical" namespace for network adapters
wireguard_refresh.sh- Copies local WG config to
/etc/wireguard/ - Accepts profile name argument
- If profile name is given, it will apply that profile
- If no profile name is given, it will list the available profiles and ask the user to choose
- Example usage:
wgrf us-co-10wgrf
- Copies local WG config to
install_mergerfs.sh- Installs MergerFS prereqs, clones Git repo, builds, installs, then cleans residual files
install_plex.sh- Retrieves specified (hardcoded) Plex Media Server executable, installs it, enables service, verifies service status, then removes executable
force_loudness- Forces a full "loudness analysis" scan on Plex's music library. CPU intensive!!
- Note on logs: CLI loudness jobs don't show in the UI, so consider enabling logs
- Defaults: normal scan, show logs
- Scan flags
-f: kick off forced loudness analysis scan-s: kick off normal loudness analysis scan (no--forcedflag). Redundant since default is "normal scan"
- Logging flags
-v: show logs ("v" for verbose). Redundant since default is "true"-q: hide logs ("q" for quiet)
- Shortcut flags
-l: show logs without starting a scan. Useful if SSH session times out. "l" for logs
- Examples
bash force_loudness.sh: kick off normal scan and show logsbash force_loudness.sh -sv: same as abovebash force_loudness.sh -fq: kick off loudness deep analysis scan but hide logsbash force_loudness.sh -f: kick off loudness deep analysis scan and show logsbash force_loudness.sh -fv: same as above
rotate_screen.sh- Rotates the terminal 90 degrees clockwise by default. Useful when I'm using the Rasberry Pi with my vertical monitor
- Optional parameter for orientation
- e.g.
rotate_screen 1to rotate terminal clockwise. Equivalent torotate_screen
- e.g.
- Bash formatting
- Contains color and style codes for use in prints
- Example color usage:
${YELLOW}Example${NOCOLOR} - Example format usage:
${underline}Example${noformat}
local_weather.sh(alias:lweather)- Used primarily in my Message of the Day (MOTD). Prints a concise weather report for Bloomington, IN (ICAO: KBMG)
- Optional verbose (
v) flag to return slightly longer weather report
startup.sh- gets updates and starts
btop
- gets updates and starts
- Fan control scripts (in
hardware/) withlm-sensors