Advertisement
jintack

A script to prepare nesting

Nov 10th, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import os
  3. import sys
  4. import pexpect
  5.  
  6. def main():
  7. if not os.geteuid() == 0:
  8. sys.exit('Script must be run as root')
  9. os.system("sudo apt-get -y install python-pexpect bridge-utils")
  10. os.chdir("/srv/vm/qemu")
  11. os.system("git remote add nested https://github.com/columbia/qemu-nested.git")
  12. child = pexpect.spawn("git fetch nested")
  13. child.expect('sername.*')
  14. child.sendline('put_user_name')
  15. child.expect('assword.*')
  16. child.sendline('put_password')
  17. child.expect (pexpect.EOF)
  18. os.system("git checkout nested-v2.3.0")
  19. os.system("make -j 10")
  20.  
  21. os.system("cp /proj/kvmarm-PG0/jintack/nested/linaro-trusty-nesting-v3.img /vmdata/linaro-trusty.img")
  22. os.system("mkdir /usr/local/etc/qemu/")
  23. os.system("echo \"allow br0\" > /usr/local/etc/qemu/bridge.conf")
  24. os.system("sed -i 's/cpu host/cpu host,nested=true/g' /srv/vm/run-guest.sh")
  25.  
  26. # Add host public key to guest
  27. os.system("mount -o loop /vmdata/linaro-trusty.img /mnt")
  28. os.system("cat /users/jintackl/.ssh/id_rsa.pub >> /mnt/root/.ssh/authorized_keys")
  29. os.system("mkdir -p /mnt_l2")
  30. os.system("mount -o loop /mnt/root/vm/l2.img /mnt_l2")
  31. os.system("cat /users/jintackl/.ssh/id_rsa.pub >> /mnt_l2/root/.ssh/authorized_keys")
  32. os.system("umount /mnt_l2")
  33. os.system("umount /mnt")
  34.  
  35. os.system("cp /proj/kvmarm-PG0/jintack/scripts/run.sh /users/jintackl")
  36.  
  37. sys.exit(1)
  38.  
  39. if __name__ == '__main__':
  40. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement