-
Notifications
You must be signed in to change notification settings - Fork 25
Ispn 8062/accept or generate password #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cd6ea54
190161b
e3580bc
014c776
123abcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| .idea | ||
| *.iml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,8 @@ | |
|
|
||
| # S2I build scripts do not override Docker Entrypoints (see https://github.com/openshift/source-to-image/issues/475#issuecomment-215891632), | ||
| # thus we need to check whether or not we are running a build or a standard container. | ||
| echo "Entry point arguments: $@" | ||
| # This line is commented intentionally, it is very useful for debugging. | ||
| # echo "Entry point arguments: $@" | ||
| if [[ $@ == *"/usr/local/s2i/bin/assemble"* ]] | ||
| then | ||
| echo "---> Performing S2I build... Skipping server startup" | ||
|
|
@@ -12,12 +13,124 @@ fi | |
|
|
||
| set -e | ||
|
|
||
| is_not_empty() { | ||
| local var=$1 | ||
| [[ -n $var ]] | ||
| } | ||
|
|
||
| generate_user_or_password() { | ||
| echo $(tr -cd '[:alnum:]' < /dev/urandom | fold -w10 | head -n1) | ||
| } | ||
|
|
||
| addMgmtUser() { | ||
| $SERVER/bin/add-user.sh -u $MGMT_USER -p $MGMT_PASS | ||
| local usr=$MGMT_USER | ||
| local pass=$MGMT_PASS | ||
|
|
||
| if is_not_empty $usr && is_not_empty $pass; then | ||
| $SERVER/bin/add-user.sh -u $usr -p $pass | ||
| else | ||
| usr=$(generate_user_or_password) | ||
| pass=$(generate_user_or_password) | ||
| echo "######################################################################################" | ||
| echo "# Using domain mode but no management user and/or password provided. #" | ||
| echo "# Management user and password has been generated. #" | ||
| echo "# Management user: $usr #" | ||
| echo "# Management password: $pass #" | ||
| echo "# #" | ||
| echo "# You can provide management user and password details via environment variables. #" | ||
| echo "# #" | ||
| echo "# Docker run example: #" | ||
| echo "# docker run ... -e \"MGMT_USER=user\" -e \"MGMT_PASS=changeme\" ... #" | ||
| echo "# #" | ||
| echo "# Dockerfile example: #" | ||
| echo "# ENV MGMT_USER admin #" | ||
| echo "# ENV MGMT_PASS admin #" | ||
| echo "# #" | ||
| echo "# Kubernetes Example: #" | ||
| echo "# spec: #" | ||
| echo "# containers: #" | ||
| echo "# - args: #" | ||
| echo "# image: jboss/infinispan-server:... #" | ||
| echo "# ... #" | ||
| echo "# env: #" | ||
| echo "# - name: MGMT_USER #" | ||
| echo "# value: admin #" | ||
| echo "# - name: MGMT_PASS #" | ||
| echo "# value: admin #" | ||
| echo "# #" | ||
| echo "# OpenShift client example: #" | ||
| echo "# oc new-app ... -e MGMT_USER=user -e MGMT_PASS=changeme ... #" | ||
| echo "######################################################################################" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we skip the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually left it as is. I think it has some value. Besides we can remove it whenever we want without breaking any backwards compatibility. Let's also ask original author, @galderz, what to do with that.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine either way. I thought it could be useful, but happy to remove it if its too noisy/big. |
||
| $SERVER/bin/add-user.sh -u $usr -p $pass | ||
| fi | ||
| } | ||
|
|
||
| addAppUser() { | ||
| $SERVER/bin/add-user.sh -a -u $APP_USER -p $APP_PASS | ||
| local usr=$APP_USER | ||
| local pass=$APP_PASS | ||
| local roles=$APP_ROLES | ||
|
|
||
| if is_not_empty $usr && is_not_empty $pass; then | ||
| if is_not_empty $roles; then | ||
| $SERVER/bin/add-user.sh -a -u $usr -p $pass -g $roles | ||
| else | ||
| $SERVER/bin/add-user.sh -a -u $usr -p $pass | ||
| fi | ||
| else | ||
| usr=$(generate_user_or_password) | ||
| pass=$(generate_user_or_password) | ||
| echo "######################################################################################" | ||
| echo "# No application user and/or password provided. #" | ||
| echo "# Application user and password has been generated. #" | ||
| echo "# Application user: $usr #" | ||
| echo "# Application password: $pass #" | ||
| echo "# #" | ||
| echo "# You can provide application user and password details via environment variables. #" | ||
| echo "# #" | ||
| echo "# Docker run example: #" | ||
| echo "# docker run ... -e APP_USER=user -e APP_PASS=changeme #" | ||
| echo "# #" | ||
| echo "# Dockerfile example: #" | ||
| echo "# ENV APP_USER user #" | ||
| echo "# ENV APP_PASS changeme #" | ||
| echo "# #" | ||
| echo "# Kubernetes example: #" | ||
| echo "# spec: #" | ||
| echo "# containers: #" | ||
| echo "# - args: #" | ||
| echo "# image: jboss/infinispan-server:... #" | ||
| echo "# ... #" | ||
| echo "# env: #" | ||
| echo "# - name: APP_USER #" | ||
| echo "# value: user #" | ||
| echo "# - name: APP_PASS #" | ||
| echo "# value: changeme #" | ||
| echo "# #" | ||
| echo "# OpenShift client example: #" | ||
| echo "# oc new-app ... -e APP_USER=user -e APP_PASS=changeme ... #" | ||
| echo "######################################################################################" | ||
| $SERVER/bin/add-user.sh -a -u $usr -p $pass | ||
| fi | ||
| } | ||
|
|
||
| checkIfUserExistsForDomainMode() { | ||
| local usr=$MGMT_USER | ||
| local pass=$MGMT_PASS | ||
|
|
||
| if [ "$RUN_TYPE" != "STANDALONE" ] | ||
| then | ||
| if [ "x$usr" = "x" ] | ||
| then | ||
| echo "Specifying management user is required for domain mode" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "x$pass" = "x" ] | ||
| then | ||
| echo "Specifying management password is required for domain mode" | ||
| exit 1 | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
| # Based on https://github.com/fabric8io-images/run-java-sh/blob/master/fish-pepper/run-java-sh/fp-files/container-limits | ||
|
|
@@ -72,11 +185,9 @@ SERVER_CONFIGURATION="clustered.xml" | |
| JAVA_OPTS="-Xms64m -Djava.net.preferIPv4Stack=true" | ||
| PERCENT_OF_MEMORY_FOR_MX=70 | ||
|
|
||
| addAppUser | ||
|
|
||
| for i in "$@" | ||
| do | ||
| case $i in | ||
| case $1 in | ||
| domain-controller) | ||
| RUN_TYPE='DOMAIN_CONTROLLER' | ||
| shift | ||
|
|
@@ -98,6 +209,10 @@ case $i in | |
| echo "# docker-entrypoint.sh host-controller [-n|--no-container-settings] [other options] #" | ||
| echo "# Starts a default standalone Server #" | ||
| echo "# -n|--no-container-settings omits memory and CPU settings for container mode #" | ||
| echo "# docker-entrypoint.sh -ap pass -au user [-ar roles] [other options] #" | ||
| echo "# Creates application user with specified password and roles #" | ||
| echo "# docker-entrypoint.sh -mp pass -mu user [other options] #" | ||
| echo "# Creates management user with specified password #" | ||
| echo "# #" | ||
| echo "# Examples: #" | ||
| echo "# docker-entrypoint.sh -c clustered.xml -Djboss.default.jgroups.stack=kubernetes #" | ||
|
|
@@ -111,27 +226,60 @@ case $i in | |
| CONTAINER_SETTINGS="false" | ||
| shift | ||
| ;; | ||
| -au|--application-user) | ||
| shift | ||
| APP_USER="$1" | ||
| shift | ||
| ;; | ||
| -ap|--application-password) | ||
| shift | ||
| APP_PASS="$1" | ||
| shift | ||
| ;; | ||
| -ar|--application-roles) | ||
| shift | ||
| APP_ROLES="$1" | ||
| shift | ||
| ;; | ||
| -mu|--management-user) | ||
| shift | ||
| MGMT_USER="$1" | ||
| shift | ||
| ;; | ||
| -mp|--management-password) | ||
| shift | ||
| MGMT_PASS="$1" | ||
| shift | ||
| ;; | ||
| -c) | ||
| # -c configuration.xml, so we need to shift the -c | ||
| shift | ||
| SERVER_OPTIONS="-c $1" | ||
| # -c configuration.xml, so we need to shift the -c | ||
| shift | ||
| SERVER_OPTIONS="-c $1" | ||
| shift | ||
| ;; | ||
| *) | ||
| if [ -f "$SERVER/standalone/configuration/$i.xml" ] | ||
| then | ||
| SERVER_CONFIGURATION="$i.xml" | ||
| elif [ -f "$SERVER/standalone/configuration/$i" ] | ||
| if [ -z "$1" ] | ||
| then | ||
| SERVER_CONFIGURATION="$i" | ||
| break | ||
| else | ||
| SERVER_OPTIONS="$SERVER_OPTIONS $i" | ||
| if [ -f "$SERVER/standalone/configuration/$1.xml" ] | ||
| then | ||
| SERVER_CONFIGURATION="$1.xml" | ||
| elif [ -f "$SERVER/standalone/configuration/$1" ] | ||
| then | ||
| SERVER_CONFIGURATION="$1" | ||
| else | ||
| SERVER_OPTIONS="$SERVER_OPTIONS $1" | ||
| fi | ||
| fi | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| checkIfUserExistsForDomainMode | ||
| addAppUser | ||
| addMgmtUser | ||
|
|
||
| if [ "$CONTAINER_SETTINGS" == "true" ] | ||
| then | ||
|
|
@@ -157,7 +305,6 @@ fi | |
|
|
||
| if [ "$RUN_TYPE" = "DOMAIN_CONTROLLER" ] | ||
| then | ||
| addMgmtUser | ||
| LAUNCHER=$SERVER/bin/domain.sh | ||
| exec $LAUNCHER --host-config host-master.xml $BIND_OPTS $SERVER_OPTIONS | ||
| elif [ "$RUN_TYPE" == "HOST_CONTROLLER" ] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running domain mode without setting a password now gives an exception:
We should:
-e "MGMT_USER=...." -e "MGMT_PASS=..."when using domain mode (and don't use auto-generation, nor print the banner)