Skip to content

Instantly share code, notes, and snippets.

@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..."
@papamoose
papamoose / show_GET_and_POST_requests.py
Created October 15, 2021 17:40
A simple web server that displays any GET or POST requests sent to it.
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
@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 / 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 / dkmsbuildall.py
Created January 28, 2021 21:26
Build all DKMS modules
#!/usr/bin/env python3
#
# NOTE: This assumes that all modules and versions are built for at
# least one kernel. If that's not the case, adapt parsing as needed.
import os
import subprocess
# Permission check.
if os.geteuid() != 0:
print("You need to be root to run this script.")
@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 / pdm60onlinuxnotes.md
Last active January 23, 2020 02:48
PDM60 on Linux notes

dmesg output when plugging in the usb serial cable:

[161312.500002] usb 3-2: new full-speed USB device number 3 using xhci_hcd
[161312.926854] usb 3-2: New USB device found, idVendor=0403, idProduct=6001, bcdDevice= 6.00
[161312.926860] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[161312.926863] usb 3-2: Product: FT232R USB UART
[161312.926866] usb 3-2: Manufacturer: FTDI
[161312.926869] usb 3-2: SerialNumber: AC01PV6Q
[161312.966524] usbcore: registered new interface driver usbserial_generic
[161312.966534] usbserial: USB Serial support registered for generic
@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)