Skip to content

Instantly share code, notes, and snippets.

@xcorvis
xcorvis / script-template.sh
Created December 15, 2020 15:30 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@xcorvis
xcorvis / usb-reset
Last active March 12, 2020 19:32
usb-reset script for linux
#!/bin/sh
if [ "$(id -u)" != 0 ] ; then
echo This must be run as root!
exit 1
fi
# Look for the most common cases
for driver in xhci_hcd ehci_hcd uhci_hcd ; do
# Some distros need to use these instead: xhci-pci ehci-pci uhci-pci