Skip to content

Instantly share code, notes, and snippets.

View starkers's full-sized avatar

David Stark starkers

  • London, UK
  • 13:47 (UTC +01:00)
View GitHub Profile
@starkers
starkers / xpass
Last active May 17, 2021 17:41
generate password and copy it into clipboard
#!/usr/bin/env bash
# See: https://gist.github.com/starkers/234909caf153904e5428
#Check xpass exists
if [ ! -x "$(which xclip)" ]; then
echo "Please install xclip" ; exit 1
fi
#Length of string:
LEN=32
@starkers
starkers / make-bundle
Last active June 10, 2019 03:01
Generate a new client for OpenVPN, create a .ovpn file and bundle it into a zip
#!/usr/bin/env bash
# NB: I use this on centos 6 but should work on other stuff
#
# Ensure that reverse DNS works so it can lookup its IP/hostname
# Also relies on "zip" and dig
#
# ....I should probably do some more checks on:
# Destination folders existence
# client cert is correctly inserted into the index
# host lookup worked
@starkers
starkers / myip
Created May 17, 2014 16:57
Determine you're outbound (http) IP and reverse DNS
#!/usr/bin/env bash
# Depends on curl and dig
TIMEOUT=1
SERVER=4.2.2.3
IP=`curl -s --connect-timeout "$TIMEOUT" https://outboundip.com 2>/dev/null`
#echo :$?:
@starkers
starkers / any2mp3
Last active August 29, 2015 14:01
Convert any flv/mp4 and pretty much anything into .mp3
#!/usr/bin/env bash
# any2mp3
# Converts to mp3 anything mplayer can play
# requires: mplayer and lame
# Also ensure you have space to dump the .wav
TMP=audiodump-`date +%s`.wav
[ "$1" ] || { echo "Usage: $0 file1.wma file2.mp4"; exit 1; }
@starkers
starkers / doorman
Last active August 29, 2015 14:01
Looping command doorman - I use this "doorman" to comapre output of two slightly different commands
#!/usr/bin/env bash
# This script loops forever and waits for a standard STDIN for each loop.
#
# When you hit [RETURN] it pipes you're input into the command you launched the script with
#
# For example.. If I want to compare public DNS records (on 4.2.2.3 for example) with the
# records on my own DNS server.. EG: 1.2.3.4 I would split a terminator it two and run:
# Terminal 1: doorman dig @4.2.2.3 +short
# Terminal 2: doorman dig @1.2.3.4 +short
@starkers
starkers / gencsr
Last active August 29, 2015 14:01
Generate a webserver csr quickly and easily
#!/usr/bin/env bash
#
# simple templating script for Generating CSR's -david@starkers.org 121001
# .. this relies on having openssl availble in your path ..
# Its not elegant but its easy to use..
#
# TODO: too much ugly wraping of whitespace into openssl commands
# (there is another way but I forgot and this works)
# This program is free software. It comes without any warranty, to
@starkers
starkers / prune_old_vols.sh
Last active August 28, 2023 11:11
prune delete and remove old bacula volumes
#!/usr/bin/env bash
#set -x
# Prune and volumes older than 2 months:
PAST=`date --date='-2 months 0 day ago' +%Y-%m-%d`
#EG a hard coded date
#PAST="2012-11-29"
#PAST="2013-11-29"
@starkers
starkers / yubiwatch
Last active August 29, 2015 14:13
yubiwatch
#!/usr/bin/env bash
ENV="$(env)"
if ! grep -q DISPLAY= <<<"$ENV" ; then
echo dunno what your DISPLAY= is, setting default and crossing fingers
export DISPLAY=:0
fi
# simple script that watches for a Yubikey being plugged in..
#
@starkers
starkers / bash-prompt
Created February 2, 2015 14:55
bash git prompt
# I wanted a dead simple reminder if I'm in a git managed directory
# This takes the standard ubuntu $PS1 and adds (branch-name) in "default" terminal colour just before your $ / #
#
# the correct way on centos is to add it to something like /etc/sysconfig/bash-prompt-{xterm,default,screen}
# I can't be arsenaled... -david@starkers.org
#
# centos6: add to /etc/bashrc
# ubuntu14/mint: add to /etc/bash.bashrc
# vim:ts=2:sw=2
@starkers
starkers / wp_backup
Last active August 29, 2015 14:14
wp_backup.sh
#!/usr/bin/env bash
# quickly backs up a wordpress install for you, just specify the wordpress install path
ConfFile="$1/wp-config.php"
if [ "X$1" == "X" ]; then
echo ".. quickly backs up a wordpress database for you, just specify the wordpress install path"