Created
October 18, 2011 20:01
-
-
Save mbseid/1296533 to your computer and use it in GitHub Desktop.
ColdGold Hole #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="getFile"> | |
<cfargument name="path"> | |
<cffile action="READ" file="#path#" variable="serverXML"> | |
<cfreturn xmlParse(serverXML)> | |
</cffunction> | |
<cffunction name="writeFile"> | |
<cfargument name="path"> | |
<cfargument name="xml"> | |
<cffile action="write" file="#path#" output="#ToString(xml)#"> | |
</cffunction> | |
<cfscript> | |
function createHostXML(xml, name, path, domain){ | |
var e = XmlElemNew(xml, name); | |
s = { | |
name=arguments.domain, | |
appBase="webapps", | |
unpackWARs="true", | |
autoDeploy="true", | |
xmlValidation="false", | |
xmlNamespaceAware="false" | |
}; | |
e.XmlAttributes = s; | |
var c = XMLElemNew(xml, "Context"); | |
t = { | |
path="", | |
docBase=arguments.path | |
}; | |
c.XmlAttributes = t; | |
ArrayAppend(e.XmlChildren, c); | |
return e; | |
} | |
function createHost(path, domain, projectPath){ | |
var serverXML = getFile(path); | |
var xmlElement = createHostXML(serverXML, "Host", arguments.path, arguments.domain); | |
ArrayAppend(serverXML.Server.Service.Engine.XmlChildren, xmlElement); | |
writeFile(path, serverXML); | |
return serverXML; | |
} | |
path = expandPath("."); | |
createHost(path&"/server.xml", "test", "/Path/To/Test"); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment