david/sshbackup
david
/
sshbackup
Archived
1
0
Fork 0

push to github

This commit is contained in:
david 2013-07-01 20:57:55 +02:00
parent 2d261409eb
commit 9c2b55a248
1 changed files with 19 additions and 14 deletions

View File

@ -17,8 +17,6 @@ rsyncoptions="-qpogEthrzl --numeric-ids --no-motd"
remotecmd="shopt -s dotglob; /usr/bin/sudo /usr/bin/rsync"
localcmd="/usr/bin/rsync"
sshkeyfile="$HOME/.ssh/id_rsa"
versions=999
config=0
sshkey=0
@ -65,12 +63,20 @@ interactive()
return $?
}
amiroot()
{
if [ $(id -u) -eq 0 ]; then
return 0
else
return 1
fi
}
preflight()
{
#amiroot?
if [ $(whoami) != "root" ]; then
echo "aborting mission. you must be root."
if ( ! amiroot ); then
echo "aborting mission. you must be root"
return 1
fi
@ -92,7 +98,7 @@ preflight()
# echo "aborting mission. no sshkey found."
# return 1
#fi
keymgmt $sshkeyfile
keymgmt
fi
return 0
@ -100,10 +106,10 @@ preflight()
keymgmt()
{
local username=$(id -un)
#get executing user id
local userid=$(id -u)
#find out where running users $HOME is
#find out where executing users $HOME is
while read line; do
line=$(echo $line | sed 's/ //g')
line=$(echo $line | sed 's/:/ /g')
@ -112,10 +118,8 @@ keymgmt()
fi
done < /etc/passwd
if [ -z $1 ]; then
if [ -z $sshkeyfile ]; then
sshkeyfile="$home/.ssh/id_rsa"
else
sshkeyfile="$1"
fi
if [ -r $sshkeyfile ]; then
@ -186,6 +190,7 @@ sshbackup()
trap bashtrap INT
# **** option handler ****
#end script if no options are given
if [ -z $1 ]; then
usage
exit 0
@ -267,6 +272,7 @@ for option in $options; do
esac
done
#read config if there is one
if [ -r "$configfile" ]; then
source "$configfile"
fi
@ -274,7 +280,7 @@ fi
#read list if listfile is given
if [ -r "$listfile" ]; then
while read line; do
# find first letter
#find first letter
fletter=${line:0:1}
if [ -z $fletter ]; then
#skip line it's empty
@ -320,6 +326,5 @@ else
fi
fi
# **** end of script ****
exit 0
# **** end of script ****