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