summaryrefslogtreecommitdiff
path: root/utils/mknwzboot/uninstall_script.sh
diff options
context:
space:
mode:
Diffstat (limited to 'utils/mknwzboot/uninstall_script.sh')
-rw-r--r--utils/mknwzboot/uninstall_script.sh122
1 files changed, 122 insertions, 0 deletions
diff --git a/utils/mknwzboot/uninstall_script.sh b/utils/mknwzboot/uninstall_script.sh
new file mode 100644
index 0000000000..0e409c63cd
--- /dev/null
+++ b/utils/mknwzboot/uninstall_script.sh
@@ -0,0 +1,122 @@
1#!/bin/sh
2
3# NOTE: busybox is using ash, a very posix and very pedantic shell, make sure
4# you test your scripts with
5# busybox sh -n <script>
6# and if you really, really don't want to download busybox to try it, then go
7# ahead and brick your device
8
9# The updater script on the NWZ has a major bug/feature:
10# it does NOT clear the update flag if the update scrit fails
11# thus causing a update/reboot loop and a bricked device
12# always clear to make sure we don't end up being screwed
13nvpflag fup 0xFFFFFFFF
14
15# go to /tmp
16cd /tmp
17
18# get content partition path
19CONTENTS="/contents"
20CONTENTS_PART=`mount | grep contents | awk '{ print $1 }'`
21
22# print a message to the screen and also on the standard output
23# lcdprint x,y msg
24lcdprint ()
25{
26 echo $2
27 lcdmsg -f /usr/local/bin/font_08x12.bmp -l $1 "$2"
28}
29
30# clear screen
31lcdmsg -c ""
32lcdprint 0,3 "Contents partition:\n$CONTENTS_PART"
33
34# We need to remount the contents partition in read-write mode be able to
35# write something on it
36lcdprint 0,6 "Remount $CONTENTS rw"
37mount -o remount,rw $CONTENTS_PART $CONTENTS
38if [ "$?" != 0 ]; then
39 lcdprint 0,15 "ERROR: remount failed"
40 sleep 3
41 exit 0
42fi
43
44# redirect all output to a log file
45exec > "$CONTENTS/uninstall_dualboot_log.txt" 2>&1
46
47# import constants
48. /install_script/constant.txt
49ROOTFS_TMP_DIR=/tmp/rootfs
50SPIDERAPP_PATH=$ROOTFS_TMP_DIR/usr/local/bin/SpiderApp
51
52# mount root partition
53lcdprint 0,7 "Mount root filesystem"
54mkdir $ROOTFS_TMP_DIR
55if [ "$?" != 0 ]; then
56 lcdprint 0,15 "ERROR: mkdir failed"
57 sleep 3
58 exit 0
59fi
60
61# If there is an ext4 mounter, try it. Otherwise or on failure, try ext3 and
62# then ext2.
63# NOTE some platforms probably use an mtd and this might need some fixing
64if [ -e /usr/local/bin/icx_mount.ext4 ]; then
65 /usr/local/bin/icx_mount.ext4 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR
66else
67 false
68fi
69if [ "$?" != 0 ]; then
70 mount -t ext3 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR
71fi
72if [ "$?" != 0 ]; then
73 mount -t ext2 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR
74fi
75if [ "$?" != 0 ]; then
76 lcdprint 0,15 "ERROR: mount failed"
77 sleep 3
78 exit 0
79fi
80
81# the installer renames the OF to $SPIDERAPP_PATH.of so if it does not exists
82# print an error
83lcdprint 0,8 "Restore OF"
84if [ ! -e $SPIDERAPP_PATH.of ]; then
85 lcdprint 0,15 "ERROR: cannot find OF"
86 lcdprint 0,16 "ERROR: is Rockbox installed?"
87 sleep 3
88 exit 0
89fi
90# restore the OF
91mv $SPIDERAPP_PATH.of $SPIDERAPP_PATH
92if [ "$?" != 0 ]; then
93 lcdprint 0,15 "ERROR: restore failed"
94 sleep 3
95 exit 0
96fi
97
98# unmount root partition
99lcdprint 0,11 "Unmount root filesystem"
100sync
101if [ "$?" != 0 ]; then
102 umount "$ROOTFS_TMP_DIR"
103 lcdprint 0,15 "ERROR: sync failed"
104 sleep 3
105 exit 0
106fi
107
108umount $ROOTFS_TMP_DIR
109if [ "$?" != 0 ]; then
110 lcdprint 0,15 "ERROR: umount failed"
111 sleep 3
112 exit 0
113fi
114
115# Success screen
116lcdprint 0,15 "Rebooting in 3 seconds."
117sleep 3
118sync
119
120echo "Uninstallation successful"
121# finish
122exit 0