Running bash script post install?

SDK Docs: http://installatron.com/developer/apps
SDK GUI Editor: http://installatron.com/editor

Running bash script post install?

Postby darryl » Wed Aug 31, 2011 7:50 am

I wondered if it was possible to execute a script after an install had taken place. What I am looking to do is change permissions for some Drupal files post-install, I know this can be done using the customizer and code like
Code: Select all
$this->chmod("inc/example.php",0707);
however I need to apply this recursively for some directories and from what I can see there is no support for this.

I thought the easiest way would be to create a bash script that would chmod -R the various files/directories to the required permissions, but I am not sure how to run a script post install.

Any advice appreciated, thanks.
darryl
 
Posts: 20
Joined: Wed Aug 31, 2011 7:43 am

Re: Running bash script post install?

Postby Phil » Wed Aug 31, 2011 8:31 am

Hello,

You can just change that command to:

Code: Select all
$this->chmod("inc",0707,0707,true);

That will tell Installatron to chmod files 0707, directories 0707, and perform the action recursively. We recommend using this method.

There is also a hook file:

Code: Select all
/usr/local/installatron/etc/hook_install.php

This file must be owned by root. $this->install->ini["path"] provides the path to the install, and $this->install->ini["installer"] identifies the name of the app. For example this might work (untested):
Code: Select all
<?php

if ( $this->install->ini["installer"] === "drupal" )
{
       exec("chmod -R 707 ".escapeshellarg($this->install->ini["path"]."/inc"));
}

If there are any questions let us know.

Thank you,
Phil.
Phillip Stier
Installatron Co-Founder
Phil
Staff
 
Posts: 425
Joined: Tue Jun 19, 2007 6:06 am

Re: Running bash script post install?

Postby darryl » Wed Aug 31, 2011 8:38 am

Thanks a lot for that, gives me some things to try out :)

Is there any docs for the sdk commands like chmod, if I knew that syntax probably wouldn't have had to bother you. I checked on http://installatron.com/developer/apps#chmod but it seems the chmod section is missing, not sure if this is a work in progress?
darryl
 
Posts: 20
Joined: Wed Aug 31, 2011 7:43 am

Re: Running bash script post install?

Postby darryl » Wed Aug 31, 2011 9:40 am

Having some further issues here, this is the code that I want to run after a Drupal install:

Code: Select all
$this->chmod("./",0540,0540,true);
$this->chmod("./sites/default/files",0755,0755,true);


I've entered this but for some reason this doesn't seem to be running post install, it's running somewhere towards the start of the install, and because it's changing the permissions of the folder too early it's actually breaking the install as Installatron sets these and no longer has the permissions it requires to complete the install.

As far as I can see this should be ran post install, the description says:

Simply enter the installer code that you want to run at the end of an install and/or upgrade and click the Generate button at the bottom of the page.


I'm not sure if this is a problem with Installatron?
darryl
 
Posts: 20
Joined: Wed Aug 31, 2011 7:43 am

Re: Running bash script post install?

Postby Josh » Wed Aug 31, 2011 10:16 am

darryl wrote:Thanks a lot for that, gives me some things to try out :)

Is there any docs for the sdk commands like chmod, if I knew that syntax probably wouldn't have had to bother you. I checked on http://installatron.com/developer/apps#chmod but it seems the chmod section is missing, not sure if this is a work in progress?

Yeah, it does appear to be missing from that document. I've added this to our todo list. The new website has been a lot of work. :)

Thanks,
Josh
Josh
Staff
 
Posts: 105
Joined: Wed Jul 07, 2010 3:53 pm

Re: Running bash script post install?

Postby Josh » Wed Aug 31, 2011 10:18 am

darryl wrote:Having some further issues here, this is the code that I want to run after a Drupal install:

Code: Select all
$this->chmod("./",0540,0540,true);
$this->chmod("./sites/default/files",0755,0755,true);


I've entered this but for some reason this doesn't seem to be running post install, it's running somewhere towards the start of the install, and because it's changing the permissions of the folder too early it's actually breaking the install as Installatron sets these and no longer has the permissions it requires to complete the install.

As far as I can see this should be ran post install, the description says:

Simply enter the installer code that you want to run at the end of an install and/or upgrade and click the Generate button at the bottom of the page.


I'm not sure if this is a problem with Installatron?

You can control exactly when the code runs in the register call. What does that line look like right now?
Josh
Staff
 
Posts: 105
Joined: Wed Jul 07, 2010 3:53 pm

Re: Running bash script post install?

Postby darryl » Wed Aug 31, 2011 11:04 am

This is the code that the tool gives me currently and what I have put into Installatron:

Code: Select all
<?php
class i_installer_customcode
{
   function init()
   {
$this->registerCustomCode("drupal", "all", "install", "last", "process", "drupalinstall");
   }
   function drupalinstall($o)
   {
$o->chmod("./",0540,0540,true);
$o->chmod("./sites/default/files",0755,0755,true);
   }
}
?>
darryl
 
Posts: 20
Joined: Wed Aug 31, 2011 7:43 am

Re: Running bash script post install?

Postby Phil » Wed Aug 31, 2011 4:41 pm

Hello,

Your custom code is actually correct. This might be a bug. What version of Installatron is installed on this server?

As a workaround, try changing "last" to: 3 (without quotes)

Thank you,
Phil.
Phillip Stier
Installatron Co-Founder
Phil
Staff
 
Posts: 425
Joined: Tue Jun 19, 2007 6:06 am

Re: Running bash script post install?

Postby darryl » Thu Sep 01, 2011 5:14 am

We are running the latest Edge release 7.0.0

I tried the workaround unfortunately to the same effect, it seems it's definitely running too early before the install has completed. If you need any further information I'd be happy to provide it, would love to get a fix for this if possible.
darryl
 
Posts: 20
Joined: Wed Aug 31, 2011 7:43 am

Re: Running bash script post install?

Postby Phil » Thu Sep 01, 2011 5:22 am

Hi,

We're going to run some tests later today. I'll let you know what we find.

Thank you,
Phil.
Phillip Stier
Installatron Co-Founder
Phil
Staff
 
Posts: 425
Joined: Tue Jun 19, 2007 6:06 am

Next

Return to Application Packaging SDK and Application Customizations

Who is online

Users browsing this forum: Baidu [Spider] and 0 guests

cron