PDA

View Full Version : Move User Between Resellers



Mindlash
10-15-2003, 05:33 PM
I saw a previous post by Two-A-T (hi c-man) about manually editing files move users... though I have a feeling it may be a bit incomplete?

Have there been any updates since then that would need attention.

I currently need to move 5 users from one reseller to another reseller account.

Any suggestions?

The file user.conf once edited didn't seem to make any differences once the 'new' reseller logged in and checked their users.

... Thanks.

l0rdphi1
10-15-2003, 06:11 PM
I think you have to edit the reseller's user list in addition to each users' user.conf file.

One thing on the top of my list right now is the option to convert a user to a reseller and vicaversa. It's a pain in the arse right now.

Mindlash
10-15-2003, 06:22 PM
Awsome... that worked:

Files Edited
[user file]
/usr/local/directadmin/data/users/[username]/user.conf
-- change line:
creator=older_resller_name
to
creator=new_resller_name

[reseller list]
usr/local/directadmin/data/users/[reseller_username]/users.list
-- copy all files from
usr/local/directadmin/data/users/[old_reseller_username]/users.list
to
usr/local/directadmin/data/users/[reseller_username]/users.list

Log into DA as the new reseller and boom... all there.

NOW, question is.... How simple is it to not only move a current reseller to a normal user account under a reseller... but also to rename that account

Example Current Tree:
-+Reseller_A
--user1
--user2
-Reseller_B

Needs to be
-+Reseller_B
--user1
--user2
--user3 (old Reseller_A)

I've already gotten the old users moved over to the new reseller... just got to move the old reseller (A) to under the new reseller (B) and rename the old reseller :-)

Thanks again for your quick response and help l0rdphi1

l0rdphi1
10-15-2003, 06:40 PM
It's simply a matter of tinkering with the right files :D

Um..well actually... what I would first do is backup and remove the old resellers DA configuration files. Next I'd copy an existing users' directory overtop the old reseller's directory. Then it is a matter of modifying the user's files you copied to match the old reseller's data which you backed up.

I don't think I made much sense there. Good luck. =|

Mindlash
10-15-2003, 09:22 PM
Tinkering is what I did... I always like posting findings so here's what I did... files I edited... etc in case other have this need.

1) backup these files before doing what I've done, just in case

2) continue... :-)

[Renaming User] (in my case a reseller)
usermod -d /home/newname oldname
#sets new home directory. File affected: /etc/passwd

usermod -g newname oldname
#sets intial group.

groupmod -n newname oldname
#changes the group name. File(s) affected: /etc/group & /etc/gshadow

cat /etc/passwd |grep newname
#this verifies the home directory was set properly (displays)

[Move old home directory to new directory]
mv /home/oldname /home/newname

[Change Apache to point to new home location]
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue

replace /home/oldname/ /home/newname/ -- /etc/httpd/conf/httpd.conf
#This replaces the individual path for Apache to load the new location's individual httpd.conf settings

replace oldname newname -- /etc/httpd/conf/ips.conf
#makes sure to replace the normally 'auto-generated' file here, otherwise apache will give errors

/etc/rc.d/init.d/httpd restart
# restart appache to take affect
# Also note, if you don't use that script, you'll probably get SSLEngine errors when restarting apache.

[Change FTPD info]
replace oldename: newname: -- /etc/proftpd.passwd
#Notice the colon's at the end of the names, keep those but change the names as needed

#NOTE:
#if by chance the UID in /etc/proftpd/passwd is 9999:9999: you will need to put in the original UID, found simply by typing:
#ls -n /home/
#... this should return a number (probably a 500'ish number) replace both sets of 9999 with that number.

service proftpd restart
#restart proftpd

---- someone with a bit more skill than I could easily write a script to take care of all these changes simply prompting the user for two vars.. 1) old name to change, 2) new name to be...

*wink?*


Far as I know these should do the trick. If anyone else can think of any other changes that need to be done, lemmie know. :-)

l0rdphi1
10-16-2003, 08:17 AM
Oh. For some reason I thought you wanted to convert a reseller to a user.

Oh well :)

Mindlash
10-16-2003, 08:20 AM
Yes, I did need that to... which I did but forgot to post. :-/

Just edit the user.conf file and change the type from reseller to user

...

:-) .. the rest are also instructions on how to rename the reseller account if needed.

:-)

l0rdphi1
10-16-2003, 08:28 AM
Yeah, but I remember there being conf files for resellers that aren't needed for normal users. I'm sure they don't hurt though.

Mindlash
10-16-2003, 08:30 AM
You're right.. they don't...

I removed them but forgot to note which ones they were! I just compared to another user account.. hehe woops.

