2021-12-22 13:51:22 +00:00
|
|
|
#!/bin/bash
|
2022-07-04 09:56:45 +00:00
|
|
|
##makedesc: Install composer (latest)
|
|
|
|
|
2022-01-09 08:56:25 +00:00
|
|
|
echo
|
|
|
|
echo "==============================================="
|
2022-07-04 09:56:45 +00:00
|
|
|
echo "Installing composer (latest)..."
|
2022-01-09 08:56:25 +00:00
|
|
|
echo "==============================================="
|
|
|
|
echo
|
|
|
|
|
|
|
|
installed() {
|
|
|
|
command -v "$1" >/dev/null 2>&1
|
|
|
|
}
|
2021-12-22 13:51:22 +00:00
|
|
|
|
|
|
|
if installed "php"; then
|
|
|
|
if installed "composer"; then
|
2022-01-09 08:56:25 +00:00
|
|
|
echo "WARNING: You already have composer installed - removing to install actual version"
|
2021-12-22 13:51:22 +00:00
|
|
|
sudo apt remove -y --autoremove composer
|
|
|
|
sudo rm -f /bin/composer
|
|
|
|
sudo rm -f /usr/bin/composer
|
|
|
|
sudo rm -f /usr/local/bin/composer
|
|
|
|
sudo rm -rf /usr/src/composer
|
|
|
|
fi
|
|
|
|
sudo mkdir -m 0777 -p /usr/src/composer
|
|
|
|
cd /usr/src/composer
|
|
|
|
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
|
|
|
|
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
|
|
|
|
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
|
|
|
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
|
|
|
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
|
|
|
|
>&2 echo 'ERROR: Invalid installer checksum'
|
|
|
|
rm composer-setup.php
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
php composer-setup.php --quiet
|
|
|
|
sudo cp /usr/src/composer/composer.phar /usr/local/bin/composer
|
|
|
|
cd - >/dev/null
|
|
|
|
sudo rm -rf /usr/src/composer/
|
2022-01-09 08:56:25 +00:00
|
|
|
installed "composer" && composer --version
|
2021-12-22 13:51:22 +00:00
|
|
|
else
|
2022-01-09 08:56:25 +00:00
|
|
|
echo "WARNING: You need to have php installed"
|
2021-12-22 13:51:22 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# title "Installing composer.phar in home dir..."
|
|
|
|
# cd ~
|
|
|
|
# EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
|
|
|
|
# php -r "copy('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
|
|
|
|
# php composer-setup.php --quiet
|
|
|
|
# RESULT=$?
|
|
|
|
# rm composer-setup.php
|