install drupal bash script

Events happening in the community are now at Drupal community events on www.drupal.org.
tarvid's picture

Rough cut of a script that will set up a user, domain, database, dns, apache on Ubuntu or Debian and allow a user to start Drupal installation at http://domain/

Problems, comments, suggestions to tarvid@ls.net.

More at http://drupal.ls.net/

Comments

Looks pretty useful. I

yaph's picture

Looks pretty useful. I wouldn't grant all mysql priviliges to the database user but only those needed.

Btw. to quickly find the script: http://drupal.ls.net/node/47

I created a modified version

yaph's picture

I created a modified version of your script that is useful for development installations, which you can find at: http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/yaph/script...
It only installs Drupal no apache or DNS configuration.

Drupal module install bash script

manuel garcia's picture

Following up on the idea, which I love, and I am using it perfectly, I went ahead and made one for installing modules to avoid repetitive tasks of downloading/decompressing/removing the file:

#!/bin/bash
# Script for downloading / uncompressing drupal modules

# check for user input
if [ ! $@ ]; then
  echo "Example usage:"
  echo "$0 drupal http://ftp.drupal.org/files/projects/views_accordion-6.x-1.2-beta1.tar.gz"
  echo "Where 'drupal' is the name of your directory within your localhost."
  exit 0
fi

NAME=$1
DOWNLOAD=$2
FILENAME=${DOWNLOAD#'http://ftp.drupal.org/files/projects/'}
MODULE=${FILENAME%'.tar.gz'}
INSTALL_DIR="/var/www/$1/sites/all/modules"
MODULE_INSTALL_DIR="/var/www/$1/sites/all/modules/$MODULE"

if [ -d $MODULE_INSTALL_DIR ]; then
  echo "$MODULE_INSTALL_DIR exists!"
  exit 0
fi


cd $INSTALL_DIR

# example download link http://ftp.drupal.org/files/projects/views_accordion-6.x-1.2-beta1.tar.gz
echo "Starting download..."
wget $DOWNLOAD

echo "Decompressing package..."
tar xzf $FILENAME
echo "Done!"
echo ""
# removing downloaded package
rm $FILENAME
echo "Removed $FILENAME for you."
echo ""
echo "***********************************************************************"
echo "** Finished installing $MODULE"
echo "** You can find it under: $INSTALL_DIR"
echo "** Go to http://localhost/$NAME/admin/build/modules/ to activate it."
echo "***********************************************************************"

Hope you like it!

Looks like I reinvented the wheel...

jakery's picture

I composed a similar script a few days ago, not realizing this was already here. Oh well...

#!/bin/bash -e
# -e means stop the script if something goes wrong

#your drupal module directory, NO trailing slash
MODDIR="${HOME}/html/jacobCMS/drupal/sites/all/modules"

#generic name for downloaded .tar.gz file so it can be easily removed later
FILE=${MODDIR}"/wget.tar.gz"

#message if there is an error: "failed," colored red
trap 'echo -e "\e[0;31mfailed\e[0m\n"' ERR

#if a URL isn't provided, give instructions
if [ -z "$1" ]
then
        echo -e "Example Use: \nwget http://ftp.drupal.org/files/projects/taxonomy_multi_edit-6.x-1.1.tar.gz"
        exit
fi


#"Getting..." colored cyan
echo -e "\n\e[1;36mGetting...\e[0m"

#download tgz, give it generic name
wget $1 -O $FILE

#unpack
tar -xvf $FILE -C $MODDIR

#remove .tar.gz download
rm $FILE


#"Done" colored green
echo -e "\e[0;32mDone\e[0m\n"

My web site has the color coding for BASH scripts for easier readability.
http://www.jacobkking.com/story/improved-drupal-module-script

Installing BASH Script Question (OFF TOPIC)

giganet's picture

Hello group..

I am quite a newb to NIX and have been searching the WWW trying to figure out how to install BASH scripts to a NIX server.

A friend of mine directed me to "Blocking IP address of any country with iptables" located at http://blogama.org/node/62

My questions are dumb and will most likely frustrate some, for this I applogize.

1) Into which directory should I install the API? (/root)

2) How is the script executed? (incoming/outgoing traffic requests)

3) Would there be a specific name I apply to the AP and should any special permissions be applied to the API?

Thanking you in advance for your words of wisdom and shared knowledge.

Best Regards

BASH

jakery's picture

Bash scripting really doesn't have anything to do with banning web traffic. If you're trying to block IP addresses from logging in or creating accounts, you can do so in Administer -> User Management -> Access Rules.

If you're trying to block IP addresses from your site altogether, you'll want to add a blacklist to your .htaccess file like so:

order allow,deny
deny from [ip address 1]
deny from [ip address 2]
deny from [ip address 3]
deny from [ip address 4, and so on]
allow from all

My Drupal Script Library

toddgee's picture

Check http://toddgee.com/drupalScripts -- I have written a library that (I think, anyway) is very feature complete. I have used Drush before and find my scripts to be the better solution.

I now manage round 50ish drupal sites and couldn't do it w/o my script library.

t

thanks!

Wappie08's picture

toddgee, thank you very much for all these scripts, it will definitely cost me some time to figure out all functions :) Could you elaborate on why your script work better than Drush, I'm quite used to Drush and it all works well!

Greets Wappie

re: thanks!

toddgee's picture

Hey Wappie08 -

I wrote my scripts w/ a functional target rather than building blocks which seems are the idea behind Drush. I wouldn't say that they're 'more useful' rather that they allow drupal deployers do the work that needs to get done. My recent re-write to handle Git based installations (rather than the previous CVS installations) handle Git based installs a little better than Drush currently (I believe) but I doubt it's long until Drush gets there (and surpasses what I have).

One thing my scripts do is leverage my identified best practices to be able to perform operations on groups of deployed sites in a consistent manner. I also provide ample bash completion rules to allow easy command line management.

I would recommend using both. I do. I provide integration w/ Drush with the script drupalManageDrush.sh to check Drush out (into a specific directory) and the bash function 'ddrush ' which calls the drush function for the specified site (setting up the path parameters correctly).

I think the Drush makefiles are neat. However, my drupalSiteCopy.sh script, which copies complete site state from one site to another, is very useful -- I have a script 'drupalUpdate.sh' which copies a site to a development domain, updates that development domain, allows the user to check it out -- make sure the update broke nothing, and then (assuming that nothing went wrong) make the same updates against the original site.

hope this helps.

check them out at svn.toddgee.com / drupalScripts (this is a URL -- just trying to get around that famous Drupal post censor)

Drubuntu

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week