• Blogs (9)
    • 📱 236 - 992 - 3846

      đź“§ jxjwilliam@gmail.com

    • Version: ‍🚀 1.1.0
  • Drupal modules: automatically install in LAMP

    Blogs20102010-11-14


    Some developers install Drupal modules like this:
    By looping individual module in Windows:

    1. download the module into local directory
    2. unzip
    3. ftp the module to server’s Drupal module directory.

    This is tired work. I wrote a shell script to automatically install all the modules in LAMP without hand interference.
    The steps are:

    1. Collect all the modules you want to install, put them in a seperate file, or simpler in this example, put in the script.
      my modules are: views-6.x-2.11.tar.gz cck-6.x-3.x.tar.gz token-6.x-1.15.tar.gz pathauto-6.x-1.5.tar.gz devel-6.x-1.22.tar.gz admin_menu-6.x-1.6.tar.gz advanced_help-6.x-1.2.tar.gz ubercart-6.x-2.4.tar.gz
    2. runing the following script: $ drupal_module_install.sh
      That’s it.
    3. If you want to customize the module from command-line, like:
      $ **drupal\module_install.sh views-6.x-2.11.tar.gz**_
      Pretty easy.
    #!/bin/bash
    
    DRUPAL_MODULES='views-6.x-2.11.tar.gz cck-6.x-3.x.tar.gz token-6.x-1.15.tar.gz pathauto-6.x-1.5.tar.gz devel-6.x-1.22.tar.gz admin_menu-6.x-1.6.tar.gz advanced_help-6.x-1.2.tar.gz ubercart-6.x-2.4.tar.gz'
    
    DRUPAL_DIR=$HOME/drupal/
    TMP=$DRUPAL_DIR/tmp/
    DEST=$DRUPAL_DIR/sites/all/modules/
    
    if [ ! -d $TMP ]; then
    	mkdir $TMP
    fi
    cd $TMP
    
    if [ $# -eq 1 ]; then
    		module=$1
    		strip_name=`echo $i | cut -f 1 -d -`
    		if [ -d $DEST/$strip_name ]; then
    			echo "The '$module' already exists in $DEST.nTo install new, delete it first."
    			exit 8;
    		fi
    		wget http://ftp.drupal.org/files/projects/$module
    		tar -zxvf $module
    		mv $strip_name $DEST
    else
    	for i in `echo $DRUPAL_MODULES`
    	do
    		strip_name=`echo $i | cut -f 1 -d -`
    		# or: $strip_name=`echo $i | sed -e 's/-.*$//'`
    		if [ -d $DEST/$strip_name ]; then
    			echo "The '$strip_name' already exists in $DEST. Ignore. To install new, delete $DEST/$strip_name first."
    		else
    			wget http://ftp.drupal.org/files/projects/$i
    			tar -zxvf $i
    			mv $strip_name $DEST
    		fi
    	done
    
    fi
    cd -

    This saves time. For other modules installation, e.g Perl’s modules, PHP’s packages and libraries, the same method is applicable.