3 # plc Manages all PLC services on this machine
7 # description: Manages all PLC services on this machine
9 # $Id: host.init,v 1.8 2006/07/06 17:43:52 mlhuang Exp $
12 PATH=/sbin:/bin:/usr/bin:/usr/sbin
14 # Source function library.
15 if [ -f /etc/init.d/functions ] ; then
16 . /etc/init.d/functions
19 # If success() or failure() are not defined
20 if ! type -type success >/dev/null || ! type -type failure >/dev/null ; then
31 # Source configuration
32 SERVICE=$(basename $0)
33 if [ ! -f /etc/sysconfig/$SERVICE ] ; then
36 if [ -f /etc/sysconfig/$SERVICE -a -z "${PLC_ROOT}${PLC_DATA}" ] ; then
37 . /etc/sysconfig/$SERVICE
40 # Total number of errors
43 # Count the exit status of the last command
46 ERRORS=$(($ERRORS+$?))
51 if cut -d' ' -f2 /proc/mounts | grep -q "$1" ; then
60 echo -n $"Mounting PLC: "
62 if ! mounted $PLC_ROOT ; then
63 if ! e2fsck -a $PLC_ROOT.img | logger -t "PLC" ; then
66 mount -o loop $PLC_ROOT.img $PLC_ROOT
69 if ! mounted $PLC_ROOT/data ; then
70 mount -t none -o bind,rw $PLC_DATA $PLC_ROOT/data
73 if ! mounted $PLC_ROOT/proc ; then
74 mount -t proc none $PLC_ROOT/proc
78 [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"
90 chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS start $*
96 echo -n $"Unmounting PLC: "
98 for dir in $PLC_ROOT/proc $PLC_ROOT/data $PLC_ROOT ; do
99 if mounted $dir ; then
105 [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"
111 if mounted $PLC_ROOT ; then
112 chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS stop $*
117 if [ -z "$1" ] ; then
124 for dir in $PLC_ROOT/proc $PLC_ROOT/data $PLC_ROOT ; do
125 if mounted $dir ; then
132 shift $(($OPTIND - 1))
149 chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS reload $*
152 mount|umount|mountstatus)
157 echo "Usage: $0 {start|stop|restart|reload|mount|umount|mountstatus}"