Drupal module install script

Update: This script has been improved here.

While developing a new Drupal site, one tends to install lots of modules to shape his site into something specific. The problem is, doing so through a GUI takes much more time than I care to spend.

  1. Click the "download" link on a drupal module page
  2. Open the folder where my download was sent
  3. Open your "modules" folder on my drupal site's local copy
  4. Extract the files from the .tar.gz bundle
  5. Delete the .tar.gz download file because I'm done with it
  6. Drag and drop my files into my module directory
  7. Open an FTP client
  8. Upload the new files in my module directory to my site's server.

For every module I install, that's about 90 seconds of boring work that requires my undivided attention. YUCK.
There's a much better way. Logged into my shell on the server, I wrote a relatively simple function in my .bashrc file.

  1. function getmod {
  2.  
  3. if [ -z "$1" ]
  4. then
  5. echo "Error: specify a URL."
  6. return
  7. fi
  8.  
  9. FILE="wget.tar.gz"
  10. cd ~/html/sites/all/modules/
  11.  
  12. wget $1 -O $FILE
  13.  
  14. tar -xvf $FILE
  15.  
  16. rm $FILE
  17.  
  18. return
  19. }

In a nutshell, this downloads and installs a module directly onto the server in one easy step on my part. As soon as I find a module I want on drupal.org, I right-click the "download" link and copy the file's address. Then, in my bash shell, all I have to do is type
  1. getmod [paste URL of .tar.gz file]

and it's done. The real benefit isn't so much the 60 seconds of time it saves; it's the automation that lets me stay focused on the big picture without having to mentally switch gears to do back-end work. It just makes the whole design process a little bit less stressful.