Drupal provision module and drush? - drupal

I'm trying to automate the use of the provision drush extension. Mostly that works well, but I can't make a custom drush extension perform a provision-install command, unless I manually use proc_open to call drush again directly.
To keep my code consistent, and use drush's API as much as possible, I would like to avoid any direct spawning of new processes.
So: what I want to work is the call I use for other drush commands, which is
drush_backend_process('#sitealias', 'provision-install', array());"
1) Why does this work for other commands using #aliases, but not provision-install?
2) How well can I make it work, within drush's API? (So as to avoid direct use of proc_open)
More info in this issue: https://drupal.org/node/1844038

Related

How do I access my external MYSQL database from Asterisk dialplan?

I am trying to access my external database from an Asterisk dialplan but I get the error "No application MySQL for extension mycontextname".
So I run the command “module show like mysql” and it shows 0 module. I read on a blog that I have to add mysql addons such as app_addon_sql_mysql.so module, but the once I found isn't solving the situation either. I still get 0 module after the "module show like mysql" command.
I am using Asterisk 13.10.0 and please which mysql module will work well for my Asterisk version, also where can I get it?
Mysql is outdated AND addtional application. You should not use it. If you HAVE, you need compile it(do make menuconfig before make).
Recommended way is use of func_odbc or REALTIME
Personally, I don't like doing database stuff in the Asterisk dialplan. I find it ugly, difficult to write (quoting), difficult to maintain, and fragile.
I prefer to write applications (logic and database access) in an AGI. You have 'full' access to the database and you 'hide' all the details in a nice black box where your code can be checked by a real compiler (or script interpreter).

How to execute php file in Drupal 6 by Cron

What I need is execute one php file every hour. I found a lot of weird and not-understandable things about creating a module for Drupal (I don't need a whole module, I need to execute just ONE file).
Because my brain can't handle this dull realisation of Drupal or Cron.
Better solution is to use system crontab because it reduces load to php and your site will run faster.
Read more:
https://en.wikipedia.org/wiki/Cron
http://www.computerhope.com/unix/ucrontab.htm.
If you can't use system cron try to configure Drupal's cron: https://www.drupal.org/cron.
In worse case you can try https://www.drupal.org/project/poormanscron module.
If you want to do it the Drupal-y way, instead of a more hacky way outside of what Drupal is meant to do, use hook_cron().
To do this, you will need to create a new module with that function inside of module_name.module. You can view the documentation on creating a new module in Drupal six here. You should only need the "Getting Started" and "Tell Drupal about your module" sections.
In your module_name.module file, write a hook_cron() function. The hook will be replaced by the machine-name of your module.
The description of hook_cron() on Drupal.org is as follows:
Modules that require to schedule some commands to be executed at regular intervals can implement hook_cron(). The engine will then call the hook at the appropriate intervals defined by the administrator. This interface is particularly handy to implement timers or to automate certain tasks. Database maintenance, recalculation of settings or parameters, and automatic mailings are good candidates for cron tasks.
Without more details of what you are trying to accomplish or more details about your script, this is all I can provide.

Unix scripting for servces to check

I am struggling to write a script to check a particular service running on my server and then send me mails.
So should this script be the part of bash profile so that its always running..
regards
rick
The .profile, .bashrc and friends will be run on login, so they are of no good use for background monitoring. Two solutions come to mind:
Either use cron to run your script at predefined intervals
Or make it loop and use your system's init environment (SysV, Upstart, SystemD, ...) to control it
My recommendation is to stick with cron - it even makes the mailing of results dead easy - just create output.

How should I implement a runonce script for Symfony 2?

I use Scrum methodology and deploy functionality in builds every sprint.
There is necessity to perform different changes in the stored data (I mean data in database and on filesystem). I'd like to implement it as a PHP scripts invoked from console. But they should be executed only once, during the deployment.
Is there any way to implement it through app/console without listing it in the list of registered Console commands? Or is there any other way to implement runonce scripts?
DoctrineMigrations covers some part of my requirements, but it's hard to implement complex changes in Model. And it does not cover changes in files on the filesystem.
I don't think symfony has a facility for that, and besides, hiding the command is not the same as securing the command.
Instead, I would make the script determine if it has been run already (could be as simple as adding a version number to a file and checking that number before running) and stop if it detects it has already run before.

Using the simpletest automator in Drupal 6

I've been trying to learn how to use simpletest, and I found the simpletest automator. I was able to install it and run it, but where is the file with the results of the 'macro' saved? I haven't been able to find it.
Also, is there a quick way to duplicate a drupal install in simpletest? I know it starts from a clean install, but I don't want to have to go through and figure out what all is enabled and who has what permissions at the start of the test. Is there a script that can figure out the settings of the current drupal install?
Thank You.
Is there a script that can figure out the settings of the current drupal install?
The short answer is no.
Essentially simpletest should be used as a unit test framework. Where all of the data that is needed is set up at the beginning of the test and it is not reliant on system setting or a particular user having a permission. It does this quite well, and can test core functionality and individual modules easily. If you are testing an indavidual module you have written using simpletest is, well, simple.
Unfortunately most websites use a number of modules and are configured to work together in a very specific way. Simpletest doesn't cope with this very well.
There are ways to get around this:
One option is to write a setup script in php which will work as a big setup script for your test. This can create users, set settings and permissions. This can be dificult to write and maintain and can cause the tests to take a long time to run.
Another option is for the site testing (which is different from unit testing) to be done in a tool other than simpletest. I have had some success with selenium. The downside to this is that you need to find a way have clean data. Which can be tricky, copying a database works but doesn't scale.
I've been pointed to this blog post as an answer to the question: http://www.trellon.com/content/blog/forcing-simpletest-use-live-database
You can also use a site deployment module and enable only that at the very beginning of your test (in your SetUp() function).

Resources