user_create_post + cmd_api_pop = "Unable to determine Usertype"

Aspegic

Verified User
Joined
Aug 4, 2005
Messages
283

user_create_post.sh
:
Code:
#!/bin/sh

# Some debugging code to check the contents of user.conf:
echo -e "---------------------------------------------\n" > /usr/local/directadmin/scripts/custom/cmd_api_pop.create.log
cat /usr/local/directadmin/data/users/$username/user.conf >> /usr/local/directadmin/scripts/custom/cmd_api_pop.create.log
echo -e "---------------------------------------------\n" >> /usr/local/directadmin/scripts/custom/cmd_api_pop.create.log

# Create a new 'root'-mailbox for $domain with the same password as the default mail account:
php -f /usr/local/directadmin/scripts/custom/cmd_api_pop.create.php $domain $username $passwd $user root $passwd 10

exit 0;
cmd_api_pop.create.php:
Code:
<?php include '/usr/local/directadmin/scripts/custom/httpsocket.php';
if ( $argc < 7 ) { 
 echo "\n Usage: php -f cmd_api_pop.create.php <domain> <loginname> <loginpass> <user> <passwd> <quota> \n"
     ."\n Where: \n"
     ."   domain    = the name of the domain for which the new mail account will be created \n"
     ."   loginname = the loginname of a user who is allowed to create mail accounts for domain \n"
     ."   loginpass = the password of loginname \n"
     ."   user      = the name of the new mailbox \n"
     ."   passwd    = the password for the new mailbox \n"
     ."   quota     = the quota for the new mailbox \n";
 die("\n");
}
list($script, $domain, $loginname, $loginpass, $user, $passwd, $quota) = $argv;
$da = new HTTPSocket;
$da->connect('127.0.0.1', 2222);
$da->set_login($loginname, $loginpass);
$da->query('/CMD_API_POP', array('action'=>'create', 'domain'=>$domain, 'user'=>$user, 'passwd'=>$passwd, 'quota'=>$quota));
$result = $da->fetch_parsed_body();
print_r($result);
?>

This code works fine if executed manually from the command-line. But if executed automatically from user_create_post.sh it will result in the following error: Unable to determine Usertype

The problem seems to be caused by the fact that user.conf hasn't been created yet when user_create_post.sh is called.

Can someone confirm that user_create_post.sh is called before user.conf is created ?
 
Last edited:
Back
Top