shell script, create bulk account

Discussion in 'Programming/Scripts' started by webelo, Jan 4, 2008.

  1. webelo

    webelo New Member

    hello there,

    was wondering if there is or if its easy to create a shell script that will let me add domains to a server in bulk (like 200 domain), I want to get a list of domain in a .data file, the script should read the file, create the usernames and group for each domain, set a default password, add to virtualhosting apache, create user folder /home/<user>/

    Is this possible? Is there anything like this out there?

    I don't know, maybe it can run like this...
    #!/bin/sh
    cat domain.data | \
    while read domain
    do
    echo "Found domain: $domain"
    done
    ---------------

    But than have to do the rest :(

    Can anyone help?


    Thanks
     
  2. devnull3d

    devnull3d New Member

    That shouldn't be too hard even in bash but I'd perfer to use perl. I'll attempt to throw something together (untested)
    Code:
    #!/bin/bash
    for domain in `cat domain`
    do
     mkdir /home/$domain
     chown apache:apache /home/$domain
     cat apache_vhost_template | sed "s/domain_template/$domain" >> /etc/apache2/sites-enabled/000-default
    done
    
    Not exactly what you asked for but it should do the trick, of course you need to create apache_vhost_template yourself, it should look something like this
    Code:
    $ cat apache_vhost_template
    <VirtualHost *:80>
    ServerName domain_template
    DocumentRoot /home/domain_template
    </VirtualHost>
    
     

Share This Page