Skip to content

Instantly share code, notes, and snippets.

@sethwebster
Last active January 30, 2016 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethwebster/b47f1b54736974ae950c to your computer and use it in GitHub Desktop.
Save sethwebster/b47f1b54736974ae950c to your computer and use it in GitHub Desktop.
addUser() {
echo "Adding user $1..."
adduser $1
gpasswd -a $1 sudo
}
enableSwap() {
echo "Enabling Swap..."
sudo fallocate -l 4G /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo echo "/swapfile none swap sw 0 0" >> /etc/fstab
sudo sysctl vm.swappiness=10
sudo sysctl vm.vfs_cache_pressure=50
sudo echo "vm.swappiness=10" >> /etc/sysctl.conf
sudo echo "vm.vfs_cache_pressure=50" >> /etc/sysctl.conf
}
createApp() {
dokku apps:create $2
}
username=""
appname=""
echo "Digital Ocean / Dokku Post Setup Script"
echo
while [[ -z "$username" ]]
do
read -s -p "Enter new user name: " username
echo
if [[ $username = "" ]]; then
echo "User name cannot be blank."
fi
done
while [[ -z "$appname" ]]
do
read -s -p "Enter new application name: " appname
echo
if [[ $appname = "" ]]; then
echo "App name cannot be blank."
fi
done
addUser $username
enableSwap
createApp $appname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment