Support

Admin Tools

#32632 actions with CLI commands

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by toonetcreation on Thursday, 12 March 2020 08:55 CDT

toonetcreation
Hi,

I would like to know if I can launche the following tools throught CLI/script command?
See attached file.

thanks
L.

toonetcreation
I have seen that database optimise is available in CLI folder.
but for other features?

tampe125
Akeeba Staff
Hello,

some of them are available as CLI scripts, others as features of the System plugin

Others are not possible at all using the CLI (the ones you numbered 1,2,3). Could you please explain your use case? Why you feel the need for that?

Davide Tampellini

Developer and Support Staff

🇮🇹Italian: native 🇬🇧English: good • 🕐 My time zone is Europe / Rome (UTC +1)
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

toonetcreation
this is to make some automation process when a website is migrated from stagged to production.
I don't want to waste my time clicking on X buttons, I have made some scripts to make an automatic build of my deployments and works fine.
the goal is to automate all the clicking tasks.
and the problem with HTACCESS generation, files permissions etc...I have to click manually on admin tools web interface to generate them....would be very helpful if we could do it automatically.

nicholas
Akeeba Staff
Manager
The short answer: no, you do not need a CLI script for reconfiguring a transferred site and one will not be provided.

Here's the much longer answer.

While I understand the use case I am not convinced that having a CLI script would be practical for you to use or for us to document and support.

It is technically feasible to create a CLI script which would allow you to set parameters like:
php imaginary-script.php wafopt set nofesalogin 1

or something like
php imaginary-script.php htmaker add fepexdirs subfolder


What I typed above is not deliberately obfuscated. It's what you would be actually getting with a script like you asked. These are the internal parameter names of the "Forbid frontend Super Administrator login" and "Frontend directories where file type exceptions are allowed" options in WAF and .htaccess Maker respectively. They are indecipherable to you and extremely complicated for us to document. More so when we have options which internally are represented as arrays, strings, integers (with certain limits) or booleans. Even worse when you realize there are interconnected parameters. The potential for breaking your site with a script like that is more than real, it's a near certainty.

Now let me explain why you don't need a CLI script.

If you are making changes to the WAF configuration on your dev site they are transferred and applied to the live site by restoring the #__admintools_storage table. If, quite to the contrary, you DO NOT want any changes you made to the WAF configuration to survive the site transfer then quite simply don't include the #__admintools_strage table when transferring the site.

Regarding the .htaccess, you could have the configuration ready when transferring the site and just click on the Save and Create .htaccess button. That's something that can be automated with Selenium or a similar tool.

But that's complicated. A simpler thing to do is set up the .htaccess Maker before the site transfer and generate the .htaccess. Your dev site will break BUT you have the .htaccess that you need on the live site. This can be transferred with the site itself or, if you are using Akeeba Backup, rename it to htaccess.bak, do not include a .htaccess in the backup archive and you can rest assured that this file will be renamed to .htaccess at the end of the (manual or automatic) restoration.

File permissions: you SHOULD NOT use Admin Tools after the site transfer to enforce permissions! By definition, your site transfer process transfers files. This is where the correct ownership and permissions need to be applied. If you are getting the wrong permissions to begin with you are doing the site transfer wrong or, at least, in a very suboptimal manner.

Same with the temporary directory and logs directory. If you expect to use Admin Tools after the transfer to fix glaring configuration.php issues you are doing the site transfer wrong. FWIW Akeeba Backup handles that automatically and it can be automated in the Pro version using Akeeba UNiTE.

As you understand, there really is no need for a CLI control script just for transferring sites. Admin Tools and Akeeba Backup are designed to work together. With a minimum of planning you can transfer your sites automatically without having to click anything. Take that from the guy who is restoring a backup of the akeebabackup.com live site on a dev server every day, unattended, without either the live or dev site requiring manual reconfiguration :)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

toonetcreation
Hi Nicholas,

Thank you, four you long answer, very helpful :-)
Just few remarks to be sure, because what you said is very interested and make sense I understand.

While I understand the use case I am not convinced that having a CLI script would be practical for you to use or for us to document and support.

What I typed above is not deliberately obfuscated. It's what you would be actually getting with a script like you asked. These are the internal parameter names of the "Forbid frontend Super Administrator login" and "Frontend directories where file type exceptions are allowed" options in WAF and .htaccess Maker respectively. They are indecipherable to you and extremely complicated for us to document. More so when we have options which internally are represented as arrays, strings, integers (with certain limits) or booleans. Even worse when you realize there are interconnected parameters. The potential for breaking your site with a script like that is more than real, it's a near certainty.



yes of course I understand, that's why I asked, but I was pretty sure of the answer



If you are making changes to the WAF configuration on your dev site they are transferred and applied to the live site by restoring the #__admintools_storage table. If, quite to the contrary, you DO NOT want any changes you made to the WAF configuration to survive the site transfer then quite simply don't include the #__admintools_strage table when transferring the site.



About WAF, yes this is what I am doing since several years.



Regarding the .htaccess, you could have the configuration ready when transferring the site and just click on the Save and Create .htaccess button. That's something that can be automated with Selenium or a similar tool.



But that's complicated. A simpler thing to do is set up the .htaccess Maker before the site transfer and generate the .htaccess. Your dev site will break BUT you have the .htaccess that you need on the live site. This can be transferred with the site itself



Yes this is true and simple....even if I generate htaccess , of course DEV site will be broken, but when entire site will be migrated to PROD environment, of course will work.I did not think about it ;-)



if you are using Akeeba Backup, rename it to htaccess.bak, do not include a .htaccess in the backup archive and you can rest assured that this file will be renamed to .htaccess at the end of the (manual or automatic) restoration.



I'm using my own backup scripts.
But this means thanks to Akeeba Backup, I will be able to schedule an automatic rename of .htaccess.bak file from DEV website to .htaccess file on PROD website?



Regarding the .htaccess, you could have the configuration ready when transferring the site and just click on the Save and Create .htaccess button. That's something that can be automated with Selenium or a similar tool.



yes good idea also...but complicate just for 1 file :-/



File permissions: you SHOULD NOT use Admin Tools after the site transfer to enforce permissions! By definition, your site transfer process transfers files. This is where the correct ownership and permissions need to be applied. If you are getting the wrong permissions to begin with you are doing the site transfer wrong or, at least, in a very suboptimal manner.



Of so what is the goal of admin tools permission tool?



Same with the temporary directory and logs directory. If you expect to use Admin Tools after the transfer to fix glaring configuration.php issues you are doing the site transfer wrong.



No I'm not doing it at this time, because when I migrate my website from DEV to PROD, my current script handle configuration.php file update, so everything is fine for this file.



FWIW Akeeba Backup handles that automatically and it can be automated in the Pro version using Akeeba UNiTE.



What can do Akeeba UNiTE exactly?
When you say : it can be automated ?



With a minimum of planning you can transfer your sites automatically without having to click anything. Take that from the guy who is restoring a backup of the akeebabackup.com live site on a dev server every day, unattended, without either the live or dev site requiring manual reconfiguration :)



yes I hope for this guy :-)

nicholas
Akeeba Staff
Manager
But this means thanks to Akeeba Backup, I will be able to schedule an automatic rename of .htaccess.bak file from DEV website to .htaccess file on PROD website?


It does that automatically, no configuration necessary. However, the file name is htaccess.bak (without a dot in front).

You must also NOT include the .htaccess file in the backup.

Here's how it works. During archive extraction, Kickstart will extract .htaccess (if it exists) renamed to htaccess.bak. At the end of the restoration if a htaccess.bak exists it will be renamed back to .htaccess to "undo" this change. These two events are independent. Therefore if there is no .htaccess file in the backup archive BUT there is a htaccess.bak then we know for sure that htaccess.bak will be renamed to .htaccess at the end of the restoration. Ta-da! What we wanted :)

Of so what is the goal of admin tools permission tool?


Some FTP servers have a default umask (permissions mask) for uploaded files which causes the files to be uploaded to have the wrong permissions, either too wide (e.g. 0755) or too narrow (e.g. 0600 -- that's the most typical case). This can either be a security issue or simply not allow you to access these files over the web e.g. making images impossible to display. Normally you'd have to trawl your site to find which files have screwed up permissions and fix them manually. Admin Tools does that for you.

Furthermore, some configuration files need not have any permissions but read access for their owner (0400). However, every time you modify them (manually or through a web interface) you may get the wrong permissions, e.g. 0644. You can configure these permissions per file or folder in Admin Tools and apply them en masse, without thinking about it.

What can do Akeeba UNiTE exactly?

When you say : it can be automated ?


Akeeba UNiTE is an unattended site restoration script. You give it a configuration file and a backup archive and it performs the entire restoration without human interaction. At the end of the process you can also have it extract additional ZIP file(s) and / or restore additional SQL file(s). ZIP files can be used to deploy files which are not in the backup archive. SQL files can be used to apply database changes which are not in the backup. In your use case you could use a ZIP file to deploy the customized .htaccess and the SQL files to deploy customized Admin Tools configuration settings.

If you want, you can give it only a configuration file with information to take a backup of a site remotely (using the Akeeba Backup JSON API), download the backup archive from the remote server and restore it on the target server — WITHOUT any human interaction whatsoever.

Combining all these features you can end up with a solution that has unite.phar (the executable file of Akeeba UNiTE), a unite XML configuration file, a ZIP file with the custom .htaccess and a SQL file with the custom Admin Tools settings. Put all of that in an off-side directory of the target site and launch UNiTE with a CRON job. Sit back while your site is being automatically transferred from your (accessible over the Internet) dev server to your live server. The same can be done of course to clone your live site to a dev server when you want to start working on it again.

FYI I am using UNiTE to restore a backup of our live site to my dev server. Using the features I pointed out I can automatically wipe it clean of personally identifiable information (so my local copy is GDPR compliant), create a custom .htaccess (there are things in our live site's .htaccess which wouldn't work on my dev server) and even deploy a customized configuration.php file which redirects all mail to a Docker image that runs a development catch-all mail server so that the dev site's email doesn't get sent over the Internet and I can review what was sent.

As I've been saying for the last 14 years, Akeeba Backup doesn't make site backup and site transfers possible, it makes it easier as a whole and particularly easier to automate. That's why I started writing its predecessor, JoomlaPack, all those years ago. I was building sites and I was fed up with the manual site transfer method. I wanted to automate things. That's why I got into computers at the age of 11. I wanted to have a machine do things for me instead of the other way around ;)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

toonetcreation
Ok I undsertand now, thanks again for all these infos :)

About UNiTE, is it possible to use it with my own backup file?
or is it mandatory to use it with Akeeba Backup?

because I have currently a lot of backup like this :

- web files : files-backup.tar.bz2 : this archive contains all website files
- database : db-backup.sql.bz2 : this archive contains a .sql file, which a mysql dump

nicholas
Akeeba Staff
Manager
UNiTE can only be used with backup archives created with Akeeba Backup. It actually uses the backup restoration script included in the archive to restore your site. Flat backups like yours lack not only the code for restoration but also the necessary information and structure to restore them reliably on any server.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

toonetcreation
Ok I see, thank you again for your time/help :)

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!