Friday, October 25, 2013

Shell script to download files from anywhere

As the title suggests, this is just a simple script I figured out for downloading files. The list of urls for downloading are located in an xml document that I'm parsing, storing briefly, looping through and downloading what I wanted to a predetermined location (though that could be modified for user input).

Script:

read_dom () {
    local IFS=\>
    read -d \< ENTITY CONTENT
}

while read_dom; do
    if [[ $ENTITY = "xmlTag" ]]; then
echo $CONTENT
if [[ $CONTENT != "null" ]]; then
wget -Nrkpl 0 $CONTENT -nd -Pdownloads
fi      
    fi
done < listOfXML.xml > temporaryXMLPage.txt

echo "File cleanup"
rm temporaryXMLPage.txt

source:
http://stackoverflow.com/questions/893585/how-to-parse-xml-in-bash
and
http://stackoverflow.com/questions/15407884/javascript-download-images-from-url


Tuesday, October 1, 2013

Using Drush to deploy themes and modules to multi-sites on CentOS

Previously I discussed setting up multi-site on CentOS, now, using Drush, we can also download, enable, and set themes and modules for individual sites.  The default Drupal7 site gets all the glory of files downloaded to it, but the individual sites should be the ones showing the updates.

Steps to use Drush:

1) cd /var/www/vhosts/drupal7/sites/your.alternative.site
get into the correct folder that you want to have the theme enabled
2) drush dl theme
This is the last part of a url available from drupal, i.e. drupal.org/project/omega would use omega

3) drush en theme
This enables the them for all sites. From what I understand, the files themselves get downloaded to the main drupal7/sites/all/themes/ directory. Somehow Drupal knows to find the themes for each individual site, which in the next step we set as the default. Setting it this way makes it available to all sites to enable themselves, but not as a default for all sites. If you'd like it to be exclusive just for your one site, and not maintained for the rest of them, you might have to just move it around or not use drush for that...not sure? ask on the forums.

4) drush vset theme_default theme
This sets the default theme for the site that you're in. This is awesome because it does it only for the specified site. Even if I set the Drupal7 default site default theme, it would have no impact on the other sites because they all get their own choices.

5) drush pm-list --type=theme
this last one is pretty neat because drush has some pretty cool project management tools. this one just lists out all of the themes available for your main installation, including the package it comes with, the name, status, and version.

Enjoy!