Last active
December 18, 2016 11:10
-
-
Save mul14/8e9941dab7149d23238977c0814ecfa5 to your computer and use it in GitHub Desktop.
Laravel Homesteak
This file contains hidden or 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
#!/usr/bin/env sh | |
# Laravel Homestead v3 and v4 are sucks! | |
# They removes useful commands like "homestead up" or "homestead ssh" from v2. | |
# Here is "homesteak", simple script to bring back those commands. | |
# Set composer directory. | |
if [ ! $COMPOSER_HOME = '' ]; then | |
COMPOSER_DIRECTORY="$COMPOSER_HOME"; | |
elif [ ! $XDG_CONFIG_HOME = '' ]; then | |
COMPOSER_DIRECTORY="$XDG_CONFIG_HOME/composer"; | |
elif [ -d $HOME/config/composer ]; then | |
COMPOSER_DIRECTORY="$HOME/config/composer"; | |
else | |
COMPOSER_DIRECTORY="$HOME/.composer"; | |
fi | |
# Check if Homestead already installed. | |
HOMESTEAD_DIRECTORY="$COMPOSER_DIRECTORY/vendor/laravel/homestead"; | |
if [ ! -d "$HOMESTEAD_DIRECTORY" ]; then | |
echo "Laravel Homestead is not installed."; | |
exit 1; | |
fi | |
# Check if user provide command or not. | |
if [ $# -eq 0 ]; then | |
echo "Homesteak command is required." | |
echo "Available commands: \"up down halt suspend destroy ssh status version\""; | |
echo "Usage example: homesteak version" | |
exit 1; | |
fi | |
CURRENT_WORKING_DIRECTORY=$(pwd) | |
array=('up' 'down' 'halt' 'suspend' 'destroy' 'ssh' 'status' 'version') | |
for i in "${array[@]}" | |
do | |
if [ $i = "$1" ]; then | |
# Command alias | |
if [ $1 = 'down' ]; then | |
COMMAND='halt' | |
else | |
COMMAND="$1" | |
fi | |
cd "$HOMESTEAD_DIRECTORY"; | |
vagrant "$COMMAND"; | |
cd "$CURRENT_WORKING_DIRECTORY"; | |
exit 0; | |
fi | |
done | |
echo "Homesteak command \"$1\" is not available."; | |
exit 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Laravel Homesteak
Overview
Laravel Homestead v3 and v4 are sucks!
Taylor removes useful commands like
homestead up
orhomestead ssh
from v2.Here is "homesteak", simple script to bring back those commands.
Installation
Easy way
Just copy & paste this to your terminal
Manual
Put the script to your
$PATH
. For example to/usr/local/bin/homesteak
. And don't forget to make it executable by usingchmod +x /usr/local/bin/homesteak
.