bernhard

ProcessWire Kickstart

Recommended Posts

I'm very happy to share my newest module called "ProcessWire Kickstart" that I developed during the holidays :) Maybe some of you already saw the preview thread about this...

What it does:

This module makes it possible to install ProcessWire in a fully automated process. You can define all necessary settings in one single php file and you can even define "recipes" that  get executed after installation. This means you can install modules, adopt settings and do whatever you want with your new site using the PW API (like creating pages and so on). You could also place a kind of frontend boilerplate on your git account and grab that after installation and place it in your templates folder. I ran out of time so maybe someone could try that out and show how he did it :)

Additional to that there is a ProcessModule to install in your ProcessWire admin which makes creating and testing recipes super easy.

 

Note:

Alpha realese until this module gets some more testing. Please be careful with this tool since it does some heavy file system manipulations (unzipping, moving and DELETING whole directories...). Use at your own risk.

 

Usage:

Just grab a copy of the kickstarter, place it on your server, visit yournewsite.com/kickstart.php, adjust settings (like username+password) as needed and hit "install".

If your mysql user does not have the rights to create a new database then you have to create a database before running the installer!

 

Download:

via SSH:

cd /var/www/yournewsitedirectory
wget baumrock.com/kickstart.php

Manually:

Klick baumrock.com/kickstart.php and upload the file to your server

Note: baumrock.com/kickstart.php returns the current master file from the gitlab repo and changes the namespace of the script so that it can install itself via recipe. If you don't need to install the kickstart processmodule via recipe you could also download the kickstart.php file from gitlab.

 

Screenshots/Walkthrough:

The initial Screen:

screencapture-kicktest-baumrock-kickstart-php-1515348512496.thumb.png.03fb884b1a8e4786679c3c6ebb3b4761.png

You can either upload a file via the left panel or take my example file from the gitlab repo:

5a5279cb3d7d3_2018-01-0719_08_57-PWKickstartpoweredbybaumrock_com.png.f2c5d771c602a2563d5a782bdb15a94a.png

This way you can create your own kickstartfiles and host it on your own accounts.

When the file is loaded you can easily edit all necessary informations, like username, password and the url where to grab ProcessWire from. I just tried it with an old version as well... 2.7 worked just fine (having the old installer that recently was updated) but an ancient 2.2.4 version failed. I don't think anybody will ever need to install lots of old versions of pw with this tool but I wanted to mention it here.

screencapture-kicktest-baumrock-kickstart-php-1515348660090.thumb.png.d7a590bd637e0f20fec7281282c28762.png

Hit "install" and lean back - on my VPS it takes 15 seconds to install my very own custom version of processwire with all modules that i need O0

screencapture-kicktest-baumrock-kickstart-php-1515348752466.thumb.png.2397180c3eb2d3b15837abc56d1a6d70.png

After logging into your admin you'll see that all modules from your recipe are installed:

5a5279b9f2a87_2018-01-0719_14_54-ModulesProcessWirekicktest.baumrock_com.thumb.png.a3bfbad0a9f100cf1e0d92e876ecc336.png

 

 

Recipe Editor:

As recipes are executed after processwire was installed you have all your API magic available there. Running this scripts is only possible inside of a working processwire installation, so I created a module to help you with that task. See the comments of the sample recipe for more information!

screencapture-kick1-to-admin-setup-kickstartrecipes-1515355389885.thumb.png.9bd31c60cb21a2a9196550f37388bde1.png

 

I hope this tool helps you to save lots of time and create lots of awesome ProcessWire websites :) I would be happy to see how you use this and please share useful recipes here in the thread so that everybody can profit. Maybe you just want to throw in an idea what could be done (for example I can imagine a recipe that checks file permissions on the system after installation)...

Some parts of the code and maybe also part of the idea are taken from @Soma 's old and still great online installer, thx for that!

  • Like 19

Share this post


Link to post
Share on other sites

Thank you Bernhard for your efforts. This looks great. Hope I find the time to test it in the next days.

  • Like 2

Share this post


Link to post
Share on other sites

Looks cool, thanks!

I think it would be a good idea to include some advice that when using on a live server users should password protect the directory that kickstart.php is uploaded to, until the install process is completed and kickstart.php is removed. Otherwise there is a security risk that a third-party might access the script and thereby be able to upload any files of their choosing.

Password protection info:
Apache
cPanel (essentially just a GUI for Apache basic auth)

  • Like 1

Share this post


Link to post
Share on other sites
45 minutes ago, Robin S said:

I think it would be a good idea to include some advice that when using on a live server users should password protect the directory that kickstart.php is uploaded to,

I haven't studied the code but wondering if uploading to a non-web-accessible system directory might help? E.g.

Quote

/var/outsidewebaccess/.dotdirectory

 

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, Robin S said:

Otherwise there is a security risk that a third-party might access the script and thereby be able to upload any files of their choosing.

Hm... thanks for that hint. I'm not sure if I like the idea of adding a password. It would break the functionality - at least I would have to put in more work. I didn't think of password protecting it, because that's the same with the regular installer (it is also visible to the public as long as the installation did not finish). The only difference at PW Kickstart is that it enables you uploading files, that's true...

But still i don't think that it is necessary to password protect the directory. The goal of this installer to make the process of creating new pw websites as easy and as fast as possible and to eliminate all of the repetitive tasks that one has to do on every new pw installation.

Ok I just got an idea: The downloader at baumrock.com/kickstart.php actually grabs the file from the gitlab repo and replaces the namespace ProcessWire on the first line with namespace Kickstart. This is do make sure the installer works both as an installer and as a helper for the Recipe Processmodule. I could easily add some lines of code to that service that adds the IP of the requesting client to the kickstart.php file and blocks all requests that do not come from that IP.

What do you guys think?

  • Like 2

Share this post


Link to post
Share on other sites

How about making it only visible when a get variable is set and has the same value as a variable set by the user?

$pass = '12345';
if ($_GET['pass'] !== $pass) {
	exit;
}

 

  • Like 1

Share this post


Link to post
Share on other sites

I think this unnecessary, because there is not a single installer (of which I know) out there that is password protected (not PW, not WordPress, not Drupal, not NextCloud, etc.). And even if it was so, I think that most guys develop on a local machine and then upload to a live server. I know:  People do stuff differently.

However: Because of the upload functionality, it is a high security risk if people can upload files, without checking for permission. I think this does not matter on a local server, but on a live server it does.

  • Like 3

Share this post


Link to post
Share on other sites

Just to clarify: The security problem exists if your server is reachable from the internet. No matter if local or housed.

Share this post


Link to post
Share on other sites

Hi @bernhard. I wanted to test your module, but it does not work on my system. Maybe it's windows related.

I am on Windows 10, with latest PHP/APACHE/MYSQL.

When I select "Load a Kickstartfile from URL" and enter the URL to your Example Snippet from Gitlab Repo it downloads ProcessWire and after this my directory looks like this:

image.png.55110970b137c9bd569e26ab6e97a7d8.png

but then the script says: "404 page not found (no site configuration or install.php available)".

I would like to test and help you fix this.

  • Like 1

Share this post


Link to post
Share on other sites

hey jmartsch thanks for your interest and help

I found the problem and did a quickfix. Seems to work now inside the root directory and also in a subdirectory: https://gitlab.com/baumrock/kickstart/commit/a68ba04c53e144ee1255faea704ab9c350b7fbe8

I have to leave now so I could not do more testing - could you please check if the recipes folder gets deleted after installation? Think I have to fix that. Also it should have thrown an error during installation, have to fix that too. But it should work now :)

Thanks

Share this post


Link to post
Share on other sites

Just pushed a little update that makes the definition of recipes easier, see this sample:

<?php
$password = $this->randomPassword();
return [
  'pw' =>'https://github.com/processwire/processwire/archive/dev.zip',
  'profile' => 'site-default',
  
  'settings' => [
    'timezone' => 368, // vienna
    
    'dbName' => 'yourdbname',
    'dbUser' => 'root',
    'dbPass' => $this->randomPassword(),
    
    'admin_name' => 'youradminurl',
    'username' => 'youradminusername',
    'userpass' => $password,
    'userpass_confirm' => $password,

    //'dbTablesAction' => 'remove', // overwrite existing tables?
  ],
  
  'recipes' => [
    function() {
      $this->msg('Installing RockMockup...');
      $this->installModule('RockMockup', 'https://gitlab.com/baumrock/RockMockup/repository/master/archive.zip');
      $this->succ('RockMockup installation completed');
    },
  ],
];

I also added this video to the first post to demonstrate how easy it is to use (I think all the screenshots may have made the impression that it is complicated)!

 

  • Like 3

Share this post


Link to post
Share on other sites
11 minutes ago, StanLindsey said:

Can this module set up some templates, fields and pages?

yes

  1. google "site:processwire.com create template field api"
  2. see some example code: https://processwire.com/talk/topic/1051-adding-and-assigning-fields-without-using-gui/?do=findComment&comment=9150
  3. create a recipe that executes this code

you could also make the recipe install the migrations module, copy over some migrations from a git repo and then execute this migrations.

  • Like 1

Share this post


Link to post
Share on other sites
16 minutes ago, bernhard said:

yes

  1. google "site:processwire.com create template field api"
  2. see some example code: https://processwire.com/talk/topic/1051-adding-and-assigning-fields-without-using-gui/?do=findComment&comment=9150
  3. create a recipe that executes this code

you could also make the recipe install the migrations module, copy over some migrations from a git repo and then execute this migrations.

I already do this for most of my builds for fixtures but can't find a way to edit the other "data" of a template - the url info or other advanced data.

Share this post


Link to post
Share on other sites
10 minutes ago, StanLindsey said:

but can't find a way to edit the other "data" of a template - the url info or other advanced data.

I don't get your point, sorry. But it seems like this has nothing to do with my kickstart module so I guess it would be better to ask in the general support category?

Share this post


Link to post
Share on other sites
3 minutes ago, bernhard said:

I don't get your point, sorry. But it seems like this has nothing to do with my kickstart module so I guess it would be better to ask in the general support category?

Yeah sorry - went off topic - but that's why I originally asked - if there was any additional functionality included for setting up templates and fields beyond the default APIs capabilities.

The migrations module install idea is genius though.

Thanks.

  • Like 1

Share this post


Link to post
Share on other sites
  'recipes' => [
    // sample callback as recipe
    function() {
      $this->msg('Installing AOS...');
      $aos = $this->installModule('AdminOnSteroids', 'https://github.com/rolandtoth/AdminOnSteroids/archive/master.zip');
      $this->wire->modules->saveConfig($aos, [
        'enabled' => 1,
        'enabledSubmodules' => ['FieldAndTemplateEditLinks'],
      ]);
      
      $tracy = $this->installModule('TracyDebugger', 'https://github.com/adrianbj/TracyDebugger/archive/master.zip');
      $this->wire->modules->saveConfig($tracy, [
        'superuserForceDevelopment' => 1,
        'editor' => 'vscode://file/%file:%line',
      ]);
    },
  ],

Current version of the kickstartfile: Installs AOS, enables it, enables editlinks. Installs TracyDebugger and sets editor protocoll handler for vscode.

1-click installation of ProcessWire with custom module setup and (in contrary to using site profiles) UP-TO-DATE modules and pw-version!

Since january I have not run the default pw installer once...

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.