Command line upgrade C5
Permalink
Whats the best way to upgrade C5 5.7 through the linux shell? I'd like to run the upgrade script through the command line and not have to login and load the UI and click upgrade. Similarly is there a way to trigger package or block updates through the command line?
Thanks, curious by what you mean new console features? Can you elaborate on that further? I'll be digging into this soon so if anybody has any feedback that would be great. I noticed that the plesk and cpanel installers do auto updates so they must be hooking in somehow. Anybody know where the source of those installers live?
I do not know how to use any of the new command line/console features. I am aware of them because I try and look at all the pull requests.
From the 5.7.5 Release Notes:
You can now run concrete5 jobs from the command line using concrete/bin/concrete5 c5:job (thanks ChrisHougard!)
Completely new approach to command line utilities built off of the Symfony command line class; existing utilities ported (thanks mlocati!)
Packages can also add command line utilities through their on_start() method (thanks hissy)
From GitHub:
Console command for running jobs #2619
https://github.com/concrete5/concrete5/pull/2619...
Re: Make console command extendable from packages #2720
https://github.com/concrete5/concrete5/pull/2720...
Integrate CLI commands #2387
https://github.com/concrete5/concrete5/pull/2387...
From the 5.7.5 Release Notes:
You can now run concrete5 jobs from the command line using concrete/bin/concrete5 c5:job (thanks ChrisHougard!)
Completely new approach to command line utilities built off of the Symfony command line class; existing utilities ported (thanks mlocati!)
Packages can also add command line utilities through their on_start() method (thanks hissy)
From GitHub:
Console command for running jobs #2619
https://github.com/concrete5/concrete5/pull/2619...
Re: Make console command extendable from packages #2720
https://github.com/concrete5/concrete5/pull/2720...
Integrate CLI commands #2387
https://github.com/concrete5/concrete5/pull/2387...
I'd be interested in this as well.
See attached, I found this script in one of my clients that uses the plesk auto installer for C5. Looks to be the script it was using to handle the upgrades. See attached and if it's any help. Also it would be nice to get access to the code for the various control panels installers. Anybody know where these are stored? Most likely someone from C5 wrote the control panel integrations?
There is also an installer in Softaculous AMPPS that installs C5 in one shot, (without user interaction on C5 itself), not the latest version though. They have some scripts, but they are all obfuscated. Softaculous has a way of triggering it's install via the command line, but that involves having their software installed. +1 for me on getting more info on the CLI for C5.
I found an install script in 5.7.5 at /concrete/src/Console/Command/InstallCommand.php. It has the name c5:install. So based on the github links above I am guessing you would call it like this ?
php index.php/web/cli c5:install <param1> <paramn>
There are also some other commands there including a job ID command where I am guessing you could run your upgrade job from.
php index.php/web/cli c5:install <param1> <paramn>
There are also some other commands there including a job ID command where I am guessing you could run your upgrade job from.
After digging a while I got a response from @mkly and @KorvinSzanto over on Github on how to use the cli. First to get help on a command do this at the command prompt:
>php -f concrete/bin/concrete5.php help c5:install
To run this command just leave out the help and include any arguments at the end:
>php -f concrete/bin/concrete5.php c5:install arg1="whatever1" arg2="whatever2"
There looks to be 5 commands:
c5:config
c5:ide-symbols
c5:install
c5:job
c5:reset
I think in your case c5:job might work with some sort of upgrade job. I have already included c5:install in a script and it works like a charm.
>php -f concrete/bin/concrete5.php help c5:install
To run this command just leave out the help and include any arguments at the end:
>php -f concrete/bin/concrete5.php c5:install arg1="whatever1" arg2="whatever2"
There looks to be 5 commands:
c5:config
c5:ide-symbols
c5:install
c5:job
c5:reset
I think in your case c5:job might work with some sort of upgrade job. I have already included c5:install in a script and it works like a charm.
On unix based operating systems you can just do
/path/to/<root>/concrete/bin/concrete5 help
and it does the same thing :)
/path/to/<root>/concrete/bin/concrete5 help
and it does the same thing :)
Anybody know how to set the database configuration with the console command? I'm trying
and even though the site it lives in has the proper db config it gives me:
and if I add it to the core config/database.php as a test I get:
./concrete5 c5:job --list
and even though the site it lives in has the proper db config it gives me:
[InvalidArgumentException] Database [] not configured.
and if I add it to the core config/database.php as a test I get:
[Doctrine\DBAL\Driver\PDOException] SQLSTATE[HY000] [2002] No such file or directory
There is no way to set database with c5:job command...
I've tried this command with latest c5 version, but it works correctly.
I've tried this command with latest c5 version, but it works correctly.
$ ./concrete5 c5:job --list Available Jobs +--------------------------+-------------------------------+ | Job Handle | Job Name | +--------------------------+-------------------------------+ | index_search | Index Search Engine - Updates | | index_search_all | Index Search Engine - All | | check_automated_groups | Check Automated Groups | | generate_sitemap | Generate the sitemap.xml file | | process_email | Process Email Posts | | remove_old_page_versions | Remove Old Page Versions | | update_gatherings | Update Gatherings | +--------------------------+-------------------------------+ Available Job Sets +----------+--------------------------------------------------------------------------------------------------------------------------------+
Viewing 15 lines of 19 lines. View entire code block.
Thanks for confirming it works fine for you Hissy, I figured out that the reason it can't get the db connection is I am symlinking to a shared concrete folder to make upgrades easier and the php command line script is not able to figure out what project the concrete folder lives in because it's using absolute paths on the filesystem to figure it out.
So basically as coded none of these console scripts are going to work in a symlinked environment. Changing the concrete5 script to allow passing in the $DIR_BASE_CORE as a param fixed it for me. I'll submit a patch on github and see how it goes.
So basically as coded none of these console scripts are going to work in a symlinked environment. Changing the concrete5 script to allow passing in the $DIR_BASE_CORE as a param fixed it for me. I'll submit a patch on github and see how it goes.
Copying the bin folder to my application folder and changing this line fixed it for me so it works with symlinks:
$DIR_BASE_CORE = dirname(__DIR__)."/../concrete";
Thanks for the direction! Not seeing an upgrade option built in however. Anybody tried automated upgrades yet?
Okay I finally had a chance to dig around and I discovered there is a way to enable automatic upgrades for c5 and it does appear to work. It does not download the latest version's files however so you have to do that yourself. It simply installs the version in the concrete directory if it is greater than the currently installed c5 version.
To get this to work replace the /concrete directory with the newest like in a manual upgrade steps then set the config variable: concrete.updates.enable_auto_update_core to true in your config/concrete.php file like so then refresh the page while logged in as admin and it will do the installation silently in the background. You can check that it worked by going to your dashboard environment info page and see the installed version was indeed upgraded.
There is also an 'enable_auto_update_packages' => true config value which appears to be what I am looking for to do similar auto upgrading of packages but unfortunately it does not work and has a bug in the setupPackages function of Concrete\Core\Application on line 256 where the variable $p is not initialized properly. I'll file a bug on github and work on my own patch in the meantime.
To get this to work replace the /concrete directory with the newest like in a manual upgrade steps then set the config variable: concrete.updates.enable_auto_update_core to true in your config/concrete.php file like so then refresh the page while logged in as admin and it will do the installation silently in the background. You can check that it worked by going to your dashboard environment info page and see the installed version was indeed upgraded.
There is also an 'enable_auto_update_packages' => true config value which appears to be what I am looking for to do similar auto upgrading of packages but unfortunately it does not work and has a bug in the setupPackages function of Concrete\Core\Application on line 256 where the variable $p is not initialized properly. I'll file a bug on github and work on my own patch in the meantime.
Here is the patch for automated package upgrades btw not clean at all but works for now until a real fix comes out:
https://github.com/concrete5/concrete5/issues/2993#issuecomment-1424...
https://github.com/concrete5/concrete5/issues/2993#issuecomment-1424...
This is an interesting question. Hopefully some of the authors of the new console features will weigh in with their input.