problems with order of init scripts on SLES

Dear colls,

first: I put the script (oemagent) into the dir /etc/rc.d and at the symlinks (S14oemagent) to rc3.d and rc5.d. And Reboot the box, I see at the boot.msg that the script is not startet in order of S10*, much more is it start before S10*.

S10winbind is need vor the new Script(S14oemagent), because of user verification on Windows ADS.

Script:

#!/sbin/sh
2 #
3 # DATEI: /etc/init.d/oemagent
4 # DATE : 06.08.2013
5 #
9
10 # Allowed exit values:
11 # 0 = success; causes “OK” to show up in checklist.
12 # 1 = failure; causes “FAIL” to show up in checklist.
13 # 2 = skip; causes “N/A” to show up in the checklist.
14 # Use this value if execution of this script is overridden
15 # by the use of a control variable, or if this script is not
16 # appropriate to execute for some other reason.
17 # 3 = reboot; causes the system to be rebooted after execution.
18
19 # Input and output:
20 # stdin is redirected from /dev/null
21 #
22 # stdout and stderr are redirected to the /etc/rc.log file
23 # during checklist mode, or to the console in raw mode.
24
25 ### BEGIN INIT INFO
26 # Provides: oemagent
27 # Required-Start: $network winbind
28 # Should-Start:
29 # Required-Stop: $network
30 # Should-Stop:
31 # Default-Start: 3 5
32 # Default-Stop: 0 1 2 6
33 # Short-Description: OEM Agent
34 # Description: Startet den OEM Agent
35 #
36 ### END INIT INFO
37
38 #set -vx
39 AGENT_HOME=/oem/12.1/agent_inst
40 PATH=/usr/sbin:/usr/bin:/sbin:${AGENT_HOME}/bin:/bin
41 export PATH AGENT_HOME
42
43
44 rval=0
45
46 # Check the exit value of a command run by this script. If non-zero, the
47 # exit code is echoed to the log file and the return value of this script
48 # is set to indicate failure.
49
50 # Kill the named process(es).
51 # $1=
52
53 killproc() {
54 pid=ps -e | awk '$NF~/'"$1"'/ {print $1}'
55 if [ “X$pid” != “X” ]; then
56 if kill “$pid”; then
57 echo “$1 stopped”
58 else
59 rval=1
60 echo “Unable to stop $1”
61 fi
62 fi
63 }
64
65case $1 in
67 ‘start_msg’)
68 # Emit a short message relating to running this script with
69 # the “start” argument; this message appears as part of the checklist.
70 echo “Starting ORACLE OEM-Agent”
71 ;;
72
73 ‘stop_msg’)
74 # Emit a short message relating to running this script with
75 # the “stop” argument; this message appears as part of the checklist.
76 echo “Stopping ORACLE OEM-Agent”
77 ;;
78
79 ‘start’)
80
81 # source the system configuration variables
82 #if [ -f /etc/rc.config ] ; then
83 # . /etc/rc.config
84 #else
85 # echo “ERROR: /etc/rc.config defaults file MISSING”
86 #fi
87
88 # Check to see if this script is allowed to run…
89 # wait for SLM to disconnect to port
90 echo “ORACLE OEM wird gestartet”
91 su - adm_oem -c “${AGENT_HOME}/bin/emctl start agent”
92 rval=0
93 #fi
94 ;;
95
96 ‘stop’)
97 # source the system configuration variables
98 #if [ -f /etc/rc.config ] ; then
99 # . /etc/rc.config
100 #else
101 # echo “ERROR: /etc/rc.config defaults file MISSING”
102 #fi
103
104 # Check to see if this script is allowed to run…
105 echo “SLM-Server wird jetzt gestoppt”
106 #su - adm_oem -c “${AGENT_HOME}/bin/emctl stop agent”
107
108 rval=0
109 #fi
110 ;;
111 ‘status’)
112 # source the system configuration variables
113 #if [ -f /etc/rc.config ] ; then
114 # . /etc/rc.config
115 #else
116 # echo “ERROR: /etc/rc.config defaults file MISSING”
117 #fi
118
119 # Check to see if this script is allowed to run…
120 su - adm_oem -c “${AGENT_HOME}/bin/emctl status agent”
121 rval=0
122 #fi
123 ;;
124 *)
125 echo “usage: $0 {start stop status)”
126 rval=1
127 ;;
128 esac
129
130 exit $rval

All user rights check and all symlinks.
Have any Body a Idear?

Regards
Joe

Hi Joe,

first of all: which version of SLES? SLES12, which would be using systemd, oder SLES11SP3 (or earlier)?

The following statements are assuming your running on SLES11SP3 or earlier. If this is SLES12, re-evaluate integration into systemd :slight_smile:

I put the script (oemagent) into the dir /etc/rc.d and at the symlinks (S14oemagent) to rc3.d and rc5.d.

Have you tried running “insserv oemagent” instead? That way, all dependencies are evaluated automatically and the symlinks are generated for you.

Your advantage: Other installers will run “insserv” or alike for their services, which will reorder the symlinks anyhow. By using it yourself, you can detect early where in the invocation order your script will be placed, and fix things in advance.

And Reboot the box, I see at the boot.msg that the script is not startet in order of S10*, much more is it start before S10*.

That is strange, indeed. My first guess would have been an automatic re-placement, according to my above statement - but that doesn’t match your other finding:

All user rights check and all symlinks.

I suggest to run “inserv” and check for errors and the then selected “positions” in your runlevel.

Regards,
Jens

Hi Jens,

we use SLES 11 SP2 ( planed Update asap to SP3).

I check up the inserv first, and at the LSB header.
After this insserv is clean, but the Script is not starting the oem agent, at the right time.

Hi Joe,

as you wrote that the script is invoked too early - are there by chance multiple symlinks to the oemagent script in /etc/init.d/ (more than one in a single runlevel, or both links in the final runlevel and in boot)?

As a debugging measure, how about changing the echo in line 90 to add “$0” to the output string, so that you can see by which symlink the file was invoked?

Regards,
Jens

[QUOTE=jmozdzen;26564]Hi Joe,

as you wrote that the script is invoked too early - are there by chance multiple symlinks to the oemagent script in /etc/init.d/ (more than one in a single runlevel, or both links in the final runlevel and in boot)?

As a debugging measure, how about changing the echo in line 90 to add “$0” to the output string, so that you can see by which symlink the file was invoked?

Regards,
Jens[/QUOTE]

Hi Jens,

I have $0 inserted into the oemagent scripts under /etc/rc.d and now is there an entry in boot.msg.

ORACLE OEM wird gestartet /etc/init.d/oemagent # $0
su: user adm_oem does not exist
<notice – Mar 2 11:09:18.543758000>

Any Idear?

Regards
Joe

little more info.

I delete the script under /etc/init.d. And know we’ve only one under /etc/rc.d/.
After the reboot the order is coorect, but (o.k., this is a other storie) the winbind needs more time to check the ADS Controller.

Hi Joe,

[QUOTE=jmisselbeck;26677]Hi Jens,

I have $0 inserted into the oemagent scripts under /etc/rc.d and now is there an entry in boot.msg.

ORACLE OEM wird gestartet /etc/init.d/oemagent # $0[/QUOTE]

This doesn’t help much, but

[QUOTE=jmisselbeck;26677]su: user adm_oem does not exist
<notice – Mar 2 11:09:18.543758000>[/QUOTE]
this says it all: your script tries to run the command in the “adm_oem” user context (see line 91 and “man su”)… but there is no such user.

Either adjust the script to match your setup or adjust your setup to match the script… the user given in the script needs to exists. Whether it’s that “adm_oem” or a different user, is your decision.

Regards
Jens

Solved:

Jens,

the problem was located on /etc/init.d the script here is running before rc(x).d. I deleted this and check the symlinks to rc(x).d . After this the reboot give me the right order. The Problem with the winbind auth. is also solved. A litle sleep of three seconds was good enough for the winbind process.

Thx you for help and some idears.

Joe

Hi Joe,

thank you for reporting back the final solution :slight_smile:

Regards,
Jens