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 if [ -f /etc/sysconfig/plc -a -z "${PLC_ROOT}${PLC_DATA}" ] ; then
36 # Total number of errors
39 # Count the exit status of the last command
42 ERRORS=$(($ERRORS+$?))
47 if cut -d' ' -f2 /proc/mounts | grep -q "$1" ; then
56 echo -n $"Mounting PLC: "
58 if ! mounted $PLC_ROOT ; then
59 if ! e2fsck -a $PLC_ROOT.img | logger -t "PLC" ; then
62 mount -o loop $PLC_ROOT.img $PLC_ROOT
65 if ! mounted $PLC_ROOT/data ; then
66 mount -t none -o bind,rw $PLC_DATA $PLC_ROOT/data
69 if ! mounted $PLC_ROOT/proc ; then
70 mount -t proc none $PLC_ROOT/proc
74 [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"
86 chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS start $*
92 echo -n $"Unmounting PLC: "
94 for dir in $PLC_ROOT/proc $PLC_ROOT/data $PLC_ROOT ; do
95 if mounted $dir ; then
101 [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"
107 if mounted $PLC_ROOT ; then
108 chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS stop $*
113 if [ -z "$1" ] ; then
120 for dir in $PLC_ROOT/proc $PLC_ROOT/data $PLC_ROOT ; do
121 if mounted $dir ; then
128 shift $(($OPTIND - 1))
144 mount|umount|mountstatus)
149 echo "Usage: $0 {start|stop|restart|mount|umount|mountstatus}"