Skip to content

Instantly share code, notes, and snippets.

@jerturowetz
Created September 12, 2017 22:43
Show Gist options
  • Save jerturowetz/c75d64b0aeafefd394808173543bf190 to your computer and use it in GitHub Desktop.
Save jerturowetz/c75d64b0aeafefd394808173543bf190 to your computer and use it in GitHub Desktop.
Laravel Homestead provisioning script that includes WP-CLI and AWS-CLI
#!/bin/bash
# Functions for later
noroot() {
sudo -EH -u "vagrant" "$@";
}
wp_cli() {
# WP-CLI Install
local exists_wpcli
# Remove old wp-cli symlink, if it exists.
if [[ -L "/usr/local/bin/wp" ]]; then
echo "Removing old wp-cli"
rm -f /usr/local/bin/wp
fi
exists_wpcli="$(which wp)"
if [[ "/usr/local/bin/wp" != "${exists_wpcli}" ]]; then
echo -e "Downloading wp-cli, see http://wp-cli.org"
sudo curl -sO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar
sudo chmod +x wp-cli-nightly.phar
sudo mv wp-cli-nightly.phar /usr/local/bin/wp
# Install bash completions
sudo curl -s https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash -o /srv/config/wp-cli/wp-completion.bash
else
echo -e "Updating wp-cli..."
sudo wp --allow-root cli update --nightly --yes
fi
}
# Update apt-get
echo "Updating apt-get"
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes update
# Install phpX.X-ldap
echo "Installing phpX.X-ldap (matches current php version)"
PHPVersion=$(php --version | head -n 1 | cut -d " " -f 2 | cut -c 1,2,3);
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install php${PHPVersion}-ldap
# install/update WP-CLI
echo "Installing/updating wp-cli"
wp_cli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment