initial commit of a *whole bunch* of old Egressive shell scripts, used to make many people redundant.

This commit is contained in:
Dave Lane 2016-03-16 13:43:31 +13:00
commit 43e0f5b59e
329 changed files with 31937 additions and 0 deletions

155
egrsynclogs/egrsync Executable file
View file

@ -0,0 +1,155 @@
#!/bin/bash
#
# script to do drive mirroring of another machine
# Copyright 2002, David Lane for Egressive Limited, www.egressive.com
#
#
VERSION=0.1
#
# Defaults
#
# default configuration file
DEF_CONF=/etc/egrsync/egrsync.conf
#
# default log file
DEF_LOG=/var/log/egrsync.log
#
# Commands
# the current date
DATE=`date '+%Y-%m-%d-%a'`
#
# a timestamp for logging purposes
TIMESTAMP=`date '+%Y-%m-%d %H:%M.%S'`
#
# function to direct a message...
message() {
echo "$0: $TIMESTAMP $@" >> $LOG
verbose "$TIMESTAMP $@"
}
#
# insert a blank line into the log and on the console
insert_blank() {
echo "" >> $LOG
verbose ""
}
#
# function to direct a message...
verbose() {
if test $VERBOSE=1 ; then
echo "$@"
fi
}
#
# function to perform the rsyncing
do_rsync() {
build_excludes
message "performing rsync of $SERVER..."
for DIR in $DIRS ;
do
message "starting $DIR on $SERVER (as $USER) into $BASEDIR..."
rsync $FLAGS $EXCLUDES $USER@$SERVER:$DIR $BASEDIR >> $LOG
message "done with $DIR."
done
}
#
# build excludes list
build_excludes() {
message "building excludes"
for PAT in $EXCLUDE
do
EXCLUDES="$EXCLUDES --exclude $PAT"
done
}
#
#
# control loop, using external arguments
#
# process command line arguments
#
# set some default values, so that we can test if they've
# been set in the configuration file...
VERBOSE=0
CONF=0
LOG=""
#
# set the default mode in case somebody figures out how to get
# past the options below...
MODE=help
#
# cycle through the commandline options
while test $# -ne 0 ; do # while there are arguments
case $1 in
--config|-c)
shift # shift from the flag to the value
verbose "setting configuration file to $1"
CONF=$1 # record the value
;;
--log|-l)
shift # shift from the flag to the value
verbose "setting log file to $1"
LOG=$1 # record the value
;;
--verbose|-v)
VERBOSE=1
verbose "setting verbosity to true"
;;
#
# these are the primary (and mutually exclusive) modes
# of operation for this system...
--rsync|-r)
MODE=do_rsync
verbose "setting mode to $MODE"
;;
--help|-?|?|-h)
MODE=help
verbose "setting mode to $MODE"
;;
esac
shift
done
#
# set the log file appropriately
#
if test -z $LOG ; then
LOG=$DEF_LOG
fi
#
# read in config info, from the config
# file provided, or, if none is provided
# from the default file...
if test -f $CONF ; then
. $CONF
message "reading config file: $CONF"
elif test -f "$DEF_CONF" ; then
message "reading default config file: $DEF_CONF"
. "$DEF_CONF"
else
message "config file $DEF_CONF does not exist!"
exit 1
fi
#
# Now actually try to do the job we've been asked to do...
#
case $MODE in
do_rsync)
do_rsync
insert_blank
;;
help)
echo ""
echo "$0 version $VERSION, copyright 2002 Egressive Limited, www.egressive.com"
echo ""
echo "Use rsync to mirror a series of paths (excluding some files if desired)"
echo ""
echo "Usage: $0 {-r|-c|-l}"
echo "-r or --rsync - rsyncs the directories described in $DEF_CONF - "
echo " or the conf file specifed by -c"
echo "-v or --verbose - give extra feedback on progress to stdout"
echo "-c or --config config_filename - use an alternate configuration file"
echo "-l or --log log_filename - use an alternate log file"
echo "-? or --help - display this help information"
echo ""
exit 1
;;
esac
exit 0

154
egrsynclogs/egrsync.bak Executable file
View file

