Skip to content

Instantly share code, notes, and snippets.

@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
@papamoose
papamoose / ffmpeg.md
Created November 13, 2022 21:52 — forked from steven2358/ffmpeg.md
FFmpeg cheat sheet
@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..."
@papamoose
papamoose / README.md
Created June 29, 2021 16:19 — forked from thomedes/README.md
Compare string versions in bash

version_cmp()

Simple function to (properly) compare version strings in bash

The problem

You can not do alphabetic comparison:

@papamoose
papamoose / tmux-cheatsheet.markdown
Created December 28, 2020 19:50 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@papamoose
papamoose / kextidentifiers.py
Created August 7, 2019 16:24 — forked from erikng/kextidentifiers.py
kextidentifiers.py
#!/usr/bin/python
# For mojave only
# In order for this to work, you will need to go to System Preferences in Mojave -> Security & Privacy -> Privacy -> Full Disk Access and grant Terminal.app permissions
import sqlite3
conn = sqlite3.connect('/var/db/SystemPolicyConfiguration/KextPolicy')
c = conn.cursor()
query = 'SELECT * FROM kext_policy'
c.execute(query)
@papamoose
papamoose / _INSTALL.md
Last active October 1, 2019 16:38 — forked from robinsmidsrod/_INSTALL.md
Bootstrapping full iPXE native menu with customizable default option with timeout (also includes working Ubuntu 12.04 preseed install)

Add the following chunk to your existing ISC dhcpd.conf file.

if exists user-class and ( option user-class = "iPXE" ) {
    filename "http://boot.smidsrod.lan/boot.ipxe";
}
else {
    filename "undionly.kpxe";
}

(or see https://gist.github.com/4008017 for a more elaborate setup

@papamoose
papamoose / python3_virtualenv.txt
Created July 12, 2018 17:36 — forked from wynemo/python3_virtualenv.txt
creating a python3 virtualenv environment
#install gcc git build-essential python3
$ sudo aptitude install gcc git build-essential python3
#from http://www.pip-installer.org/en/latest/installing.html
$ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
$ mkdir python3_prole
$ cd python3_prole/
$ python virtualenv.py -p /usr/bin/python3 env
$ python virtualenv.py --relocatable -p /usr/bin/python3 env
@papamoose
papamoose / lsof_funcs.py
Created May 7, 2018 16:56 — forked from lebedov/lsof_funcs.py
Python functions for finding open files and PIDs that have opened a file.
#!/usr/bin/env python
"""
Python functions for finding open files and PIDs that have opened a file.
"""
import numbers
import subprocess
try: