Bash shortcuts
Ctrl-a -> go to the start of command line
Ctrl-e -> go to the end of command line
Ctrl-p -> previous command in history
Ctrl-n -> next command in history
Ctrl-f -> next character in command line
Ctrl-b -> previous character in command line
Ctrl-r -> reverse search in history file
Ctrl-d -> delete current character
Ctrl-k -> delete from the prompt to the end of command line
Ctrl-_ -> undo (yes, but limited)
Meta-< -> go to beginning of history file
Meta-> -> go to end of history file
Meta-f -> go to next word in command line
Meta-b -> go to previous word in command line
Better rsync backup script
#!/bin/bash
# Basic backup script
# Written in February 2010
# Set to q to disable verbosity
VERBOSITY="v"
# The program we're using to backup
PROGRAM="rsync"
# The arguments to the program
OPTIONS="-aHP$VERBOSITY"
# The remote machine we're backing up
SERVER="max"
# The local disk to back up to
DISK="/mnt/disk"
# An array of shares on $SERVER to back up
SHARES=(
hr
finance
clients
operations
newsvn
svn
backup/jira
backup/svn/noah
backup/dbbackups/kontrol_live
backup/dbbackups/god
)
# The magic
for share in ${SHARES[*]}; doBash: Monitor file addition/deletion in a directory
Silly little script to monitor changes in a directory (new or removed files)
Takes the destination dir to monitor from stdin
One day I'll learn how to use inotify.
#!/bin/bash
# Monitor a directory for file changes
# (add or remove) as requested
touch /tmp/testdirb.$$
while true
do
find $1 -print > /tmp/testdira.$$
diff /tmp/testdira.$$ /tmp/testdirb.$$ > /tmp/dirdiff
if [ -s /tmp/dirdiff ]
then
sed -i s/"<"/"New files"/ /tmp/dirdiff
sed -i s/">"/"Removed files"/ /tmp/dirdiffAegir batch site backup script
Many Aegir users ask whether there is a way to schedule backups of all sites provisioned in Aegir. Currently at the time of writing, no such scheduling exists within Aegir itself, since we have a few design decisions to work out (such as where to store the backups, especially when multi-server comes in!)
For the meantime, here's a crude little shell script that might help you. You should execute it as the aegir user.
Squelching SMS floods from Nagios being sent via a third party SMS provider
So at work they implemented some 'SMS Squelching' methods to interact with a 'mail > sms' gnokii script to try and 'squelch' megaloads of SMSs that come through from Nagios all at once. It's a bunch of perl and very much specific to working with a serial-attached Nokia and gnokii. The way it essentially worked was that if an SMS got queued to mail2smsgnokii/gsm's spool, the timestamp was compared with the last sms that got sent and if the length of time in between SMS was inside a threshold (say 30 minutes), the SMS would not be sent.
