0

I tried to install drush with composer from a script that is runing with sudo

$nameofuser `logname`
#drush installation
getcomposer(){
# Composer Global installation
curl -sS https://getcomposer.org/installer | php > /dev/null 2>&1
mv composer.phar /usr/local/bin/composer > /dev/null 2>&1
sed -i '1i export PATH="/home/"$nameofuser"/.composer/vendor/bin:$PATH"' /home/"$nameofuser"/.bashrc > /dev/null 2>&1
source /home/"$nameofuser"/.bashrc
}
getdrush(){
composer global require drush/drush:dev-master > /dev/null 2>&1
if [ -f /usr/bin/drush ]; then
rm "/usr/bin/drush"
ln -s  /home/"$nameofuser"/.comoser/vendor/drush/drush/drush /bin/drush
else
ln -s  /home/"$nameofuser"/.comoser/vendor/drush/drush/drush /bin/drsuh
fi  
}
getcomposer
getdrush

The restult is

lrwxrwxrwx 1 root root Dec 28 14:55 drush --> /home/user/.comoser/vendor/drush/drush/drush

drush command is not working instead ubuntu displays

 The programm drush ist corrently not installed you can install it by typing: 
 sudo apt-get install drush 

The result of

echo $PATH is

/home//.comoser/vendor/bin:/home//.comoser/vendor/bin:/usr/local/sbin:/usr/local
/bin:/usr/sbin:user/bin:/sbin:/bin:usr/games:/usr/local/games

What is wrong here? how to get the $namefuser variable in to the $PATH, correctly, Why is the symbolic link to drush not working?

  • Logname is not defined. Try changing that to your user. – AWippler Dec 28 '14 at 15:39
  • thats strange because it works for teh rest of the script but it workjs by replaceing /home/$nameofuser with ~ I have to test if this also works when there is already an user on a seted up system – Josh Dec 28 '14 at 16:03
  • in your script, you mixed ".../.composer" and ".../.comoser" – JJoao Dec 28 '14 at 19:17
2

The first line looks wrong. That should probably be

nameofuser=`logname`

What you posted doesn't assign anything to nameofuser, and then you try to use it and it evaluates to an empty string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.