cat /etc/passwd (last line):
I need to make an
init.d script to run Tomcat EE like
service tomee start.
So I have 2 problems:
How I can execute command (from root) as a tomee user (no bash login) ?
sudo su - tomee -c "some command"
sudo - tomee -s "/bin/bash" -c "some command"
works, but I think it looks horrible.
- As far as I said I'm going to use it it
/etc/init.d/tomeeservice bash script, and the problem here I need somehow to have
JAVA_HOMEenvirioment variable set before executing the above command. (So how it could be done if tomee user is system and doesnt have shell?)
And I also have an issue (warning) that
couldn't change dir to /home/tomee. Yes, it doesn't exist, but I created the user as a system one.
I'm using an RHEL (not the newest, so there isn't systemd). How do I run TomEE as a service on RHEL6?
[root@localhost httpd]# su tomee /usr/local/tomee-webprofile-1.7.2/bin/startup.sh [root@localhost httpd]#
And no results. Only
su - tomee -s "/bin/bash" /usr/local/tomee-webprofile-1.7.2/bin/startup.sh
works, but I don't want to see this awful
-s "/bin/bash" part.
And moreover, according to
JAVA_HOME, if I put it inside
init.d script (tomee) so it has sense for root only as
init.d scripts run as root, so there will be no
JAVA_HOME for the tomee user?
[root@localhost ~]# su tomee -s "/bin/bash" -c "echo hi"
It prints "hi" - it is OK.
[root@localhost ~]# su tomee -c "echo hi"
It prints nothing. Why?
I finally made it working with:
su -s /bin/bash $TOMCAT_USER $TOMCAT_CATALINA_SH stop
I noticed oracle db's init scripts use the same approach, so I think it's ok.
BTW, I still can't understand why we need to specify shell while we executing a
*.sh file as there is the first line where