-
Notifications
You must be signed in to change notification settings - Fork 0
/
drush-with-git.sh
60 lines (48 loc) · 1.6 KB
/
drush-with-git.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
# IMPORTANT. You must have curl, git and php installed
if ! type php > /dev/null; then
echo "php is not installed. Abording." >&2;
exit 1;
fi
if ! type curl > /dev/null; then
echo "curl is not installed. Abording." >&2;
exit 1;
fi
if ! type git > /dev/null; then
echo "git is not installed. Abording." >&2;
exit 1;
fi
# Use Bash as command line (if you like you can use your own CL too!)
chsh -s "$(command -v bash)" "$USER"
# Enter Drush version (branch from Github)
echo -n "Please enter the Drush version (eg 8.x): "
read branch
# Install Composer
echo "Installing Composer"
mkdir ~/bin
curl -sS https://getcomposer.org/installer | php -- --install-dir=bin
# Download Drush files (in our home folder)
# Git method (recommended)
echo "Cloning Drush from Github"
cd ~
git clone -b ${branch} https://github.com/drush-ops/drush.git ~/drush
# Make the drush folder executable by current USER
echo "Making the drush folder executable by current USER"
chmod u+x ~/drush/drush
# Install Drush from Composer
echo "Compile Drush with Composer"
cd ~/drush && \
php ~/bin/composer.phar update && \
php ~/bin/composer.phar install
# Add alias to dotfiles
echo "Adding drush and composer alias"
touch ~/.bash_profile
echo "alias composer='php ~/bin/composer.phar'" > ~/.bash_profile
echo "alias drush='~/drush/drush'" > ~/.bash_profile
touch ~/.bashrc
echo "alias composer='php ~/bin/composer.phar'" > ~/.bashrc
echo "alias drush='~/drush/drush'" > ~/.bashrc
# Source the changed .bash_profile or restart ssh session
source ~/.bash_profile
source ~/.bashrc
echo "Drush installation finished! Run Drush to test it."