Last active
February 18, 2019 16:55
-
-
Save edjames/5bb297f26feef64ce680bf598509e5e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "-------------------------------" | |
echo "Starting user-data execution..." | |
echo "-------------------------------" | |
cd /root | |
# | |
# Setup swap for better performance | |
# Note: Swap file size should generally be double the RAM, up to a 4G max | |
# | |
fallocate -l 4G /swapfile | |
chmod 600 /swapfile | |
mkswap /swapfile | |
swapon /swapfile | |
cp /etc/fstab /etc/fstab.bak | |
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab | |
sysctl vm.swappiness=10 | |
echo "vm.swappiness=10" >> /etc/sysctl.conf | |
sysctl vm.vfs_cache_pressure=50 | |
echo "vm.vfs_cache_pressure=50" >> /etc/sysctl.conf | |
# | |
# Setup Additional Entropy for Cloud Servers Using Haveged | |
# https://www.digitalocean.com/community/tutorials/how-to-setup-additional-entropy-for-cloud-servers-using-haveged | |
# | |
apt-get install -y haveged | |
update-rc.d haveged defaults | |
# | |
# Additional packages and utils | |
# | |
apt-get install -y direnv | |
# | |
# bash setup | |
# | |
wget https://gist.githubusercontent.com/edjames/80e95379caefbe35f3bb51178400560a/raw/6615a5a80ab1352bc363f3340eeff89e947cbe11/.bash_login .bash_login | |
wget https://gist.githubusercontent.com/edjames/ff80ccbaafd0b51cb2e1f19ed349ba5e/raw/bafa8fe507957c4b1f9c567039976b0360f35715/.bash_logout .bash_logout | |
wget https://gist.githubusercontent.com/edjames/e5c706393517b7a0e5ae2c9dd6d15aba/raw/200d63bb8bd6940c68495fe2c68525adbbe851cd/.bashrc .bashrc | |
echo "-------------------------------------------" | |
echo "User-data execution completed successfully." | |
echo "-------------------------------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment