running task.queue as admin

BrianUK

Verified User
Joined
Feb 4, 2006
Messages
89
I want to do a command line backup ie http://help.directadmin.com/item.php?id=198 via a bash script that logs into my da server does a backup then transfers the file to another server. The script will login to the da server as user admin however I see this user can't execute task.queue.

I tried adding

Code:
admin host = (root) NOPASSWD: /usr/local/directadmin/data/task.queue

to the /etc/sudoers file but still get the same 'permission denied' message.
 
because when I do

Code:
echo "action=backup&local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackups&owner=admin&select%30=testuser&type=admin&value=multiple&when=now&where=local" >> /usr/local/directadmin/data/task.queue

as admin, I get

Code:
bash: /usr/local/directadmin/data/task.queue: Permission denied
 
As per my op "The script will login to the da server as user admin however I see this user can't execute task.queue.

And second post "because when I do 'run task.queue' as admin, I get 'permission denied'"

I can run

Code:
echo "action=backup&local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackups&owner=admin&select%30=testuser&type=admin&value=multiple&when=now&where=local" >> /usr/local/directadmin/data/task.queue

fine as root but I want to be able to do it as the user admin.
 
thank you i'm a little stuck so wondered if you could help, I started da in debug mode and ran a backup on a user, output was (ip ommited)

8: Referer: http://0.0.0.0:2222/CMD_USER_BACKUP
9: User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:25.0) Gecko/20100101 Firefox/25.0
Post string: action=create&who=selected&select16=user&when=now&minute=0&hour=5&dayofmonth=*&month=*&dayofweek=*&where=local&ftp_ip=&ftp_username=&ftp_password=&ftp_path=%2F&ftp_port=21
Checking referer http://0.0.0.0:2222/CMD_USER_BACKUP to 95.154.244.127:2222
Referer check passed: 0.0.0.0=0.0.0.0 2222=2222
Command::doCommand(/CMD_USER_BACKUP)
Command::doCommand(/CMD_USER_BACKUP) : finished
Command::run: finished /CMD_USER_BACKUP

How do I turn this into a single line api call?
 
Those are the information you need: Post string: action=create&who=selected&select16=user&when=now&minute=0&hour=5&dayofmonth=*&month=*&dayofweek=*&where=local&ftp_ip=&ftp_username=&ftp_password=&ftp_path=%2F&ftp_port=21

for every variable you need to create the variable in the api,

This is the command: CMD_USER_BACKUP or CMD_API_USER_BACKUP

This is a basic php script i usually use with API

Code:
<?php

include 'httpsocket.php';

$sock = new HTTPSocket;
$sock->connect('localhost',2222);

$sock->set_login("admin","password");

$sock->set_method('POST');

$sock->query('/CMD_DOMAIN',
        array(
                'action' => 'create',
                'domain' => 'base.crazynetwork.it',
                'ubandwidth' => 'unlimited',
                'uquota' => 'unlimited',
                'ssl' => 'ON',
                'cgi' => 'ON',
                'php' => 'ON',
                'create' => 'Create'
    ));

$result = $sock->fetch_body();

?>

Edit with correct data and variables using the httpsocket: http://forum.directadmin.com/showthread.php?t=258&highlight=httpsocket

Once you did end with this, let me know if it work correctly, and, i would appreciate also if you share it via email with me or here on the forum for community use.

Regards
 
am I completely on the wrong track?

Code:
<?php

include '../httpsocket.php';

$sock = new HTTPSocket;

$sock->connect('0.0.0.0',2222);
$sock->set_login('admin','password');
$sock->set_method('POST');
$sock->query('/CMD_USER_BACKUP, array( 'action' => 'create', 'who' => 'selected', 'select' => '16', 'user1' => 'when' => 'now', 'where' => 'local' ));

?>

PHP Parse error: syntax error, unexpected T_STRING
 
Back
Top