Skip to content

Instantly share code, notes, and snippets.

@bubba-h57
Last active October 11, 2017 15:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bubba-h57/772dcf865ebfe1f5cdf4 to your computer and use it in GitHub Desktop.
Save bubba-h57/772dcf865ebfe1f5cdf4 to your computer and use it in GitHub Desktop.
after.sh for Homestead
#!/bin/bash
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
##
# Handle some generic stuff
##
source $HOMESTEAD_SCRIPTS/importEnvVars.sh
source $HOMESTEAD_SCRIPTS/installAptPackages.sh
source $HOMESTEAD_SCRIPTS/configureAWS.sh
source $HOMESTEAD_SCRIPTS/configureSSH.sh
source $HOMESTEAD_SCRIPTS/configureGit.sh
source $HOMESTEAD_SCRIPTS/configureComposer.sh
source $HOMESTEAD_SCRIPTS/configureZSH.sh
##
# Customize some stuff
##
echo "source $STS_HOME/etc/zsh/.zshrc" >> /home/vagrant/.zshrc
#!/bin/bash
source $HOMESTEAD_SCRIPTS/helperFunctions.sh
###############################################################################
#
# Setup AWS
#
###############################################################################
mkdir -p /home/vagrant/.aws
cat <<EOT > /home/vagrant/.aws/config
[default]
aws_access_key_id=$AWS_ACCESS_KEY_ID
aws_secret_access_key=$AWS_SECRET_ACCESS_KEY
region=$AWS_DEFAULT_REGION
EOT
cat <<EOT > /home/vagrant/.aws/credentials
[Credentials]
aws_access_key_id=$AWS_ACCESS_KEY_ID
aws_secret_access_key=$AWS_SECRET_ACCESS_KEY
region=$AWS_DEFAULT_REGION
EOT
updateAuth /home/vagrant/.aws 0755
updateAuth /home/vagrant/.aws/config 0600
updateAuth /home/vagrant/.aws/credentials 0600
#!/bin/bash
source $HOMESTEAD_SCRIPTS/helperFunctions.sh
###############################################################################
#
# Setup Composer
#
###############################################################################
cat <<EOT > /home/vagrant/.composer/auth.json
{
"http-basic": {},
"github-oauth": {
"github.com": "$GIT_HUB_TOKEN"
}
}
EOT
updateAuth /home/vagrant/.composer/auth.json 0600
#!/bin/bash
source $HOMESTEAD_SCRIPTS/helperFunctions.sh
###############################################################################
#
# Setup git
#
###############################################################################
cat <<EOT > /home/vagrant/.gitconfig
[user]
name = $GIT_AUTHOR_NAME
email = $GIT_AUTHOR_EMAIL
[core]
editor = vi
[alias]
lol = log --graph --decorate --pretty=oneline --abbrev-commit --all
[credential]
helper = cache
username = $GIT_HUB_USER_NAME
[push]
default = simple
EOT
cat <<EOT > /home/vagrant/.gittokens
FullAccess - $GIT_HUB_TOKEN
EOT
updateAuth /home/vagrant/.gitconfig 0600
updateAuth /home/vagrant/.gittokens 0600
git config user.name "Bubba"
git config user.email "rob@stechstudio.com"
#!/bin/bash
source $HOMESTEAD_SCRIPTS/helperFunctions.sh
###############################################################################
#
# Setup SSH
#
###############################################################################
cp $MY_ID_RSA /home/vagrant/.ssh/id_rsa
cp $MY_ID_RSA_PUB /home/vagrant/.ssh/id_rsa.pub
updateAuth /home/vagrant/.ssh/id_rsa 0600
updateAuth /home/vagrant/.ssh/id_rsa.pub
cat <<EOT > /home/vagrant/.ssh/config
Host github.com
StrictHostKeyChecking no
User git
IdentityFile /home/vagrant/.ssh/id_rsa
Host gist.github.com
StrictHostKeyChecking no
User git
IdentityFile /home/vagrant/.ssh/id_rsa
EOT
updateAuth /home/vagrant/.ssh/config
#!/bin/bash
source $HOMESTEAD_SCRIPTS/helperFunctions.sh
###############################################################################
#
# Setup ZSH
#
###############################################################################
apt-get install zsh -y
# If it doesn't exist, lets clone it
export ZSH=/home/vagrant/.oh-my-zsh
if [ ! -d "$ZSH" ]; then
git clone git://github.com/robbyrussell/oh-my-zsh.git $ZSH
fi
chown -R vagrant:vagrant $ZSH
cat <<EOT > /home/vagrant/.zshrc
#!/usr/bin/zsh
# Path to our oh-my-zsh installation.
export ZSH=/home/vagrant/.oh-my-zsh
# If it doesn't exist, lets clone it
if [ ! -d "\$ZSH" ]; then
git clone git://github.com/robbyrussell/oh-my-zsh.git \$ZSH
fi
EOT
grep export /home/vagrant/.profile | while read line; do echo "$line" >> /home/vagrant/.zshrc; done
updateAuth /home/vagrant/.zshrc
chsh -s /usr/bin/zsh vagrant
#!/bin/bash
if [ "$HELPERS_LOADED" = true ] ; then
#we have already been loaded.
return;
fi
# Helper function for ensuring permissions are correct
updateAuth () {
if [ -z "$1" ]
then
return 0
else
THISPATH="$1"
fi
if [ -z "$2" ]
then
THISPERM="0644"
else
THISPERM="$2"
fi
chown -R vagrant:vagrant $THISPATH
chmod -R $THISPERM $THISPATH
}
HELPERS_LOADED=true
variables:
- key: STS_USER
value: "<your name>"
- key: STS_HOME
value: "<your customized home dir>"
- key: AWS_ACCESS_KEY_ID
value: "<your key>"
- key: AWS_SECRET_ACCESS_KEY
value: "<your secret>"
- key: AWS_DEFAULT_REGION
value: "<your region>"
- key: GIT_AUTHOR_NAME
value: "<your name>"
- key: GIT_AUTHOR_EMAIL
value: "<your email>"
- key: GIT_COMMITTER_NAME
value: "<your name>"
- key: GIT_COMMITTER_EMAIL
value: "<your email>"
- key: GIT_HUB_TOKEN
value: "<your github token>"
- key: MY_ID_RSA
value: "<your path to the desired RSA key>"
- key: MY_ID_RSA_PUB
value: "<your path to the desired RSA pub file>"
#!/bin/bash
# Lets be clever and pull the environment variables stored in our Homestead.yaml
# Those are written to /home/vagrant/.profile, so we can can just parse them
# From there and ensure we have them available as root for provosioning.
ENVARS="$(mktemp)"
grep export /home/vagrant/.profile |while read -r line; do
echo "$line" >> $ENVARS
done
source $ENVARS
#!/bin/bash
# I like to update apt-get and I know I want imagemagick installed, so lets get that out of the way
apt-get update
apt-get install -y imagemagick expect --fix-missing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment