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 source /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
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
113 for step in "${steps[@]}" ; do
114 if [ -x /etc/plc.d/$step ] ; then
115 /etc/plc.d/$step start
116 # Steps may alter the configuration, may need to regenerate
119 echo "PLC: $step: unrecognized step" >&4
126 for i in $(seq 1 $nsteps) ; do
127 step=${steps[$(($nsteps - $i))]}
128 if [ -x /etc/plc.d/$step ] ; then
129 /etc/plc.d/$step stop
130 # Steps may alter the configuration, may need to regenerate
133 echo "PLC: $step: unrecognized step" >&4
155 if [ -z "$cpfile" ] ; then
156 echo "PLC: checkpoint requires a filename as an argument"
159 cpdir=$(mktemp -d tmp.XXXXXX)
161 mkdir -p ./etc/planetlab/
162 rsync -av /etc/planetlab/ ./etc/planetlab/
163 /etc/plc.d/db checkpoint ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint
171 cpdir=$(mktemp -d tmp.XXXXXX)
174 /etc/plc.d/db restore ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint
175 rm -f ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint
176 rsync -av ./etc/planetlab/ /etc/planetlab/
182 echo "${steps[@]}" >&4
185 # for backwards compatibility
186 mount|umount|mountstatus)
187 echo "${command} not used within native myplc environment"