summaryrefslogtreecommitdiffstats
path: root/rescue/tree/usr/sbin/fakeshutdown
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2013-12-01 20:57:39 +0000
committerColin Guthrie <colin@mageia.org>2013-12-07 17:16:59 +0000
commit645e6932216fddd154865a9bebb0fd0e3beed301 (patch)
tree9cd5e48aefcfdba197b83a321d8d1478befb2b86 /rescue/tree/usr/sbin/fakeshutdown
parentc0ccdccb16f6d9211ad5c8e13e3fd67f0562623a (diff)
downloaddrakx-645e6932216fddd154865a9bebb0fd0e3beed301.tar
drakx-645e6932216fddd154865a9bebb0fd0e3beed301.tar.gz
drakx-645e6932216fddd154865a9bebb0fd0e3beed301.tar.bz2
drakx-645e6932216fddd154865a9bebb0fd0e3beed301.tar.xz
drakx-645e6932216fddd154865a9bebb0fd0e3beed301.zip
rescue: Avoid having to run dracut convertfs script by setting up the tree.
We can easily avoid post processing the tree simply by moving the tree around and ensuring we set it up correctly (with the compat symlinks) early in the process.
Diffstat (limited to 'rescue/tree/usr/sbin/fakeshutdown')
-rwxr-xr-xrescue/tree/usr/sbin/fakeshutdown39
1 files changed, 39 insertions, 0 deletions
diff --git a/rescue/tree/usr/sbin/fakeshutdown b/rescue/tree/usr/sbin/fakeshutdown
new file mode 100755
index 000000000..309f26c6c
--- /dev/null
+++ b/rescue/tree/usr/sbin/fakeshutdown
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+#
+# Guillaume Cottenceau (gc)
+#
+# Copyright 2001 Mandrakesoft
+#
+# This software may be freely redistributed under the terms of the GNU
+# public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+# From MDK::Common:
+sub cat_ { open(my $F, '<', $_[0]) or die "cat of file $_[0] failed: $!\n"; my @l = <$F>; wantarray() ? @l : join '', @l }
+print "\n";
+
+
+#- try to umount as much as possible; uses Pixel's ultra optimized algo (let you guess how it works..)
+print "Umounting:\n";
+my @mounts = cat_('/proc/mounts');
+my $something_moved;
+do {
+ $something_moved = 0;
+ foreach (@mounts) {
+ my $where = (split)[1];
+ next if $where eq '/'; #- ouch! umounting the ramdisk on / always succeeds, and makes it becoming ro :-(
+ if (!system("umount $where 2>/dev/null")) {
+ print "\t$where\n";
+ $something_moved++;
+ }
+ }
+} while $something_moved;
+
+
+#- shutdown with init
+exec '/sbin/init', 6;