X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=guest.init;h=e95c34ed75a2efd6871fa4b02297726a8fdb7629;hb=c266971e752cd413423f574315c38f1f46cdfb9c;hp=38632fe625649aea85e427531f07dc7a35fa1169;hpb=96360f7d9c40895a14ff03293bed4ec9e9e4ffce;p=myplc.git diff --git a/guest.init b/guest.init index 38632fe..e95c34e 100755 --- a/guest.init +++ b/guest.init @@ -6,7 +6,7 @@ # # description: Manages all PLC services on this machine # -# $Id: guest.init,v 1.19 2006/07/10 21:10:21 mlhuang Exp $ +# $Id$ # # Source function library and configuration @@ -20,11 +20,27 @@ verbose=0 # being run. The idea is that when the configuration changes, "service # plc restart" is called, all dependencies are fixed up, and # everything just works. + +### NOTE. +# we want the resulting myplc to be able to easily skip +# some steps. e.g. the packages step takes ages if you install +# all rpms under the repository. +# We skip steps whose name contains a dot (.) or a tilde (~) +# this way the operations would just rename a step name e.g. +# cd /etc/plc.d +# mv packages packages.hide +# +# The drawback is, this stuff does not survive an rpm update +# but that's maybe a good thing, that all is done at first start +### + steps=($( for step in /etc/plc.d/* ; do - if [ -f $step -a -x $step ] ; then + stepname=$(basename $step) + plainstepname=$(echo $stepname | sed -e 's,\.,,' -e 's,~,,') + if [ -f $step -a -x $step -a "$stepname" = "$plainstepname" ] ; then priority=$(sed -ne 's/# priority: \(.*\)/\1/p' $step) - echo $priority $(basename $step) + echo $priority $stepname fi done | sort -n | cut -d' ' -f2 )) @@ -37,10 +53,10 @@ reload () # Regenerate the main configuration file from default values # overlaid with site-specific and current values. + # Thierry -- 2007-07-05 : values in plc_config.xml are *not* taken into account here files=( /etc/planetlab/default_config.xml - /etc/planetlab/configs/* - /etc/planetlab/plc_config.xml + /etc/planetlab/configs/site.xml ) for file in "${files[@]}" ; do if [ -n "$force" -o $file -nt /etc/planetlab/plc_config.xml ] ; then @@ -48,7 +64,7 @@ reload () plc-config --xml "${files[@]}" >$tmp if [ $? -eq 0 ] ; then mv $tmp /etc/planetlab/plc_config.xml - chmod 644 /etc/planetlab/plc_config.xml + chmod 444 /etc/planetlab/plc_config.xml else echo "PLC: Warning: Invalid configuration file(s) detected" rm -f $tmp @@ -78,6 +94,9 @@ usage() echo " stop Stop all PLC subsystems" echo " reload Regenerate configuration files" echo " restart Restart all PLC subsystems" + echo " checkpoint filename : Checkpoint the current state of MyPLC to filename" + echo " restore filename : Restore MyPLC state from filename" + echo " steps Displays ordered list of subsystems" echo echo "Steps:" for step in "${steps[@]}" ; do @@ -171,6 +190,43 @@ case "$command" in reload force ;; + checkpoint) + cpfile=$1 + if [ -z "$cpfile" ] ; then + echo "PLC: checkpoint requires a filename as an argument" + exit 1 + fi + cpdir=$(mktemp -d tmp.XXXXXX) + cd $cpdir + mkdir -p ./etc/planetlab/ + rsync -av /etc/planetlab/ ./etc/planetlab/ + /etc/plc.d/db checkpoint ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint + tar cjf $cpfile etc + cd - + rm -rf $cpdir + ;; + + restore) + cpfile=$1 + cpdir=$(mktemp -d tmp.XXXXXX) + cd $cpdir + tar xjf $cpfile + /etc/plc.d/db restore ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint + rm -f ./etc/planetlab/plc_db.checkpoint ./etc/planetlab/plc_drupal.checkpoint + rsync -av ./etc/planetlab/ /etc/planetlab/ + cd - + rm -rf $cpdir + ;; + + steps) + echo "${steps[@]}" >&4 + ;; + + # for backwards compatibility + mount|umount|mountstatus) + echo "${command} not used within native myplc environment" + ;; + *) usage >&3 ;;