Skip to content

Instantly share code, notes, and snippets.

@metalrufflez
metalrufflez / monitordhl.sh
Created November 21, 2011 13:54
Script to parse and mail DHL tracking updates
#!/bin/bash
URL='http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=<INSERT_TRACKING_CODE_HERE>%0D%0A'
BULK="$(curl -s "$URL" | egrep -A1 -m1 '<td class=".*" style="width: 5% ;text-align:left">.+</td>' | egrep -o '>.+<' | sed 's/[><]//g')"
CODE="$(echo $BULK | cut -d " " -f1)"
CTLFILE=/root/ctlfile
if [ "$CODE" -ne "$(cat $CTLFILE)" ]; then
echo $CODE > $CTLFILE
mail -s "DHL Update" <INSERT_YOUR_EMAIL_HERE> < <(echo $BULK)
@metalrufflez
metalrufflez / migratevm.sh
Created November 21, 2011 14:05
Migrate Xen 5.* VMs using an external disk on the newhost
#!/bin/bash
# Uncomment the lines below to print the commands instead of executing them
# DEBUG refers to exporting from external dom0
# DEBUG2 refers to importing the vm to local dom0
#DEBUG="echo"
#DEBUG2="echo"
# You HAVE to inform at lease vm and host or else, usage in your face
if [ "$#" -lt 2 ]; then
@metalrufflez
metalrufflez / mlogrotate.sh
Created November 21, 2011 14:08
manual logrotate (remember to adapt the FILE_DATE to your case)
#!/bin/bash
FILE_DIR="/path/to/dir/"
DATE_TARGET=$(date +"%Y%m%d" --date='2 days ago')
for FILE_NAME in $(ls $FILE_DIR/*.log)
do
FILE_DATE=$(echo $FILE_NAME | cut -d"-" -f2 | cut -d"." -f1)
if [ "$FILE_DATE" -le "$DATE_TARGET" ]; then
rm -f $FILE_NAME
@metalrufflez
metalrufflez / ora10bkp.sh
Created November 21, 2011 14:12
Script to fully backup Oracle 10g databases (remember to alter the target date)
#!/bin/bash
export ORACLE_HOME="/path/to/oracle/home"
export ORACLE_SID=SID
DB_BKPDIR="/path/to/backup/directory"
DMPNAME="bkp_$(date +%y%m%d).dmp"
TARNAME="bkp_$(date +%y%m%d).tar.bz2"
LOGNAME="bkp_$(date +%y%m%d).log"
@metalrufflez
metalrufflez / ora10bkphourly.sh
Created November 21, 2011 14:14
Dump an Oracle 10g (set it to run houly on cron)
#!/bin/bash
export ORACLE_HOME="/path/to/oracle/home"
export ORACLE_SID=SID
DB_BKPDIR="/path/to/backup/directory"
#EXPORT DA BASE DE DADOS
echo "Dumping Database"
${ORACLE_HOME}/bin/exp \"/ as sysdba\" file=$DB_BKPDIR/bkp_hourly.dmp log=$DB_BKPDIR/bkp_hourly.log buffer=3000000 compress=y full=y
@metalrufflez
metalrufflez / ora11bkp.sh
Created November 21, 2011 14:16
Full backup an Oracle 11g database (remember to alter the target date to keep the backups)
#!/bin/bash
export ORACLE_HOME="/path/to/oracle/home"
export ORACLE_SID=SID
DB_BKPDIR="/path/to/backup/directory"
DMPFILE="bkp_$(date +%y%m%d).dmp"
TARFILE="bkp_$(date +%y%m%d).tar.bz2"
LOGFILE="bkp_$(date +%y%m%d).log"
@metalrufflez
metalrufflez / ora11bkphourly.sh
Created November 21, 2011 14:17
Dump and Oracle 11g (set it to run houly on cron)
#!/bin/bash
export ORACLE_HOME="/path/to/oracle/home"
export ORACLE_SID=SID
DB_BKPDIR="/path/to/backup/dir"
#EXPORT DA BASE DE DADOS
echo "Dumping Database"
#${ORACLE_HOME}/bin/exp \"/ as sysdba\" file=$DB_BKPDIR/bkp_hourly.dmp log=$DB_BKPDIR/bkp_hourly.log buffer=3000000 compress=y full=y
@metalrufflez
metalrufflez / zmcreateuser.sh
Created December 2, 2011 16:48
Mass create zimbra accounts
#/bin/bash
# zmcreateusers
# Mass create zimbra accounts
#
# AUTHORS: Caio Corrêa, Thompson Alves
# LAST UPDATED: 2011/12/02
#
# Version 1.2: Added the report at the ending
# Version 1.1: Added security check of alias and username
@metalrufflez
metalrufflez / zmparseusers.sh
Last active September 28, 2015 10:18
Create a file to use with the zmcreateusers
#!/bin/bash
# zmparseusers
# Create a formatted list to be used with zmcreateusers
# AUTHOR: Caio Correa
# Provided a file with a list of names like
#
# John Doe
# Lucy Doe
@metalrufflez
metalrufflez / autophoto.sh
Created December 9, 2011 11:55
Takes a screenshot and a photo with isight
#!/bin/bash
PHOTODIR="~/Pictures/AutoPhotos"
/usr/sbin/screencapture -x -t jpg $PHOTODIR/$(date +%Y%m%d-%H%M)s.jpg
# The isightcapture does not comes with OSX, so you'll have to download it somewhere
# The developer took down it's site and I couldn't find it anywhere
/usr/local/bin/isightcapture $PHOTODIR/$(date +%Y%m%d-%H%M)p.jpg