S2S-Robert
Verified User
Well you've seen my bug, I can give you the cPanel backups if you like?
source1. Login to old server as root
2. cd /var/named
3. perl -pi.bak -e "s/14400/900/g" *.db
4. /etc/rc.d/init.d/named restart
user1 user2 user3 user4
cat > backup.transfer.|PACKAGENAME|
for user in user1 user2 user3 user4
do
/scripts/./pkgacct $user
done
for user in user1 user2 user3 user4
do
ftp -u [url]ftp://admin:admin_pass@new_server:21/user_backups/[/url]|PACKAGENAME|/cpmove-$user.tar.gz /home/cpmove-$user.tar.gz
done
chmod 755 backup.transfer|PACKAGENAME|
57 23 19 2 * /home/cpanel/./backup.transfer.Large >> output.txt
username|[email protected]|domain.ext|package|password
<?php
$file = "userlist.txt"; // the file with the users formated like above
$new_file = "new_userlist.txt"; // create the file in samedir as userlist.txt, and chmod it 666
$users = file($file); // grab each user-line in een array
foreach($users as $user) { // loop trough all the users
$user = explode("|",$user);
// Generate password
$totalChar = 8; // number of chars in the password
$salt = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789"; // salt to select chars from
srand((double)microtime()*1000000); // start the random generator
$password=""; // set the inital variable
for ($i=0;$i<$totalChar;$i++) { // loop and create password
$password = $password . substr ($salt, rand() % strlen($salt), 1);
}
// make the new user_list
$new_user = $user['0']."|".$user['1']."|".$user['2']."|".$user['3']".$password."\n";
$handle = fopen($new_file, "a");
fwrite($handle, $new_user);
fclose($handle);
}
?>
<?php
// some vars:
$file = "userlist.txt"; // the file with the users formated like above
// Get userinfo:
$users = file($file);
// Let's connect to DirectAdmin
include 'config/config.php';
include 'protocol/httpsocket.php';
$Socket = new HTTPSocket;
$Socket->connect($siteurl,$siteport);
$Socket->set_login($adminusername,$adminpassword);
// {admin_username} and {admin_password} are not specifically your administrative DA user,
// but rather the user that you want to own this new user.
foreach($users as $user){
// Order userinfo
$userinfo = explode("|",$user);
$username = $userinfo['0'];
$email = $userinfo['1'];
$passwd = $userinfo['4'];
$domain = $userinfo['2'];
$package = $userinfo['3'];
$notify = $no;
// Create the account
$Socket->query('/CMD_API_ACCOUNT_USER',
array(
'username' => $username, // The User's username. 4-8 characters, alphanumeric
'email' => $email, // A valid email address
'passwd' => $passwd, // The User's password. 5+ characters, ascii
'passwd2' => $passwd, // Password double check. 5+ characters, ascii
'domain' => $domain, // A valid domain name in the form: domain.com
'package' => $package, // One of the User packages created by the Reseller
'ip' => $ipaddress, // One of the ips which is available for user creation. Only free or shared ips are allowed.
'notify' => $notify, // yes or no. If yes, an email will be sent to email
'action' => 'create',
'add' => 'Submit'
));
$result = $Socket->fetch_parsed_body();
if ( $Socket->get_status_code() != 200 || !empty($result['error']) ) {
// Failure
$handle = fopen("failure.txt", "a");
fwrite($handle, $username."|".$email."|".$domain."|".$package."|".$passwd."|".$result['text']."|".$result['details']."\n");
fclose($handle);
echo $handle, $username."|".$email."|".$domain."|".$package."|".$passwd."|".$result['text']."|".$result['details']." FAILED <br />";
} else {
echo $handle, $username."|".$email."|".$domain."|".$package."|".$passwd."|".$result['text']."|".$result['details']." SUCCESS <br />";
// Message to e-mail on success: should contain at least the new password: $passwd, please escape double quotes like this: \"
$subject = "Your account is moved";
$message = "Dear Customer,
We succesfully moved you to the new server, your account settings will be restored within a few minutes.
Your account information:
DirectAdmin URL: [url]http://[/url]".$domain."/config.
DirectAdmin Password: ".$passwd.".
DirectAdmin username: ".$username."
With best regards,
Some hosting-company ([url]www.somecompany.com[/url])";
// Success
$handle = fopen("success.txt", "a");
fwrite($handle, $username."|".$email."|".$domain."|".$package."|".$passwd."|".$result['text']."|".$result['details']."\n");
fclose($handle);
mail($email, $subject, $message,
"From: [email][email protected][/email]\r\n" .
"Reply-To: [email][email protected][/email]\r\n" .
"X-Mailer: PHP/".phpversion());
}
}
?>
source1. Login to old server as root
2. cd /var/named
3. perl -pi.bak -e "s/[oldip]/[newip]/g" *.db
4. /etc/rc.d/init.d/named restart
dxoxb said:I am a reseller of another hosting company and I don't want to be responsible crashing their server[/B]
Since you're reseller, you don't have root permissions and that way, you aren't able to edit the zones. You need to edit the zones by hand, replacing the old IP with the new one... we've done this on another server, 6 months ago or something. Yes, it sucks.Login to old server as root
dxoxb said:I've root access with SCP to a existing Cpanel server. Any chance that I can migrate some user account over? if yes where can I look out for them?