diff --git a/packaging/org.linkedin.glu.packaging-all/src/cmdline/resources/bin/setup.sh b/packaging/org.linkedin.glu.packaging-all/src/cmdline/resources/bin/setup.sh index 6c7adf00..162ba742 100644 --- a/packaging/org.linkedin.glu.packaging-all/src/cmdline/resources/bin/setup.sh +++ b/packaging/org.linkedin.glu.packaging-all/src/cmdline/resources/bin/setup.sh @@ -17,4 +17,4 @@ # BASEDIR=`cd $(dirname $0)/.. ; pwd` -$BASEDIR/packages/org.linkedin.glu.packaging-setup-5.0.0-SNAPSHOT/bin/setup.sh "$@" \ No newline at end of file +$BASEDIR/packages/org.linkedin.glu.packaging-setup-@glu.version@/bin/setup.sh "$@" \ No newline at end of file diff --git a/packaging/org.linkedin.glu.packaging-all/src/cmdline/resources/conf/tutorial/glu-meta-model.json.groovy b/packaging/org.linkedin.glu.packaging-all/src/cmdline/resources/conf/tutorial/glu-meta-model.json.groovy index fd48a122..079d8658 100644 --- a/packaging/org.linkedin.glu.packaging-all/src/cmdline/resources/conf/tutorial/glu-meta-model.json.groovy +++ b/packaging/org.linkedin.glu.packaging-all/src/cmdline/resources/conf/tutorial/glu-meta-model.json.groovy @@ -21,35 +21,37 @@ def fabric = 'glu-dev-1' def gluVersion = '@glu.version@' def zooKeeperVersion = '@zooKeeper.version@' -fabrics[fabric] = [ - keys: [ - agentKeyStore: [ - uri: 'agent.keystore', - checksum: 'JSHZAn5IQfBVp1sy0PgA36fT_fD', - storePassword: 'nacEn92x8-1', - keyPassword: 'nWVxpMg6Tkv' - ], +def keys = [ + agentKeyStore: [ + uri: 'agent.keystore', + checksum: 'JSHZAn5IQfBVp1sy0PgA36fT_fD', + storePassword: 'nacEn92x8-1', + keyPassword: 'nWVxpMg6Tkv' + ], - agentTrustStore: [ - uri: 'agent.truststore', - checksum: 'CvFUauURMt-gxbOkkInZ4CIV50y', - storePassword: 'nacEn92x8-1', - keyPassword: 'nWVxpMg6Tkv' - ], + agentTrustStore: [ + uri: 'agent.truststore', + checksum: 'CvFUauURMt-gxbOkkInZ4CIV50y', + storePassword: 'nacEn92x8-1', + keyPassword: 'nWVxpMg6Tkv' + ], - consoleKeyStore: [ - uri: 'console.keystore', - checksum: 'wxiKSyNAHN2sOatUG2qqIpuVYxb', - storePassword: 'nacEn92x8-1', - keyPassword: 'nWVxpMg6Tkv' - ], + consoleKeyStore: [ + uri: 'console.keystore', + checksum: 'wxiKSyNAHN2sOatUG2qqIpuVYxb', + storePassword: 'nacEn92x8-1', + keyPassword: 'nWVxpMg6Tkv' + ], - consoleTrustStore: [ - uri: 'console.truststore', - checksum: 'qUFMIePiJhz8i7Ow9lZmN5pyZjl', - storePassword: 'nacEn92x8-1', - ], + consoleTrustStore: [ + uri: 'console.truststore', + checksum: 'qUFMIePiJhz8i7Ow9lZmN5pyZjl', + storePassword: 'nacEn92x8-1', ], +] + +fabrics[fabric] = [ + keys: keys, console: 'tutorialConsole', zooKeeperCluster: 'tutorialZooKeeperCluster' ] diff --git a/packaging/org.pongasoft.glu.packaging-setup-impl/src/main/groovy/org/pongasoft/glu/packaging/setup/KeysGenerator.groovy b/packaging/org.pongasoft.glu.packaging-setup-impl/src/main/groovy/org/pongasoft/glu/packaging/setup/KeysGenerator.groovy index d6f629ac..9241e6a4 100644 --- a/packaging/org.pongasoft.glu.packaging-setup-impl/src/main/groovy/org/pongasoft/glu/packaging/setup/KeysGenerator.groovy +++ b/packaging/org.pongasoft.glu.packaging-setup-impl/src/main/groovy/org/pongasoft/glu/packaging/setup/KeysGenerator.groovy @@ -63,6 +63,7 @@ public class KeysGenerator KeysMetaModelImpl keys def passwords = [:] + def encryptedPasswords = [:] def passwordGenerator = { String name -> OneWayCodec codec = OneWayMessageDigestCodec.createSHA1Instance(masterPassword, base64Codec) @@ -104,11 +105,16 @@ public class KeysGenerator def getEncryptedPasswords() { - Base64Codec codec = new Base64Codec(encryptingKey); + if(!encryptedPasswords) + { + Base64Codec codec = new Base64Codec(encryptingKey); - passwords.collectEntries { k, v -> - [k, CodecUtils.encodeString(codec, v.toString())] + encryptedPasswords = getPasswords().collectEntries { k, v -> + [k, CodecUtils.encodeString(codec, v.toString())] + } } + + return encryptedPasswords } String computeChecksum(Resource resource) @@ -337,14 +343,19 @@ public class KeysGenerator } private Resource createResourceInOutputFolder(String name, - boolean callClosureOnlyIfFileDoesNotExist = true, + boolean failOnFileAlreadyExists = true, Closure closure) { if(!outputFolder.exists()) shell.mkdirs(outputFolder) Resource resource = outputFolder.createRelative(name) - if(!callClosureOnlyIfFileDoesNotExist || !resource.exists()) + if(!failOnFileAlreadyExists || !resource.exists()) + { + shell.rm(resource) resource = closure(resource) + } + else + throw new IllegalStateException("${resource} already exists") return resource } diff --git a/packaging/org.pongasoft.glu.packaging-setup-impl/src/main/groovy/org/pongasoft/glu/packaging/setup/SetupMain.groovy b/packaging/org.pongasoft.glu.packaging-setup-impl/src/main/groovy/org/pongasoft/glu/packaging/setup/SetupMain.groovy index aed6e2ab..ba7cf9ac 100644 --- a/packaging/org.pongasoft.glu.packaging-setup-impl/src/main/groovy/org/pongasoft/glu/packaging/setup/SetupMain.groovy +++ b/packaging/org.pongasoft.glu.packaging-setup-impl/src/main/groovy/org/pongasoft/glu/packaging/setup/SetupMain.groovy @@ -33,6 +33,8 @@ public class SetupMain protected Resource outputFolder protected Shell shell = ShellImpl.createRootShell() + private int exitValue = 0 + SetupMain() { JulToSLF4jBridge.installBridge() @@ -112,25 +114,34 @@ public class SetupMain def gen_keys = { println "Generating keys..." char[] masterPassword = System.console().readPassword("Enter a master password:") - def kmm = new KeysGenerator(shell: shell, - outputFolder: outputFolder.createRelative('keys'), - masterPassword: new String(masterPassword)).generateKeys().toExternalRepresentation() - println "Keys have been generated in the following folder: ${outputFolder.path}" + def km = new KeysGenerator(shell: shell, + outputFolder: outputFolder.createRelative('keys'), + masterPassword: new String(masterPassword)) + try + { + def kmm = km.generateKeys().toExternalRepresentation() - println "Copy the following section in your meta model (see comment in meta model)" + println "Keys have been generated in the following folder: ${outputFolder.path}" - println "//" * 20 + println "Copy the following section in your meta model (see comment in meta model)" - println "keys: [" - kmm.each { storeName, store -> - println " ${storeName}: [" - println store.findAll {k, v -> v != null}.collect { k, v -> " ${k}: '${v}'"}.join(',\n') - println " ]," - } - println "]" + println "//" * 20 - println "//" * 20 + println "def keys = [" + kmm.each { storeName, store -> + println " ${storeName}: [" + println store.findAll {k, v -> v != null}.collect { k, v -> " ${k}: '${v}'"}.join(',\n') + println " ]," + } + println "]" + println "//" * 20 + } + catch(IllegalStateException e) + { + exitValue = 1 + println "${e.message} => if you want to generate new keys, either provide another folder or delete them first" + } } public static void main(String[] args) @@ -150,6 +161,8 @@ public class SetupMain clientMain.cli.usage() } } + + System.exit(clientMain.exitValue) } protected def getConfig(cli, options)