New scripts

Yes, they should be added by default :) And you will get them with an update.
 
Thank you for the good words, I really appreciate them :) Happy using!
 
Thanks Smtalk. Hope this can be put in the admin gui one day. Call it something like "Convert/Move Users"
 
Several things wrong with the move_domain.sh script so far.

It doesn't add the domains httpd.conf in the main httpd.conf file, rebuilding the httpd.conf, doesn't help either, have to manually add it in.

And the e-mails in /etc/virtual/ , the permissions doesn't change to the proper user, have to manually chown the folders over, to the correct new UID.

Thanks!
 
Yes, that's why it's marked as beta. It's the only script which is in beta now :) Anyway, thank you for the report.
 
I know, but just helping it to make it better :)

Also, IMAP logins are failing, but attempting to figure it out.
 
Any chance of this feature bcoming a browser based solution in the admin panel??????...

I'm 100% sure this would be something that more than DA customer would like to see in their admin panels.
 
Any chance of this feature bcoming a browser based solution in the admin panel??????...

I'm 100% sure this would be something that more than DA customer would like to see in their admin panels.

I agree with you completely!! I would love to have this available as an admin option!! Couldnt it be made into a Module so there would be admin links?

Chad
 
Hi smtalk,

Can you provide me a linkr the user_to_reseller.sh script? It gives a 404 when I try to download it.

Thanks :D
 
user_to_reseller.sh:
Code:
#!/bin/sh
# This script is written by Martynas Bendorius and DirectAdmin
# It is used to convert user to reseller
# Official DirectAdmin webpage: http://www.directadmin.com
# Usage:
# ./user_to_reseller.sh <user>

if [ $UID != 0 ]; then
        echo "You require Root Access to run this script";
        exit 0;
fi

