3 # plc Manages all PLC services on this machine
7 # description: Manages all PLC services on this machine
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 [ -d /data/fedora ] ; then
74 if ! mounted $PLC_ROOT/data/fedora ; then
75 mount -t none -o bind,ro /data/fedora $PLC_ROOT/data/fedora
80 if ! mounted $PLC_ROOT/svn ; then
81 mount -t none -o bind,ro /svn $PLC_ROOT/svn
85 if ! mounted $PLC_ROOT/proc ; then
86 mount -t proc none $PLC_ROOT/proc
90 [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"
102 chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS start $*
108 echo -n $"Unmounting PLC: "
110 for dir in $PLC_ROOT/proc $PLC_ROOT/svn $PLC_ROOT/data/fedora $PLC_ROOT/data $PLC_ROOT ; do
111 if mounted $dir ; then
117 [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"
123 if mounted $PLC_ROOT ; then
124 chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS stop $*
129 if [ -z "$1" ] ; then
136 for dir in $PLC_ROOT/proc $PLC_ROOT/svn $PLC_ROOT/data/fedora $PLC_ROOT/data $PLC_ROOT ; do
137 if mounted $dir ; then
144 shift $(($OPTIND - 1))
161 chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS reload $*
164 mount|umount|mountstatus)
169 echo "Usage: $0 {start|stop|restart|reload|mount|umount|mountstatus}"