some final changes to oh_four
This commit is contained in:
parent
212c211d22
commit
8a59d57b81
|
@ -13,8 +13,7 @@ sudo chmod +x /usr/bin/sshbackup
|
||||||
|
|
||||||
### usage
|
### usage
|
||||||
```text
|
```text
|
||||||
usage: sshbackup <options> source destination [versions]
|
usage: sshbackup <options> [[user@]server:]/source/path /destination/path [versions]
|
||||||
source/destination example: [[user@]server:]/path/to/files
|
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help show this message
|
-h, --help show this message
|
||||||
|
@ -25,7 +24,7 @@ OPTIONS:
|
||||||
-s, --sshkey <file> alternate sshkey [~/.ssh/id_rsa]
|
-s, --sshkey <file> alternate sshkey [~/.ssh/id_rsa]
|
||||||
-b, --bandwidth <kbps> bandwidth limit in kbit/s
|
-b, --bandwidth <kbps> bandwidth limit in kbit/s
|
||||||
|
|
||||||
-d, --deploy <hostname> deploy settings to remote host
|
-d, --deploy deploy settings to remote host
|
||||||
-n, --no-root run without root privileges
|
-n, --no-root run without root privileges
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
19
sshbackup
19
sshbackup
|
@ -134,7 +134,7 @@ deploy()
|
||||||
echo "i will now attempt to create the user $user and apply all needed"
|
echo "i will now attempt to create the user $user and apply all needed"
|
||||||
echo "settings on following remote host: $machine"
|
echo "settings on following remote host: $machine"
|
||||||
echo "in order to do so i need a sudo enabled username and"
|
echo "in order to do so i need a sudo enabled username and"
|
||||||
echo "password on the remote host."
|
echo "password on the remote host. (hit Ctrl-C to abort)"
|
||||||
echo -e "please enter your [sudo] username: \c"
|
echo -e "please enter your [sudo] username: \c"
|
||||||
read username
|
read username
|
||||||
echo -e "please enter your [sudo] password: \c"
|
echo -e "please enter your [sudo] password: \c"
|
||||||
|
@ -149,6 +149,8 @@ deploy()
|
||||||
eval pipewrap '$password' '$lockfile' | (sshpass -p "$password" ssh -q "$username@$machine" "sudo -S '$script'"; rm "$lockfile")
|
eval pipewrap '$password' '$lockfile' | (sshpass -p "$password" ssh -q "$username@$machine" "sudo -S '$script'"; rm "$lockfile")
|
||||||
sshpass -p $password ssh -q "$username@$machine" rm $script
|
sshpass -p $password ssh -q "$username@$machine" rm $script
|
||||||
rm $script
|
rm $script
|
||||||
|
#we will assume everything went fine
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
preflight()
|
preflight()
|
||||||
|
@ -168,8 +170,8 @@ preflight()
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#TODO: check for dependencies and install them if necessary
|
|
||||||
#check for dependencies
|
#check for dependencies
|
||||||
|
#TODO: and install them if necessary
|
||||||
local deps="rsync cat ssh scp sshpass rm mv grep awk date tty id"
|
local deps="rsync cat ssh scp sshpass rm mv grep awk date tty id"
|
||||||
local missingdeps=""
|
local missingdeps=""
|
||||||
local depscount="0"
|
local depscount="0"
|
||||||
|
@ -193,9 +195,8 @@ preflight()
|
||||||
if [[ $sourcepath =~ .*@.* ]]; then
|
if [[ $sourcepath =~ .*@.* ]]; then
|
||||||
|
|
||||||
#deactivate StrictHostKeyChecking for ssh client
|
#deactivate StrictHostKeyChecking for ssh client
|
||||||
#TODO: what if StrictHostKeyChecking is set but not to "no"
|
|
||||||
if [ -r $HOME/.ssh/config ]; then
|
if [ -r $HOME/.ssh/config ]; then
|
||||||
cat $HOME/.ssh/config | grep "StrictHostKeyChecking no" >> /dev/null
|
cat $HOME/.ssh/config | grep "StrictHostKeyChecking" >> /dev/null
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "StrictHostKeyChecking no" >> $HOME/.ssh/config
|
echo "StrictHostKeyChecking no" >> $HOME/.ssh/config
|
||||||
fi
|
fi
|
||||||
|
@ -222,9 +223,15 @@ preflight()
|
||||||
echo "aborting mission. error occured while creating ssh key pair"
|
echo "aborting mission. error occured while creating ssh key pair"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
echo -e "do you want to create a user and deploy this key now as well \c"
|
||||||
|
read choice
|
||||||
|
if [ -z $choice ]; then
|
||||||
|
echo "aborting mission. remote host must accept ssh key."
|
||||||
|
return 1
|
||||||
|
elif [ $choice == "y" ] || [ $choice == "Y" ]; then
|
||||||
#deploy key to remote system
|
#deploy key to remote system
|
||||||
deploy ${sourcepath%:*} $pubkeyfile
|
deploy ${sourcepath%:*} $pubkeyfile
|
||||||
return 0
|
fi
|
||||||
else
|
else
|
||||||
echo "aborting mission. no ssh key found."
|
echo "aborting mission. no ssh key found."
|
||||||
return 1
|
return 1
|
||||||
|
|
Reference in New Issue