Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Help with creating Init Script
New Posts  All Forums:Forum Nav:

Help with creating Init Script - Page 2

post #11 of 17
Thread Starter 
Quote:
Originally Posted by Plan9 View Post

Can you post the contents of bliss.sh. It looks like the script is just calling a java app that either daemonising itself or by bliss.sh. So you may not need to be daemonishing bliss.sh as well.

What's more, since bliss.sh is exiting, it means your init.d script cannot get it's PID, which is why your init.d script isn't working properly.

Fixing the init.d script would be very easy though. But I just want to check how bliss.sh works first.
bliss.sh (Click to show)
Code:
[root@media ~]# cat /var/bliss/bin/bliss.sh
#!/bin/bash
#
# Shell script to run bliss

INSTALL_HOME=`dirname "$0"`/..

JAVA_EXEC=java
if [ -e "${JAVA_HOME}" ]
then
JAVA_EXEC=${JAVA_HOME}/bin/java
fi

if [ -z "${BLISS_MAX_HEAP}" ]
then
BLISS_MAX_HEAP=128M
fi

exec ${JAVA_EXEC} ${VMARGS} -Xmx${BLISS_MAX_HEAP} -splash:bliss-splash.png -XX:H
eapDumpPath=/tmp -XX:+HeapDumpOnOutOfMemoryError -XX:+CMSClassUnloadingEnabled -
Djava.awt.headless=true -Djava.util.logging.config.file=${INSTALL_HOME}/conf/log
ging.properties -Djava.library.path=${INSTALL_HOME}/lib -Dbliss.periodicHeapDump
Threshold=0.9 -Dorg.osgi.framework.storage=${INSTALL_HOME}/felix-cache -Dfelix.a
uto.deploy.dir=${INSTALL_HOME}/bundle -Dbliss.bootstrapbundle.initialbundledir=$
{INSTALL_HOME}/bliss-bundle -Dbliss.launcher="$0" -jar ${INSTALL_HOME}/bin/felix
.jar "$@"
[root@media ~]#

Yeah, looks like it just calls a jar with variables. I assume the smart thing would be to have the init script call the jar directly?
post #12 of 17
Quote:
Originally Posted by tycoonbob View Post

bliss.sh (Click to show)
Code:
[root@media ~]# cat /var/bliss/bin/bliss.sh
#!/bin/bash
#
# Shell script to run bliss

INSTALL_HOME=`dirname "$0"`/..

JAVA_EXEC=java
if [ -e "${JAVA_HOME}" ]
then
JAVA_EXEC=${JAVA_HOME}/bin/java
fi

if [ -z "${BLISS_MAX_HEAP}" ]
then
BLISS_MAX_HEAP=128M
fi

exec ${JAVA_EXEC} ${VMARGS} -Xmx${BLISS_MAX_HEAP} -splash:bliss-splash.png -XX:H
eapDumpPath=/tmp -XX:+HeapDumpOnOutOfMemoryError -XX:+CMSClassUnloadingEnabled -
Djava.awt.headless=true -Djava.util.logging.config.file=${INSTALL_HOME}/conf/log
ging.properties -Djava.library.path=${INSTALL_HOME}/lib -Dbliss.periodicHeapDump
Threshold=0.9 -Dorg.osgi.framework.storage=${INSTALL_HOME}/felix-cache -Dfelix.a
uto.deploy.dir=${INSTALL_HOME}/bundle -Dbliss.bootstrapbundle.initialbundledir=$
{INSTALL_HOME}/bliss-bundle -Dbliss.launcher="$0" -jar ${INSTALL_HOME}/bin/felix
.jar "$@"
[root@media ~]#

Yeah, looks like it just calls a jar with variables. I assume the smart thing would be to have the init script call the jar directly?

yes and no. Normally that should go in your init file, but we wont on this occasion because it will make it easier to keep bliss up to date (ie you don't have to manually edit the init file each time - just pull bliss.sh which presumably comes as part of the package)

My earlier code just calls bliss.sh
post #13 of 17
Thread Starter 
Quote:
Originally Posted by Plan9 View Post

yes and no. Normally that should go in your init file, but we wont on this occasion because it will make it easier to keep bliss up to date (ie you don't have to manually edit the init file each time - just pull bliss.sh which presumably comes as part of the package)

My earlier code just calls bliss.sh

Yes, bliss.sh comes from the package. Alright, I'm going to give your init script a try and see what happens!
post #14 of 17
Thread Starter 
So your init script works with starting and stopping (haven't tried restarting yet). Starting does work, but it reports back failed:
Code:
[root@media ~]# /etc/init.d/bliss start
Starting bliss:         /etc/init.d/bliss: line 52: [: missing `]'
[FAILED]

Yet it does start.
post #15 of 17
Quote:
Originally Posted by tycoonbob View Post

So your init script works with starting and stopping (haven't tried restarting yet). Starting does work, but it reports back failed:
Code:
[root@media ~]# /etc/init.d/bliss start
Starting bliss:         /etc/init.d/bliss: line 52: [: missing `]'
[FAILED]

Yet it does start.
Yeah, the daemon is kicked off in line 48. line 52 onwards is checking to see if it shows up in the process list so it knows whether to return a successful status or not

try changing line 52 to read:
Code:
while [ "$i" -le 5 ]; do

Even after years of writing shell scripts, I still struggle with the format of conditionals. Sometimes you use double brackets, sometimes you use quotations, sometimes conditionals are prefixed with a hyphen, and sometimes non of those rules apply. I can never remember which format to follow and when.
post #16 of 17
Thread Starter 
Quote:
Originally Posted by Plan9 View Post

Yeah, the daemon is kicked off in line 48. line 52 onwards is checking to see if it shows up in the process list so it knows whether to return a successful status or not

try changing line 52 to read:
Code:
while [ "$i" -le 5 ]; do

Even after years of writing shell scripts, I still struggle with the format of conditionals. Sometimes you use double brackets, sometimes you use quotations, sometimes conditionals are prefixed with a hyphen, and sometimes non of those rules apply. I can never remember which format to follow and when.

That did the trick!
post #17 of 17
excellent
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Help with creating Init Script