Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a service installed to start jasper reporting server on boot. I believe it is correctly setup.

here is the startup script placed in /etc/init.d/jasperserver

#!/bin/sh
### BEGIN INIT INFO
# Provides:          jasperserver
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start JasperServer at boot time
# Description:       Enable service provided by JasperServer.
### END INIT INFO

JASPER_HOME="/opt/jaspersoft/jasperreports-server-5.5"

case "$1" in
  start)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      echo "Starting JasperServer"
      sudo -u ec2-user $JASPER_HOME/ctlscript.sh start
    fi
    ;;
  stop)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      echo "Stopping JasperServer"
      sudo -u ec2-user $JASPER_HOME/ctlscript.sh stop

    fi
    ;;
  restart)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      echo "Restarting JasperServer"
      sudo -u ec2-user $JASPER_HOME/ctlscript.sh restart
    fi
    ;;
  status)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      sudo -u ec2-user $JASPER_HOME/ctlscript.sh status
    fi
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac

Also, I run the command

sudo chmod +x /etc/init.d/jasperserver

I then have run the commands

sudo chkconfig --add jasperserver
sudo chkconfig jasperserver on

If I run:

chkconfig --list  | grep jasper

I see:

jasperserver    0:off   1:off   2:on    3:on    4:on    5:on    6:off

I can also run:

sudo service jasperserver (start|stop|restart) 

successfully

However when I issue a reboot, the service isn't running. I wondered if there's a way I can get logging information or enable logging to be able to tackle this.


More detail

uname -a
Linux jaspersoft.localdomain 3.10.42-52.145.amzn1.x86_64 #1 SMP Tue Jun 10 23:46:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Also after adding the line:

# chkconfig: 2345 70 30

the symlinks are as follows:

[ec2-user@jaspersoft ~]$ ls -laF /etc/rc.d/rc3.d/*jasper*
lrwxrwxrwx 1 root root 22 Aug  6 08:09 /etc/rc.d/rc3.d/S70jasperserver -> ../init.d/jasperserver*

and likewise for /etc/rc.d/rc[2-5].d/jasper

share|improve this question
1  
it can be util if you say your centos version, anyway are you sure you don't have nothing in your log? –  c4f4t0r Aug 6 at 7:50

3 Answers 3

I don't see a # chkconfig: - 30 60 line in your start-up script mandating the order number in the startup sequence (30) or shutdown (60) sequence.

What symlinks are being set up in /etc/rc[0-6].d/ for your service?

IIRC when none is defined prio 50 is used. That could result in trying to start your service before other dependancies have been started.

share|improve this answer

A stock CentOS installation will typically have Defaults requiretty set in /etc/sudoers. This will cause sudo -u $user $command to fail inside an init script on startup, as the script isn't necessarily running in a "complete" tty.

Usefully, CentOS provides a common init functions file (/etc/rc.d/init.d/functions) that contains the daemon function - a wrapper for running programs with different options (e.g., user, nice, pid files, etc.).

Try modifying your script as follows:

# Source function library.
. /etc/rc.d/init.d/functions

...

  start)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      echo "Starting JasperServer"
      daemon --user $JASPER_USER $JASPER_HOME/ctlscript.sh start
    fi
  ;;

This will use runuser -s /bin/bash $user to create a shell with the correct permissions in order to run the command, neatly avoiding any environment-meddling or security issues with su or sudo.

share|improve this answer

I have found a solution and I believe the issue is regarding this line:

sudo -u ec2-user ....

This is the new script:

#!/bin/sh

# chkconfig: 2345 96 14
#
# Start/Stop of JasperReports Server
#

JASPER_HOME="/opt/jaspersoft/jasperreports-server-5.5"

JASPER_USER=ec2-user


case "$1" in
  start)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      echo "Starting JasperServer"
      su $JASPER_USER -c "$JASPER_HOME/ctlscript.sh start"
    fi
    ;;
  stop)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      echo "Stopping JasperServer"
      su $JASPER_USER -c "$JASPER_HOME/ctlscript.sh stop"
    fi
    ;;
  restart)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      echo "Restarting JasperServer"
      su $JASPER_USER -c "$JASPER_HOME/ctlscript.sh restart"
    fi
    ;;
  status)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      su $JASPER_USER -c "$JASPER_HOME/ctlscript.sh status"
    fi
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.