-
-
Save willis7/33c478e332de7d9e8fc3 to your computer and use it in GitHub Desktop.
Revisions
-
willis7 revised this gist
Sep 13, 2014 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,9 +9,7 @@ def myFile = new File("data.txt") def fileText = myFile.text ( 1..9 ).each { fileText = (fileText =~ /James/).replaceFirst("user${it}") } myFile.write(fileText) /* Usage in Cloudify: -
Tamir Korem revised this gist
Aug 5, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,7 @@ myFile.write(fileText) with the current actual http port and all the occurrences of 8009 with the current actual AJP port. */ def config = new ConfigSlurper().parse(new File("tomcat-service.properties").toURL()) def context = ServiceContextFactory.getServiceContext() def home = "${context.serviceDirectory}/${config.name}" -
Tamir Korem revised this gist
Aug 5, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,9 +15,9 @@ for ( index in 1..9 ) { myFile.write(fileText) /* Usage in Cloudify: The following code snippet replaces all the occurrences of 8080 with the current actual http port and all the occurrences of 8009 with the current actual AJP port. */ def config = new ConfigSlurper().parse(new File("tomcat-service.properties").toURL()) def context = ServiceContextFactory.getServiceContext() -
Tamir Korem revised this gist
Aug 5, 2012 . 1 changed file with 18 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,4 +12,21 @@ def fileText = myFile.text for ( index in 1..9 ) { fileText = (fileText =~ /James/).replaceFirst("user${index}") } myFile.write(fileText) /* Usage in Cloudify: The following code snippet replaces all the occurrences of 8080 with the current actual http port. and all the occurrences of 8009 with the current actual AJP port. */ def config = new ConfigSlurper().parse(new File("tomcat-service.properties").toURL()) def context = ServiceContextFactory.getServiceContext() def home = "${context.serviceDirectory}/${config.name}" portIncrement = 0 def serverXmlFile = new File("${home}/conf/server.xml") def serverXmlText = serverXmlFile.text portReplacementStr = "port=\"${config.port + portIncrement}\"" ajpPortReplacementStr = "port=\"${config.ajpPort + portIncrement}\"" serverXmlText = serverXmlText.replace("port=\"8080\"", portReplacementStr) serverXmlText = serverXmlText.replace("port=\"8009\"", ajpPortReplacementStr) serverXmlFile.write(serverXmlText) -
Tamir Korem created this gist
Aug 5, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ /* Groovy Usage: The following example replaces: the 1st occurrence of "James" in data.txt with "user1", the 2nd occurrence of "James" in data.txt with "user2", the 3rd occurrence of "James" in data.txt with "user3", .. the 9th occurrence of "James" in data.txt with "user9". */ def myFile = new File("data.txt") def fileText = myFile.text for ( index in 1..9 ) { fileText = (fileText =~ /James/).replaceFirst("user${index}") } myFile.write(fileText)