Execute Recipe

Use Execute Recipe API to execute recipes on your server.

HTTP Request

https://hostname:4083/index.php?act=listrecipes&svs=vpsid&rid=rid

Parameters

NameTypeValueDescriptionRequired
actGETlistrecipesThe action specified is used to retrieve dataYes
vidPOSTIntThe vpsid whose recipe needs to be executed. This will be passed as a POST parameterYes
svsPOSTIntThe vps whose recipes needs to be listed. This is passed to the URLYes
exec_recipePOST1If set, then the specified recipe will be executedYes
ridPOSTridAn array of ids if you want to execute multiple recipes or send single id that needs to be executedYes

Sample Code

PHP

<?php
    require_once('/usr/local/virtualizor/sdk/enduser.php');

    $key =  '';
    $pass = '';
    $ip = '';
    $admin = new Virtualizor_Enduser_API($ip, $key, $pass);

    $vid = 3609;
    $rid = 9;

    $rid = array(9,10,3); //for multiple recipes



    $output = $admin->execrecipe($vid,$rid);

    print_r(json_encode($output));
?>

Curl

curl -k -X POST -d "exec_rid=9&exec_recipe=1" -L "
https://hostname:4083/index.php?act=listrecipes& 
svs=3609&rid=9&api=json&apikey=you-api_key& 
apipass=your_api_key"

Output

{
    "uid": "321",
    "act": "listrecipes",
    "timezone": 1,
    "timenow": "September 23, 2016, 7:20 am",
    "vpsid": "3008",
    "username": "test@test.com",
    "user_type": "2",
    "preferences": {
        "fname": "test",
        "lname": "test",
        "language": "english",
        "theme": "default",
        "timezone": 1,
        "logo": ""
    },
    "url": "index.php?",
    "rdns": {
        "pdnsid": null
    },
    "support_link": "http://softaculous.com",
    "disable_login_logo": 1,
    "title": "Virtualizor",
    "done": {
        "msg": "Recipe will be cooked when you reboot the VPS"
    },
    "onboot": "Recipe will be cooked when you reboot the VPS",
    "recipes": {
        "9": {
            "rid": "9",
            "name": "test287",
            "code": "#!/bin/shnntouch /newtest",
            "desc": "Just testing yar",
            "logo": "",
            "status": "1"
        },
        "13": {
            "rid": "13",
            "name": "test",
            "code": "#!/bin/shnecho "Europe/Budapest" > /etc/localtime",
            "desc": "",
            "logo": "",
            "status": "1"
        },
        "16": {
            "rid": "16",
            "name": "test279",
            "code": "#!/bin/shnecho "recepi" > /test.txt",
            "desc": "Just testing yarrn<a>softaculous.com</a>",
            "logo": "https://hostname:4083/sessbpxbng7dzqjuykqr/themes/default/images/loginlogo.gif",
            "status": "1"
        },
        "17": {
            "rid": "17",
            "name": "Recipe01",
            "code": "#!/bin/shnecho `date` >> /root/test1.txtn",
            "desc": "",
            "logo": "",
            "status": "1"
        },
        "18": {
            "rid": "18",
            "name": "WinRecipe1",
            "code": "#!/bin/shnecho date c:test1.txt",
            "desc": "",
            "logo": "",
            "status": "1"
        },
        "19": {
            "rid": "19",
            "name": "test recipe",
            "code": "#!/bin/shnThis is your test recipe",
            "desc": "This is the description for test recipe",
            "logo": "",
            "status": "1"
        }
    },
    "page": {
        "start": 0,
        "len": 50,
        "maxNum": "6"
    },
    "time_taken": "0.551"
}
Was this helpful to you?