How do I enable delivery server with command line php call

inaspin

New Member
Hi,

I am trying to enable delivery servers via a ssh command line. I can see that the enable icon on the delivery servers page points to

http://mydomain.co.uk/backend/index.php/delivery-servers/enable/id/222

and I want to run a script via the command line that does the same thing. I am thinking it will be something like

/usr/bin/php /var/www/html/backend/index.php delivery-servers --enable --id 222

but obviously this does not work!!:-)

Could someone help?

Many thanks
 
@inaspin - unfortunately things don't really work like so. If you want to enable the delivery servers via command line you would have to write the command line code yourself since as it stays, we don't have such option.
I am wondering, why do you need to do this ?
 
Thanks a lot for the reply.

The reason behind it is so I can automatically enable/disable servers if their senderscore is under a certain value. I am simple trying to automate the stuff that currently needs to be done by hand.

I am not confident enough in php to track how this command is actually executed over http and I don't want to manually alter (flipping the status field in the delivery servers table) the mysql database in case this causes unintended behavior/corruption.
 
@inaspin - create this file: /apps/console/commands/MyDeliveryServersCommand.php with this content:
PHP:
<?php defined('MW_PATH') || exit('No direct script access allowed');

class MyDeliveryServersCommand extends ConsoleCommand
{
    /**
     * @return int
     */
    public function actionEnable($id)
    {
        $server = DeliveryServer::model()->findByPk((int)$id);
        if (empty($server)) {
            return 1;
        }
        $server->saveStatus(DeliveryServer::STATUS_ACTIVE);
        return 0;
    }

    /**
     * @return int
     */
    public function actionDisable($id)
    {
        $server = DeliveryServer::model()->findByPk((int)$id);
        if (empty($server)) {
            return 1;
        }
        $server->saveStatus(DeliveryServer::STATUS_DISABLED);
        return 0;
    }
}

Then from command line you will be able to do:
Code:
/usr/bin/php /var/www/html/apps/console/console.php mydeliveryservers enable --id=222

Code:
/usr/bin/php /var/www/html/apps/console/console.php mydeliveryservers disable --id=222
 
Back
Top