Install composer srcipt
A bash script that will install composer in the bin dir of your choice for the user of your choice.
<br/>
<br/>
Usage Example : ./install-composer.bash /usr/bin root
<br/>
will install composer in /usr/bin for the root user. Then the command \"composer\" wil lbe available on the whole system
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
#!/bin/bash
BIN_DIRECTORY=$1
USER=$2
usage ()
{
echo "Usage : $0 bin_directory owner"
}
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
if [ "$#" -lt 2 ] ; then
echo "Error: bad command usage"
usage
exit 1
fi
if [ ! -d $BIN_DIRECTORY ] ; then
echo "Error: Bin directory doesnt exist"
usage
exit 1
fi
if [ -f "$BIN_DIRECTORY/composer" ] ; then
echo "Error: composer file already exist in bin directory"
exit 1
fi
if [ `grep -c "^$USER:" /etc/passwd` -ne 1 ] ; then
echo "Error: user $USER doesnt exists"
usage
exit 1
fi
if ! type "php" > /dev/null ; then
echo "Error: php is not installed"
fi
TMP_DIR=$(mktemp -d /tmp/installcomposer.tpm.XXXXXXXXXX) || { echo "Error: failed to create tmp dir"; exit 1; }
wget -O $TMP_DIR/installer https://getcomposer.org/installer
(cd $TMP_DIR ; php installer)
X
Url: http://git.io/yyxOXQ
Language: Shell | User: souf | Created: Oct 6, 2013 | Tags: php composer bash