@ -0,0 +1,154 @@
#!/bin/bash
#
# script to do drive mirroring of another machine
# Copyright 2002, David Lane for Egressive Limited, www.egressive.com
#
#
VERSION=0.1
#
# Defaults
#
# default configuration file
DEF_CONF=/etc/egrsync/egrsync.conf
#
# default log file
DEF_LOG=/etc/egrsync/egrsync.log
#
# Commands
# the current date
DATE=`date '+%Y-%m-%d-%a'`
#
# a timestamp for logging purposes
TIMESTAMP=`date '+%Y-%m-%d %H:%M.%S'`
#
# function to direct a message...
message() {
echo "$0: $TIMESTAMP $@" >> $LOG
verbose "$TIMESTAMP $@"
}
#
# insert a blank line into the log and on the console
insert_blank() {
echo "" >> $LOG
verbose ""
}
#
# function to direct a message...
verbose() {
if test $VERBOSE=1 ; then
echo "$@"
fi
}
#
# function to perform the rsyncing
rsync() {
excludes
message "performing rsync..."
for DIR in $DIRS ;
do
message "starting $DIR..."
rsync $FLAGS $EXCLUDES $USER@$SERVER:$DIR $BASEDIR
message "done with $DIR."
done
}
#
# build excludes list
excludes() {
for PAT in $EXCLUDE ;
do
EXCLUDES="$EXCLUDES --exclude $PAT"
done
}
#
#
# control loop, using external arguments
#
# process command line arguments
#
# set some default values, so that we can test if they've
# been set in the configuration file...
VERBOSE=0
CONF=0
LOG=""
#
# set the default mode in case somebody figures out how to get
# past the options below...
MODE=help
#
# cycle through the commandline options
while test $# -ne 0 ; do # while there are arguments
case $1 in
--config|-c)
shift # shift from the flag to the value
verbose "setting configuration file to $1"
CONF=$1 # record the value
;;
--log|-l)
shift # shift from the flag to the value
verbose "setting log file to $1"
LOG=$1 # record the value
;;
--verbose|-v)
VERBOSE=1
verbose "setting verbosity to true"
;;
#
# these are the primary (and mutually exclusive) modes
# of operation for this system...
--rsync|-r)
MODE=rsync
verbose "setting mode to $MODE"
;;
--help|-?|?|-h)
MODE=help
verbose "setting mode to $MODE"
;;
esac
shift
done
#
# set the log file appropriately
#
if test -z $LOG ; then
LOG=$DEF_LOG
fi
#
# read in config info, from the config
# file provided, or, if none is provided
# from the default file...
if test -f $CONF ; then
. $CONF
message "reading config file: $CONF"
elif test -f "$DEF_CONF" ; then
message "reading default config file: $DEF_CONF"
. "$DEF_CONF"
else
message "config file $DEF_CONF does not exist!"
exit 1
fi
#
# Now actually try to do the job we've been asked to do...
#
case $MODE in
rsync)
rsync
insert_blank
;;
help)
echo ""
echo "$0 version $VERSION, copyright 2002 Egressive Limited, www.egressive.com"
echo ""
echo "Use rsync to mirror a series of paths (excluding some files if desired)"
echo ""
echo "Usage: $0 {-r|-c|-l}"
echo "-r or --rsync - rsyncs the directories described in $DEF_CONF -
echo " or the conf file specifed by -c"
echo "-v or --verbose - give extra feedback on progress to stdout"
echo "-c or --config config_filename - use an alternate configuration file"
echo "-l or --log log_filename - use an alternate log file"
echo "-? or --help - display this help information"
echo ""
exit 1
;;
esac
exit 0

12
egrsynclogs/egrsync.cron Executable file
View file

@ -0,0 +1,12 @@
#
# run system mirroring sessions
#
# hourly - every hour from 7am to 9pm 7 days a week...
10 7-21 * * mon,tue,wed,thu,fri,sat,sun egrsync /etc/egrsync/egrsync -r -c /etc/egrsync/hourly.conf
#37 23 * * * root /etc/egrsync/egrsync -r -c /etc/egrsync/hourly.conf
#
# daily - at 2:30 am, mon-sat
15 2 * * mon,tue,wed,thu,fri,sat egrsync /etc/egrsync/egrsync -r -c /etc/egrsync/daily.conf
#
# weekly - at 2:30 am, sun
45 2 * * sun egrsync /etc/egrsync/egrsync -r -c /etc/egrsync/weekly.conf

11
egrsynclogs/egrsync.gruyere Executable file
View file

@ -0,0 +1,11 @@
#
# run system mirroring sessions
#
# hourly - every hour from 7am to 9pm 7 days a week...
10 7-21/3 * * mon,tue,wed,thu,fri,sat,sun root /etc/egrsync/egrsync -r -c /etc/egrsync/gruyere/hourly.conf
#
# daily - at 2:30 am, mon-sat
#15 2 * * mon,tue,wed,thu,fri,sat root /etc/egrsync/egrsync -r -c /etc/egrsync/gruyere/daily.conf
#
# weekly - at 2:30 am, sun
#45 2 * * sun root /etc/egrsync/egrsync -r -c /etc/egrsync/gruyere/weekly.conf

11
egrsynclogs/egrsync.new Executable file
View file

@ -0,0 +1,11 @@
#
# run system mirroring sessions
#
# hourly - every hour from 7am to 9pm 7 days a week...
10 7-21/3 * * mon,tue,wed,thu,fri,sat,sun root /etc/egrsync/egrsync -r -c /etc/egrsync/new/hourly.conf
#
# daily - at 2:30 am, mon-sat
15 2 * * mon,tue,wed,thu,fri,sat root /etc/egrsync/egrsync -r -c /etc/egrsync/new/daily.conf
#
# weekly - at 2:30 am, sun
45 2 * * sun root /etc/egrsync/egrsync -r -c /etc/egrsync/new/weekly.conf

11
egrsynclogs/egrsync.work Executable file
View file

@ -0,0 +1,11 @@
#
# run system mirroring sessions
#
# hourly - every hour from 7am to 9pm 7 days a week...
#5 7-21 * * mon,tue,wed,thu,fri,sat,sun egrsync /etc/egrsync/egrsync -r -c /etc/egrsync/work/hourly.conf
#
# daily - at 2:30 am, mon-sat
25 2 * * mon,tue,wed,thu,fri,sat root /etc/egrsync/egrsync -r -c /etc/egrsync/work/daily.conf
#
# weekly - at 2:30 am, sun
50 2 * * sun root /etc/egrsync/egrsync -r -c /etc/egrsync/work/weekly.conf

145
egrsynclogs/egrsynclogs Executable file
View file

@ -0,0 +1,145 @@
#!/bin/bash
#
# script to do drive mirroring of another machine
# Copyright 2002, David Lane for Egressive Limited, www.egressive.com
#
#
VERSION=0.1
#
# Defaults
#
# default configuration file
DEF_CONF=/etc/egrsynclogs/egrsynclogs.conf
#
# default log file
DEF_LOG=/var/log/egrsynclogs.log
#
# Commands
# the current date
DATE=`date '+%Y-%m-%d-%a'`
#
# a timestamp for logging purposes
TIMESTAMP=`date '+%Y-%m-%d %H:%M.%S'`
#
# function to direct a message...
message() {
echo "$0: $TIMESTAMP $@" >> $LOG
verbose "$TIMESTAMP $@"
}
#
# insert a blank line into the log and on the console
insert_blank() {
echo "" >> $LOG
verbose ""
}
#
# function to direct a message...
verbose() {
if test $VERBOSE=1 ; then
echo "$@"
fi
}
#
# function to perform the rsyncing
do_rsync() {
message "performing rsync of $SERVER..."
for DIR in $DIRS ;
do
message "starting $DIR on $SERVER (as $USER) into $BASEDIR..."
rsync $FLAGS $EXCLUDES $USER@$SERVER:$DIR $BASEDIR >> $LOG
message "done with $DIR."
done
}
#
#
# control loop, using external arguments
#
# process command line arguments
#
# set some default values, so that we can test if they've
# been set in the configuration file...
VERBOSE=0
CONF=0
LOG=""
#
# set the default mode in case somebody figures out how to get
# past the options below...
MODE=help
#
# cycle through the commandline options
while test $# -ne 0 ; do # while there are arguments
case $1 in
--config|-c)
shift # shift from the flag to the value
verbose "setting configuration file to $1"
CONF=$1 # record the value
;;
--log|-l)
shift # shift from the flag to the value
verbose "setting log file to $1"
LOG=$1 # record the value
;;
--verbose|-v)
VERBOSE=1
verbose "setting verbosity to true"
;;
#
# these are the primary (and mutually exclusive) modes
# of operation for this system...
--rsync|-r)
MODE=do_rsync
verbose "setting mode to $MODE"
;;
--help|-?|?|-h)
MODE=help
verbose "setting mode to $MODE"
;;
esac
shift
done
#
# set the log file appropriately
#
if test -z $LOG ; then
LOG=$DEF_LOG
fi
#
# read in config info, from the config
# file provided, or, if none is provided
# from the default file...
if test -f $CONF ; then
. $CONF
message "reading config file: $CONF"
elif test -f "$DEF_CONF" ; then
message "reading default config file: $DEF_CONF"
. "$DEF_CONF"
else
message "config file $DEF_CONF does not exist!"
exit 1
fi
#
# Now actually try to do the job we've been asked to do...
#
case $MODE in
do_rsync)
do_rsync
insert_blank
;;
help)
echo ""
echo "$0 version $VERSION, copyright 2005 Egressive Limited, www.egressive.com"
echo ""
echo "Use rsync to mirror a series files with certain permissions on one machine on this machine."
echo ""
echo "Usage: $0 {-r|-c|-l}"
echo "-r or --rsync - rsyncs the directories described in $DEF_CONF - "
echo " or the conf file specifed by -c"
echo "-v or --verbose - give extra feedback on progress to stdout"
echo "-c or --config config_filename - use an alternate configuration file"
echo "-l or --log log_filename - use an alternate log file"
echo "-? or --help - display this help information"
echo ""
exit 1
;;
esac
exit 0

