X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=host.init;h=f207e008a525ab98501024070e0b4c4dafd31e21;hb=c8804c0a38459acca6c7e9eff91db68fd7fb0f75;hp=0f46162281c336b22e5dfe7688dd73e62f2451a2;hpb=c1128f0209da864281ee2a29e46f8a73d077fd41;p=myplc.git diff --git a/host.init b/host.init index 0f46162..f207e00 100755 --- a/host.init +++ b/host.init @@ -6,17 +6,35 @@ # # description: Manages all PLC services on this machine # -# $Id: host.init,v 1.6 2006/04/20 09:01:00 thierry Exp $ +# $Id: host.init,v 1.8 2006/07/06 17:43:52 mlhuang Exp $ # PATH=/sbin:/bin:/usr/bin:/usr/sbin # Source function library. -. /etc/init.d/functions +if [ -f /etc/init.d/functions ] ; then + . /etc/init.d/functions +fi + +# If success() or failure() are not defined +if ! type -type success >/dev/null || ! type -type failure >/dev/null ; then + success() { + echo -ne "[ OK ]\r" + return 0 + } + failure() { + echo -ne "[FAILED]\r" + return 1 + } +fi # Source configuration -if [ -f /etc/sysconfig/plc -a -z "${PLC_ROOT}${PLC_DATA}" ] ; then - . /etc/sysconfig/plc +SERVICE=$(basename $0) +if [ ! -f /etc/sysconfig/$SERVICE ] ; then + SERVICE=plc +fi +if [ -f /etc/sysconfig/$SERVICE -a -z "${PLC_ROOT}${PLC_DATA}" ] ; then + . /etc/sysconfig/$SERVICE fi # Total number of errors @@ -101,15 +119,13 @@ stop () fi } -mount_status () +mountstatus_plc () { - lines=$(mount | grep $PLC_ROOT) - if [ -z "$lines" ] ; then - echo "==== $PLC_ROOT is *not* mounted" - else - echo "==== The following mount points remain active" - echo "$lines" - fi + for dir in $PLC_ROOT/proc $PLC_ROOT/data $PLC_ROOT ; do + if mounted $dir ; then + echo $dir + fi + done } # Get command @@ -129,16 +145,16 @@ case "$command" in start $* ;; - mount|umount) - ${command}_plc $* - ;; + reload) + chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS reload $* + ;; - mountstatus) - mount_status $* + mount|umount|mountstatus) + ${command}_plc $* ;; *) - echo "Usage: $0 {start|stop|restart|mount|umount|mountstatus}" + echo "Usage: $0 {start|stop|restart|reload|mount|umount|mountstatus}" RETVAL=1 ;; esac