0

We have this problem where people start the tomcat server as root and that causes start up issues. We have a script and want to force system admins to start tomcat using the script which starts tomcat as webuser.

Can I modify catalina.sh or through any other mechanism for tomcat to fail at startup if the user is any other than webuser ?

Craig Watson
  • 9,575
  • 3
  • 32
  • 47
skillguru
  • 113
  • 4

1 Answers1

3

You can use something like this within a wrapper script that calls catalina.sh, so that future upgrades of Tomcat will not overwrite your changes.

if [ "$(whoami)" != "webuser" ]; then
  echo "Please start this process as 'webuser'" >&2
  exit 1
fi
Craig Watson
  • 9,575
  • 3
  • 32
  • 47
  • +1 but do you have any suggestions on how to deal with your modified catalina.sh getting overwritten by updates of tomcat? – fvu Jul 06 '16 at 17:58
  • @fvu - not specifically, which is why I also mentioned that you can use the above snippet in a script which wraps `catalina.sh` - I'll edit to make it clear that this is the preferred option though – Craig Watson Jul 06 '16 at 18:00
  • I added this script to my etenv,sh which is used to inject application variables and jvm settings – skillguru Jul 06 '16 at 20:12