Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.17 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Where this script exists
  4. dir=$(dirname "$(readlink -f "$0")")
  5.  
  6. # MOTD is worthless IMO
  7. cat /dev/null > /etc/motd
  8.  
  9. # Embiggen tty console to a more cromulant size
  10. sed -i 's/^.*GRUB_GFXMODE=640x480.*$/GRUB_GFXMODE=1024x768\nGRUB_GFXPAYLOAD_LINUX=keep/' /etc/default/grub
  11. update-grub
  12.  
  13. # Because that's how I roll...
  14. sed -i 's/^.*PermitRootLogin.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
  15.  
  16. # (Make your own authorized_keys file and uncomment)
  17. #mkdir -p /root/.ssh
  18. #cp "$dir/authorized_keys" /root/.ssh/
  19.  
  20. # Install firstboot setup script
  21. cp "$dir/firstboot" /root/
  22. cp "$dir/profile" /root/.profile
  23.  
  24. # Install update-issue script to get eth0 IP and MAC addr on login prompt
  25. cp "$dir/update-issue" /etc/network/if-post-down.d/
  26. cp "$dir/update-issue" /etc/network/if-up.d/
  27.  
  28. # Gotta be current, yo!
  29. apt-get update && apt-get dist-upgrade -y
  30.  
  31. # No system would be complete without:
  32. apt-get install -y \
  33.         sysstat strace htop \
  34.         iperf iperf3 nload tcpdump ethtool \
  35.         curl tmux rsync sshfs git ntp \
  36.         unzip p7zip-full unrar-free \
  37.         libpam-systemd dbus open-vm-tools
  38.  
  39. # Delete apt cache to save space
  40. apt-get clean
  41.  
  42. # Zero out block-backed swap devices, and just delete file-backed swap devices.
  43. # Disk space consumed by files will be taken care of by zerofree run after this
  44. # script is run.
  45. swapoff -a
  46. for s in $(grep swap /etc/fstab | awk '{print $1}') ; do
  47.         if [ -b "$s" ] ; then
  48.                 dd if=/dev/zero of="$s" bs=512
  49.         elif [ -f "$s" ] ; then
  50.                 rm "$s"
  51.         fi
  52. done
  53. # Clean up /var/log/
  54. rm -rf /var/log/installer
  55. find /var/log/ -type f -name '*.gz' -delete
  56. find /var/log/ -type f -name '*.[[:digit:]]*' -delete
  57. find /var/log/ -type f -exec grep -Iq . {} \; -and -exec truncate {} --size 0 \;
  58.  
  59. # Shhh, none of this ever happened...
  60. find /root/.ssh/ ! -path /root/.ssh/ ! -name 'authorized_keys' -delete
  61. rm -f /root/.bash_history
  62.  
  63. ### MANUAL STEPS
  64.  
  65. # Delete prep files and power off
  66.  
  67. # Mount disk (eg by booting from a live cd) and run zerofree on all ext4-formatted block devices
  68.  
  69. # Power system off, remove any attached disk images, and capture an OVA of it. My OVA is < 450M
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement