Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #cloud-config
  2. bootcmd:
  3. - |
  4. /bin/bash <<-'EOS'
  5. #!/bin/bash
  6. exec > >(tee /root/log.txt)
  7. exec 2>&1
  8. set -x
  9. set -e
  10. if [ -e /new ]; then
  11. # avoid loops
  12. exit 0
  13. fi
  14. sed -i -e 's/^Port 22$/Port 122/' /etc/ssh/sshd_config
  15. cat > /sbin/myinit <<-'EOF'
  16. #!/bin/bash
  17. set -x
  18. set -e
  19. mount -o rw,remount /
  20. mkdir -p /tmp/root
  21. mount none -t tmpfs /tmp/root
  22. cp -ax / /tmp/root
  23. rm -rf /tmp/root/dev
  24. cp -ax /dev /tmp/root/dev
  25. mount none -t sysfs /tmp/root/sys
  26. mount none -t proc /tmp/root/proc
  27. mount none -t devpts /tmp/root/dev/pts
  28. touch /old
  29. touch /tmp/root/new
  30. mkdir /tmp/root/oldroot
  31. mount --make-private /
  32. mount --make-private /tmp/root
  33. rm -f /tmp/root/etc/mtab
  34. ln -fsv /proc/self/mounts /tmp/root/etc/mtab
  35. pivot_root /tmp/root/ /tmp/root/oldroot
  36. cat /proc/mounts|cut -d ' ' -f 2 | grep '/oldroot/'| sort -r | xargs -n1 umount || true
  37. umount -l /oldroot/dev || true
  38. umount /oldroot || true
  39. exec /sbin/init "$@"
  40. EOF
  41. chmod +x /sbin/myinit
  42. echo 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} init=/sbin/myinit"' >> /etc/default/grub
  43. test ! -e /etc/default/grub.d/50-cloudimg-settings.cfg || rm /etc/default/grub.d/50-cloudimg-settings.cfg
  44. grub-mkconfig -o /boot/grub/grub.cfg
  45. EOS
  46.  
  47. power_state:
  48. timeout: 30
  49. mode: reboot
  50.  
  51. # Capture all subprocess output into a logfile
  52. # Useful for troubleshooting cloud-init issues
  53. output: {all: '| tee -a /var/log/cloud-init-output.log'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement