From a5c455ece91dfe8666390610f69429ff46842cca Mon Sep 17 00:00:00 2001 From: Adam Gerard Date: Sun, 15 Oct 2017 20:55:48 +0100 Subject: [PATCH 1/3] BAEL-456: Introduction to Spring Cloud CLI - Bash Scripts --- spring-cloud-cli/decrypt.sh | 10 +++++ spring-cloud-cli/encrypt.sh | 14 +++++++ spring-cloud-cli/groovy.sh | 15 +++++++ spring-cloud-cli/groovy/eureka.groovy | 2 + spring-cloud-cli/groovy/restapi.groovy | 6 +++ spring-cloud-cli/install.sh | 54 ++++++++++++++++++++++++++ spring-cloud-cli/spring-cli-cmds.sh | 51 ++++++++++++++++++++++++ spring-cloud-cli/yml/configserver.yml | 4 ++ spring-cloud-cli/yml/eureka.yml | 8 ++++ 9 files changed, 164 insertions(+) create mode 100644 spring-cloud-cli/decrypt.sh create mode 100644 spring-cloud-cli/encrypt.sh create mode 100644 spring-cloud-cli/groovy.sh create mode 100644 spring-cloud-cli/groovy/eureka.groovy create mode 100644 spring-cloud-cli/groovy/restapi.groovy create mode 100644 spring-cloud-cli/install.sh create mode 100644 spring-cloud-cli/spring-cli-cmds.sh create mode 100644 spring-cloud-cli/yml/configserver.yml create mode 100644 spring-cloud-cli/yml/eureka.yml diff --git a/spring-cloud-cli/decrypt.sh b/spring-cloud-cli/decrypt.sh new file mode 100644 index 000000000000..3aee0f6ad609 --- /dev/null +++ b/spring-cloud-cli/decrypt.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +@echo off +mode con: cols=130 lines=60 + +echo Decrypting my_value as key my_key +spring decrypt --key my_key + +echo +echo You should see: \"my_value\" +echo \ No newline at end of file diff --git a/spring-cloud-cli/encrypt.sh b/spring-cloud-cli/encrypt.sh new file mode 100644 index 000000000000..bb0740615dc6 --- /dev/null +++ b/spring-cloud-cli/encrypt.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +@echo off +mode con: cols=130 lines=60 + +echo Encrypting my_value as key my_key +spring encrypt my_value --key my_key + +echo +echo You should see something like: c93cb36ce1d09d7d62dffd156ef742faaa56f97f135ebd05e90355f80290ce6b +echo +echo You can use: \"{cipher}c93cb36ce1d09d7d62dffd156ef742faaa56f97f135ebd05e90355f80290ce6b\" in your configuration files +echo + +pause \ No newline at end of file diff --git a/spring-cloud-cli/groovy.sh b/spring-cloud-cli/groovy.sh new file mode 100644 index 000000000000..b226884bf2c5 --- /dev/null +++ b/spring-cloud-cli/groovy.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +@echo off +mode con: cols=130 lines=60 + +echo "Run Groovy Rest API Server" +echo "spring run restapi.groovy" +echo "http://localhost:8080/api/get" +spring run restapi.groovy +echo + +echo "Run Groovy Eureka Server" +echo "spring run eureka.groovy" +echo "http://localhost:8761" +spring run eureka.groovy +echo \ No newline at end of file diff --git a/spring-cloud-cli/groovy/eureka.groovy b/spring-cloud-cli/groovy/eureka.groovy new file mode 100644 index 000000000000..9f7acdd7698b --- /dev/null +++ b/spring-cloud-cli/groovy/eureka.groovy @@ -0,0 +1,2 @@ +@EnableEurekaServer +class Eureka {} \ No newline at end of file diff --git a/spring-cloud-cli/groovy/restapi.groovy b/spring-cloud-cli/groovy/restapi.groovy new file mode 100644 index 000000000000..1526f7f825ea --- /dev/null +++ b/spring-cloud-cli/groovy/restapi.groovy @@ -0,0 +1,6 @@ +@RestController +@RequestMapping('/api') +class api { + @GetMapping('/get') + def get() { [message: 'Hello'] } +} \ No newline at end of file diff --git a/spring-cloud-cli/install.sh b/spring-cloud-cli/install.sh new file mode 100644 index 000000000000..6c09f1183821 --- /dev/null +++ b/spring-cloud-cli/install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +@echo off +mode con: cols=130 lines=60 +echo See: https://howtoprogram.xyz/2016/08/28/install-spring-boot-command-line-interface-on-linux/ +echo + +echo "Setting up Java JDK 8" +echo See: http://tipsonubuntu.com/2016/07/31/install-oracle-java-8-9-ubuntu-16-04-linux-mint-18/ +sudo add-apt-repository ppa:webupd8team/java +sudo apt-get update +sudo apt-get install oracle-java8-set-default +echo + +echo "Downloading Spring Boot CLI 1.5.7" +wget http://repo.spring.io/release/org/springframework/boot/spring-boot-cli/1.5.7.RELEASE/spring-boot-cli-1.5.7.RELEASE-bin.tar.gz +echo + +echo "Extracting and Installing" +sudo mkdir /opt/spring-boot +sudo tar xzf spring-boot-cli-1.5.7.RELEASE-bin.tar.gz -C /opt/spring-boot +export SPRING_HOME=/opt/spring-boot/spring-1.5.7.RELEASE +export PATH=$SPRING_HOME/bin:$PATH +source /etc/profile +echo + +echo "Verifying Install of Spring CLI" +spring --version +echo + +echo "Maven Install" +sudo apt-get install maven +echo + +echo "Installing JCE" +sudo apt-get install p7zip-full +echo please go to: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html +echo Download the jce_policy-8.zip after you agree to the terms +sleep 25 +sudo 7z x jce_policy-8.zip +sudo mv /usr/lib/jvm/java-8-oracle/jre/lib/security/local_policy.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/local_policy.jar.backup +sudo mv /usr/lib/jvm/java-8-oracle/jre/lib/security/US_export_policy.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/US_export_policy.jar.backup +sudo mv UnlimitedJCEPolicyJDK8/*.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/ +echo + +echo "Installing Spring Cloud CLI" +sudo mkdir /opt/spring-boot/spring-1.5.7.RELEASE/lib/ext +sudo chown -R $USER:$USER /opt/spring-boot/spring-1.5.7.RELEASE/lib/ext +echo see: https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-cli/ if manual install required +spring install org.springframework.cloud:spring-cloud-cli:1.3.2.RELEASE +echo + +echo "Verify Installation" +spring cloud --version +echo \ No newline at end of file diff --git a/spring-cloud-cli/spring-cli-cmds.sh b/spring-cloud-cli/spring-cli-cmds.sh new file mode 100644 index 000000000000..fa3e2f9cb054 --- /dev/null +++ b/spring-cloud-cli/spring-cli-cmds.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +@echo off +mode con: cols=130 lines=60 +echo + +echo "Run Config Server" +echo "spring cloud configserver" +echo "http://localhost:8888" +spring cloud configserver +echo + +echo "Run Eureka Server" +echo "spring cloud eureka" +echo "http://localhost:8761" +spring cloud eureka +echo + +echo "Run H2 Server" +echo "spring cloud h2" +echo "http://localhost:9095" +spring cloud h2 +echo + +echo "Run Kafka Server" +echo "spring cloud kafka" +echo "http://localhost:9091" +spring cloud kafka +echo + +echo "Run Zipkin Server" +echo "spring cloud zipkin" +echo "http://localhost:9411" +spring cloud zipkin +echo + +echo "Run Dataflow Server" +echo "spring cloud dataflow" +echo "http://localhost:9393" +spring cloud dataflow +echo + +echo "Run Hystrixdashboard Server" +echo "spring cloud hystrixdashboard" +echo "http://localhost:7979" +spring cloud hystrixdashboard +echo + +echo "List Services" +echo "spring cloud --list" +spring cloud --list +echo \ No newline at end of file diff --git a/spring-cloud-cli/yml/configserver.yml b/spring-cloud-cli/yml/configserver.yml new file mode 100644 index 000000000000..2932bddcbf14 --- /dev/null +++ b/spring-cloud-cli/yml/configserver.yml @@ -0,0 +1,4 @@ +spring: + profiles: + active: git + cloud.config.server.git.uri: https://github.com/spring-cloud/spring-cloud-cli/tree/master/spring-cloud-launcher/spring-cloud-launcher-configserver \ No newline at end of file diff --git a/spring-cloud-cli/yml/eureka.yml b/spring-cloud-cli/yml/eureka.yml new file mode 100644 index 000000000000..9a21c1ce1c3b --- /dev/null +++ b/spring-cloud-cli/yml/eureka.yml @@ -0,0 +1,8 @@ +spring: + profiles: + active: git + cloud: + config: + server: + git: + uri: https://github.com/spring-cloud/spring-cloud-cli/tree/master/spring-cloud-launcher/spring-cloud-launcher-eureka \ No newline at end of file From c44db192ca05a08bbcbcd1912b471e8b198b80fe Mon Sep 17 00:00:00 2001 From: Adam Gerard Date: Sun, 15 Oct 2017 21:01:16 +0100 Subject: [PATCH 2/3] Readme added --- spring-cloud-cli/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 spring-cloud-cli/README.md diff --git a/spring-cloud-cli/README.md b/spring-cloud-cli/README.md new file mode 100644 index 000000000000..5f83ab06faa0 --- /dev/null +++ b/spring-cloud-cli/README.md @@ -0,0 +1,6 @@ +========= + +## Spring Cloud CLI + +### Relevant Articles: +- [Introduction to Spring Cloud CLI](http://www.baeldung.com/introduction-to-spring-cloud-cli/) \ No newline at end of file From 1090f19ce8351fe20e39330e3ef7612b591c8a5a Mon Sep 17 00:00:00 2001 From: Adam Gerard Date: Sun, 15 Oct 2017 21:05:29 +0100 Subject: [PATCH 3/3] Removed batch script artifacts --- spring-cloud-cli/decrypt.sh | 4 ---- spring-cloud-cli/encrypt.sh | 8 +------- spring-cloud-cli/groovy.sh | 4 ---- spring-cloud-cli/install.sh | 2 -- spring-cloud-cli/spring-cli-cmds.sh | 11 ----------- 5 files changed, 1 insertion(+), 28 deletions(-) diff --git a/spring-cloud-cli/decrypt.sh b/spring-cloud-cli/decrypt.sh index 3aee0f6ad609..450ac156bcf5 100644 --- a/spring-cloud-cli/decrypt.sh +++ b/spring-cloud-cli/decrypt.sh @@ -1,10 +1,6 @@ #!/usr/bin/env bash -@echo off -mode con: cols=130 lines=60 - echo Decrypting my_value as key my_key spring decrypt --key my_key - echo echo You should see: \"my_value\" echo \ No newline at end of file diff --git a/spring-cloud-cli/encrypt.sh b/spring-cloud-cli/encrypt.sh index bb0740615dc6..a5ea678952fb 100644 --- a/spring-cloud-cli/encrypt.sh +++ b/spring-cloud-cli/encrypt.sh @@ -1,14 +1,8 @@ #!/usr/bin/env bash -@echo off -mode con: cols=130 lines=60 - echo Encrypting my_value as key my_key spring encrypt my_value --key my_key - echo echo You should see something like: c93cb36ce1d09d7d62dffd156ef742faaa56f97f135ebd05e90355f80290ce6b echo echo You can use: \"{cipher}c93cb36ce1d09d7d62dffd156ef742faaa56f97f135ebd05e90355f80290ce6b\" in your configuration files -echo - -pause \ No newline at end of file +echo \ No newline at end of file diff --git a/spring-cloud-cli/groovy.sh b/spring-cloud-cli/groovy.sh index b226884bf2c5..19f785989b69 100644 --- a/spring-cloud-cli/groovy.sh +++ b/spring-cloud-cli/groovy.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash -@echo off -mode con: cols=130 lines=60 - echo "Run Groovy Rest API Server" echo "spring run restapi.groovy" echo "http://localhost:8080/api/get" spring run restapi.groovy echo - echo "Run Groovy Eureka Server" echo "spring run eureka.groovy" echo "http://localhost:8761" diff --git a/spring-cloud-cli/install.sh b/spring-cloud-cli/install.sh index 6c09f1183821..e01a8fc22e5a 100644 --- a/spring-cloud-cli/install.sh +++ b/spring-cloud-cli/install.sh @@ -1,6 +1,4 @@ #!/usr/bin/env bash -@echo off -mode con: cols=130 lines=60 echo See: https://howtoprogram.xyz/2016/08/28/install-spring-boot-command-line-interface-on-linux/ echo diff --git a/spring-cloud-cli/spring-cli-cmds.sh b/spring-cloud-cli/spring-cli-cmds.sh index fa3e2f9cb054..6947122a18aa 100644 --- a/spring-cloud-cli/spring-cli-cmds.sh +++ b/spring-cloud-cli/spring-cli-cmds.sh @@ -1,50 +1,39 @@ #!/usr/bin/env bash -@echo off -mode con: cols=130 lines=60 -echo - echo "Run Config Server" echo "spring cloud configserver" echo "http://localhost:8888" spring cloud configserver echo - echo "Run Eureka Server" echo "spring cloud eureka" echo "http://localhost:8761" spring cloud eureka echo - echo "Run H2 Server" echo "spring cloud h2" echo "http://localhost:9095" spring cloud h2 echo - echo "Run Kafka Server" echo "spring cloud kafka" echo "http://localhost:9091" spring cloud kafka echo - echo "Run Zipkin Server" echo "spring cloud zipkin" echo "http://localhost:9411" spring cloud zipkin echo - echo "Run Dataflow Server" echo "spring cloud dataflow" echo "http://localhost:9393" spring cloud dataflow echo - echo "Run Hystrixdashboard Server" echo "spring cloud hystrixdashboard" echo "http://localhost:7979" spring cloud hystrixdashboard echo - echo "List Services" echo "spring cloud --list" spring cloud --list