Skip to content

Instantly share code, notes, and snippets.

@jrh-spg
jrh-spg / named_check.sh
Created June 12, 2013 18:51
Q&D script for monitoring if named is running locally.
#!/bin/bash
contact=name@domain.tld
host=`ifconfig eth0|grep inet\ addr|cut -d: -f2|awk {'print $1'}`
check=`dig +short @$host localhost|awk {'print $1'}`
if [ $check != 127.0.0.1 ]
then
# Uncomment the next line for testing.
#echo "He's dead, Jim."
service named restart
grep named /var/log/messages|tail -300 |mail -s "Named failed on `hostname`" $contact
@jrh-spg
jrh-spg / ipcheck.sh
Created October 26, 2013 20:05
Script to email you if your home IP changes.
#!/bin/bash
IP=`cat /tmp/ip`
PUBIP=`curl -s http://icanhazip.com`
EMAIL=youremail@domain.com
if [ "$IP" != "$PUBIP" ]; then
echo $PUBIP|mail -s "IP changed at home" $EMAIL
echo $PUBIP > /tmp/ip
fi
@jrh-spg
jrh-spg / web_backup.sh
Last active January 9, 2016 19:18
Backup script to backup my document root and MySQL databases to a remote backup server.
#!/bin/bash
LOCKFILE=/tmp/.wb.lck
HOST=web01.fisys.us
BACKUPHOST=25.23.239.150
DOCROOT=/var/www
EXCLUDEDB='schema\|mysql'
EXCLUDE=.git
DATE=`date +%Y-%m-%d.%H%M`
BACKUPDIR=/mnt/backup
BACKUPFILE=$BACKUPDIR/$HOST.backup-$DATE.tar.bz2
#!/bin/bash
FILE=/tmp/iibot.pid
while x=0
do
if [ ! -f $FILE ];
then
/bin/bash /home/irc/bot.sh&
fi
sleep 5
done

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
# 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
function imgup
chmod 644 $argv
rsync -paqe ssh $argv mountain:~/images
for i in $argv
echo "http://images.cookietronics.net/$i"
end
end
@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"
@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
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