3 # plc Manages all PLC services on this machine
7 # description: Manages all PLC services on this machine
12 # Source function library and configuration
13 . /etc/plc.d/functions
18 # All steps should be idempotent. This means that you should be able
19 # to run them multiple times without depending on anything previously
20 # being run. The idea is that when the configuration changes, "service
21 # plc restart" is called, all dependencies are fixed up, and
22 # everything just works.
25 # we want the resulting myplc to be able to easily skip
26 # some steps. e.g. the packages step takes ages if you install
27 # all rpms under the repository.
28 # We skip steps whose name contains a dot (.) or a tilde (~)
29 # this way the operations would just rename a step name e.g.
31 # mv packages packages.hide
33 # The drawback is, this stuff does not survive an rpm update
34 # but that's maybe a good thing, that all is done at first start
38 for step in /etc/plc.d/* ; do
39 stepname=$(basename $step)
40 plainstepname=$(echo $stepname | sed -e 's,\.,,' -e 's,~,,')
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
49 # Regenerate configuration files
54 # Regenerate the main configuration file from default values
55 # overlaid with site-specific and current values.
56 # Thierry -- 2007-07-05 : values in plc_config.xml are *not* taken into account here
58 /etc/planetlab/default_config.xml
59 /etc/planetlab/configs/site.xml
61 for file in "${files[@]}" ; do
62 if [ -n "$force" -o $file -nt /etc/planetlab/plc_config.xml ] ; then
63 tmp=$(mktemp /tmp/plc_config.xml.XXXXXX)
64 plc-config --xml "${files[@]}" >$tmp
65 if [ $? -eq 0 ] ; then
66 mv $tmp /etc/planetlab/plc_config.xml
67 chmod 444 /etc/planetlab/plc_config.xml
69 echo "PLC: Warning: Invalid configuration file(s) detected"
76 # Convert configuration to various formats
77 if [ -n "$force" -o /etc/planetlab/plc_config.xml -nt /etc/planetlab/plc_config ] ; then
78 plc-config --shell >/etc/planetlab/plc_config
80 if [ -n "$force" -o /etc/planetlab/plc_config.xml -nt /etc/planetlab/php/plc_config.php ] ; then
81 mkdir -p /etc/planetlab/php
82 plc-config --php >/etc/planetlab/php/plc_config.php
88 echo "Usage: $0 [OPTION]... [COMMAND] [STEP]..."
90 echo " -h This message"
93 echo " start Start all PLC subsystems"
94 echo " stop Stop all PLC subsystems"
95 echo " reload Regenerate configuration files"
96 echo " restart Restart all PLC subsystems"
97 echo " steps Displays ordered list of subsystems"
100 for step in "${steps[@]}" ; do
101 if [ -x /etc/plc.d/$step ] ; then
102 echo " $(basename $step)"
109 while getopts "vh" opt ; do
120 # Redirect stdout and stderr of each step to /var/log/boot.log
121 if [ $verbose -eq 0 ] ; then
122 touch /var/log/boot.log
123 chmod 600 /var/log/boot.log
124 exec 1>>/var/log/boot.log
125 exec 2>>/var/log/boot.log
129 shift $(($OPTIND - 1))
130 if [ -z "$1" ] ; then
137 if [ -z "$1" ] ; then
138 # Start or stop everything. Regenerate configuration first.
141 # Start or stop a particular step
150 for step in "${steps[@]}" ; do
151 if [ -x /etc/plc.d/$step ] ; then
152 /etc/plc.d/$step start
153 # Steps may alter the configuration, may need to regenerate
156 echo "PLC: $step: unrecognized step" >&4
164 for i in $(seq 1 $nsteps) ; do
165 step=${steps[$(($nsteps - $i))]}
166 if [ -x /etc/plc.d/$step ] ; then
167 /etc/plc.d/$step stop
168 # Steps may alter the configuration, may need to regenerate
171 echo "PLC: $step: unrecognized step" >&4
192 echo "${steps[@]}" >&4