Commit 7a5792bb authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

target_scp reminds to copy-ssh-id

parent 2d51dc75
......@@ -4,15 +4,41 @@ REMOTE_USER ??= "root"
REMOTE_IP ??= "192.168.0.9"
IDENTITY_FILE ??= "~/.ssh/id_rsa"
do_target_scp () {
#Without next echo - no trace of the scp in the log!
SSH_COMMAND='tar -C / -xzpf /image.tar.gz; rm -f /image.tar.gz; sync'
tar -czvf ${WORKDIR}/image.tar.gz -C ${WORKDIR}/image .
echo scp -i ${IDENTITY_FILE} -p ${WORKDIR}/image.tar.gz ${REMOTE_USER}@${REMOTE_IP}:/
scp -i ${IDENTITY_FILE} -p ${WORKDIR}/image.tar.gz ${REMOTE_USER}@${REMOTE_IP}:/
echo ssh -i ${IDENTITY_FILE} ${REMOTE_USER}@${REMOTE_IP} ${SSH_COMMAND}
ssh -i ${IDENTITY_FILE} ${REMOTE_USER}@${REMOTE_IP} ${SSH_COMMAND}
#do_target_scp () {
# #Without next echo - no trace of the scp in the log!
# SSH_COMMAND='tar -C / -xzpf /image.tar.gz; rm -f /image.tar.gz; sync'
# tar -czvf ${WORKDIR}/image.tar.gz -C ${WORKDIR}/image .
# echo scp -i ${IDENTITY_FILE} -p ${WORKDIR}/image.tar.gz ${REMOTE_USER}@${REMOTE_IP}:/
# scp -i ${IDENTITY_FILE} -p ${WORKDIR}/image.tar.gz ${REMOTE_USER}@${REMOTE_IP}:/
# echo ssh -i ${IDENTITY_FILE} ${REMOTE_USER}@${REMOTE_IP} ${SSH_COMMAND}
# ssh -i ${IDENTITY_FILE} ${REMOTE_USER}@${REMOTE_IP} ${SSH_COMMAND}
#}
python do_target_scp () {
import subprocess
WORKDIR = d.getVar('WORKDIR', True)
IDENTITY_FILE = d.getVar('IDENTITY_FILE', True)
REMOTE_USER = d.getVar('REMOTE_USER', True)
REMOTE_IP = d.getVar('REMOTE_IP', True)
cmd = "tar -czvf "+WORKDIR+"/image.tar.gz -C "+WORKDIR+"/image ."
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
cmd = "ping "+REMOTE_IP+" -c 1"
try:
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
except subprocess.CalledProcessError:
raise Exception("No route to target "+REMOTE_IP)
cmd = "scp -i "+IDENTITY_FILE+" -p "+WORKDIR+"/image.tar.gz "+REMOTE_USER+"@"+REMOTE_IP+":/"
try:
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
except subprocess.CalledProcessError:
raise Exception("Copying to target requires access by public key. Run: ssh-copy-id "+REMOTE_USER+"@"+REMOTE_IP)
cmd = "ssh -i "+IDENTITY_FILE+" "+REMOTE_USER+"@"+REMOTE_IP+" tar -C / -xzpf /image.tar.gz; rm -f /image.tar.gz; sync"
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
}
addtask do_target_scp after do_install
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment