07a841baf002455d0889f2eac9791da0f13a62c0
[kernel-power] / kernel-power-2.6.28 / debian / kernel-power-deinstall
1 #!/bin/sh
2 tmp=/tmp/kernel-deinstall
3 cat > $tmp <<EOF
4 This program will remove the enhanced power-user Linux kernel
5 and restore the original Nokia kernel.
6 The settings will be kept but will have no effect.
7
8 For the deinstallation please make sure that you are connected to
9 the Internet and that Application Manager is not running.
10
11 If you want keep the enhanced kernel, cancel the installation now
12 by tapping the blurred area above this dialog.
13 Otherwise confirm the dialog to proceed with the deinstallation.
14
15 After the installation, you need to unplug the USB cable,
16 completely shutdown your device, and boot again to activate the original Nokia kernel.
17 EOF
18 maemo-confirm-text "Kernel-Power Flasher" $tmp
19 res=$?
20 rm -f $tmp
21 dbus="run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications"
22 dbusmsg () { $dbus org.freedesktop.Notifications.SystemNoteInfoprint string:"$1"; }
23 dbusbox () { $dbus org.freedesktop.Notifications.SystemNoteDialog string:"$1" uint32:0 string:OK; }
24
25 if test "$res" != 0; then
26     dbusmsg "User has cancelled the deinstallation. No changes were made."
27     exit 1
28 fi
29
30 if pgrep -f /usr/bin/hildon-application-manager > /dev/null; then
31     dbusbox "Error: Application Manager is running. Please close it before deinstallation."
32     exit 1
33 fi
34 if pgrep -f apt-worker > /dev/null; then
35     dbusbox "Error: apt is running. Please wait and try again later."
36     exit 1
37 fi
38
39 dbusmsg "Please wait while restoring Nokia kernel..."
40
41 apt-get install --reinstall -y kernel kernel-flasher > $tmp
42 ok=$?
43 cat $tmp
44 if grep -qE "(Could not resolve host|cannot be downloaded)" $tmp; then
45     dbusbox "Error during deinstallation: Could not download Nokia kernel. Please make sure the internet connection is working."
46     rm $tmp
47     exit 1
48 fi
49 if test $ok = 0 && grep -q "Image flashed successfully" $tmp; then :
50 else
51     dbusbox "Error during deinstallation: Could not install Nokia kernel."
52     rm $tmp
53     exit 1
54 fi
55 dbusmsg "Nokia kernel was restored. Removing enhanced kernel packages..."
56 apt-get remove -y kernel-power kernel-power-modules > $tmp
57 ok=$?
58 cat $tmp
59 if test $ok = 0; then
60     dbusbox "Kernel sucessfully deinstalled. Nokia kernel was restored."
61 else
62     dbusbox "Warning: Nokia kernel was restored but could not remove enhanced kernel."
63 fi
64 rm $tmp
65 exit $ok