Highlighted
New Member.
1823 views

How to launch mfds automatically as a Linux service

Jump to solution

I have Linux SUSE 11 SP3 with Cobol Server 2.2. When restart the server i need to change to $COBDIR/bin and execute mfds.

 

I tried launch as a service in /etc/init.d activate for level 3 and 5 of boot. It don't work.

I tried launch as a process in crontab (at reboot). It don't work.

 

Check /var/log/boot.msg

...

<notice -- Nov 17 14:17:43.782447000> mfds start
Running /etc/init.d/rc5.d/S01mfds (start)...
Done /etc/init.d/rc5.d/S01mfds
<notice -- Nov 17 14:17:44.70369000>
'mfds start' exits with status 0

...

but mfds don´t work (the port 86 web administrator show not found and the process mfds is not in the list of active process).

 

What need to start mfds automatically at reboot?

 

Please send me any suggestions.

Thanks in advance,

 

Enrique Vera.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Well, for one thing, you're not exporting COBDIR. (PATH should already be exported, though it wouldn't hurt to export it again.) Nor are you setting LD_LIBRARY_PATH, though $COBDIR/bin/mfds is actually a shell script which exports it for you.

I'm also wondering why you're including things like /usr/bin/X11 and /usr/games in PATH. That looks like you copied some other start/stop script rather than creating one specific to your needs.

And you're not capturing any output from the mfds script or the mfds32 process it will eventually execute.

And you made this an S01* script, which means it will run early in the runlevel. Possibly too early. Why are you trying to run it at that point?

(And "Micro Focus" is two words.)

I suggest renaming the script to something more reasonable like S95mfds, and rewriting it along these lines:


#!/bin/bash
# Author: your name here
#
# /etc/init.d/mfds
#
### BEGIN INIT INFO
# Provides: mfds
# Required-Start: $null
# Should-Start: $null
# Required-Stop: $null
# Should-Stop: $null
# Default-Start: 3 4 5
# Default-Stop: 3 4 5
# Short-Description: Micro Focus Directory Services.
# Description: MFDS for Web Services Cobol.
### END INIT INFO

. /etc/rc.status
rc_reset

export COBDIR=/opt/microfocus/VisualCOBOL
export PATH=$COBDIR/bin:$PATH:/bin

# log file
LOGDIR=/var/mfcobol/logs
LOGFILE=$LOGDIR/S95mfds.log
mkdir -p $LOGDIR
echo "$(date): $1" >>| $LOGFILE

case "$1" in
start)
# use colour for ease of spotting
echo -e "\E[36mRunning $0 (start)...\E[0m";
nohup $COBDIR/bin/mfds >> $LOGFILE 2>&1 &
echo -e "\E[36mDone $0 \E[0m";
;;
stop)
echo -e "\E[36mRunning $0 (stop)...\E[0m";
$COBDIR/bin/mfds -s 2 >> $LOGFILE 2>&1
echo -e "\E[36mDone $0 \E[0m";
;;
restart)
$0 stop
$0 start
rc_status
;;
*)
echo "Usage $0 (start|stop|restart)"
exit 1;
;;
esac

rc_exit
#

Untested, but give it a try. If it doesn't work, post the contents of /var/mfcobol/logs/S95mfds.log.

View solution in original post

0 Likes
4 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert
Probably you're missing something necessary in the environment, or starting MFDS under a non-privileged account. (MFDS needs to run as root in order to bind to port 86, which is a reserved port on UNIX/Linux systems.)

If you provided the contents of S01mfds, we might be able to guess what the problem is.
0 Likes
Highlighted
New Member.
Michael,

The contents of S01mfds is:

#!/bin/bash
# Author: your name here
#
# /etc/init.d/mfds
#
### BEGIN INIT INFO
# Provides: mfds
# Required-Start: $null
# Should-Start: $null
# Required-Stop: $null
# Should-Stop: $null
# Default-Start: 3 4 5
# Default-Stop: 3 4 5
# Short-Description: Microfocus Directory Services.
# Description: MFDS for Web Services Cobol.
### END INIT INFO

. /etc/rc.status
rc_reset

COBDIR=/opt/microfocus/VisualCOBOL
PATH=/opt/microfocus/VisualCOBOL/bin:/sbin:/usr/sbin:/usr/local/sbin:/root/bi
n:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/li
b/mit/bin:/usr/lib/mit/sbin

case "$1" in
start)
# use colour for ease of spotting
echo -e "\E[36mRunning $0 (start)...\E[0m";
nohup /opt/microfocus/VisualCOBOL/bin/mfds &
echo -e "\E[36mDone $0 \E[0m";
;;
stop)

echo -e "\E[36mRunning $0 (stop)...\E[0m";
/opt/microfocus/VisualCOBOL/bin/mfds -s 2
echo -e "\E[36mDone $0 \E[0m";
;;
restart)
$0 stop
$0 start
rc_status
;;
*)
echo "Usage $0 (start|stop|restart)"
exit 1;
;;
esac

rc_exit
#
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Well, for one thing, you're not exporting COBDIR. (PATH should already be exported, though it wouldn't hurt to export it again.) Nor are you setting LD_LIBRARY_PATH, though $COBDIR/bin/mfds is actually a shell script which exports it for you.

I'm also wondering why you're including things like /usr/bin/X11 and /usr/games in PATH. That looks like you copied some other start/stop script rather than creating one specific to your needs.

And you're not capturing any output from the mfds script or the mfds32 process it will eventually execute.

And you made this an S01* script, which means it will run early in the runlevel. Possibly too early. Why are you trying to run it at that point?

(And "Micro Focus" is two words.)

I suggest renaming the script to something more reasonable like S95mfds, and rewriting it along these lines:


#!/bin/bash
# Author: your name here
#
# /etc/init.d/mfds
#
### BEGIN INIT INFO
# Provides: mfds
# Required-Start: $null
# Should-Start: $null
# Required-Stop: $null
# Should-Stop: $null
# Default-Start: 3 4 5
# Default-Stop: 3 4 5
# Short-Description: Micro Focus Directory Services.
# Description: MFDS for Web Services Cobol.
### END INIT INFO

. /etc/rc.status
rc_reset

export COBDIR=/opt/microfocus/VisualCOBOL
export PATH=$COBDIR/bin:$PATH:/bin

# log file
LOGDIR=/var/mfcobol/logs
LOGFILE=$LOGDIR/S95mfds.log
mkdir -p $LOGDIR
echo "$(date): $1" >>| $LOGFILE

case "$1" in
start)
# use colour for ease of spotting
echo -e "\E[36mRunning $0 (start)...\E[0m";
nohup $COBDIR/bin/mfds >> $LOGFILE 2>&1 &
echo -e "\E[36mDone $0 \E[0m";
;;
stop)
echo -e "\E[36mRunning $0 (stop)...\E[0m";
$COBDIR/bin/mfds -s 2 >> $LOGFILE 2>&1
echo -e "\E[36mDone $0 \E[0m";
;;
restart)
$0 stop
$0 start
rc_status
;;
*)
echo "Usage $0 (start|stop|restart)"
exit 1;
;;
esac

rc_exit
#

Untested, but give it a try. If it doesn't work, post the contents of /var/mfcobol/logs/S95mfds.log.

View solution in original post

0 Likes
Highlighted
New Member.
Michael,

My previous script is "under construction", i copied the PATH (and other environment variables) and use for trial-and-error approach because lack of documentation about this topic (launch mfds as a Linux service). The use of S01 is because initially use S95 without sucess, so change it run early for test conflict with other service.

The good news: the script run fine, with a minor change: the line
echo "$(date): $1" >>| $LOGFILE
don't need the |, so the correct line is:
echo "$(date): $1" >> $LOGFILE

Thanks so much,

Enrique.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.