3 # plc Manages all PLC services on this machine
5 # chkconfig: 2345 60 40
7 # description: Manages all PLC services on this machine
10 # Source function library and configuration
11 . /etc/plc.d/functions
16 # All steps should be idempotent. This means that you should be able
17 # to run them multiple times without depending on anything previously
18 # being run. The idea is that when the configuration changes, "service
19 # plc restart" is called, all dependencies are fixed up, and
20 # everything just works.
23 # we want the resulting myplc to be able to easily skip
24 # some steps. e.g. the packages step takes ages if you install
25 # all rpms under the repository.
26 # We skip steps whose name contains a dot (.) or a tilde (~)
27 # this way the operations would just rename a step name e.g.
29 # mv packages packages.hide
31 # The drawback is, this stuff does not survive an rpm update
32 # but that's maybe a good thing, that all is done at first start
35 # do not consider files that contain '.', '~' or 'functions' in the name
37 for step in /etc/plc.d/* ; do
38 stepname=$(basename $step)
39 plainstepname=$(echo $stepname | sed -e 's,\.,,' -e 's,~,,' -e 's,functions,,' )
40 if [ -f $step -a -x $step -a "$stepname" = "$plainstepname" ] ; then
41 priority=$(sed -ne 's/# priority: \(.*\)/\1/p' $step)
42 echo $priority $stepname
44 done | sort -n | cut -d' ' -f2
50 echo "Usage: $0 [OPTION]... [COMMAND] [STEP]..."
52 echo " -h This message"
55 echo " start Start all PLC subsystems"
56 echo " stop Stop all PLC subsystems"
57 echo " reload Regenerate configuration files"
58 echo " restart Restart all PLC subsystems"
59 echo " checkpoint filename : Checkpoint the current state of MyPLC to filename"
60 echo " restore filename : Restore MyPLC state from filename"
61 echo " steps Displays ordered list of subsystems"
64 for step in "${steps[@]}" ; do
65 if [ -x /etc/plc.d/$step ] ; then
66 echo " $(basename $step)"
73 while getopts "vh" opt ; do
84 # Redirect stdout and stderr of each step to /var/log/boot.log
85 if [ $verbose -eq 0 ] ; then
86 touch /var/log/boot.log
87 chmod 600 /var/log/boot.log
88 exec 1>>/var/log/boot.log
89 exec 2>>/var/log/boot.log
93 shift $(($OPTIND - 1))
101 if [ -z "$1" ] ; then
102 # Start or stop everything. Regenerate configuration first.
105 # Start or stop a particular step
114 for step in "${steps[@]}" ; do
115 if [ -x /etc/plc.d/$step ] ; then
116 /etc/plc.d/$step start
117 # Steps may alter the configuration, may need to regenerate
120 echo "PLC: $step: unrecognized step" >&4
128 for i in $(seq 1 $nsteps) ; do
129 step=${steps[$(($nsteps - $i))]}
130 if [ -x /etc/plc.d/$step ] ; then
131 /etc/plc.d/$step stop
132 # Steps may alter the configuration, may need to regenerate
135 echo "PLC: $step: unrecognized step" >&4
157 if [ -z "$cpfile" ] ; then
158 echo "PLC: checkpoint requires a filename as an argument"
161 cpdir=$(mktemp -d tmp.XXXXXX)
163 mkdir -p ./etc/planetlab/
164 rsync -av /etc/planetlab/ ./etc/planetlab/
165 /etc/plc.d/db checkpoint ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint
173 cpdir=$(mktemp -d tmp.XXXXXX)
176 /etc/plc.d/db restore ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint
177 rm -f ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint
178 rsync -av ./etc/planetlab/ /etc/planetlab/
184 echo "${steps[@]}" >&4
187 # for backwards compatibility
188 mount|umount|mountstatus)
189 echo "${command} not used within native myplc environment"