Skip to content

Instantly share code, notes, and snippets.

tsaavik /
Created May 30, 2023 21:54
# This script grabs the Name, Ip and environment tags from aws.
# It then grabs a cesi conf header file and appends (using heredocs).
# Create the header in our new copy of conf file
cp -f "${config}.head" ${tmpconf}
tsaavik / .tmux.conf
Created August 16, 2021 15:21
# Make things colorful
set -g default-terminal "screen-256color"
setw -g window-status-current-format '#[fg=white]#I:#{?window_zoomed_flag,#[fg=colour201]#W,#W}'
# Window title for Putty,xterm,etc
set -g set-titles on
set -g allow-rename on
# ctrl-b / sets window name to hostname -s
bind-key / send-keys "printf \"\\033k$(hostname -s)\\033\ \"" \; send-keys "Enter"
tsaavik / Fix ssh sockets in Tmux
Last active October 12, 2021 21:58
Are your long running ssh agent sockets failing? Perhaps something is cleaning /tmp? This rc file for ssh fixes all these problems.
# Fix ssh sockets so they always work in Tmux/Screen, even after you re-connect dmcanulty 2021
# After putting this file at ~/.ssh/rc add the following to your ~/.bash_aliases
# alias ssh="SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock; ssh"
# alias git="SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock; git"
# If the symlink does not point at a valid socket, and the env variable is a valid socket, make a symlink
if [ ! -S ~/.ssh/ssh_auth_sock ] && [ -S "$SSH_AUTH_SOCK" ]; then
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
frontend stats
bind :8080
use_backend be_stats unless { path /favicon.ico }
errorfile 503 /etc/haproxy/errors/haproxy-favicon.ico
backend be_stats
stats enable
stats uri /
echo "DNS Checker v1.0 David Mcanulty 2017"
echo -e "\t- # repeatably tests dns and records success/failures\n"
red=$(tput setaf 1)
green=$(tput setaf 2)
tsaavik / gist:11499b9ec281f03c6a3683d526f4fc14
Created April 3, 2017 15:31
Atomic locking for bash scripts
lockfile=/var/lock/$(basename $0)
#Redirects output of file descriptor 5 to lockfile while this script runs
exec 5>"${lockfile}"
# flock file descriptor 5, otherwise fail
if ! flock -n 5 ; then
echo "Exiting: Another instance of $0 is already running";
exit 1
#setup my_project via venv
if [[ ! -d ${venv_path} ]] ;then
echo "Installing virtualenv ..."
virtualenv ${venv_path}
source ${venv_path}/bin/activate
pip install -r ${proj_path}/dependencies.txt
# Following 2 lines only needed if exporting libs
#cd ${proj_path}
tsaavik /
Created August 9, 2016 16:25
Old Process Killer - Finds the passed process name that has been running longer than 24 hours and kills it
# Check for user input
if [[ -z "${process}" ]] ;then
echo "This program requires a process name."
echo "The (oldest) given process name will be killed"
echo "if it has been running for > 24 hours"
exit 1
tsaavik / gist:c176aa97eeee7bac2502ba2b9e01f2a4
Last active July 18, 2016 15:38
Auto start xen instance confs based on images present
# Auto start xen instance confs based on images present
cd /home/dave/xen/images/
for xenimage in *.img ;do
xm create ${xenimage%%\.*}
sleep 30
# This restarts the agent every 30 days, to make sure its not hung
# And also checks that the lockfile isn't more then 1 hour old
check process puppet with pidfile /var/run/puppet/
group system
start program = "/usr/sbin/service puppet start"
stop program = "/usr/sbin/service puppet stop"
if 5 restarts within 5 cycles then timeout
if uptime > 30 days then restart