-
Notifications
You must be signed in to change notification settings - Fork 2
/
master_linuxrc
159 lines (126 loc) · 4.01 KB
/
master_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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/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 M1 Master Installer
WARNING: If you continue, you will erase *all* data and upgrades
on your M1. When you are done your unit will be reset
to its factory configuration and will only contain the
default skins.
This process will take a few minutes.
If you want to continue, please wait 30 seconds.
If you do not want to continue, remove the master USB memory
stick and restart the M1.
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
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 /
cat <<EOF
c
Doing a master install.
Step | Description
-----+------------------------
1/3 | Formatting disk.
EOF
/sbin/big_fdisk /dev/hda << __EOF__ > /dev/null 2>&1
d
1
d
2
d
3
d
4
n
p
1
+500M
n
p
2
w
q
__EOF__
#
# Zero out database
#
/bin/dd if=/dev/zero of=/dev/hda2 bs=1024 count=2000 > /dev/null 2>&1
/sbin/mkfs.ext2 -m0 /dev/hda1 > /dev/null 2>&1
/sbin/tune2fs -c0 -i0 /dev/hda1 > /dev/null 2>&1
mount -text2 /dev/hda1 /mnt > /dev/null 2>&1
# Needed by pf2fs.
mkdir -p /mnt/m1/install_db
mkdir -p /mnt/m1/keys
# Mount root read only
mount -oro /dev/sda /fat > /dev/null 2>&1
mount -oro /dev/sda1 /fat > /dev/null 2>&1
echo " 2/3 | Installing m1 system."
# Install from packfile
pf2fs -r /mnt -d /mnt/m1/install_db -p /fat
# copy serial nr
cp /serial.txt /mnt/m1/serial.txt
# Install from ram disk.
echo " 3/3 | Finishing installation."
grub --batch --device-map=/mnt/boot/grub/device.map --boot-drive=0x80 << EOF > /dev/null 2>&1
root (hd0,0)
setup (hd0)
quit
EOF
mount -oremount,ro /dev/hda1 /mnt
umount /dev/sda > /dev/null 2>&1
umount /dev/sda1 > /dev/null 2>&1
sync
cat << EOF
------------------------------
The M1 system has been installed.
Please power off the M1 now and remove the master USB memory stick.
EOF
sleep 100000
reboot