Last active
January 30, 2023 16:17
-
-
Save efann/3e5a6e58ba4792b35a8de466157abefd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# License: Eclipse Public License - v 2.0 (https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html) | |
# Updated on January 30, 2023 | |
if [[ $EUID -ne 0 ]]; then | |
echo -e "\nThis script must be run as root. Exiting. . . .\n\n" | |
exit 1 | |
fi | |
echo -e "=========================================================================================\n" | |
echo -e "$0 will install or update the drush stub and composer for Drupal installations.\n" | |
echo -e "You still need to run the following in each Drupal web root\n" | |
echo -e " composer require composer/composer -W\n" | |
echo -e " composer require drush/drush -W\n" | |
echo -e "=========================================================================================\n\n" | |
lcDrushFolder="/usr/local/bin" | |
lcDrush=$(which drush) | |
if [ -n "${lcDrush}" ]; then | |
echo -e "drush found at ${lcDrush}\n" | |
lcDrushFolder=$(dirname "${lcDrush}") | |
else | |
echo -e "Using the default folder for drush.\n" | |
fi | |
echo -e "drush folder is ${lcDrushFolder}\n\n" | |
# Below just gets the launcher (the launcher links to the project’s vendor/bin/drush command) | |
# From https://github.com/drush-ops/drush-launcher | |
cd /tmp | |
wget -O drush.phar https://github.com/drush-ops/drush-launcher/releases/latest/download/drush.phar | |
chmod +x drush.phar | |
mv drush.phar "${lcDrushFolder}"/drush | |
echo -e "\ndrush installed at $(which drush)\n\n" | |
echo -e "=========================================================================================\n\n" | |
lcComposerFolder="/usr/local/bin" | |
lcComposer=$(which composer) | |
if [ -n "${lcComposer}" ]; then | |
echo -e "composer found at ${lcComposer}\n" | |
lcComposerFolder=$(dirname "${lcComposer}") | |
else | |
echo -e "Using the default folder for composer.\n" | |
fi | |
echo -e "Composer folder is ${lcComposerFolder}n\n" | |
cd /tmp | |
curl -sS https://getcomposer.org/installer -o composer-setup.php | |
HASH=$(curl -sS https://composer.github.io/installer.sig) | |
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | |
php composer-setup.php --install-dir="${lcComposerFolder}" --filename=composer | |
echo -e "\ncomposer installed at $(which composer)\n\n" | |
echo -e "=========================================================================================\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment