By sami_k on
Here's the beginings of a shell script that will install modules from shell. Currently it only installs the ones without the need for DB, but it should only take a few lines to do that, if someone else has time they are welcome to. I just thought i'd present the idea with some work done. Any improvements, suggestions, and code is welcome.
-------------------------------------------------------------------------
#!/usr/local/bin/php -q
#$dbusername = "";
#$dbpasswd = "";
#$dbname = "";
#absolute path to drupal with a trailing /
$abspath = "";
// YOU DO NOT NEED TO EDIT BELOW HERE
$modulepath = $abspath."modules/";
$filename = $argv[1];
if(isset($filename) && file_exists($filename) && (count(explode('.',$filename)) > 1)){
$temp = explode('-', $filename);
$modulename = $temp[0];
//delete module directory
//shell_exec("rm -rf $modulename");
shell_exec("tar -xzf $filename");
if(file_exists("$modulename/INSTALL"))
echo shell_exec("more $modulename/INSTALL");
else if(file_exists("$modulename/README"))
echo shell_exec("more $modulename/README");
else if(file_exists("$modulename/README.txt"))
echo shell_exec("more $modulename/README.txt");
WHILE($bool == false){
echo "\n\nDo you want (o)nly module file, (e)ntire directory, (a)ll files? (o/e/a)?";
$input = trim(read());
if($input == 'o' || $input == 'e' || $input == 'a'){
$bool = true;
}else
$bool = false;
}
if($input == 'o'){
shell_exec("mv $modulename/*.module $modulepath");
}else if($input == 'e'){
delcruft();
shell_exec("mv $modulename $modulepath");
}else if($input == 'a'){
delcruft();
shell_exec("mv $modulename/* $modulepath");
}
//find sql file, run mysql command to pipe the sql file to the db
}else{
echo "File doesn't exist or not defined properly!";
}
function read() {
$fp=fopen("/dev/stdin", "r");
$input=fgets($fp, 4);
fclose($fp);
return str_replace("\n", "", $input);
}
function delcruft(){
shell_exec("rm -rf $modulename/CHANGELOG");
shell_exec("rm -rf $modulename/README*");
shell_exec("rm -rf $modulename/TODO");
shell_exec("rm -rf $modulename/CREDITS");
shell_exec("rm -rf $modulename/INSTALL");
shell_exec("rm -rf $modulename/LICENSE*");
}
Comments
By the way call the script
By the way call the script like this:
./install.php module.tar.gz
--
Etopian (Support & Hosting)
http://www.etopian.net/drupal
You might find www.drupalmashup.interestsphere.com useful
This site comes to the aid of experienced Drupal developers who have discovered that they rely on much the same collection of modules for a particular type of site. Once you've mashed up your collection you can view the generated drush commands and/or download the (UNIX shell) script.
www.drupalmashup.interestsphere.com
http://drupalwork.interestsphere.com/
http://drupalmashup.interestsphere.com/