blob: 13b7344ea09a25acb27552e44cc8ca4ceb5991b6 (
plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
#!/usr/bin/env bash -euo pipefail
# SymfonyCloud CLI installer.
CLI_LATEST_VERSION_URL="https://get.symfony.com/cli/LATEST"
CLI_CONFIG_DIR=".symfony"
CLI_EXECUTABLE="symfony"
CLI_TMP_NAME="$CLI_EXECUTABLE-"`date +"%s"`
CLI_NAME="Symfony CLI"
function output {
style_start=""
style_end=""
if [ "${2:-}" != "" ]; then
case $2 in
"success")
style_start="\033[0;32m"
style_end="\033[0m"
;;
"error")
style_start="\033[31;31m"
style_end="\033[0m"
;;
"info"|"warning")
style_start="\033[33m"
style_end="\033[39m"
;;
"heading")
style_start="\033[1;33m"
style_end="\033[22;39m"
;;
esac
fi
builtin echo -e "${style_start}${1}${style_end}"
}
output "${CLI_NAME} installer" "heading"
# Run environment checks.
output "\nEnvironment check" "heading"
# Check that cURL or wget is installed.
downloader=""
command -v curl >/dev/null 2>&1
if [ $? == 0 ]; then
downloader="curl"
output " [*] cURL is installed" "success"
else
command -v wget >/dev/null 2>&1
if [ $? == 0 ]; then
downloader="wget"
output " [*] wget is installed" "success"
else
output " [ ] ERROR: cURL or wget is required for installation." "error"
exit 1
fi
fi
# Check that gzip is installed.
command -v gzip >/dev/null 2>&1
if [ $? == 0 ]; then
output " [*] Gzip is installed" "success"
else
output " [ ] ERROR: Gzip is required for installation." "error"
exit 1
fi
# Check that Git is installed.
command -v git >/dev/null 2>&1
if [ $? == 0 ]; then
output " [*] Git is installed" "success"
else
output " [ ] Warning: Git will be needed." "warning"
fi
# The necessary checks have passed. Start downloading the right version.
output "\nDownload" "heading"
kernel=`uname -s`
case ${kernel} in
"Linux"|"linux")
kernel="linux"
;;
"Darwin"|"darwin")
kernel="darwin"
;;
*)
output "OS '${kernel}' not supported" "error"
exit 1
;;
esac
machine=`uname -m`
if [ machine == "i386" ]; then
machine="386"
else
machine="amd64"
fi
platform="${kernel}_${machine}"
output " Finding the latest version (platform: \"${platform}\")...";
case ${downloader} in
"curl")
latest_version=`curl --fail ${CLI_LATEST_VERSION_URL} -s`
;;
"wget")
latest_version=`wget -q ${CLI_LATEST_VERSION_URL} -O - 2>/dev/null`
;;
esac
if [ $? != 0 ]; then
output " Failed to download LATEST version file: ${CLI_LATEST_VERSION_URL}" "error"
exit 1
fi
latest_url="https://github.com/symfony/cli/releases/download/v${latest_version}/symfony_${platform}.gz"
output " Downloading version ${latest_version} (${latest_url})...";
case $downloader in
"curl")
curl --fail --location "${latest_url}" > "/tmp/${CLI_TMP_NAME}.gz"
;;
"wget")
wget -q --show-progress "${latest_url}" -O "/tmp/${CLI_TMP_NAME}.gz"
;;
esac
if [ $? != 0 ]; then
output " The download failed." "error"
exit 1
fi
output " Uncompress binary..."
gzip -d "/tmp/${CLI_TMP_NAME}.gz"
output " Making the binary executable..."
chmod 755 "/tmp/${CLI_TMP_NAME}"
binary_dest="${HOME}/${CLI_CONFIG_DIR}/bin"
if [ ! -d "${binary_dest}" ]; then
mkdir -p "${binary_dest}"
if [ $? != 0 ]; then
binary_dest="."
fi
fi
output " Installing the binary into your home directory..."
mv "/tmp/${CLI_TMP_NAME}" "${binary_dest}/${CLI_EXECUTABLE}"
installedInHomeDir="true"
if [ $? != 0 ]; then
installedInHomeDir="false"
output " Failed to move the binary." "warning"
else
output " The binary was saved to: ${binary_dest}/${CLI_EXECUTABLE}"
fi
#output " Installing the shell auto-completion..."
#"${binary_dest}/${CLI_EXECUTABLE}" self:shell-setup --silent
#if [ $? != 0 ]; then
# output " Failed to install the shell auto-completion." "warning"
#fi
output "\nThe ${CLI_NAME} v${latest_version} was installed successfully!" "success"
if [ "${installedInHomeDir}" == "true" ]; then
output "\nAdd this to your shell configuration file:" "info"
output " export PATH=\"\$HOME/${CLI_CONFIG_DIR}/bin:\$PATH\""
output "Start a new shell, and then run '${CLI_EXECUTABLE}'" "info"
else
output "\nUse it as a local file:" "info"
output " ${binary_dest}/${CLI_EXECUTABLE}"
fi
output "\nOr install it globally on your system:" "info"
output " mv ${binary_dest}/${CLI_EXECUTABLE} /usr/local/bin/${CLI_EXECUTABLE}"
output "and then run '${CLI_EXECUTABLE}'" "info"
|