annotate tomcat/createTomcatAdmin.sh @ 7:72f33ca6aa5b

add admin password and custom CATALINA_OPS
author smith@nwoca.org
date Mon, 14 Sep 2015 13:06:10 +0100
parents
children
rev   line source
7
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
1 if [ -f /.tomcat_admin_created ]; then
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
2 echo "Tomcat 'admin' user already created"
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
3 exit 0
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
4 fi
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
5
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
6 #generate password
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
7 PASS=$(TOMCAT_PASS: date | md5sum | head -c10)
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
8 _word=$( [ ${TOMCAT_PASS} ] && echo "preset" || echo "random" )
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
9
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
10 echo "=> Creating and admin user with a ${_word} password in Tomcat"
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
11 sed -i -r 's/<\/tomcat-users>//' ${CATALINA_HOME}/conf/tomcat-users.xml
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
12 echo '<role rolename="manager-gui"/>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
13 echo '<role rolename="manager-script"/>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
14 echo '<role rolename="manager-jmx"/>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
15 echo '<role rolename="admin-gui"/>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
16 echo '<role rolename="admin-script"/>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
17 echo "<user username=\"admin\" password=\"${PASS}\" roles=\"manager-gui,manager-script,manager-jmx,admin-gui, admin-script\"/>" >> ${CATALINA_HOME}/conf/tomcat-users.xml
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
18 echo '</tomcat-users>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
19 echo "=> Done!"
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
20 touch /.tomcat_admin_created
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
21
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
22 echo "========================================================================"
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
23 echo "You can now configure to this Tomcat server using:"
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
24 echo ""
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
25 echo " admin:${PASS}"
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
26 echo ""
72f33ca6aa5b add admin password and custom CATALINA_OPS
smith@nwoca.org
parents:
diff changeset
27 echo "========================================================================"