Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Where this script exists
- dir=$(dirname "$(readlink -f "$0")")
- # MOTD is worthless IMO
- cat /dev/null > /etc/motd
- # Embiggen tty console to a more cromulant size
- sed -i 's/^.*GRUB_GFXMODE=640x480.*$/GRUB_GFXMODE=1024x768\nGRUB_GFXPAYLOAD_LINUX=keep/' /etc/default/grub
- update-grub
- # Because that's how I roll...
- sed -i 's/^.*PermitRootLogin.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
- # (Make your own authorized_keys file and uncomment)
- #mkdir -p /root/.ssh
- #cp "$dir/authorized_keys" /root/.ssh/
- # Install firstboot setup script
- cp "$dir/firstboot" /root/
- cp "$dir/profile" /root/.profile
- # Install update-issue script to get eth0 IP and MAC addr on login prompt
- cp "$dir/update-issue" /etc/network/if-post-down.d/
- cp "$dir/update-issue" /etc/network/if-up.d/
- # Gotta be current, yo!
- apt-get update && apt-get dist-upgrade -y
- # No system would be complete without:
- apt-get install -y \
- sysstat strace htop \
- iperf iperf3 nload tcpdump ethtool \
- curl tmux rsync sshfs git ntp \
- unzip p7zip-full unrar-free \
- libpam-systemd dbus open-vm-tools
- # Delete apt cache to save space
- apt-get clean
- # Zero out block-backed swap devices, and just delete file-backed swap devices.
- # Disk space consumed by files will be taken care of by zerofree run after this
- # script is run.
- swapoff -a
- for s in $(grep swap /etc/fstab | awk '{print $1}') ; do
- if [ -b "$s" ] ; then
- dd if=/dev/zero of="$s" bs=512
- elif [ -f "$s" ] ; then
- rm "$s"
- fi
- done
- # Clean up /var/log/
- rm -rf /var/log/installer
- find /var/log/ -type f -name '*.gz' -delete
- find /var/log/ -type f -name '*.[[:digit:]]*' -delete
- find /var/log/ -type f -exec grep -Iq . {} \; -and -exec truncate {} --size 0 \;
- # Shhh, none of this ever happened...
- find /root/.ssh/ ! -path /root/.ssh/ ! -name 'authorized_keys' -delete
- rm -f /root/.bash_history
- ### MANUAL STEPS
- # Delete prep files and power off
- # Mount disk (eg by booting from a live cd) and run zerofree on all ext4-formatted block devices
- # 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