Skip to content

Instantly share code, notes, and snippets.

@TLMcode
Forked from ezimuel/install.sh
Created May 26, 2018 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TLMcode/5a98c99cabb0cccb4004e894642e3437 to your computer and use it in GitHub Desktop.
Save TLMcode/5a98c99cabb0cccb4004e894642e3437 to your computer and use it in GitHub Desktop.
Verify and install composer from bash command line
#!/bin/bash
# Verify and install composer from https://getcomposer.org/installer
me=`basename "$0"`
if [[ $# -eq 0 ]] ; then
echo "Usage: $me <hash>"
echo 'where <hash> is the hash value of the installer to verify'
exit 1
fi
hash=$1
php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
php -r "if (hash('SHA384', file_get_contents('composer-setup.php')) === '$hash') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
if [ -f composer-setup.php ]; then
php composer-setup.php
php -r "unlink('composer-setup.php');"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment