2021-12-22 13:51:22 +00:00
|
|
|
#!/bin/bash
|
2022-07-04 09:56:45 +00:00
|
|
|
##makedesc: Install composer (latest)
|
2023-04-14 04:06:40 +00:00
|
|
|
source `dirname $0`/../helpers || exit 255
|
2022-01-09 08:56:25 +00:00
|
|
|
|
2022-07-12 15:20:11 +00:00
|
|
|
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
|
|
|
|
|
2023-04-14 04:06:40 +00:00
|
|
|
title
|
2021-12-22 13:51:22 +00:00
|
|
|
|
2023-04-14 04:06:40 +00:00
|
|
|
require php
|
2022-07-04 15:24:27 +00:00
|
|
|
|
|
|
|
if installed "composer"; then
|
2023-04-14 04:06:40 +00:00
|
|
|
warn "WARNING: Removing current composer to install its actual version"
|
2022-07-04 15:24:27 +00:00
|
|
|
sudo apt remove -y --autoremove composer
|
2023-04-14 04:06:40 +00:00
|
|
|
sudo rm -f \
|
|
|
|
"$HOME/.local/bin/composer" \
|
|
|
|
/bin/composer \
|
|
|
|
/usr/bin/composer \
|
|
|
|
/usr/local/bin/composer \
|
|
|
|
/usr/src/composer \
|
|
|
|
"$HOME/.local/bin/composer"
|
2021-12-22 13:51:22 +00:00
|
|
|
fi
|
|
|
|
|
2023-04-14 04:06:40 +00:00
|
|
|
mkdir -p "$HOME/install" "$HOME/.local/bin"
|
|
|
|
download "https://getcomposer.org/installer" "$HOME/install/composer-setup.php" && \
|
|
|
|
php "$HOME/install/composer-setup.php" --install-dir="$HOME/.local/bin/composer"
|
|
|
|
|
|
|
|
[ $? = 0 ] && {
|
|
|
|
COMPOSER_GLOBAL_HOME="$($HOME/.local/bin/composer config -g home)"
|
|
|
|
NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\""
|
|
|
|
cat "$HOME/.profile" | grep -qoh "$NEWPATH" || {
|
|
|
|
$NEWPATH
|
|
|
|
echo "$NEWPATH" >> "$HOME/.profile"
|
|
|
|
}
|
|
|
|
|
|
|
|
echo
|
|
|
|
success "composer installed!"
|
|
|
|
composer --version
|
|
|
|
echo
|
2022-12-11 06:48:30 +00:00
|
|
|
}
|
|
|
|
|
2023-04-14 04:06:40 +00:00
|
|
|
source "$HOME/.profile"
|