This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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...] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
if [ -z "$1" ]; then | |
echo "Usage: $0 new-release-codename" | |
echo "Example: $0 saucy" | |
exit 1 | |
fi | |
NEW_CODENAME="$1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# tests openssl ciphers against a host | |
# source: https://superuser.com/questions/109213/how-do-i-list-the-ssl-tls-cipher-suites-a-particular-website-offers | |
# OpenSSL requires the port number. | |
SERVER=$1 | |
DELAY=1 | |
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g') | |
echo Obtaining cipher list from $(openssl version). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# clean up the current git directory a bit | |
# delete local branches that have been merged to master | |
# note that depending on your workflow, this could delete things you're still working on | |
( git checkout master && git pull ) || exit | |
( git branch -l --merged | egrep -v "\*|master|develop" | xargs git branch -D ) || exit | |
( git remote prune origin && git gc ) || exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# locate old library files that are still in use, such as after an openssl update | |
sudo lsof -n | grep libssl | grep DEL | |
# just the (truncated) names of the app using the library | |
sudo lsof -n | grep libssl | grep DEL | cut -c1-10 | sort | uniq | |
# Note that the names that services run as may also be useful for figuring out what needs to be restarted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add a parameter to a line in a file using sed, where that parameter is missing or may already exist at any position. | |
# Example line: | |
PARAMS=quiet,splash,elevator=noop | |
# On the line that matches, if the entry is not present append it to the line | |
sed '/^PARAMS/ {/audit=1/! s/.*/\&,audit=1/}' grub.conf | |
# Example line: | |
PARAMS="quiet splash elevator=noop" | |
# Same as above but accounts for the trailing quote on the original string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Two example one-liners for showing the lines of a file that that are less than x minutes old | |
# this is quite slow on large files | |
# uses older syslog date format | |
awk ' BEGIN { cmd="date -d \"-5 min\" +%s"; cmd | getline old; close(cmd); } { cmd="date -d \""$1" "$2" "$3"\" +%s"; cmd | getline d; close(cmd); if (d > old) print; } ' /var/log/syslog | |
# uses the slightly different date format | |
awk ' BEGIN { cmd="date -d \"-2 hour\" +%s"; cmd | getline old; close(cmd); } { cmd="date -d \""$1" "$2"\" +%s"; cmd | getline d; close(cmd); if (d > old) print; } ' /var/log/nginx/error.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install virtualbox and qemu | |
qemu-img convert image.vmdk image_2.vmdk image.bin | |
VBoxManage convertdd image.bin image.vdi |