mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Improve composer installer
- Check to signature. - Add error handling. - See Also https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
This commit is contained in:
parent
83cc9a4bcf
commit
c6f956927a
18
src/linux.sh
18
src/linux.sh
@ -13,9 +13,23 @@ if [ "$version" != "$1" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "/usr/bin/composer" ]; then
|
if [ ! -e "/usr/bin/composer" ]; then
|
||||||
sudo curl -s https://getcomposer.org/installer | php;
|
EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)"
|
||||||
sudo mv composer.phar /usr/local/bin/composer;
|
curl -s -L https://getcomposer.org/installer > composer-setup.php
|
||||||
|
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
||||||
|
|
||||||
|
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then
|
||||||
|
>&2 echo 'ERROR: Invalid installer signature'
|
||||||
|
rm composer-setup.php
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMPOSER_ALLOW_SUPERUSER=1
|
||||||
|
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
||||||
|
RESULT=$?
|
||||||
|
rm composer-setup.php
|
||||||
|
exit $RESULT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
composer global require hirak/prestissimo > /dev/null 2>&1
|
composer global require hirak/prestissimo > /dev/null 2>&1
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
ext_dir=$(/usr/bin/php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
ext_dir=$(/usr/bin/php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
|
Loading…
Reference in New Issue
Block a user