Improved drupal module script

After writing my drupal module download script, it worked just fine, save for one problem: I work on multiple Drupal sites hosted on different servers. Editing .bashrc files can get tedious, so I decided to turn "getmod" into a standalone shell script.
  1. #!/bin/bash -e
  2. # -e means stop the script if something goes wrong
  3.  
  4. #your drupal module directory, NO trailing slash
  5. MODDIR="/path/to/directory"
  6.  
  7. #generic name for downloaded .tar.gz file so it can be easily removed later
  8. FILE=${MODDIR}"/wget.tar.gz"
  9.  
  10. #message if there is an error: "failed," colored red
  11. trap 'echo -e "\e[0;31mfailed\e[0m\n"' ERR
  12.  
  13. #if a URL isn't provided, give instructions
  14. if [ -z "$1" ]
  15. then
  16. echo -e "Example Use: \ngetmod http://ftp.drupal.org/files/projects/taxonomy_multi_edit-6.x-1.1.tar.gz"
  17. exit
  18. fi
  19.  
  20.  
  21. #"Getting..." colored cyan
  22. echo -e "\n\e[1;36mGetting...\e[0m"
  23.  
  24. #download tgz, give it generic name
  25. wget $1 -O $FILE
  26.  
  27. #unpack
  28. tar -xvf $FILE -C $MODDIR
  29.  
  30. #remove .tar.gz download
  31. rm $FILE
  32.  
  33.  
  34. #"Done" colored green
  35. echo -e "\e[0;32mDone\e[0m\n"
In this new version, I also added error handling and color-coded messages for script success and failure, because I am a very visual thinker.