if [ $# != 1 ]; then
        echo "Usage:";
        echo "$0 <user>";
        echo "you gave #$#: $0 $1";
        exit 0;
fi

USERNAME=$1

BASEDIR=/usr/local/directadmin/data

ADMIN_DATA=${BASEDIR}/users/admin
RESELLER_LIST=${BASEDIR}/admin/reseller.list

USER_DATA=${BASEDIR}/users/$1
USER_BACKUP_CONF=${USER_DATA}/backup.conf
USER_CONF=${USER_DATA}/user.conf
USER_USAGE=${USER_DATA}/user.usage

RESELLER_ALLOC=${USER_DATA}/reseller.allocation
RESELLER_CONF=${USER_DATA}/reseller.conf
RESELLER_USAGE=${USER_DATA}/reseller.usage

if [ ! -d ${USER_DATA} ]; then
        echo "Directory ${USER_DATA} does not exist. Can not continue."
        exit 1;
fi

if [ "`grep -wc $1 ${RESELLER_LIST}`" = "1" ]; then
        echo "User $1 is already reseller. Can not continue."
        exit 1;
fi

if [ ! -e /usr/bin/perl ]; then
        echo "/usr/bin/perl does not exist.";
        exit 1;
fi

echo "Re-configuring user directory /home/$1."
mkdir -p /home/$1/user_backups
mkdir -p /home/$1/domains/default
mkdir -p /home/$1/domains/sharedip
mkdir -p /home/$1/domains/suspended
cp -R ${BASEDIR}/templates/default/* /home/$1/domains/default
chown -R $1:$1 /home/$1/user_backups
chown -R $1:$1 /home/$1/domains/default
chown -R $1:$1 /home/$1/domains/sharedip
chown -R $1:$1 /home/$1/domains/suspended

echo "Re-configuring DirectAdmin files."
# Changing usertype
perl -pi -e 's/usertype=user/usertype=reseller/' ${USER_CONF}

# Creating backup.conf
if [ ! -e ${USER_BACKUP_CONF} ]; then
        echo -n "" > ${USER_BACKUP_CONF}
        echo "ftp_ip=" >> ${USER_BACKUP_CONF}
        echo "ftp_password=" >> ${USER_BACKUP_CONF}
        echo "ftp_path=/" >> ${USER_BACKUP_CONF}
        echo "ftp_username=" >> ${USER_BACKUP_CONF}
        echo "local_path=" >> ${USER_BACKUP_CONF}
fi
# Creating ip.list
if [ ! -e ${USER_DATA}/ip.list ]; then
        grep "ip=" ${USER_DATA}/user.conf | cut -d= -f2 > ip.list
fi
# Creating everything else
touch ${USER_DATA}/login.hist
touch ${USER_DATA}/reseller.history
touch ${USER_DATA}/users.list
cp -f ${ADMIN_DATA}/u_welcome.txt ${USER_DATA}/u_welcome.txt

# Creating packages
mkdir -p ${USER_DATA}/packages
touch ${USER_DATA}/packages.list

# Creating reseller.allocation
if [ ! -e ${RESELLER_ALLOC} ]; then
        echo -n "" > ${RESELLER_ALLOC}
        grep "bandwidth=" ${USER_CONF} >> ${RESELLER_ALLOC}
        grep "domainptr=" ${USER_CONF} >> ${RESELLER_ALLOC}
        grep "ftp=" ${USER_CONF} >> ${RESELLER_ALLOC}
        grep "mysql=" ${USER_CONF} >> ${RESELLER_ALLOC}
        grep "nemailf=" ${USER_CONF} >> ${RESELLER_ALLOC}
        grep "nemailml=" ${USER_CONF} >> ${RESELLER_ALLOC}
        grep "nemailr=" ${USER_CONF} >> ${RESELLER_ALLOC}
        grep "nemails=" ${USER_CONF} >> ${RESELLER_ALLOC}
        grep "nsubdomains=" ${USER_CONF} >> ${RESELLER_ALLOC}
        echo "nusers=0" >> ${RESELLER_ALLOC}
        grep "quota=" ${USER_CONF} >> ${RESELLER_ALLOC}
        grep "vdomains=" ${USER_CONF} >> ${RESELLER_ALLOC}
fi

# Editing ticket.conf
if [ -e ${USER_DATA}/ticket.conf ] && [ "`grep -c 'active=' ${USER_DATA}/ticket.conf`" = "0" ]; then
        echo "active=yes" >> ${USER_DATA}/ticket.conf
        echo 'html=Follow <a href="http://www.domain.com/support">this link</a> for a 3rd party ticket system.' >> ${USER_DATA}/ticket.conf
        echo "newticket=0" >> ${USER_DATA}/ticket.conf
fi

# Creating reseller.conf
if [ ! -e ${RESELLER_CONF} ]; then
        egrep -v "account=|creator=|date_created=|docsroot=|domain=|email=|ip=|name=|skin=|suspend_at_limit=|suspended=|username=|usertype=|zoom=|language=" ${USER_CONF} > ${RESELLER_CONF}
        echo "userssh=ON" >> ${RESELLER_CONF}
        echo "dns=ON" >> ${RESELLER_CONF}
        echo "ip=shared" >> ${RESELLER_CONF}
        echo "ips=0" >> ${RESELLER_CONF}
        echo "oversell=ON" >> ${RESELLER_CONF}
        echo "serverip=ON" >> ${RESELLER_CONF}
        echo "subject=Your account for |domain| is now ready for use." >> ${RESELLER_CONF}
fi

# Creating reseller.usage
if [ ! -e ${RESELLER_USAGE} ]; then
        egrep -v "db_quota=|email_quota=" ${USER_USAGE} > ${RESELLER_USAGE}
        echo "nusers=1" >> ${RESELLER_USAGE}
fi

CREATOR=`grep "creator=" ${USER_CONF} | cut -d= -f2`
CREATOR_USERSLIST=${BASEDIR}/users/${CREATOR}/users.list
echo "Removing user from the other reseller."
perl -pi -e "s#$CREATOR\n##g" ${CREATOR_USERSLIST}

# Setting permissions
chmod 600 ${USER_DATA}/backup.conf ${USER_DATA}/reseller.usage ${USER_DATA}/reseller.conf ${USER_DATA}/reseller.allocation ${USER_DATA}/packages.list ${USER_DATA}/login.hist ${USER_DATA}/reseller.history ${USER_DATA}/users.list
chmod 700 ${USER_DATA}/packages
chmod 644 ${USER_DATA}/u_welcome.txt
chown -R diradmin:diradmin ${USER_DATA}/packages ${USER_DATA}/u_welcome.txt ${USER_DATA}/backup.conf ${USER_DATA}/reseller.usage ${USER_DATA}/reseller.conf ${USER_DATA}/reseller.allocation ${USER_DATA}/packages.list ${USER_DATA}/login.hist ${USER_DATA}/reseller.history ${USER_DATA}/users.list

echo "Adding reseller to $3 reseller list"
echo "$1" >> ${RESELLER_LIST}

echo "Changing user owner"
perl -pi -e "s/creator=$CREATOR/creator=$1/g" ${USER_CONF}

#this is needed to update "show all users" cache.
echo "action=cache&value=showallusers" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq

echo "User $1 has been converted to reseller."

exit 0;
 
I was just wandering...
I'm not that much of a command prompt wizard (yet) but I am having a customer that has several accounts within one reseller account; thos user accounts needs to be added to one (already existing) account, but so that all passwords within ALL accounts (DA login, FTP- and also email accounts!) are staying the same. After all all domains and settings and e-mail addresses, ftp accounts tec. need to be unchanged!

Is some of those scripts a solution to get this done?

Thanks in advance.
 
I would think that the Move Users to Resellers link would do it for you.
 
Yeah, I guess I will try that. Though all user accounts are now in one and the same reseller account.. I could try to create another reseller account, create a new user and transfer all user accounts to one account within the other reseller account I quess? Seems like a lot of actions to do then.. I'll go try some, I'll post the results here. Unless I am missing something..
 
You basically said that you wanted to move some user accounts from one reseller account to another reseller account. I don't understand what the problem is.
 
Back
Top