Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
total_rss=0
total_vsz=0
total_size=0
while read -r size rss vsz user command; do
total_rss=$((total_rss+rss))
total_vsz=$((total_vsz+vsz))
total_size=$((total_size+size))
@papamoose
papamoose / bolt-zfs-docker-startup
Last active February 4, 2024 00:18
Wait for ThunderBay 6 to be connected via Thunderbolt 3 before attempting to mount zpool.
#!/bin/bash
# This exists because I couldn't figure out to to make
# any of the relevant system units wait for my zpool to become available
# before importing it.
#
# zpool `tank` is a ThunderBay 6 connected via Thunderbolt 3.
#
# bolt.service -> ? -> zfs-import-cache
# ? is possibly just time as it takes a bit for the drives to spin up.
# The nvme pools work fine, for example.
@papamoose
papamoose / inject_nonfree_firmware.sh
Last active November 24, 2023 09:46
add non-free firmware into initrd.gz
#!/bin/bash
set -e
# trap keyboard interrupt (control-c)
trap control_c INT
# Must be run as root
# requires:
# - wget
# - pax
@papamoose
papamoose / One line to rebuild all DKMS modules on Ubuntu
Last active February 4, 2023 19:44 — forked from Brainiarc7/One line to rebuild all DKMS modules on Ubuntu
One line to rebuild all DKMS modules on Ubuntu
#!/bin/bash
ls -d /usr/src/linux-headers-* \
| sed -e 's/.*linux-headers-//' \
| grep generic \
| sort -V \
| tac \
| sudo xargs -n1 /usr/lib/dkms/dkms_autoinstaller start
#!/bin/bash
# iPXE build depends
apt-get install -y liblzma-dev git build-essential
# clone iPXE
[ ! -d ./ipxe ] && git clone http://git.ipxe.org/ipxe.git
cd ipxe/src
make clean
sed -i 's/#undef\tDOWNLOAD_PROTO_HTTPS/#define\tDOWNLOAD_PROTO_HTTPS/' config/general.h
@papamoose
papamoose / ffmpeg.md
Created November 13, 2022 21:52 — forked from steven2358/ffmpeg.md
FFmpeg cheat sheet
#!/bin/bash
umask 022
{% if letsencrypt_eab %}
server={{ letsencrypt_server }}
kid={{ letsencrypt_eab_kid }}
hmac={{ letsencrypt_eab_hmac }}
acmeurl={{ letsencrypt_acmeurl }}
{% elif letsencrypt_testmode %}
server=acme-staging-v02.api.letsencrypt.org
@papamoose
papamoose / README.md
Last active February 13, 2022 16:19
RobinLinus-snapdrop using docker-compose and traefik

Assumes you run Traefik.

You need to checkout the repository so you can mount the server and client directories into the container.

git clone https://github.com/RobinLinus/snapdrop.git

Then modify docker-compose.yml and create templates/default.conf.template.

@papamoose
papamoose / README.md
Created January 6, 2022 20:11
ZFS Health Check & Discord Notification Bash Script

Summary

This is a script I made to check the health of the ZFS pools on my Ubuntu server and send a notification with a summary to a Discord server channel (see image of example notification below) I have made for my servers. I borrowed and modified some parts for the actual ZFS health check from this Gist. The script checks ZFS pools overall condition, capacity, errors and time since last scrub. If an issue is detected with a pool a role on the Discord channel is pinged.

This script is only tested on Ubuntu Server 20.04.

Instructions

Copy the two bash files to a Linux server with ZFS pools and modify as required based on distro/version. Fill inn the Discord variables in the discord-variables.sh file.

@papamoose
papamoose / install-xcode-cli-tools.sh
Created December 8, 2021 17:31 — forked from mokagio/install-xcode-cli-tools.sh
Install Xcode CLI Tools without GUI
#!/bin/bash
# See http://apple.stackexchange.com/questions/107307/how-can-i-install-the-command-line-tools-completely-from-the-command-line
echo "Checking Xcode CLI tools"
# Only run if the tools are not installed yet
# To check that try to print the SDK path
xcode-select -p &> /dev/null
if [ $? -ne 0 ]; then
echo "Xcode CLI tools not found. Installing them..."