Advertisement
teknoraver

prepvm

Nov 21st, 2018
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.03 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. [ -f "$1" ] || exec echo "'$1' does not exist"
  4.  
  5. which guestfish >/dev/null 2>/dev/null || exec echo "guestfish not found"
  6.  
  7. guestfish -a "$1" -i <<'EOF'
  8. # trick to keep the SELinux context
  9. sh 'sed "s/^root:[^:]*:/root::/" /etc/shadow >/tmp/shadow ; cat /tmp/shadow >/etc/shadow ; rm -f /tmp/shadow'
  10. sh 'rm -rf /etc/rc.d/rc3.d/S*cloud-init /etc/systemd/system/cloud-init.target.wants/* /etc/systemd/system/multi-user.target.wants/cloud-*.service'
  11. mkdir /etc/systemd/system/getty@.service.d
  12. write /etc/systemd/system/getty@.service.d/override.conf "[Service]\\nExecStart=\\nExecStart=-/sbin/agetty -a root --noclear %I $TERM"
  13. mkdir /etc/systemd/system/serial-getty@.service.d
  14. write /etc/systemd/system/serial-getty@.service.d/override.conf "[Service]\\nExecStart=\\nExecStart=-/sbin/agetty -a root --keep-baud 115200,38400,9600 %I $TERM"
  15. write /etc/profile.d/colorprompt.sh "PS1='\\[\\e[1;31m\\]\\u\\[\\e[0m\\]@\\[\\e[1;36m\\]\\h\\[\\e[0m\\]:\\[\\e[1;32m\\]\\w\\[\\e[0m\\]\\$ '"
  16. write-append /etc/environment TERM=xterm-256color
  17. EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement