Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ -z "$JBOSS_USER" ]; then
  4. JBOSS_USER=wildfly
  5. fi
  6.  
  7. if [ -z "$JBOSS_HOME" ]; then
  8. JBOSS_HOME="/opt/wildfly/"
  9. fi
  10.  
  11. function enableSSL(){
  12. service wildfly stop &>/dev/null
  13. doAction keystore DownloadKeys;
  14. rm -f /var/lib/jelastic/SSL/wildfly.*;
  15. local certpass=$(/usr/bin/pwgen 30 1);
  16. /usr/bin/openssl pkcs12 -export -in /var/lib/jelastic/SSL/jelastic.crt -inkey /var/lib/jelastic/SSL/jelastic.key -certfile /var/lib/jelastic/SSL/jelastic-ca.crt -out /var/lib/jelastic/SSL/wildfly.p12 -password pass:${certpass} &>/dev/null
  17. $(dirname $(realpath $(which java)))/keytool -importkeystore -srckeystore /var/lib/jelastic/SSL/wildfly.p12 -srcstorepass ${certpass} -srcstoretype pkcs12 -destkeystore /var/lib/jelastic/SSL/wildfly.keystore -deststoretype JKS -keypass $certpass -storepass $certpass &>/dev/null
  18. cp -f /var/lib/jelastic/SSL/wildfly.keystore ${JBOSS_HOME}/domain/configuration/wildfly.keystore;
  19. mv -f /var/lib/jelastic/SSL/wildfly.keystore ${JBOSS_HOME}/standalone/configuration/wildfly.keystore;
  20. chown ${JBOSS_USER}:${JBOSS_USER} ${JBOSS_HOME}/standalone/configuration/wildfly.keystore;
  21. XML_CONFIG_FILES=("standalone.xml" "standalone-full.xml" "standalone-ha.xml" "standalone-full-ha.xml" "standalone-load-balancer.xml" "standalone-ee8.xml" "../../domain/configuration/host.xml")
  22.  
  23. for file in "${XML_CONFIG_FILES[@]}"
  24. do
  25. [ -e "${JBOSS_HOME}/standalone/configuration/${file}" ] && sed -i s/keystore-password=\".*\"/keystore-password=\"$certpass\"/ ${JBOSS_HOME}/standalone/configuration/${file};
  26. done
  27.  
  28. XML_CONFIG_FILES=("host.xml" "host-master.xml" "host-slave.xml")
  29.  
  30. for file in "${XML_CONFIG_FILES[@]}"
  31. do
  32. [ -e "${JBOSS_HOME}/domain/configuration/${file}" ] && sed -i s/keystore-password=\".*\"/keystore-password=\"$certpass\"/ ${JBOSS_HOME}/domain/configuration/${file};
  33. done
  34.  
  35. service wildfly start &>/dev/null
  36. return 0;
  37. }
  38.  
  39. function disableSSL(){
  40. service wildfly stop &>/dev/null
  41. doAction keystore remove;
  42. rm -f ${JBOSS_HOME}/domain/configuration/wildfly.keystore
  43. rm -f ${JBOSS_HOME}/standalone/configuration/wildfly.keystore
  44. selfcertgen;
  45. service wildfly start &>/dev/null
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement