Just to go back to James Dalla Rosa's posting on this topic --
creating users automatically by opening a socket --

If you use Ant, it's pretty easy to do some scripting to add
"standard" users. Put the Jakarta Commons Net into your ant lib/ , and
then do something like the following:

    <target name="James-create-users" description="Create users for
the James mail server">
        <telnet server="localhost" port="4555" timeout="5">
            <read>id:</read>
            <write>root</write>
            <read>Password:</read>
            <write>root</write>
            <read>commands</read>
            <write>adduser john john</write>
            <read>added</read>
            <write>adduser hans hans</write>
            <read>added</read>
            <write>adduser stan stan</write>
            <read>added</read>
            <write>adduser katie katie</write>
            <read>added</read>
            <write>adduser james james</write>
            <read>added</read>
            <write>quit</write>
        </telnet>
    </target>

Here is another Ant target I wrote to set up James on a machine (I use
James for testing e-mail on developer machines). A tidbit here, too,
is that we run James POP and SMTP on 8110 and 8025 and redirect ports
on Linux and BSD so that James doesn't have to run as root (to get
access to the privileged ports).

    <target name="James-prepare" depends="filter" description="Prepare
the James mail server">
        <echo message="Eclipse users, NOTE:"/>
        <echo message="  You must add JAF (activation.jar), JavaMail
(mail.jar) and"/>
        <echo message="  Commons Net (commons-net-1.3.0.jar) to your
Eclipse Ant"/>
        <echo message="  Runtime (Window / Preferences / Ant/ Runtime
/ add external"/>
        <echo message="  jars to the Ant Global Entries section)."/>
<!-- On the Mac, must:

sysctl -w net.inet.ip.forwarding=1
ipfw add fwd 127.0.0.1,8110 tcp from any to any 110 in
ipfw add fwd 127.0.0.1,8025 tcp from any to any 25 in
-->
        
        <delete quiet="true" dir="${env.OTS}/james-2.2.0"/>
        <unzip src="${env.OTS}/james-2.2.0.zip" dest="${env.OTS}"/>
        <exec os="Linux,Mac OS X" executable="/bin/bash">
                <arg line='-c "chmod +x ${james.base.dir}/bin/run.sh"' />
        </exec>
        <exec os="Linux,Mac OS X" executable="/bin/bash">
                <arg line='-c "chmod +x ${james.base.dir}/bin/phoenix.sh"' />
        </exec>

    <!-- Now set our custom config.xml -->      
        <copy verbose="true" file="${config}/james-config.xml"
overwrite="true"
tofile="${james.base.dir}/apps/james/SAR-INF/config.xml" />

        <!-- Startup / shutdown to get James initialized -->
        <antcall target="James-start"/>
        <echo message="Waiting 10 seconds for James to start up . . ."/>
        <sleep seconds="10"/>
        <antcall target="James-shutdown"/>
        <sleep seconds="5"/>

                <antcall target="James-start"/>
        <echo message="Waiting 30 seconds for James to start up . . ."/>
        <sleep seconds="30"/>
                <antcall target="James-create-users"/>
                <antcall target="James-test-email"/>
    </target>
    <target name="James-start" description="Start the James mail server">
                <java fork="yes" spawn="yes"
jar="${james.base.dir}/bin/phoenix-loader.jar" taskname="james">
                    <sysproperty key="java.ext.dirs" 
value="${james.base.dir}/lib"/>
                    <sysproperty key="phoenix.home" value="${james.base.dir}"/>
                    <sysproperty key="java.security.policy"
value="jar:file:${james.base.dir}/bin/phoenix-loader.jar!/META-INF/java.policy"/>
                </java>
    </target>
    <target name="James-shutdown" description="Shut down the James mail server">
        <telnet server="localhost" port="4555" timeout="5">
            <read>id:</read>
            <write>root</write>
            <read>Password:</read>
            <write>root</write>
            <read>commands</read>
            <write>shutdown</write>
            <write></write>
        </telnet>
    </target>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to