X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=guest.init;h=c2e5aae9224fd17a80de73a326f1aa71342f933d;hb=refs%2Fheads%2Fmodular_build;hp=48f21ba70d87db88a32b05c03f4e189bac1ad020;hpb=f872afaa7976264819814d3e3289e020c0f77eae;p=myplc.git diff --git a/guest.init b/guest.init index 48f21ba..c2e5aae 100755 --- a/guest.init +++ b/guest.init @@ -6,7 +6,7 @@ # # description: Manages all PLC services on this machine # -# $Id: guest.init,v 1.12 2006/04/04 22:09:47 mlhuang Exp $ +# $Id: guest.init,v 1.20 2006/08/08 23:19:52 mlhuang Exp $ # # Source function library and configuration @@ -22,7 +22,7 @@ verbose=0 # everything just works. steps=($( for step in /etc/plc.d/* ; do - if [ -x $step ] ; then + if [ -f $step -a -x $step ] ; then priority=$(sed -ne 's/# priority: \(.*\)/\1/p' $step) echo $priority $(basename $step) fi @@ -33,100 +33,38 @@ nsteps=${#steps[@]} # Regenerate configuration files reload () { - # Load configuration - plc-config --shell >/etc/planetlab/plc_config - . /etc/planetlab/plc_config - - # Generate various defaults - if [ -z "$PLC_DB_PASSWORD" ] ; then - PLC_DB_PASSWORD=$(uuidgen) - plc-config --category=plc_db --variable=password --value="$PLC_DB_PASSWORD" --save - fi - - if [ -z "$PLC_API_MAINTENANCE_PASSWORD" ] ; then - PLC_API_MAINTENANCE_PASSWORD=$(uuidgen) - plc-config --category=plc_api --variable=maintenance_password --value="$PLC_API_MAINTENANCE_PASSWORD" --save - fi - - # Need to configure network before resolving hostnames - /etc/plc.d/network start 3>/dev/null 4>/dev/null - - PLC_API_MAINTENANCE_SOURCES=$( - for server in API BOOT WWW ; do - hostname=PLC_${server}_HOST - gethostbyname ${!hostname} - done | sort -u + force=$1 + + # Regenerate the main configuration file from default values + # overlaid with site-specific and current values. + files=( + /etc/planetlab/default_config.xml + /etc/planetlab/configs/*.xml + /etc/planetlab/plc_config.xml ) - plc-config --category=plc_api --variable=maintenance_sources --value="$PLC_API_MAINTENANCE_SOURCES" --save - - # Save configuration - mkdir -p /etc/planetlab/php - plc-config --php >/etc/planetlab/php/plc_config.php - plc-config --shell >/etc/planetlab/plc_config - - # For backward compatibility, until we can convert all code to use - # the now standardized variable names. - - # DB constants are all named the same - ln -sf plc_config /etc/planetlab/plc_db - - # API constants - cat >/etc/planetlab/plc_api <>/etc/planetlab/plc_api - - cat >/etc/planetlab/php/site_constants.php <<"EOF" -'); -define('PLANETLAB_SUPPORT_EMAIL_ONLY', PLC_MAIL_SUPPORT_ADDRESS); -?> -EOF + break + fi + done + + # Convert configuration to various formats + if [ -n "$force" -o /etc/planetlab/plc_config.xml -nt /etc/planetlab/plc_config ] ; then + plc-config --shell >/etc/planetlab/plc_config + fi + if [ -n "$force" -o /etc/planetlab/plc_config.xml -nt /etc/planetlab/php/plc_config.php ] ; then + mkdir -p /etc/planetlab/php + plc-config --php >/etc/planetlab/php/plc_config.php + fi } usage() @@ -164,6 +102,8 @@ done # Redirect stdout and stderr of each step to /var/log/boot.log if [ $verbose -eq 0 ] ; then + touch /var/log/boot.log + chmod 600 /var/log/boot.log exec 1>>/var/log/boot.log exec 2>>/var/log/boot.log fi @@ -179,7 +119,7 @@ command=$1 shift 1 if [ -z "$1" ] ; then # Start or stop everything. Regenerate configuration first. - reload + reload force else # Start or stop a particular step steps=("$@") @@ -193,6 +133,8 @@ start () for step in "${steps[@]}" ; do if [ -x /etc/plc.d/$step ] ; then /etc/plc.d/$step start + # Steps may alter the configuration, may need to regenerate + reload else echo "PLC: $step: unrecognized step" >&4 exit 1 @@ -206,6 +148,8 @@ stop () step=${steps[$(($nsteps - $i))]} if [ -x /etc/plc.d/$step ] ; then /etc/plc.d/$step stop + # Steps may alter the configuration, may need to regenerate + reload else echo "PLC: $step: unrecognized step" >&4 exit 1 @@ -224,6 +168,7 @@ case "$command" in ;; reload) + reload force ;; *)