summaryrefslogtreecommitdiffstats
path: root/rescue/Flash/scripts/clear_systemloop
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2011-01-19 10:44:49 +0000
committerAntoine Ginies <aginies@mandriva.com>2011-01-19 10:44:49 +0000
commit530a16ec071db0e24e6e949e265a96848864967c (patch)
treefe40cacd28d67b98186754c551b7fd339ebc7e17 /rescue/Flash/scripts/clear_systemloop
downloaddrakx-backup-do-not-use-530a16ec071db0e24e6e949e265a96848864967c.tar
drakx-backup-do-not-use-530a16ec071db0e24e6e949e265a96848864967c.tar.gz
drakx-backup-do-not-use-530a16ec071db0e24e6e949e265a96848864967c.tar.bz2
drakx-backup-do-not-use-530a16ec071db0e24e6e949e265a96848864967c.tar.xz
drakx-backup-do-not-use-530a16ec071db0e24e6e949e265a96848864967c.zip
add mes5-2.6.33 branch
Diffstat (limited to 'rescue/Flash/scripts/clear_systemloop')
-rwxr-xr-xrescue/Flash/scripts/clear_systemloop89
1 files changed, 89 insertions, 0 deletions
diff --git a/rescue/Flash/scripts/clear_systemloop b/rescue/Flash/scripts/clear_systemloop
new file mode 100755
index 000000000..6d7015c84
--- /dev/null
+++ b/rescue/Flash/scripts/clear_systemloop
@@ -0,0 +1,89 @@
+#!/bin/bash
+
+# import functions library
+source rescue_common
+
+tmpdir="/tmp/flash-rescue-root"
+rootdir="$tmpdir/pen"
+
+function prepare() {
+
+ mkdir -p $rootdir
+
+ if ! mount_usbroot $rootdir; then
+ return 1
+ fi
+
+ return 0
+}
+
+function doit() {
+
+ clear
+ echo
+ echo "WARNING!"
+ echo
+ echo "Mandriva Flash will be reseted to factory defaults!"
+ echo -n "All user files, customizations and new packages installed "
+ echo "will be removed."
+ echo
+ echo "This process may take a few minutes."
+ echo
+ echo -n "Do you want to continue? [N/y] "
+ read confirm
+
+ if [ x"$confirm" = x"y" -o x"$confirm" = x"Y" ]; then
+
+ if [ ! -f $loop ] || [ x"$version" != x"1.0" ]; then
+ dd if=/dev/zero of=$loop bs=4000000 count=100
+ fi
+
+ if [ x"$version" = x"1.0" ]; then
+ /sbin/mkfs.ext2 -q -F $loop
+ fi
+
+ echo
+ if [ $? -ne 0 ]; then
+ echo 'Error reseting device to factory defaults'
+ return 1
+ else
+ echo 'Mandriva Flash was restored to factory defaults!'
+ fi
+ fi
+
+ echo
+
+ return 0
+}
+
+function cleanup() {
+
+ umount $rootdir > /dev/null 2>&1
+ rmdir $rootdir $tmpdir 2> /dev/null
+}
+
+clear
+trap cleanup SIGINT
+
+version=""
+if ! insert_pendrive; then
+ exit 1
+fi
+
+if [ x"$version" = x"1.0" ]; then
+ loop="$rootdir/loopbacks/system.loop"
+else
+ loop="$rootdir/.loopbacks/system.loop"
+fi
+
+if ! prepare; then
+ cleanup
+ exit 1
+fi
+
+if ! doit; then
+ cleanup
+ exit 1
+fi
+
+cleanup