l0rdphi1
10-16-2003, 08:33 AM
Yeah that's what my post was getting at. Anyway nice to see you got it all working :}

Maybe I'll throw a script together tonight. :)

Mindlash
10-16-2003, 08:35 AM
hha... good deal. :-)

Thanks for the help

S2S-Robert
10-17-2003, 07:16 AM
Well I'd like such a feature as well, that you can change the users properties such as:

* ownership of the user (move a user between resellers)
* Level of the user (upgrade / downgrade a user / reseller)
* Name of the user (rename a user / change his primary domain)

So if this can be put on the features wish list that'd be great ;)

l0rdphi1
10-17-2003, 06:00 PM
My list goes

1. IMAP
2. Level of the user (upgrade / downgrade a user / reseller)
3. Server-to-Server user / reseller transfer
4. Ownership of the user (move a user between resellers)
5. Name of the user (rename a user / change his primary domain)

:D

If I could find out what at least the priority of each these things are I'd know which to throw scripts together for and which not to. *cough* ;)

midro
03-18-2007, 03:14 PM
Are there any scripts to change user's ownership directly from DirecAdmin? We often need to move users from one reseller to another, so built-in function in the DirectAdmin admin area would be very usefull.
I saw similar paid script in this forum some time ago but now I did not manage to find it.

smtalk
07-03-2007, 07:03 AM
midro, I think I will create a script for that soon :)

smtalk
07-03-2007, 08:00 AM
The script is done :) Maybe it will be included into the future releases of DirectAdmin. For now just use:


cd /usr/local/directadmin/scripts
wget http://www.servermonkeys.com/projects/els/directadmin/move_user_to_reseller.sh
chmod 700 move_user_to_reseller.sh
chown diradmin:diradmin move_user_to_reseller.sh
Usage:


cd /usr/local/directadmin/scripts
./move_user_to_reseller.sh <user> <oldreseller> <newreseller>
Good luck!

seachen
07-05-2007, 03:00 AM
The script is done :) Maybe it will be included into the future releases of DirectAdmin. For now just use:


cd /usr/local/directadmin/scripts
wget http://www.servermonkeys.com/projects/els/directadmin/move_user.sh
chmod 700 move_user.sh
chown diradmin:diradmin move_user.sh


Usage:


cd /usr/local/directadmin/scripts
./move_user.sh <user> <oldreseller> <newreseller>


Good luck!
may i know how to do this? where to insert the code?

smtalk
07-05-2007, 03:05 AM
Everything is written in "Usage" :) E.g. if you need to transfer user user1 to reseller reseller2 from reseller reseller1. You need to write: ./move_user_to_reseller.sh user1 reseller1 reseller2

Splet
12-04-2007, 02:49 PM
echo "Changing user owner"
for i in `ls /usr/local/directadmin/data/users/$1/domains/*.conf`; do { perl -pi -e "s/creator=$2/creator=$3/g" $i; }; done;

But "creator=" line is user.conf, one dir up from "domains", so it never gets updated to a new creator.

Changing the line to:


for i in `find /usr/local/directadmin/data/users/$1/ -name '*.conf'`; do { perl -pi -e "s/creator=$2/creator=$3/g" $i; }; done;

would search through all conf files in user's dir. If creator is always written only in user.conf file, no searching is even necessary, but not sure about this one.

scoutman57
03-23-2008, 08:47 PM
ok i created several domains under the user tab of the master admin account. now i want to move the domains under the reseller tab of the master admin account so each domain will have its own username and password. This was i can have different people managing different domains. i have checked the move user from reseller to user and vise versa but this does not work. as the domains were not setup as a reseller or a user but more under a user account. Does anyone know how i can move these into thier own accounts?

DirectAdmin Support
03-24-2008, 12:48 PM
Splet:

The code is fine. The script is to move 1 user to a different reseller. If you check the next line of code below it, you'll see the user.conf section. The domains version is to change the "creator" value for each domain.com.conf file.

scoutman57:

Try the move_domain.sh script. It's beta, but is what you'd be looking for.

John

scoutman57
03-24-2008, 12:57 PM
where can I download that script. I do not see it listed anywhere.

DirectAdmin Support
03-24-2008, 01:00 PM
It should be in:
/usr/local/directadmin/scripts/move_domain.sh

Unless I forgot to link it into the update.tar.gz for your OS... which OS version are you running, if you don't see it there? Also make sure you have the latest version of DA.

John

scoutman57
03-24-2008, 01:13 PM
CentOS.4.4 DA Server version 1.31.4 Last updated 3-8-2008.

I see it listed in there, can you advise on how to use the script?

DirectAdmin Support
03-24-2008, 01:15 PM
You can just run it without any options and it will tell you how.

John

scoutman57
03-24-2008, 01:31 PM
John,

Checked out the move_domain.sh script and it shows
<domain> <olduser> <newuser>
Like i said before the domains were build under the user tab of the master admin account and were not built as individual users under the admin reseller tab. I dont have any other users on the system and want to make each domain their own user as if they were created under the reseller tab.

In my case the script would be like this
domain1.com admin <newuser> - not sure what would go in newuser block.

Will this also allow each domain to have individual logins? Be nice if you could assign multipal control panel logins to domains in directadmin.

DirectAdmin Support
03-24-2008, 01:35 PM
Create new Users to put them under first.
Use fake domains when creating the users.
You can delete the fake domains after.

John

scoutman57
03-24-2008, 01:49 PM
Ok John,

I hate to be a pain, but I created a new user under may admin reseller tab.
user1 fakedomain.com
then did
./move_domain.sh domain1.com admin user1
everything went great except for one thing. It did not move the database for that domain to the new user. Is this something I will have to manually do? Looks like mail all went just fine, the accounts were there. Not really seeing anything missing other than the db's for now.

If there is not script to move the db's Can I just log into mysql as root and rename the tables with the user prefix ie: admin_db1 to user1_db1?

Thanks alot for your help be nice for these script to get put in the control panel after they are out of beta. I am use to using webmin and cpanel so I am still learning all the DA tricks.

Thanks a million.

DirectAdmin Support
03-24-2008, 02:07 PM
Databases have no relation to the domains, so either manually or go into phpmyadmin as "da_admin" (/usr/local/directadmin/conf/mysql.conf) and rename it, along with all the users and accesses/privileges on it.

John

scoutman57
03-24-2008, 02:53 PM
One last question. Can you move the main domain (first one created) to a user account, and if so does the main admin have to have a domain inside of if? BTW I moved about 20+ domains with the move_domain script and it works great.

One thing I have not checked it how the move affects cron jobs or system file locations within the website like /home/admin/domains/domain1.com/file.php to
/home/user1/domains/domain1.com/file.php
I am sure all these will need to be updated according to the new file structure layout.

DirectAdmin Support
03-24-2008, 02:55 PM
You can move any domain to any user.
The Admin account does not have to have a domain.

cronjobs are also not domain related, so would have to be moved over.

John

scoutman57
03-24-2008, 03:04 PM
where are the cron jobs file, so i can edit directly in there and not have to re enter cron jobs. I can just edit the file and make the required changes.

DirectAdmin Support
03-24-2008, 09:37 PM
DA saves them in:
/usr/local/directadmin/data/users/username/crontab.conf

but that doesn't move them into the system.
You've need to copy the crontab.conf over, then add or remove a fake one to re-enter them all into the new user.

John

scoutman57
03-25-2008, 07:54 AM
Well I spoke to soon on the script working perfectly. Here are some issues I had.
I moved domain3 from the user admin to a new user3. All the mail folders were there but when they users logged into webmail, their mailboxs were empty.

Second issue.

I created a new Administrator (admin2) and created a user (user5) under the reseller tab for admin2 then i did ./move_domain.sh domain5 admin user5. The website worked but the users were unable to receive emails via pop. Not sure about webmail on this part.

Third: i did ./move_domain.sh domain7 admin admin2. The users were unable to receive email, and the domain would not show. It only went to the apache ssl is installed correctly page.

I transfered all the domains back to admin and all users were able to receive email. This seems to be the issue with moving domains from one admin to anything in a second admin. Maybe the move_domain script is not for that. Not sure about the user that had all mailboxes in webmail but no old mail. that was just transfered from admin to a user under the admin reseller tab.

On the domains that were moved to a admin2 user, I did see new mail files in the imap directories that were created for those new users. Not sure why the users could not download the mail.

Hope this is not to confusing for anyone to understand.

scoutman57
03-25-2008, 09:03 AM
after moving domains to new users, users were unable to receive email. move domains back to original locations but having issues copying new mail back. The mail was received by the system in the new location, but the users were not able to download it or view it in webmail.

old location: /home/admim/imap/domain1.com/user1/Maiddir/new
new location: /home/account1/imap/domain1.com/user1/Maildir/new

copied the new location back to the old location and chown to the correct user:group. But the mails is still not showing up in the users mailbox.

Anyone have any suggestions?

FaSan
07-10-2011, 03:31 AM
Hi,
I've use the script :

/usr/local/directadmin/scripts/move_user_to_reseller.sh


for move one user from one reseller to another. But the IP address still to assign to the old reseller, and I cannot change it.

Ho to resolve it ?



Thank you in advance

Angelokreikamp
07-10-2011, 05:10 PM
why u not use the admin lvl function for it "move users between resellers?"
that's much easyer?