#!/bin/bash
# Filename: evo-backup.sh
# Version: 020112
# Author: robz
# This script creates an encrypted archive of all the relevant Evolution Mail
# directories and preferences to act as a backup to said program. Now I know
# Evo already provides a backup feature but AFAIK it isn't automateable and
# doesn't encrypt. You will need to modify your Evolution launcher/s path/s to
# point at this script instead of just "evolution"
# If you have sym/hard links to your Evolution directories "tar" will follow
# them, "find" however is not setup this way, you'll need the -L option if the
# path to your backup directory uses links. see "man find"
# You're required to have a personal gpg key setup, see "man gpg" or goto menu:
# System > Preferences > Encryption and Keyrings and create one for yourself.
# I would strongly suggest you do a manual Evolution generated backup before
# running this script, as insurance, what works for me bla bla bla :)
/usr/bin/evolution > /dev/null & # Start Evolution Mail.
EVO_PID=$! # Get Evolution process ID.
until [ ! -e /proc/$EVO_PID ]; do sleep 2; done # Loop till quit Evolution.
BUP_LOC="/media/Ext4Backup/Evo-backup" # Where to save backup.
BUPNAME="evo-backup $(date +%H:%M" "%d%m%y).tar.gz" # Dated backup file name.
CRYPTTO="robz-public-key" # Your gpg public key name.
if [ ! -e "$BUP_LOC" ]; then # Do any backups exist?
mkdir -p "$BUP_LOC" # Create save to directory.
# Create a README file with restore instructions, put it with the backups.
cat > "$BUP_LOC/README" << EOF
# The stuff between the angle brackets will need changing to your specifics.
# To restore this Evolution Mail backup, in a terminal do:
cd <The location of your encrypted backup file>
# The next line when executed will require your gpg NOT your login password.
gpg --decrypt --output "evo-backup" "evo-backup <relevent date>.gpg"
# Unzip the achive.
tar xzf evo-backup
# You will need to use Ctrl+H to make the files visible after unzipping.
evolution --force-shutdown
gconftool-2 --shutdown
# The next commands will overwrite existing configurations and files, be sure!
gconftool-2 --unload .evolution.xml
gconftool-2 --load .evolution.xml
cp -r .evolution .camel_certs "$HOME"
# Done.
# How are we now? -- Ready!
EOF
fi
# Delete backups more than 5 days old.
find "$BUP_LOC" -name "evo-backup*" -mtime +5 -delete
# Trims to one backup a day, the newest.
find "$BUP_LOC" -name "evo-backup*" -daystart -mtime -1 -delete
evolution --force-shutdown > /dev/null # Kill Evo processes.
gconftool-2 --shutdown # Kill gconftool-2
gconftool-2 --dump /apps/evolution > .evolution.xml # Create preferences file.
# Create compressed encrypted archive.
tar -chz .evolution .camel_certs .evolution.xml -f "$BUP_LOC/$BUPNAME"
gpg --no-permission-warning --encrypt --recipient \
"$CRYPTTO" "$BUP_LOC/$BUPNAME" && \
shred -zu "$BUP_LOC/$BUPNAME" .evolution.xml # Clean up temp files.
/usr/lib/evolution/*/evolution-alarm-notify & # Restart Evolution alarms.
exit
Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.
Showing posts with label mail. Show all posts
Showing posts with label mail. Show all posts
Gmail checker
#!/bin/bash
# Filename: gmail.sh
# Version: 020311
# Author: robz
# Checks on the half-hour if I have any new "Gmails".
# I don't know how to make this access the Gnome keyring so for now the script
# resides in an "ecryptfs" encrypted "Private" directory ie. username and pass
# in plain sight whilst logged in - good enough? - maybe not for the paranoid!
# You'll need to supply a bing bong sound and an icon.
# Add this to your user crontab - all on one line without the hash character.
# */30 * * * * export DISPLAY=:0 && /$HOME/Private/gmail.sh > /dev/null 2>&1
USER_NAME="<your_user_name>"
PASSWORD="<your_password>"
ICON="/usr/share/app-install/icons/kgmailnotifier.png" # Gnomegmail now :)
HOUR=$(date $NOW +%H)
if [ "$HOUR" -lt "23" ]&&[ "$HOUR" -gt "7" ]; then # Quiet 11pm to 7am.
FROM=$(wget -T 3 -t 1 -q --secure-protocol=SSLv3 --no-check-certificate\
--user=$USER_NAME --password=$PASSWORD\
https://mail.google.com/mail/feed/atom -O - |\
grep "</name>" | sed "s/[</>]//g; s/name//g") # Who from.
HM=$(echo "$FROM" | wc -l) # How many.
if [ -n "$FROM" ]; then # Any senders.
if [ "$HM" -gt "1" ]; then s="s"; fi # Plural or singular.
notify-send -i $ICON ">> NEW MAIL@gmail.com <<"\
"$(echo -e Your inbox contains $HM new message$s\\n"$FROM")"
/usr/bin/canberra-gtk-play --volume 6 -f $SOUND &
fi
fi
# Filename: gmail.sh
# Version: 020311
# Author: robz
# Checks on the half-hour if I have any new "Gmails".
# I don't know how to make this access the Gnome keyring so for now the script
# resides in an "ecryptfs" encrypted "Private" directory ie. username and pass
# in plain sight whilst logged in - good enough? - maybe not for the paranoid!
# You'll need to supply a bing bong sound and an icon.
# Add this to your user crontab - all on one line without the hash character.
# */30 * * * * export DISPLAY=:0 && /$HOME/Private/gmail.sh > /dev/null 2>&1
USER_NAME="<your_user_name>"
PASSWORD="<your_password>"
ICON="/usr/share/app-install/icons/kgmailnotifier.png" # Gnomegmail now :)
HOUR=$(date $NOW +%H)
if [ "$HOUR" -lt "23" ]&&[ "$HOUR" -gt "7" ]; then # Quiet 11pm to 7am.
FROM=$(wget -T 3 -t 1 -q --secure-protocol=SSLv3 --no-check-certificate\
--user=$USER_NAME --password=$PASSWORD\
https://mail.google.com/mail/feed/atom -O - |\
grep "</name>" | sed "s/[</>]//g; s/name//g") # Who from.
HM=$(echo "$FROM" | wc -l) # How many.
if [ -n "$FROM" ]; then # Any senders.
if [ "$HM" -gt "1" ]; then s="s"; fi # Plural or singular.
notify-send -i $ICON ">> NEW MAIL@gmail.com <<"\
"$(echo -e Your inbox contains $HM new message$s\\n"$FROM")"
/usr/bin/canberra-gtk-play --volume 6 -f $SOUND &
fi
fi
Subscribe to:
Posts (Atom)