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 # plc_reload is defined here
12 . /etc/plc.d/functions
17 # All steps should be idempotent. This means that you should be able
18 # to run them multiple times without depending on anything previously
19 # being run. The idea is that when the configuration changes, "service
20 # plc restart" is called, all dependencies are fixed up, and
21 # everything just works.
24 # we want the resulting myplc to be able to easily skip
25 # some steps. e.g. the packages step takes ages if you install
26 # all rpms under the repository.
27 # We skip steps whose name contains a dot (.) or a tilde (~)
28 # this way the operations would just rename a step name e.g.
30 # mv packages packages.hide
32 # The drawback is, this stuff does not survive an rpm update
33 # but that's maybe a good thing, that all is done at first start
36 # do not consider files that contain '.', '~' or 'functions' in the name
38 for step in /etc/plc.d/* ; do
39 stepname=$(basename $step)
40 plainstepname=$(echo $stepname | sed -e 's,\.,,' -e 's,~,,' -e 's,functions,,' )
41 if [ -f $step -a -x $step -a "$stepname" = "$plainstepname" ] ; then
42 priority=$(sed -ne 's/# priority: \(.*\)/\1/p' $step)
43 echo $priority $stepname
45 done | sort -n | cut -d' ' -f2
51 echo "Usage: $0 [OPTION]... [COMMAND] [STEP]..."
53 echo " -h This message"
56 echo " start Start all PLC subsystems"
57 echo " stop Stop all PLC subsystems"
58 echo " reload Regenerate configuration files"
59 echo " restart Restart all PLC subsystems"
60 echo " checkpoint filename : Checkpoint the current state of MyPLC to filename"
61 echo " restore filename : Restore MyPLC state from filename"
62 echo " steps Displays ordered list of subsystems"
65 for step in "${steps[@]}" ; do
66 if [ -x /etc/plc.d/$step ] ; then
67 echo " $(basename $step)"
74 while getopts "vh" opt ; do
85 # Redirect stdout and stderr of each step to /var/log/boot.log
86 if [ $verbose -eq 0 ] ; then
87 touch /var/log/boot.log
88 chmod 600 /var/log/boot.log
89 exec 1>>/var/log/boot.log
90 exec 2>>/var/log/boot.log
94 shift $(($OPTIND - 1))
102 if [ -z "$1" ] ; then
103 # Start or stop everything. Regenerate configuration first.
106 # Start or stop a particular step
115 for step in "${steps[@]}" ; do
116 if [ -x /etc/plc.d/$step ] ; then
117 /etc/plc.d/$step start
118 # Steps may alter the configuration, may need to regenerate
121 echo "PLC: $step: unrecognized step" >&4
129 for i in $(seq 1 $nsteps) ; do
130 step=${steps[$(($nsteps - $i))]}
131 if [ -x /etc/plc.d/$step ] ; then
132 /etc/plc.d/$step stop
133 # Steps may alter the configuration, may need to regenerate
136 echo "PLC: $step: unrecognized step" >&4
158 if [ -z "$cpfile" ] ; then
159 echo "PLC: checkpoint requires a filename as an argument"
162 cpdir=$(mktemp -d tmp.XXXXXX)
164 mkdir -p ./etc/planetlab/
165 rsync -av /etc/planetlab/ ./etc/planetlab/
166 /etc/plc.d/db checkpoint ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint
174 cpdir=$(mktemp -d tmp.XXXXXX)
177 /etc/plc.d/db restore ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint
178 rm -f ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint
179 rsync -av ./etc/planetlab/ /etc/planetlab/
185 echo "${steps[@]}" >&4
188 # for backwards compatibility
189 mount|umount|mountstatus)
190 echo "${command} not used within native myplc environment"