LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Closed Thread
 
Search this Thread
Old 10-24-2005, 06:41 AM   #1
shahrokhnikou
LQ Newbie
 
Registered: Jul 2005
Location: Finland
Posts: 11

Rep: Reputation: Disabled
Initscript


Can you please lead me, How can I write my own initscript in linux?
I'm very very new in Linux.


Regards,
 
Old 10-24-2005, 07:11 AM   #2
Keruskerfuerst
Member
 
Registered: Oct 2005
Location: Lat: 482356N, Lon: 104145E
Distribution: Gentoo 2006
Posts: 719

Rep: Reputation: 31
Hello!

1. You have to choose your interpreter: usually sh or bash.
->#!/bin/sh or #!/bin/bash

2. A good choice is to have a look in the booscripts placed in /etc/init.d/rcx.d (x=1,2,3,4,5).

Greetings
 
Old 10-24-2005, 08:06 AM   #3
shahrokhnikou
LQ Newbie
 
Registered: Jul 2005
Location: Finland
Posts: 11

Original Poster
Rep: Reputation: Disabled
Hi again,

I've looked at /ect/rc3.d scripts, But my problem is I don't know how to write my own script for one my program to run (Weblogic admin server). Can you help in this regards?

Thanx,
Shahrokh
 
Old 10-24-2005, 09:14 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,969

Rep: Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343
You can just create a symlink, line this:
Code:
ln -s /path/to/startWebLogic.sh /etc/rc3.d/S90startWebLogic
 
Old 10-24-2005, 09:35 AM   #5
shahrokhnikou
LQ Newbie
 
Registered: Jul 2005
Location: Finland
Posts: 11

Original Poster
Rep: Reputation: Disabled
Hi,
Thank you for your reply. But you know what? If I create a symlink it won't start adminserver, and problem is that on that script I have no start or stop, That's why I think I need to write a new script for it which I have no idea how to do that, Once I tried to use to command in order to run it, But it failed
and here is the original script from startWebLogic.sh
===========================================

#!/bin/sh

# WARNING: This file is created by the Configuration Wizard.
# Any changes to this script may be lost when adding extensions to this configur
ation.

# *************************************************************************
# This script is used to start WebLogic Server for the domain in the
# current working directory. This script simply sets the SERVER_NAME
# variable and starts server.
#
# To create your own start script for your domain, all you need to set is
# SERVER_NAME, then starts the server.
#
# Other variables that startWLS takes are:
#
# WLS_USER - cleartext user for server startup
# WLS_PW - cleartext password for server startup
# PRODUCTION_MODE - true for production mode servers, false for
# development mode
# JAVA_OPTIONS - Java command-line options for running the server. (These
# will be tagged on to the end of the JAVA_VM and MEM_ARGS)
# JAVA_VM - The java arg specifying the VM to run. (i.e. -server,
# -hotspot, etc.)
# MEM_ARGS - The variable to override the standard memory arguments
# passed to java
#
# For additional information, refer to the WebLogic Server Administration
# Console Online Help(http://e-docs.bea.com/wls/docs81/Con.../startstop.htm
l)
# *************************************************************************

# Initialize the common environment.

WL_HOME="/opt/bea/weblogic81"

PRODUCTION_MODE=""

JAVA_VENDOR="BEA"

JAVA_HOME="/opt/bea/jrockit81sp4_142_05"

# Call commEnv here AFTER setting the java_vendor to get common environmental se
ttings.

. ${WL_HOME}/common/bin/commEnv.sh

# Set SERVER_NAME to the name of the server you wish to start up.

SERVER_NAME="TunteellinenServeri"

CLASSPATH="${WEBLOGIC_CLASSPATH}:${POINTBASE_CLASSPATH}:${JAVA_HOME}/jre/lib/rt.jar:${WL_HOME}/server/lib/webservices.jar:${CLASSPATH}"
export CLASSPATH

# Call WebLogic Server

echo "."
echo "CLASSPATH=${CLASSPATH}"
echo "."
echo "PATH=${PATH}"
echo "."
echo "***************************************************"
echo "* To start WebLogic Server, use a username and *"
echo "* password assigned to an admin-level user. For *"
echo "* server administration, use the WebLogic Server *"
echo "* console at http://[hostname]:[port]/console *"
echo "***************************************************"

${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} -Dweblogic.Name=${SERVER_NAME} -Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} -Djava.securi
ty.policy="${WL_HOME}/server/lib/weblogic.policy" weblogic.Server
 
Old 10-24-2005, 09:51 AM   #6
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,969

Rep: Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343
OK my mistake. It should be:
Code:
ln -s /path/to/startWebLogic.sh /etc/init.d/rc3.d/S90startWebLogic
It does not need the "start" and "stop" options.
 
Old 10-24-2005, 01:13 PM   #7
shahrokhnikou
LQ Newbie
 
Registered: Jul 2005
Location: Finland
Posts: 11

Original Poster
Rep: Reputation: Disabled
Hi,

I did exactly what you said.
I made a symlink to


ln -s /opt/bea/domains/admin/startWebLogic.sh /etc/init.d/rc3.d/S90startWebLogic

And the I rebooted my server, But When I check my adminserver was not running. I did get my server run when I entered manually this command:

./startWebLogic.sh


What do you think, Do you have any suggestion?

Regards,
Shahrokh
 
Old 10-24-2005, 04:07 PM   #8
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,452

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
What you need to do is, "when in Rome, do as the Romans do." That means...

(1) Look at the existing symbolic-links in /etc/rc.d/rc?.d and note where the scripts are located. Put your script in the same place, say /etc/init.d.

(2) Look at the existing initscripts on your system. Pick one and copy it, choosing an appropriate new name, keeping the same naming convention that they used. Observe the permissions that are set upon the file, and who owns it. Do the same.

(3) Strip the existing text out of the copied script and paste your existing logic into it, perhaps as a function at the top of the script. Follow the existing pattern of expecting to receive a start, stop, status parameter, and of dealing with unexpected parameters in a sensible way.

(4) Now you should be able to start or stop the service, i.e. test it all out, by using an existing command such as /sbin/service servicename start. This basically invokes the appropriate initscript.

(5) Be sure to document all of what you are doing! Put comments in your code, right now as you write it, so that you or someone else can easily remember what you did, when you did it, and why you did it.
 
Old 10-24-2005, 04:23 PM   #9
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php

http://www.linuxquestions.org/questi...hreadid=376302
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Top initscript shahrokhnikou Programming 2 10-25-2005 09:54 AM
Initscript shahrokhnikou Linux - General 3 10-24-2005 08:40 AM
My sound module (snd-mia) works, but without manually restarting the initscript... jacksonscottsly Linux - Hardware 0 07-31-2005 09:19 AM


All times are GMT -5. The time now is 08:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration