3 # plc Manages all PLC services on this machine
7 # description: Manages all PLC services on this machine
9 # $Id: host.init,v 1.3 2006/04/07 17:12:52 mlhuang Exp $
12 PATH=/sbin:/bin:/usr/bin:/usr/sbin
14 # Source function library.
15 . /etc/init.d/functions
17 # Source configuration
18 if [ -f /etc/sysconfig/plc -a -z "${PLC_ROOT}${PLC_DATA}" ] ; then
22 # Total number of errors
25 # Count the exit status of the last command
28 ERRORS=$(($ERRORS+$?))
33 if cut -d' ' -f2 /proc/mounts | grep -q "$1" ; then
42 echo -n $"Mounting PLC: "
44 if ! mounted $PLC_ROOT ; then
45 if ! e2fsck -a $PLC_ROOT.img | logger -t "PLC" ; then
48 mount -o loop $PLC_ROOT.img $PLC_ROOT
51 if ! mounted $PLC_ROOT/data ; then
52 mount -t none -o bind,rw $PLC_DATA $PLC_ROOT/data
55 if ! mounted $PLC_ROOT/proc ; then
56 mount -t proc none $PLC_ROOT/proc
60 [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"
63 chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS start $*
69 if mounted $PLC_ROOT ; then
70 chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS stop $*
74 echo -n $"Unmounting PLC: "
76 for dir in $PLC_ROOT/proc $PLC_ROOT/data $PLC_ROOT ; do
77 if mounted $dir ; then
83 [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"
88 shift $(($OPTIND - 1))
105 echo "Usage: $0 {start|stop|restart}"