#!/bin/bash # # plc Manages all PLC services on this machine # # chkconfig: 2345 99 5 # # description: Manages all PLC services on this machine # # $Id: host.init,v 1.1.1.1 2006/03/27 17:36:46 mlhuang Exp $ # PATH=/sbin:/bin:/usr/bin:/usr/sbin # Source function library. . /etc/init.d/functions # Source configuration if [ -f /etc/sysconfig/plc -a -z "${PLC_ROOT}${PLC_DATA}" ] ; then . /etc/sysconfig/plc fi RETVAL=0 start () { echo -n $"Mounting PLC: " if ! cut -d' ' -f2 /proc/mounts | grep -q $PLC_ROOT ; then if ! e2fsck -a $PLC_ROOT.img | logger -t "PLC" ; then e2fsck $PLC_ROOT.img fi mount -o loop $PLC_ROOT.img $PLC_ROOT RETVAL=$(($RETVAL+$?)) fi if ! cut -d' ' -f2 /proc/mounts | grep -q $PLC_ROOT/data ; then mount -t none -o bind,rw $PLC_DATA $PLC_ROOT/data RETVAL=$(($RETVAL+$?)) fi if ! cut -d' ' -f2 /proc/mounts | grep -q $PLC_ROOT/proc ; then mount -t proc none $PLC_ROOT/proc RETVAL=$(($RETVAL+$?)) fi if [ $RETVAL -eq 0 ]; then success $"PLC mount" else failure $"PLC mount" fi echo chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS start RETVAL=$? } stop () { chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS stop echo -n $"Unmounting PLC: " umount $PLC_ROOT/proc RETVAL=$(($RETVAL+$?)) umount $PLC_ROOT/data RETVAL=$(($RETVAL+$?)) umount $PLC_ROOT RETVAL=$(($RETVAL+$?)) if [ $RETVAL -eq 0 ]; then success $"PLC unmount" else failure $"PLC unmount" fi echo } case "$1" in start|stop) $1 ;; restart) stop start ;; *) echo "Usage: $0 {start|stop|restart}" RETVAL=1 ;; esac exit $RETVAL