-
Notifications
You must be signed in to change notification settings - Fork 2
/
upgrade_linuxrc
138 lines (106 loc) · 3.25 KB
/
upgrade_linuxrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/ash
# (C) 2006,2007 Magden LLC. All rights reserved.
# This script will be /sbin/init of the master USB memory stick created by create_master.sh
# The purpose of the script is to do a factory (re-)install of an M1 unit.
#
#
# Decrease logging to avoid clutter
#
dmesg -n 1
insmod /lib/modules/2.6.24/kernel/drivers/scsi/scsi_mod.ko
insmod /lib/modules/2.6.24/kernel/drivers/scsi/sd_mod.ko
insmod /lib/modules/2.6.24/kernel/drivers/usb/core/usbcore.ko
insmod /lib/modules/2.6.24/kernel/drivers/hid/usbhid/usbhid.ko
insmod /lib/modules/2.6.24/kernel/drivers/usb/storage/usb-storage.ko
insmod /lib/modules/2.6.24/kernel/drivers/usb/host/uhci-hcd.ko
insmod /lib/modules/2.6.24/kernel/drivers/usb/host/ohci-hcd.ko
# We get high speed USB device resets in the kernel log when we use ehci. Fall back to ohci for now.
# insmod /lib/modules/2.6.24/kernel/drivers/usb/host/ehci-hcd.ko
#sleep 7
mount -t proc none /proc
cat <<EOF
c
Magden M.1 Upgrade.
This process will take a few minutes. Your settings
will be preserved.
If you want to continue, please wait 15 seconds.
If you do not want to continue, please power off
the M.1 and remove the USB stick.
EOF
# No expr and minimalistic shell gives crappy performance.
echo -ne " ............... \r"; sleep 1
echo -ne " .............. \r"; sleep 1
echo -ne " ............. \r"; sleep 1
echo -ne " ............ \r"; sleep 1
echo -ne " ........... \r"; sleep 1
echo -ne " .......... \r"; sleep 1
echo -ne " ......... \r"; sleep 1
echo -ne " ........ \r"; sleep 1
echo -ne " ....... \r"; sleep 1
echo -ne " ...... \r"; sleep 1
echo -ne " ..... \r"; sleep 1
echo -ne " .... \r"; sleep 1
echo -ne " ... \r"; sleep 1
echo -ne " .. \r"; sleep 1
echo -ne " . \r"; sleep 1
cd /
mount /dev/hda1 /mnt
# Mount root read only
mount -oro /dev/sda /fat > /dev/null 2>&1
mount -oro /dev/sda1 /fat > /dev/null 2>&1
M1_SERIAL=`cat /mnt/m1/serial.txt`
#
# Check that we have the correct serial
#
for i in /fat/*.pfl
do
# Check that our target device is correct.
strings $i | grep -q Target-Device
SPECIFIC_TARGET="$?"
strings $i | grep Target-Device | grep -q $M1_SERIAL
if [ $SPECIFIC_TARGET == "0" -a "$?" != "0" ]
then
echo "c"
echo -n "The USB stick is for "
strings $i | grep Target-Device:
echo "The upgrade on the USB stick is for M.1 unit: $M1_SERIAL."
echo
echo "Please remove USB stick and power cycle the M.1 unit."
sleep 100000
reboot
fi
done
cat <<EOF
c
Doing a master install.
Step | Description
-----+------------------------
1/2 | Installing upgrade.
EOF
# Install from packfile
pf2fs -r /mnt -d /mnt/m1/install_db -p /fat
PF_RES="$?"
if [ $PF_RES == "0" ]
then
echo " 2/2 | Finishing install."
fi
mount -oremount,ro /dev/hda1 /mnt
umount /dev/sda > /dev/null 2>&1
umount /dev/sda1 > /dev/null 2>&1
sync
if [ $PF_RES == "0" ]
then
cat << EOF
------------------------------
The M1 system has been upgraded.
Please power off the M1 now and remove the master USB memory stick.
EOF
else
cat << EOF
------------------------------
The M1 system could not be upgraded.
Please power off the M1 now and remove the master USB memory stick.
EOF
fi
sleep 100000
reboot