X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=pl_mop.sh;h=61b7a6359d1f5bd189989d845f75d54aae637ab2;hb=288b66d5ba2651b9184a25d2a795dfb912439701;hp=d80ce64b95a75a84870c928121068fe1e6c63aa2;hpb=67cc76870b2f956d6655a129839431b96f5f7f11;p=mom.git diff --git a/pl_mop.sh b/pl_mop.sh index d80ce64..61b7a63 100755 --- a/pl_mop.sh +++ b/pl_mop.sh @@ -5,11 +5,18 @@ # Mark Huang # Copyright (C) 2005 The Trustees of Princeton University # -# $Id$ +# $Id: pl_mop.sh,v 1.6 2006/04/28 19:28:59 mlhuang Exp $ # PATH=/sbin:/usr/sbin:$PATH +# Parse PLC configuration +if [ -r /etc/planetlab/plc_config ] ; then + . /etc/planetlab/plc_config +else + PLC_SLICE_PREFIX="pl" +fi + PIDFILE=/var/run/pl_mop.pid # Record PID @@ -46,7 +53,7 @@ fix_etc_shadow() { # keep essential services running restart_services() { - for service in autofs sshd pl_sshd pl_mom pl_nm pl_conf proper ; do + for service in sshd pl_sshd swapmon pl_nm proper ; do echo "* Checking $service" status=$(service $service status) if [ $? -ne 0 ] || echo $status 2>&1 | grep -q stopped ; then @@ -68,6 +75,58 @@ restart_netflow() { fi } +# keep pl_conf running +restart_pl_conf() { + echo "* Checking pl_conf" + vserver pl_conf exec /sbin/service pl_conf status >/dev/null 2>&1 + if [ $? -ne 0 ] ; then + echo "* Restarting pl_conf" + vserver pl_conf stop + vserver pl_conf start + fi +} + +# GPG keys are installed in /etc/pki/rpm-gpg by both the Boot Manager +# during initial installation, and by PlanetLabConf during daily +# updates. NodeUpdate imports the keys into the RPM database before +# running yum daily. vserver-reference copies and imports the keys +# into the reference images and system slices daily. The only parts of +# this process that are actually necessary, are the Boot Manager and +# vserver-reference. However, we do not want to force a re-install of +# all nodes, and we do not want to force an update of +# vserver-reference, so in the meantime, PlanetLabConf and NodeUpdate +# take care of getting the keys installed and imported in /, and this +# script takes care of getting them installed in the reference images +# and system slices, until we can get a new vserver-reference image +# pushed out. +update_vserver_reference() { + echo "* Updating VServer reference" + + shopt -s nullglob + + VROOTS="/vservers/vserver-reference /vservers/.vcache/* /vservers/${PLC_SLICE_PREFIX}_*" + + # Copy configuration files from host to slices + for file in \ + /etc/hosts /etc/resolv.conf /etc/yum.conf /etc/planetlab/node_id \ + /etc/planetlab/plc_config* /etc/planetlab/php/* \ + /etc/pki/rpm-gpg/* ; do + if [ -r $file ] ; then + for vroot in $VROOTS ; do + install -D -m 644 $file $vroot/$file + done + fi + done + + # (Re)install GPG signing keys + if [ -d /etc/pki/rpm-gpg ] ; then + for vroot in $VROOTS ; do + chroot $vroot rpm --allmatches -e gpg-pubkey || : + chroot $vroot rpm --import /etc/pki/rpm-gpg/* || : + done + fi +} + # kill all the processes running in slice contexts vkillall() { vps -A | awk '(int($2) > 1) { system("vkill -c " $2 " -s 9 " $1); }' @@ -98,9 +157,6 @@ fix_vservers() { # kill all processes running in slice contexts vkillall - # stop the key automounter - service autofs stop - # stop vcached pidfile=/var/run/vcached.pid if [ -r "$pidfile" ] ; then @@ -121,17 +177,17 @@ fix_vservers() { # blow away the vserver cache rm -rf /vservers/.vcache/* - # re-mount /vservers - mount /vservers + # XXX re-mount /vservers + # mount /vservers + + # shutdown instead to avoid clearing disk quotas + shutdown -r now "/vservers filesystem repaired, rebooting" else echo "Unable to unmount /vservers!" >&2 fi # allow vcached to run again rm -f $pidfile - - # restart the key automounter - service autofs start } kill_duplicate_ssh() { @@ -168,6 +224,10 @@ run fix_etc_shadow run restart_services +run restart_pl_conf + run restart_netflow run kill_duplicate_ssh + +run update_vserver_reference