View file

@ -0,0 +1,15 @@
#
# the egrsynclogs configuration file...
#
# directories to mirror on this machine...
# srchost:srcpath:srcfile:localpath:localfile:owner
LOGLIST="
warhol.kc:/home/far/logs/:access_log:/home/sites/logs/far:acces_log:sites
"
#
# rsync arguments...
FLAGS="--archive -e ssh --delete --delete-excluded --stats"
# user on SERVER - NOTE: this assumes that this user has the
# right to access the necessary info on the server, and has
# password-less login access via ssh...
USER=root

7
egrsynclogs/test.sh Normal file
View file

@ -0,0 +1,7 @@
#!/bin/bash
test="a:b:c:d"
new=()
array -j ':' new $test
declare -p new

View file

@ -0,0 +1,22 @@
#
# the egrsync configuration file...
#
# directories to mirror on this machine...
DIRS="/etc /home/dlane /home/damien /home/cschneid /home/jonathan"
#
# directories or files (patterns) to exclude...
EXCLUDE="archive *.log *~"
#
# rsync arguments...
FLAGS="--archive -e ssh --delete --delete-excluded --stats"
#
# base directory into which to copy the rsync'd stuff
BASEDIR=/storage/warhol/daily
#
# machine to copy from
SERVER=localhost
#
# user on SERVER - NOTE: this assumes that this user has the
# right to access the necessary info on the server, and has
# password-less login access via ssh...
USER=root

View file

@ -0,0 +1,22 @@
#
# the egrsync configuration file...
#
# directories to mirror on this machine...
DIRS="/etc /home/dlane /home/damien /home/cschneid /home/jonathan"
#
# directories or files (patterns) to exclude...
EXCLUDE="archive *.log *~"
#
# rsync arguments...
FLAGS="--archive -e ssh --delete --delete-excluded --stats"
#
# base directory into which to copy the rsync'd stuff
BASEDIR=/storage/warhol/hourly
#
# machine to copy from
SERVER=localhost
#
# user on SERVER - NOTE: this assumes that this user has the
# right to access the necessary info on the server, and has
# password-less login access via ssh...
USER=root

View file

@ -0,0 +1,22 @@
#
# the egrsync configuration file...
#
# directories to mirror on this machine...
DIRS="/etc /home /var/www/html /var/djbdns"
#
# directories or files (patterns) to exclude...
EXCLUDE="archive *.log .netscape home/redhatinstall home/mdkinstall home/software home/server"
#
# rsync arguments...
FLAGS="--archive -e ssh --delete --delete-excluded --stats"
#
# base directory into which to copy the rsync'd stuff
BASEDIR=/storage/new/weekly
#
# machine to copy from
SERVER=new.egressive.com
#
# user on SERVER - NOTE: this assumes that this user has the
# right to access the necessary info on the server, and has
# password-less login access via ssh...
USER=root