see also https://spaces.at.internet2.edu/display/Grouper/Grouper+Shell+Improvements
Plan to improve GSH
- Grouper 2.3 uses BeanShell. There's no tab completion, history, etc.
- We're looking to switch to Groovy as the default for GSH.
- The goal would be to keep any existing GSH scripts that deployers may have written as compatible as possible with the new Groovy based GSH.
- Built in GSH commands (e.g. obliterateStem) would be modified to work with both BeanShell and Groovy.
With a 2.3 patch, default it to Groovy with an option to go back to BeanShell.
- The configuration would be via grouper.properties.
- gsh.sh and gsh.bat shouldn't have to change.
- Grouper will include Groovy so deployers won't have to do anything special to get Groovy installed.
- Users can still use another shell as they do today (e.g. https://github.com/wgthom/groovysh4grouper)
- Other advantages of Groovy: Grouper Shell Improvements
This is how GSH would start up after applying the future 2.3 patch that would contain this change (with an example built in gsh command - obliterateStem). (There's no change.):
shilen@Shilens-MacBook-Pro-2 grouper (GRP-1553) $ ./bin/gsh.sh Using GROUPER_HOME: /Users/shilen/Desktop/internet2/github2/grouper Using GROUPER_CONF: /Users/shilen/Desktop/internet2/github2/grouper/conf Using JAVA: java using MEMORY: 64m-750m Grouper starting up: version: 2.3.0, build date: 2017/06/02 16:18:52, env: <no label configured> grouper.properties read from: /Users/shilen/Desktop/internet2/github2/grouper/conf/grouper.properties Grouper current directory is: /Users/shilen/Desktop/internet2/github2/grouper log4j.properties read from: /Users/shilen/Desktop/internet2/github2/grouper/conf/log4j.properties Grouper is logging to file: /Users/shilen/Desktop/internet2/github2/grouper/logs/grouper_error.log, at min level WARN for package: edu.internet2.middleware.grouper, based on log4j.properties grouper.hibernate.properties: /Users/shilen/Desktop/internet2/github2/grouper/conf/grouper.hibernate.properties grouper.hibernate.properties: sa@jdbc:hsqldb:hsql://localhost:9001/grouper subject.properties read from: /Users/shilen/Desktop/internet2/github2/grouper/conf/subject.properties sources.xml read from: /Users/shilen/Desktop/internet2/github2/grouper/conf/sources.xml sources configured in: sources.xml sources.xml groupersource id: g:gsa sources.xml groupersource id: grouperEntities sources.xml jdbc source id: jdbc: GrouperJdbcConnectionProvider Grouper warning: jarfile mismatch, expecting name: 'subject.jar' size: LinkedHashSet size: 2: [0]: 271917 [1]: 266056 manifest version: 2.2.0. However the jar detected is: /Users/shilen/Desktop/internet2/github2/grouper/lib/grouper/subject.jar, name: subject.jar size: 271917 manifest version: 2.3.0 Type help() for instructions gsh 0% obliterateStem("etc:grouperUi", true, true) Would obliterate stem: etc:grouperUi Would be done deleting group: etc:grouperUi:grouperUiUserData Would be done obliterating stem: etc:grouperUi true gsh 1%
But then if you set the property to use the new Groovy based GSH:
shilen@Shilens-MacBook-Pro-2 grouper (GRP-1553) $ ./bin/gsh.sh Using GROUPER_HOME: /Users/shilen/Desktop/internet2/github2/grouper Using GROUPER_CONF: /Users/shilen/Desktop/internet2/github2/grouper/conf Using JAVA: java using MEMORY: 64m-750m Grouper starting up: version: 2.3.0, build date: 2017/06/02 16:18:52, env: <no label configured> grouper.properties read from: /Users/shilen/Desktop/internet2/github2/grouper/conf/grouper.properties Grouper current directory is: /Users/shilen/Desktop/internet2/github2/grouper log4j.properties read from: /Users/shilen/Desktop/internet2/github2/grouper/conf/log4j.properties Grouper is logging to file: /Users/shilen/Desktop/internet2/github2/grouper/logs/grouper_error.log, at min level WARN for package: edu.internet2.middleware.grouper, based on log4j.properties grouper.hibernate.properties: /Users/shilen/Desktop/internet2/github2/grouper/conf/grouper.hibernate.properties grouper.hibernate.properties: sa@jdbc:hsqldb:hsql://localhost:9001/grouper subject.properties read from: /Users/shilen/Desktop/internet2/github2/grouper/conf/subject.properties sources.xml read from: /Users/shilen/Desktop/internet2/github2/grouper/conf/sources.xml sources configured in: sources.xml sources.xml groupersource id: g:gsa sources.xml groupersource id: grouperEntities sources.xml jdbc source id: jdbc: GrouperJdbcConnectionProvider Grouper warning: jarfile mismatch, expecting name: 'subject.jar' size: LinkedHashSet size: 2: [0]: 271917 [1]: 266056 manifest version: 2.2.0. However the jar detected is: /Users/shilen/Desktop/internet2/github2/grouper/lib/grouper/subject.jar, name: subject.jar size: 271917 manifest version: 2.3.0 Type help() for instructions Groovy Shell (2.4.11, JVM: 1.8.0_121) Type ':help' or ':h' for help. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- groovy:000> :load /Users/shilen/Desktop/internet2/github2/grouper//conf/groovysh.profile groovy:000> obliterateStem("etc:grouperUi", true, true) Would obliterate stem: etc:grouperUi Would be done deleting group: etc:grouperUi:grouperUiUserData Would be done obliterating stem: etc:grouperUi ===> true groovy:000>
(That first load command is done automatically on start up.)
Also, other parameters to gsh (e.g. -registry) would continue working as before.
And normal Java calls would continue to work as well, e.g.
groovy:000> grouperSession = GrouperSession.startRootSession() ===> 5c455cfc3511413abdb20276c45f8d7d,'GrouperSystem','application' groovy:000> new GroupSave(grouperSession).assignName("stem1:a").assignCreateParentStemsIfNotExist(true).save(); ===> Group[name=stem1:a,uuid=535a12b070e54474bf67f0e538adebe8] groovy:000>