summaryrefslogtreecommitdiffstats
path: root/rescue/tree/sbin/fakeshutdown
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-05-30 11:11:18 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-05-30 11:11:18 +0000
commitc1af4addb6f18c15b59fc270854a0fbb8d92dcb6 (patch)
tree5a6f717efc60087849f45827fcbf618d40e15d46 /rescue/tree/sbin/fakeshutdown
downloaddrakx-c1af4addb6f18c15b59fc270854a0fbb8d92dcb6.tar
drakx-c1af4addb6f18c15b59fc270854a0fbb8d92dcb6.tar.gz
drakx-c1af4addb6f18c15b59fc270854a0fbb8d92dcb6.tar.bz2
drakx-c1af4addb6f18c15b59fc270854a0fbb8d92dcb6.tar.xz
drakx-c1af4addb6f18c15b59fc270854a0fbb8d92dcb6.zip
create branch 2007.1 from drakx-installer-* tarballs
(needed after the big svn loss)
Diffstat (limited to 'rescue/tree/sbin/fakeshutdown')
-rwxr-xr-xrescue/tree/sbin/fakeshutdown39
1 files changed, 39 insertions, 0 deletions
diff --git a/rescue/tree/sbin/fakeshutdown b/rescue/tree/sbin/fakeshutdown
new file mode 100755
index 000000000..3511020ff
--- /dev/null
+++ b/rescue/tree/sbin/fakeshutdown
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+#
+# Guillaume Cottenceau (gc@mandrakesoft.com)
+#
+# 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.
+#
+
+sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\n" : return; 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;