Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 308 → Rev 309

/bash/check-wireless.sh
File deleted
Property changes:
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: backup.sh
===================================================================
--- backup.sh (revision 308)
+++ backup.sh (nonexistent)
@@ -1,129 +0,0 @@
-#!/bin/bash
-#
-# This script actss as a frontend for rsnapshot. It checks to see if
-# my laptop is connected to my network at home, and if it is, then
-# it fires up the backup.
-#
-# To install the script, add the following line to /etc/cron.d/rsnapshot
-#
-# 00 2 * * * root /home/dhylands/projects/bash/backup.sh daily
-#
-# cron should pick up the change automatically
-
-scriptname=$(basename $0)
-scriptdir=$(dirname $0)
-
-LOG=/var/log/backup.log
-
-HOSTNAME=$(hostname)
-
-echo "$(date): ==============================================" >> ${LOG}
-echo "$(date): Starting backup of HOSTNAME = ${HOSTNAME}" >> ${LOG}
-
-BACKUP_MOUNT=/backup-dave
-BACKUP_DIR=${BACKUP_MOUNT}/${HOSTNAME}
-
-# Check to see if we're at home or not.
-
-CHECK_WIRELESS=0
-
-case ${HOSTNAME} in
-
- # These machines are always attached to the network, so don't
- # need the wireless check
-
- dave-ubuntu)
- CHECK_WIRELESS=0
- ;;
-
- dave-laptop)
- CHECK_WIRELESS=1
- ;;
-
- *)
- echo "$(date): Unrecognized hostname '${HOSTNAME}'" >> ${LOG}
- exit 0
- ;;
-
-esac
-
-if [ ${CHECK_WIRELESS} = 1 ];
-then
- if ! ${scriptdir}/check-wireless.sh >> ${LOG}
- then
- exit 1
- fi
-fi
-
-#
-# Check to see that /backup-dave is mounted, and if not
-# then mount it
-#
-
-if mount | grep ${BACKUP_MOUNT}
-then
- echo "$(date): ${BACKUP_MOUNT} appears to be mounted." >> ${LOG}
-else
- echo "$(date): ${BACKUP_MOUNT} doesn't appear to be mounted - trying to mount" >> ${LOG}
-
- # Volume doesn't appear to be mounted. Mount it now
- # so we don't backup locally
-
- if mount ${BACKUP_MOUNT}
- then
- echo "$(date): ${BACKUP_MOUNT} mounted successfully" >> ${LOG}
- else
- echo "$(date): Unable to mount ${BACKUP_MOUNT} - aborting backup" >> ${LOG}
- exit 1
- fi
-fi
-
-#
-# Since we may not be connected to the network all of the time, we run this
-# script often, but only do the backups when the oldest backup of a given
-# level is more than it's period old. So when weekly.0 is more than a week
-# old then we do a weekly backup.
-#
-
-daySecs=$(( 24 * 60 * 60 ))
-weekSecs=$(( $daySecs * 7 ))
-monthSecs=$(( $daySecs * 365 / 12 ))
-
-currTime=$(date '+%s')
-
-#
-# Always do a daily backup
-#
-
-echo "$(date): Started daily rsnapshot" >> ${LOG}
-nice /usr/bin/rsnapshot -v daily >> ${LOG} 2>&1
-echo "$(date): Finished daily rsnapshot" >> ${LOG}
-
-weekStamp=$(find ${BACKUP_DIR}/ -maxdepth 1 -name weekly.0 -printf '%T@\n')
-weekStamp=${weekStamp%.*}
-
-if [ $(( $weekStamp + $weekSecs + $weekSecs )) -lt $currTime ]
-then
- # weekly.0 is more than two weeks old. Do a weekly backup.
- # We need to use two weeks since daily.6 will become weekly.0
- # and daily.6 is already a week old
-
- echo "$(date): Started weekly rsnapshot" >> ${LOG}
- nice /usr/bin/rsnapshot -v weekly >> ${LOG} 2>&1
- echo "$(date): Finished weekly rsnapshot" >> ${LOG}
-fi
-
-monthStamp=$(find ${BACKUP_DIR}/ -maxdepth 1 -name monthly.0 -printf '%T@\n')
-monthStamp=${monthStamp%.*}
-
-if [ $(( $monthStamp + $monthSecs + $monthSecs )) -lt $currTime ]
-then
- # monthly.0 is more than two months old. Do a monthly backup.
- # weekly.4 will become monthly.0
-
- echo "$(date): Started monthly rsnapshot" >> ${LOG}
- nice /usr/bin/rsnapshot -v monthly >> ${LOG} 2>&1
- echo "$(date): Finished monthly rsnapshot" >> ${LOG}
-fi
-
-
/backup.sh
Property changes:
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: bin/check-wireless.sh
===================================================================
--- bin/check-wireless.sh (nonexistent)
+++ bin/check-wireless.sh (revision 309)
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# Script which checks to see if we're at home
+#
+# Check to see if we're on my wireless LAN
+#
+# For reference, the output of iwconfig looks like this when associated:
+#
+# eth1 IEEE 802.11b/g ESSID:"Seeker-WLAN" Nickname:"Broadcom 4306"
+# Mode:Managed Frequency=2.437 GHz Access Point: 00:00:00:00:00:00
+# Bit Rate=24 Mb/s Tx-Power=15 dBm
+# RTS thr:off Fragment thr:off
+# Link Quality=60/100 Signal level=-62 dBm Noise level=-72 dBm
+# Rx invalid nwid:0 Rx invalid crypt:30678 Rx invalid frag:0
+# Tx excessive retries:0 Invalid misc:0 Missed beacon:0
+
+SSID=$(/sbin/iwconfig 2>&1 | grep ESSID | sed -e 's/^.*ESSID://' -e 's/ .*//' -e 's/"//g')
+
+case "${SSID}" in
+
+ Blue-Heron*)
+ echo "$(date): SSID: ${SSID}: Home network detected"
+ exit 0
+ ;;
+
+ *)
+ echo "$(date): SSID ${SSID}: Not on home network"
+ exit 1
+ ;;
+esac
+
/bin/check-wireless.sh
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: bin/pathlist
===================================================================
--- bin/pathlist (nonexistent)
+++ bin/pathlist (revision 309)
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# This script prints out your PATH, one subdirectory per line.
+#
+
+IFS=:
+
+RED="\033[1;31m"
+GREEN="\033[1;32m"
+NO_COLOR="\033[0m"
+
+
+for dir in ${PATH}
+do
+ if [ -d ${dir} ]
+ then
+ echo -e "${GREEN}${dir}${NO_COLOR}"
+ else
+ echo -e "${RED}${dir}${NO_COLOR} - doesn't exist"
+ fi
+done
+
/bin/pathlist
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: bin/git-setup.sh
===================================================================
--- bin/git-setup.sh (nonexistent)
+++ bin/git-setup.sh (revision 309)
@@ -0,0 +1,14 @@
+#!/bin/sh
+#
+# This script does some common git setup that I do for any new account/machine I use.
+#
+
+git config --global user.name "Dave Hylands"
+git config --global user.email "dhylands@broadcom.com"
+git config --global color.diff auto
+git config --global color.status auto
+git config --global color.branch auto
+
+git config --global alias.status-report \!sh -c "git log --pretty='%C(yellow)%h%Creset %cn %Cgreen%cr%Creset %s\'" \| grep Hylands
+git config --global alias.summary-report \!sh -c "git log --pretty='%C(yellow)%h%Creset %cn %Cgreen%cr%Creset %s\'"
+
/bin/git-setup.sh
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: bin/backup.sh
===================================================================
--- bin/backup.sh (nonexistent)
+++ bin/backup.sh (revision 309)
@@ -0,0 +1,129 @@
+#!/bin/bash
+#
+# This script actss as a frontend for rsnapshot. It checks to see if
+# my laptop is connected to my network at home, and if it is, then
+# it fires up the backup.
+#
+# To install the script, add the following line to /etc/cron.d/rsnapshot
+#
+# 00 2 * * * root /home/dhylands/projects/bash/backup.sh daily
+#
+# cron should pick up the change automatically
+
+scriptname=$(basename $0)
+scriptdir=$(dirname $0)
+
+LOG=/var/log/backup.log
+
+HOSTNAME=$(hostname)
+
+echo "$(date): ==============================================" >> ${LOG}
+echo "$(date): Starting backup of HOSTNAME = ${HOSTNAME}" >> ${LOG}
+
+BACKUP_MOUNT=/backup-dave
+BACKUP_DIR=${BACKUP_MOUNT}/${HOSTNAME}
+
+# Check to see if we're at home or not.
+
+CHECK_WIRELESS=0
+
+case ${HOSTNAME} in
+
+ # These machines are always attached to the network, so don't
+ # need the wireless check
+
+ dave-ubuntu)
+ CHECK_WIRELESS=0
+ ;;
+
+ dave-laptop)
+ CHECK_WIRELESS=1
+ ;;
+
+ *)
+ echo "$(date): Unrecognized hostname '${HOSTNAME}'" >> ${LOG}
+ exit 0
+ ;;
+
+esac
+
+if [ ${CHECK_WIRELESS} = 1 ];
+then
+ if ! ${scriptdir}/check-wireless.sh >> ${LOG}
+ then
+ exit 1
+ fi
+fi
+
+#
+# Check to see that /backup-dave is mounted, and if not
+# then mount it
+#
+
+if mount | grep ${BACKUP_MOUNT}
+then
+ echo "$(date): ${BACKUP_MOUNT} appears to be mounted." >> ${LOG}
+else
+ echo "$(date): ${BACKUP_MOUNT} doesn't appear to be mounted - trying to mount" >> ${LOG}
+
+ # Volume doesn't appear to be mounted. Mount it now
+ # so we don't backup locally
+
+ if mount ${BACKUP_MOUNT}
+ then
+ echo "$(date): ${BACKUP_MOUNT} mounted successfully" >> ${LOG}
+ else
+ echo "$(date): Unable to mount ${BACKUP_MOUNT} - aborting backup" >> ${LOG}
+ exit 1
+ fi
+fi
+
+#
+# Since we may not be connected to the network all of the time, we run this
+# script often, but only do the backups when the oldest backup of a given
+# level is more than it's period old. So when weekly.0 is more than a week
+# old then we do a weekly backup.
+#
+
+daySecs=$(( 24 * 60 * 60 ))
+weekSecs=$(( $daySecs * 7 ))
+monthSecs=$(( $daySecs * 365 / 12 ))
+
+currTime=$(date '+%s')
+
+#
+# Always do a daily backup
+#
+
+echo "$(date): Started daily rsnapshot" >> ${LOG}
+nice /usr/bin/rsnapshot -v daily >> ${LOG} 2>&1
+echo "$(date): Finished daily rsnapshot" >> ${LOG}
+
+weekStamp=$(find ${BACKUP_DIR}/ -maxdepth 1 -name weekly.0 -printf '%T@\n')
+weekStamp=${weekStamp%.*}
+
+if [ $(( $weekStamp + $weekSecs + $weekSecs )) -lt $currTime ]
+then
+ # weekly.0 is more than two weeks old. Do a weekly backup.
+ # We need to use two weeks since daily.6 will become weekly.0
+ # and daily.6 is already a week old
+
+ echo "$(date): Started weekly rsnapshot" >> ${LOG}
+ nice /usr/bin/rsnapshot -v weekly >> ${LOG} 2>&1
+ echo "$(date): Finished weekly rsnapshot" >> ${LOG}
+fi
+
+monthStamp=$(find ${BACKUP_DIR}/ -maxdepth 1 -name monthly.0 -printf '%T@\n')
+monthStamp=${monthStamp%.*}
+
+if [ $(( $monthStamp + $monthSecs + $monthSecs )) -lt $currTime ]
+then
+ # monthly.0 is more than two months old. Do a monthly backup.
+ # weekly.4 will become monthly.0
+
+ echo "$(date): Started monthly rsnapshot" >> ${LOG}
+ nice /usr/bin/rsnapshot -v monthly >> ${LOG} 2>&1
+ echo "$(date): Finished monthly rsnapshot" >> ${LOG}
+fi
+
+
/bin/backup.sh
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property