Skip to content

Instantly share code, notes, and snippets.

@charego
charego / nginx-backup
Created November 24, 2020 06:39
Backup NGINX/webserver config
#!/bin/bash
SCRIPT_DIR=$( cd "$( dirname "$0" )" && pwd )
USER=charles
HOST=gould.dev
echo "Backing up nginx config..."
mkdir -p "${SCRIPT_DIR}/etc/nginx/"
rsync -azv ${USER}@${HOST}:/etc/nginx/ etc/nginx/
@charego
charego / cassandra
Created January 5, 2018 16:34
Cassandra Docker helper
#!/bin/bash
CASSANDRA_IMAGE='cassandra'
CASSANDRA_VERSION='2.2.9'
CASSANDRA_CONTAINER="${CASSANDRA_IMAGE}-${CASSANDRA_VERSION}"
cassandraCreate() {
docker run -d -p 9042:9042 --name ${CASSANDRA_CONTAINER} ${CASSANDRA_IMAGE}:${CASSANDRA_VERSION}
}
@charego
charego / tcpdump-host
Created January 5, 2018 15:39
Run tcpdump on the specified host
#!/bin/bash
HOSTNAME=${1:?Specify the hostname to run tcpdump on}
LOGFILE="/tmp/$HOSTNAME.tcpdump"
sudo tcpdump -i any host $HOSTNAME -w "$LOGFILE"
@charego
charego / vbox
Created January 5, 2018 15:37
VirtualBox VM helper
#!/bin/bash
VM_NAME='ubuntu-64'
vmStart() {
# & (the first one) detaches the command from stdin.
# >/dev/null detaches the shell session from stdout and stderr.
# &disown removes the command from the shell's job list.
VBoxHeadless --startvm "${VM_NAME}" &>/dev/null &disown
@charego
charego / commit-msg
Created April 15, 2015 05:13
Git commit message hook
#!/bin/sh
#
# This hook rejects commit messages that do not have an issue tag.
#
COMMIT_MSG=`cat $1`
COMMIT_PREFIX="\[[A-Z]+-[0-9]+\][[:blank:]][A-Z]"
# The normal way to match regular expression doesn't work on msysGit?
# if [[ $COMMIT_MSG =~ $COMMIT_PREFIX ]]; then