summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAles Kozumplik <akozumpl@redhat.com>2010-05-18 19:03:46 +0200
committerAles Kozumplik <akozumpl@redhat.com>2010-06-07 16:25:28 +0200
commit592438a12dcd5423723f0832e8c84b0306513772 (patch)
treed07b33ce60443085ffb74cef232994f2c461f971 /scripts
parent8510671e6fc8b16e44526c5413fef7ff8c4858ec (diff)
downloadanaconda-592438a12dcd5423723f0832e8c84b0306513772.tar.gz
anaconda-592438a12dcd5423723f0832e8c84b0306513772.tar.xz
anaconda-592438a12dcd5423723f0832e8c84b0306513772.zip
Restarting anaconda.
Provides a shell script that restarts stage2 anaconda by killing it along with everything it has spwawned (X server, metacity). This also needs some support by the loader.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.am3
-rwxr-xr-xscripts/restart-anaconda51
-rwxr-xr-xscripts/upd-instroot1
3 files changed, 55 insertions, 0 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 9ca8b1a36..187d4c66a 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -28,4 +28,7 @@ dist_noinst_SCRIPTS = getlangnames.py upd-bootimage upd-initrd upd-kernel \
analogdir = $(libexecdir)/$(PACKAGE_NAME)
dist_analog_SCRIPTS = analog
+stage2scriptsdir = $(datadir)/$(PACKAGE_NAME)
+dist_stage2scripts_SCRIPTS = restart-anaconda
+
MAINTAINERCLEANFILES = Makefile.in
diff --git a/scripts/restart-anaconda b/scripts/restart-anaconda
new file mode 100755
index 000000000..4e3cd7e89
--- /dev/null
+++ b/scripts/restart-anaconda
@@ -0,0 +1,51 @@
+#! /bin/bash
+#
+# restart-anaconda: Debugging tool to restart stage2 Anaconda.
+#
+# Copyright (C) 2010
+# Red Hat, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+RESTART_FILE=/tmp/restart_anaconda
+ANACONDA_PID=`cat /var/run/anaconda.pid`
+
+descendants() {
+ PID=$1
+ DIRECT=`ps --ppid $PID -o pid=`
+ INDIRECT=''
+ for child in $DIRECT; do
+ INDIRECT+=' '`descendants $child`
+ done
+ # prepend grandchildren, we are goingt to kill them first
+ DESCENDANTS=$INDIRECT' '$DIRECT
+ echo $DESCENDANTS
+}
+
+anaconda_descendants() {
+ descendants $ANACONDA_PID
+}
+
+# this is how loader knows it should restart stuff.
+# it will also delete the file once the restart is in progress.
+touch $RESTART_FILE
+
+# kill all anaconda descendants and anaconda itself
+RESTART_VICTIMS=`anaconda_descendants`
+RESTART_VICTIMS+=' '$ANACONDA_PID
+echo "killing processes: " $RESTART_VICTIMS
+for child in $RESTART_VICTIMS; do
+ kill -s KILL $child &>/dev/null
+done
diff --git a/scripts/upd-instroot b/scripts/upd-instroot
index 9369c4ba1..8ebd1bda1 100755
--- a/scripts/upd-instroot
+++ b/scripts/upd-instroot
@@ -1085,6 +1085,7 @@ cp $DEST/usr/share/anaconda/losetup-stub $DEST/usr/bin/losetup
cp $DEST/usr/share/anaconda/list-harddrives-stub $DEST/usr/bin/list-harddrives
cp $DEST/usr/share/anaconda/loadkeys-stub $DEST/usr/bin/loadkeys
cp $DEST/usr/share/anaconda/mknod-stub $DEST/usr/bin/mknod
+cp $DEST/usr/share/anaconda/restart-anaconda $DEST/usr/bin/restart-anaconda
mv $DEST/usr/sbin/anaconda $DEST/usr/bin/anaconda
mv $DEST/usr/$LIBDIR/python?.?/site-packages/pyanaconda/sitecustomize.py $DEST/usr/$LIBDIR/python?.?/site-packages