Skip to content

Commit 6fab6f8

Browse files
committed
od: od-update: Give ability for users to select device manually
Signed-off-by: Sergiy Kukunin <[email protected]>
1 parent 721178c commit 6fab6f8

File tree

2 files changed

+91
-11
lines changed

2 files changed

+91
-11
lines changed

board/opendingux/create-opk.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ ${HOST_DIR}/usr/bin/mksquashfs \
5656
board/opendingux/opendingux_icon.png \
5757
board/opendingux/opk_update_script.sh \
5858
${TARGET_DIR}/usr/sbin/od-update \
59+
${TARGET_DIR}/usr/bin/thisdevice \
5960
${BINARIES_DIR}/${CONFIG}-update-${DATE}.opk \
6061
-noappend -no-xattrs -all-root
6162

board/opendingux/opk_update_script.sh

Lines changed: 90 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,85 @@ cd `dirname $0`
44

55
DATE_FILE=./date.txt
66

7+
export DIALOGOPTS="--colors --no-shadow"
8+
if [ -f "$DATE_FILE" ] ; then
9+
DATE="`cat $DATE_FILE`"
10+
export DIALOGOPTS="$DIALOGOPTS --backtitle \"OpenDingux update $DATE\""
11+
fi
12+
13+
echo "screen_color = (RED,RED,ON)" > /tmp/dialog_err.rc
14+
15+
# ----------
16+
# 1. Select and confirm device
17+
# ----------
18+
THISDEVICE=./thisdevice
19+
DEVICE=$($THISDEVICE --detect)
20+
while true; do
21+
if [ -n "$DEVICE" ]; then
22+
eval $($THISDEVICE --device $DEVICE | grep DEVICE_NAME)
23+
if [ -z "$DEVICE_NAME" ]; then
24+
DEVICE=
25+
continue
26+
fi
27+
DEVICE_LINE="
28+
\Zb\Z3$DEVICE_NAME\Zn
29+
"
30+
if [ "$DEVICE_SELECTED" -eq 1 ]; then
31+
TITLE="The selected device is"
32+
else
33+
TITLE="We detected this device as"
34+
fi
35+
DEVICE_CONFIRMATION="$TITLE:
36+
$DEVICE_LINE
37+
Flashing incorrect firmware will
38+
likely make your device unbootable.
39+
40+
You can select your device from
41+
manually from the list.
42+
43+
Proceed with the current device?"
44+
45+
dialog --yes-label 'Continue' --no-label 'Select' \
46+
--yesno "$DEVICE_CONFIRMATION" 0 0
47+
if [ $? -eq 0 ] ; then
48+
break
49+
fi
50+
else
51+
DEVICE_WARNING="\Zb\Z1We could not detect your device\Zn
52+
53+
Flashing incorrect firmware will
54+
likely make your device unbootable.
55+
56+
Please CAREFULLY select your device
57+
manually from the list."
58+
59+
dialog --defaultno --yes-label 'Select' --no-label 'Exit' \
60+
--yesno "$DEVICE_WARNING" 0 0
61+
if [ $? -ne 0 ] ; then
62+
exit $?
63+
fi
64+
fi
65+
66+
exec 3>&1
67+
NEW_DEVICE=$($THISDEVICE --devices $1 | while read i; do
68+
echo $i | cut -d'-' -f1 | xargs
69+
echo $i | cut -d'-' -f2- | xargs
70+
done | tr \\n \\0 | xargs -0 \
71+
dialog --menu "Select your device from the list" 0 0 3 \
72+
2>&1 1>&3)
73+
EXIT_STATUS=$?
74+
exec 3>&-
75+
if [ $EXIT_STATUS -ne 0 ] ; then
76+
continue
77+
fi
78+
79+
DEVICE=$NEW_DEVICE
80+
DEVICE_SELECTED=1
81+
done
82+
83+
# ----------
84+
# 2. Final confirmation
85+
# ----------
786
DISCLAIMER="\Zb\Z3NOTICE\Zn
887
988
While we carefully constructed this
@@ -16,30 +95,27 @@ you perform the update.
1695
1796
Do you want to update now?"
1897

19-
UP_TO_DATE=yes
20-
21-
if [ -f "$DATE_FILE" ] ; then
22-
DATE="`cat $DATE_FILE`"
23-
export DIALOGOPTS="--colors --no-shadow --backtitle \"OpenDingux update $DATE\""
24-
fi
25-
26-
echo "screen_color = (RED,RED,ON)" > /tmp/dialog_err.rc
27-
2898
dialog --defaultno --yes-label 'Update' --no-label 'Cancel' --yesno "$DISCLAIMER" 0 0
2999
if [ $? -ne 0 ] ; then
30100
exit $?
31101
fi
32102

103+
# ----------
104+
# 3. Flashing
105+
# ----------
33106
clear
34107
echo 'Update in progress - please be patient.'
35108
echo
36109

37110
if [ "$(whoami)" = "root" -a ! -x /usr/sbin/od-update ]; then
38-
./od-update $1
111+
PATH=$(pwd):$PATH FORCE_DEVICE="$DEVICE" ./od-update $1
39112
else
40-
sudo od-update $1
113+
sudo PATH=$(pwd):$PATH FORCE_DEVICE="$DEVICE" od-update $1
41114
fi
42115

116+
# ----------
117+
# 4. Checking status
118+
# ----------
43119
ERR=$?
44120
if [ $ERR -ne 0 ] ; then
45121
case $ERR in
@@ -92,6 +168,9 @@ if [ $ERR -ne 0 ] ; then
92168
exit $ERR
93169
fi
94170

171+
# ----------
172+
# 5. Reboot
173+
# ----------
95174
case $1 in
96175
rs90)
97176
LAST_KERNEL=START

0 commit comments

Comments
 (0)