Hi Ramesh,
thanks for pointing out, I'll update and will move the removing of the
$lockfile_inprogress up to:
+ touch "$lockfile_inprogress"
+ start_daemon $binary $args
+ RETVAL=$?
+ rm -f "$lockfile_inprogress"
+ if [ $RETVAL -eq 0 ]; then
/BR HansN
On 01/04/2017 11:40 AM, ramesh betham wrote:
> Minor comments on top of Anders comments.
>
> * Typo correction: logger -t $osafprog "opensafd start/stop already
> in progress. Unable to *contiune*
>
> * Also there might be the possibility of not removing the
> $lockfile_inprogress in due of fast reboot. Please check.
>
> /+ logger -t $osafprog "Starting OpenSAF failed,
> rebooting..." //
> //+ sleep $REBOOT_ON_FAIL_TIMEOUT //
> //+ /sbin/reboot & //
> //+ else //
> //+ logger -t $osafprog "Starting OpenSAF failed" //
> //+ fi //
> // fi //
> //+ rm -rf "$lockfile_inprogress" //
> /
>
>
> Best Regards,
> Ramesh.
>
> On 1/3/2017 6:11 PM, Anders Widell wrote:
>> Ack with comments:
>>
>> 1) Better to use "rm -f" instead of "rm -rf" to remove the lock file,
>> since "rm -rf" could be dangerous if the parameter is wrong.
>>
>> 2) Maybe also use log_failure_msg (or log_warning_msg) instead of
>> just logger, so that you get messages on the screen when calling
>> /etc/init.d/opensafd from the command prompt.
>>
>> regards,
>>
>> Anders Widell
>>
>>
>> On 12/22/2016 02:17 PM, Hans Nordeback wrote:
>>> osaf/services/infrastructure/nid/scripts/opensafd.in | 105
>>> +++++++++++-------
>>> 1 files changed, 62 insertions(+), 43 deletions(-)
>>>
>>>
>>> diff --git a/osaf/services/infrastructure/nid/scripts/opensafd.in
>>> b/osaf/services/infrastructure/nid/scripts/opensafd.in
>>> --- a/osaf/services/infrastructure/nid/scripts/opensafd.in
>>> +++ b/osaf/services/infrastructure/nid/scripts/opensafd.in
>>> @@ -14,6 +14,7 @@
>>> osafdirfile=@sysconfdir@/@PACKAGE_NAME@/osafdir.conf
>>> osafprog="opensafd"
>>> +osafprog_inprogress="opensafd_inprogress"
>>> # Source LSB functions library
>>> . /lib/lsb/init-functions
>>> @@ -28,6 +29,7 @@ fi
>>> binary=$pkglibdir/$osafprog
>>> lockfile=$lockdir/$osafprog
>>> +lockfile_inprogress=$lockdir/$osafprog_inprogress
>>> amfnd_bin=$pkglibdir/osafamfnd
>>> amfnd_pid=$pkgpiddir/osafamfnd.pid
>>> @@ -216,22 +218,30 @@ start() {
>>> #enable_coredump
>>> echo -n "Starting OpenSAF Services (Using $MDS_TRANSPORT):"
>>> - start_daemon $binary $args
>>> - RETVAL=$?
>>> - if [ $RETVAL -eq 0 ]; then
>>> - logger -t $osafprog "OpenSAF($osafversion - $osafcshash)
>>> services successfully started"
>>> - touch $lockfile
>>> - log_success_msg
>>> + if [ -e "$lockfile_inprogress" ]; then
>>> + RETVAL=1
>>> + logger -t $osafprog "opensafd start/stop already in
>>> progress. Unable to contiune"
>>> + logger -t $osafprog "To forcefully start/stop OpenSAF
>>> remove $lockfile_inprogress"
>>> else
>>> - final_clean
>>> - log_failure_msg
>>> - if [ $REBOOT_ON_FAIL_TIMEOUT -ne 0 ]; then
>>> - logger -t $osafprog "Starting OpenSAF failed,
>>> rebooting..."
>>> - sleep $REBOOT_ON_FAIL_TIMEOUT
>>> - /sbin/reboot &
>>> + touch "$lockfile_inprogress"
>>> + start_daemon $binary $args
>>> + RETVAL=$?
>>> + if [ $RETVAL -eq 0 ]; then
>>> + logger -t $osafprog "OpenSAF($osafversion -
>>> $osafcshash) services successfully started"
>>> + touch $lockfile
>>> + log_success_msg
>>> else
>>> - logger -t $osafprog "Starting OpenSAF failed"
>>> + final_clean
>>> + log_failure_msg
>>> + if [ $REBOOT_ON_FAIL_TIMEOUT -ne 0 ]; then
>>> + logger -t $osafprog "Starting OpenSAF failed,
>>> rebooting..."
>>> + sleep $REBOOT_ON_FAIL_TIMEOUT
>>> + /sbin/reboot &
>>> + else
>>> + logger -t $osafprog "Starting OpenSAF failed"
>>> + fi
>>> fi
>>> + rm -rf "$lockfile_inprogress"
>>> fi
>>> return $RETVAL
>>> }
>>> @@ -239,40 +249,49 @@ start() {
>>> stop() {
>>> logger -t $osafprog "Stopping OpenSAF Services"
>>> - amfpid=`pidofproc -p $amfnd_pid $amfnd_bin`
>>> - echo -n "Stopping OpenSAF Services: "
>>> - if [ -n "$amfpid" ]; then
>>> - kill $amfpid
>>> - timeout=$TERMTIMEOUT
>>> - while [ $timeout -gt 0 ]; do
>>> - sleep 1
>>> - [ -d /proc/$amfpid ] || break
>>> - timeout=$((timeout-1))
>>> - done
>>> - [ -d /proc/$amfpid ] && RETVAL=1
>>> - if [ $RETVAL -eq 1 ]; then
>>> - logger -t $osafprog "amfnd has not yet exited, killing
>>> it forcibly."
>>> - kill -9 $amfpid
>>> + if [ -e "$lockfile_inprogress" ]; then
>>> + RETVAL=1
>>> + logger -t $osafprog "opensafd start/stop already in
>>> progress. Unable to contiune"
>>> + logger -t $osafprog "To forcefully start/stop OpenSAF
>>> remove $lockfile_inprogress"
>>> + else
>>> + touch "$lockfile_inprogress"
>>> + amfpid=`pidofproc -p $amfnd_pid $amfnd_bin`
>>> + echo -n "Stopping OpenSAF Services: "
>>> + if [ -n "$amfpid" ]; then
>>> + kill $amfpid
>>> + timeout=$TERMTIMEOUT
>>> + while [ $timeout -gt 0 ]; do
>>> + sleep 1
>>> + [ -d /proc/$amfpid ] || break
>>> + timeout=$((timeout-1))
>>> + done
>>> + [ -d /proc/$amfpid ] && RETVAL=1
>>> + if [ $RETVAL -eq 1 ]; then
>>> + logger -t $osafprog "amfnd has not yet exited,
>>> killing it forcibly."
>>> + kill -9 $amfpid
>>> + fi
>>> + else
>>> + pkill -9 osaf* >/dev/null 2>&1
>>> fi
>>> - else
>>> - pkill -9 osaf* >/dev/null 2>&1
>>> - fi
>>> - final_clean
>>> + final_clean
>>> - if [ $RETVAL -eq 0 ]; then
>>> - logger -t $osafprog "OpenSAF services successfully stopped"
>>> - log_success_msg
>>> - else
>>> - log_failure_msg
>>> - # If AMF fails to terminate its components,
>>> - # this system is out of control, reboot it now!
>>> - if [ $REBOOT_ON_FAIL_TIMEOUT -ne 0 ]; then
>>> - logger -t $osafprog "Stopping OpenSAF failed,
>>> rebooting..."
>>> - sleep $REBOOT_ON_FAIL_TIMEOUT
>>> - /sbin/shutdown -r now "OpenSAF termination failed
>>> (timeout)"
>>> + rm -rf "$lockfile_inprogress"
>>> +
>>> + if [ $RETVAL -eq 0 ]; then
>>> + logger -t $osafprog "OpenSAF services successfully
>>> stopped"
>>> + log_success_msg
>>> else
>>> - logger -t $osafprog "Stoping OpenSAF failed"
>>> + log_failure_msg
>>> + # If AMF fails to terminate its components,
>>> + # this system is out of control, reboot it now!
>>> + if [ $REBOOT_ON_FAIL_TIMEOUT -ne 0 ]; then
>>> + logger -t $osafprog "Stopping OpenSAF failed,
>>> rebooting..."
>>> + sleep $REBOOT_ON_FAIL_TIMEOUT
>>> + /sbin/shutdown -r now "OpenSAF termination failed
>>> (timeout)"
>>> + else
>>> + logger -t $osafprog "Stoping OpenSAF failed"
>>> + fi
>>> fi
>>> fi
>>> return $RETVAL
>>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel