-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwp-cli.setup.sh
More file actions
92 lines (71 loc) · 1.35 KB
/
wp-cli.setup.sh
File metadata and controls
92 lines (71 loc) · 1.35 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh
#
# wp-cli.setup.sh
#
# Copyright 2014 -, tecking
# Version 0.3.0
#
# Licensed under the MIT License.
#
#
# Check existence for wget command.
#
command -v wget >/dev/null 2>&1 || { cat >&2 <<-EOT
*
* Unfortunately, installation has failed.
*
EOT
exit 1
}
#
# Download WP-CLI.
#
if [ ! -d "~/usr/local/bin" ]; then
mkdir -p ~/usr/local/bin
fi
wget -nc --no-check-certificate https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O ~/usr/local/bin/wp
chmod +x ~/usr/local/bin/wp
#
# Set path.
#
# bash
if expr $SHELL : ".*bash" > /dev/null; then
wget -nc --no-check-certificate https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash -O ~/wp-completion.bash
if [ -f "~/.bash_profile" ]; then
chmod +w ~/.bash_profile
fi
cat >> ~/.bash_profile <<-"EOT"
PATH=$PATH:~/usr/local/bin
source ~/wp-completion.bash
EOT
message="source ~/.bash_profile"
# csh
elif expr $SHELL : ".*csh" > /dev/null; then
if [ -f "~/.cshrc" ]; then
chmod +w ~/.cshrc
fi
cat >> ~/.cshrc <<-"EOT"
set path = ($path ~/usr/local/bin)
EOT
message="source ~/.cshrc"
# Other shells
else
cat <<-EOT
*
* Unfortunately, Installation has failed.
*
EOT
exit 1
fi
#
# Report the result.
#
cat <<EOT
*
* Installation has completed successfully.
* Please enter the following command. Have fun :)
*
* $message
*
EOT
exit 0