Issue with Elasticsearch installation on CentOS

I am trying to install elasticsearch 5.2.2 in CentOS. What's unique is that I want to use the jre which is distributed with our product. We create a user say user1 and install our product. The jre is in directory say /XYZ/jre64. Now I want to install elasticsearch and make it use our jre to run.

I was able to run it with the following changes:

  1. Installed ES using the rpm distribution and installed it.
  2. Upon installation it creates a default user and group called elasticsearch
  3. I went to the /etc/init.d/elasticsearch script and changed the user to user1. I did this because elasticsearch user didn't have permission to the /XYZ/jre64 folder which was created by user1 and I didn't want to change the permission of it.
  4. Then I had to give read write permissions to the log ,config ,path folders of the elasticsearch.
  5. Ran the service and it worked.

I am overall not satisfied with the way I changed the user and then had to change the permissions of the elasticsearch specific directories.
Is there a better approach to do this? Can we specify custom user while installing the elasticsearch and not after installing and changing the permissions?

Is there a better approach to this type of installation?

Maybe you can just use the tar.gz or zip distributions?

Ok let me try it out then..