Skip to content

Instantly share code, notes, and snippets.

@jrh-spg
jrh-spg / icywatch.sh
Last active June 4, 2021 15:03
Icecast connection watcher
#!/bin/bash
TERM=xterm-256color
bold=$(printf '\033[1m')
lred=$(printf '\033[91m')
lblue=$(printf '\033[94m')
white=$(printf '\033[97m')
green=$(printf '\033[92m')
lgreen=$(printf '\033[36m')
yellow=$(printf '\033[33m')
@jrh-spg
jrh-spg / sinkselector.sh
Last active December 22, 2019 18:50
Pulse Audio Sink Selector
#!/bin/bash
tempfile=$(tempfile 2>/dev/null) || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15
INPUT=$(mktemp)
function get_all_sinks() {
pacmd list-sinks | grep -e 'name:' | cut -d: -f2 | cut -d\< -f2 | cut -d\> -f1
}
#!/bin/bash
options=':i:s:d:n:p:h:'
while getopts ${options} option
do
case ${option} in
i) interval=$OPTARG;;
s) site=$OPTARG;;
d) domain=$OPTARG;;
n) nameservers=$OPTARG;;
while [ "$hn" == "" ]; do
clear
read -p "Hostname: " hn
done
clear
echo "network --device eth0 --bootproto=dhcp --hostname ${hn}" > /tmp/network.ks
pw=""
while [ "$pw" == "" ]; do
@jrh-spg
jrh-spg / backup.sh
Last active March 11, 2019 21:07
A simple duplicity backup script
#!/bin/bash
ulimit -n 10000
PIDFILE=/var/run/backup.pid
LOGFILE=/var/log/backup.log
if [ -f "$PIDFILE" ]; then
RUNPID=`cat $PIDFILE`
if ps -p $RUNPID; then
echo "Backups are already running..."
exit 1
@jrh-spg
jrh-spg / diskclone.sh
Last active November 17, 2021 03:52
Disk Cloner Script that uses dd to clone disks
#!/bin/bash
# https://asciinema.org/a/6LZefsbvLjgsuwQHOnQsBEaSj
IF=notset
OF=notset
BS=128M
CURDIR=$(dirname $(realpath -s $0))
SCRIPT=`basename "$0"`
if [[ ! -f /usr/bin/pv ]]; then
echo "pv is not installed. Please install pv and try again"
function imgup
chmod 644 $argv
rsync -paqe ssh $argv mountain:~/images
for i in $argv
echo "http://images.cookietronics.net/$i"
end
end
#!/bin/bash
# Create the lock file to prevent parallel instances.
LOCKFILE=/tmp/.backup.sh.lck
if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
echo "already running"
exit
fi
# make sure the lockfile is removed when we exit and then claim it

Keybase proof

I hereby claim:

  • I am cespgoespoop on github.
  • I am cesp (https://keybase.io/cesp) on keybase.
  • I have a public key whose fingerprint is C61F BFFD DD2F 9065 0E89 FF14 7CB3 DEF1 882B FF97

To claim this, I am signing this object:

#!/bin/bash
FILE=/tmp/iibot.pid
while x=0
do
if [ ! -f $FILE ];
then
/bin/bash /home/irc/bot.sh&
fi
sleep 5
done