I am trying to start OpenFire and I only have sudo access to root. It seems impossible to start OpenFire with sudo.
First I tried to just start with /etc/init.d/openfire start
isdmjp/:98> /etc/init.d/openfire start
/etc/init.d/openfire must be run as root
ok, easy enough just sudo:
isdmjp/:96> sudo /etc/init.d/openfire start
Starting openfire: sh: /opt/openfire/logs/nohup.out: Permission denied
It seems to fail to start because it can’t write to the nohup.out file.
So how do I start this thing? Note that even our system admins only have sudo access to root. Only our hardware people have true root access (crazy I know!).
I was able to start it with ./bin/openfire.sh
However, I need this to run in the background and start if the box would reboot.
What would be real nice is if could start with an Upstart script.
Ok, solved my own problem. I was able to get it to start with a simple Upstart script:
description “OpenFire”
start on started network-up or fastrespawn-restart
stop on runlevel [!2345]
respawn
respawn limit 10 5
exec /bin/su - userToRunAs -c “/opt/openfire/bin/openfire.sh” > /dev/null
On CentOS 6.5 with latest OpenFire, your script didn’t work as described. However, I was able to modify it to function based on stuff from the /etc/init.d script + its behavior on trying to start itself a bunch of times. Your solution did help in that its the first one that got me in the right direction.
Edit; alternative version added: been having trouble stopping the service. “Fork” appears needed to prevent constant respawn, but a stuck fork may mean a reboot to allow proper restarting of the job.
========
description “OpenFire”
env OPENFIRE_HOME="/opt/openfire"
env OPENFIRE_USER=jive
start on runlevel [2345]
stop on runlevel [!2345]
expect fork
respawn
exec /bin/su - $OPENFIRE_USER -c “/opt/openfire/bin/openfire start” > /dev/null
post-stop exec sleep 10
=========
description “OpenFire”
env OPENFIRE_HOME="/opt/openfire"
env OPENFIRE_USER=jive
start on runlevel [2345]
stop on runlevel [!2345]
expect fork
respawn
exec /bin/su - $OPENFIRE_USER -c “/opt/openfire/bin/openfire start” > /dev/null
pre-stop exec /bin/su - $OPENFIRE_USER -c “/opt/openfire/bin/openfire stop” > /dev/null
post-stop exec sleep 5
Our servers are RHEL 6 which uses Upstart 0.6.x which is ancient (as of right now current version is 1.12.1). So I have no doubt my Upstart script might not work on newer versions, I should have mentioned this in my post. Glad you posted one that works on newer version to help searchers out.
Personally I despise Upstart, IMHO it is a solution looking for a problem. inittab worked just fine for me for many years. We have tons of problems with Upstart.
(nods) Upstart is a mix of elegant and not. Its waaaay less verbose than an init.d script, but the version differences and documentation quirks do not make it easy to adopt. I haven’t had a chance to look at systemd yet, but that seems to be where init+upstart role is going to now.