-
Notifications
You must be signed in to change notification settings - Fork 35
/
jun.patch
executable file
·256 lines (248 loc) · 7.01 KB
/
jun.patch
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
diff --git a/etc/passwd b/etc/passwd
index 6a0344d..cf95fbd 100644
--- a/etc/passwd
+++ b/etc/passwd
@@ -1,4 +1,4 @@
-root:x:0:0::/root:/bin/ash
+root::0:0::/root:/bin/ash
system:x:1:1::/usr/syno/synoman:/usr/bin/nologin
daemon:x:2:2::/:/bin/sh
lp:x:7:7::/var/spool/lpd:/bin/sh
diff --git a/etc/rc b/etc/rc
index e706c59..2d29b47 100755
--- a/etc/rc
+++ b/etc/rc
@@ -163,6 +163,8 @@ if [ "$PLATFORM" = "grantley" ]; then
fi
SYNOLoadIPv6
+. /etc.defaults/rc.modules
+KERNEL_MODULES="${KERNEL_MODULES} ${EXTRA_MODULES}"
SYNOLoadModules ${KERNEL_MODULES}
SYNOLoadAdt7490
SoftLink7490fanInput
diff --git a/etc/synoinfo.conf b/etc/synoinfo.conf
index 3536bde..f158b28 100755
--- a/etc/synoinfo.conf
+++ b/etc/synoinfo.conf
@@ -276,7 +276,6 @@ support_disk_performance_test="yes"
support_share_quota="yes"
support_dr_snap="yes"
support_performance_event="yes"
-supportadt7490="yes"
support_hotspare="yes"
vpn_conn_max="30"
buzzeroffen="0x9f"
-maxdisks="12"
+maxdisks="15"
-internalportcfg="0xfff"
+internalportcfg="0x78FF"
-esataportcfg="0x1000"
+esataportcfg="0x0"
-usbportcfg="0xffe000"
+usbportcfg="0x8700"
diff --git a/linuxrc.syno b/linuxrc.syno
index 78583d2..a8f641b 100755
--- a/linuxrc.syno
+++ b/linuxrc.syno
@@ -37,12 +37,48 @@ USB_MODULES="${USB_MODULES} etxhci-hcd" # for Etron USB3.0
SupportSAS=`/bin/get_key_value $SYNOINFO_DEF supportsas`
SupportDualhead=`/bin/get_key_value $SYNOINFO_DEF support_dual_head`
+FixSynoboot()
+{
+ tail -n+3 /proc/partitions | while read major minor sz name
+ do
+ if echo $name | grep -q "^sd[[:alpha:]]*$";then
+ basename=$name
+ minor0=$minor
+ synoboot1=""
+ synoboot2=""
+ continue
+ fi
+ if [ $name = "${basename}1" -a $sz -le 512000 ]; then
+ synoboot1="$name"
+ minor1=$minor
+ elif [ $name = "${basename}2" -a $sz -le 512000 ]; then
+ synoboot2="$name"
+ minor2=$minor
+ else
+ continue
+ fi
+ if [ -n "$synoboot1" -a -n "$synoboot2" ]; then
+ rm "/dev/$basename"
+ rm "/dev/$synoboot1"
+ rm "/dev/$synoboot2"
+ # leave other partitions as is for now
+ mknod /dev/synoboot b $major $minor0
+ mknod /dev/synoboot1 b $major $minor1
+ mknod /dev/synoboot2 b $major $minor2
+ break
+ fi
+ done
+}
+
Exit()
{
if [ -n "$2" ]; then
echo "Exit on error [$1] $2..."
fi
+ sleep 2
+ [ -e /dev/synoboot ] || FixSynoboot
+
# show date for login info
date
@@ -80,6 +116,9 @@ fi
# insert basic USB modules for detect f401/FDT
echo "Insert basic USB modules..."
SYNOLoadModules $USB_MODULES
+SYNOLoadModules "usb-storage"
+. /etc.defaults/rc.modules
+SYNOLoadModules $DISK_MODULES
#insert net driver(Mindspeed only)
echo "Insert net driver(Mindspeed only)..."
@@ -345,8 +384,11 @@ fi
# check if upgrade
#
if [ 0 -eq $FsckFailed ]; then
- echo '------------upgrade'
- /bin/sh /usr/syno/sbin/upgrade.sh
+ if echo '------------upgrade';then
+ /bin/sh /usr/syno/sbin/upgrade.sh
+ else
+ /bin/sh /usr/syno/sbin/upgrade.sh > /dev/null
+ fi
if [ $? -ne 0 ]; then
touch /.untar_upgrade_file_failed
Exit 6 "upgrade failed"
diff --git a/usr/sbin/init.post b/usr/sbin/init.post
index 17fd86d..b515d25 100755
--- a/usr/sbin/init.post
+++ b/usr/sbin/init.post
@@ -21,6 +21,126 @@ done
mount $RootDevice /tmpRoot -o barrier=1
+RC_MODULES=/etc.defaults/rc.modules
+RC_EXTRAS=""
+WL_MODULES=""
+WL_FIRMWARES=""
+OPTIONAL_MODULES=""
+
+if ! fgrep -q "$RC_MODULES" /tmpRoot/etc/rc; then
+ /tmpRoot/usr/bin/sed -i '/^SYNOLoadModules \${KERNEL_MODULES}$/{$!{N;s/^.*\n\SYNOLoadAdt7490$/&/ ;t i;P;D;:i
+i . '"$RC_MODULES"'
+i KERNEL_MODULES="${KERNEL_MODULES} ${EXTRA_MODULES}"
+}}' /tmpRoot/etc/rc
+fi
+
+if ! fgrep -q "$RC_MODULES" /tmpRoot/etc.defaults/rc; then
+ /tmpRoot/usr/bin/sed -i '/^SYNOLoadModules \${KERNEL_MODULES}$/{$!{N;s/^.*\n\SYNOLoadAdt7490$/&/ ;t i;P;D;:i
+i . '"$RC_MODULES"'
+i KERNEL_MODULES="${KERNEL_MODULES} ${EXTRA_MODULES}"
+}}' /tmpRoot/etc.defaults/rc
+fi
+
+if ! fgrep -q '_modpath=/lib/modules/update/${_mod}${_suffix}' /tmpRoot/etc/rc.subr; then
+ /tmpRoot/usr/bin/sed -i '\%^\t\t_modpath=/lib/modules/${_mod}${_suffix}%{
+ i\ \ _modpath=/lib/modules/update/${_mod}${_suffix}
+ i\ \ [ -f "$_modpath" ] ||
+ }' /tmpRoot/etc/rc.subr
+fi
+
+if ! fgrep -q '_modpath=/lib/modules/update/${_mod}${_suffix}' /tmpRoot/etc.defaults/rc.subr; then
+ /tmpRoot/usr/bin/sed -i '\%^\t\t_modpath=/lib/modules/${_mod}${_suffix}%{
+ i\ \ _modpath=/lib/modules/update/${_mod}${_suffix}
+ i\ \ [ -f "$_modpath" ] ||
+ }' /tmpRoot/etc.defaults/rc.subr
+fi
+
+/tmpRoot/usr/bin/cmp -s "$RC_MODULES" "/tmpRoot/$RC_MODULES" ||
+ cp "$RC_MODULES" "/tmpRoot/$RC_MODULES"
+
+. $RC_MODULES
+
+
+# $1 src, $2 dst, $3 shortname
+_cp_mod()
+{
+ local dest="/tmpRoot/$2"
+ [ -f "$1" ] || return 1
+ /tmpRoot/usr/bin/cmp -s "$1" "$dest" && return 2
+
+ if [ -f "$dest" ]; then
+ echo "Updating $dest..."
+ else
+ [ "x$1" != "x$2" -a -f "/tmpRoot/$1" ] &&
+ /tmpRoot/usr/bin/cmp -s "$1" "/tmpRoot/$1" &&
+ return 3
+ echo "Installing $dest..."
+ local d=`dirname "$dest"`
+ [ -d "$d" ] || mkdir -p "$d" || return 4
+ fi
+ cp -a "$1" "$dest"
+}
+
+# should modify module to avoid overwrite firmware
+# otherwise there is no good way to update firmware
+_cp_fw()
+{
+ local dst="/tmpRoot/$2"
+ /tmpRoot/usr/bin/cmp -s "$1" "$dst" && return 1
+ if [ -f "$dst" ]; then
+ echo "Updating $dst..."
+ else
+ local d=`dirname "$dst"`
+ [ -d "$d" ] || mkdir -p "$d" || return 2
+ echo "Installing $dst..."
+ fi
+ cp -a "$1" "/tmpRoot/$2"
+}
+
+for mod in $DISK_MODULES $EXTRA_MODULES $OPTIONAL_MODULES; do
+ src=/usr/lib/modules/${mod}.ko
+ dest=/usr/lib/modules/update/${mod}.ko
+ _cp_mod $src $dest
+ #echo "install $mod returns $?"
+done
+
+for fw in $EXTRA_FIRMWARES; do
+ path=/usr/lib/firmware/${fw}
+ _cp_fw $path $path
+ #echo "install $fw returns $?"
+done
+
+#$1 pattern, $2 path
+_del()
+{
+ if grep -q "$1" "$2";then
+ /tmpRoot/usr/bin/sed -i "$2" -e "/$1/ d"
+ fi
+}
+
+_del 'supportadt7490="yes"' /tmpRoot/etc.defaults/synoinfo.conf
+
+#$1 pattern, $2 replace, $3 path
+_replace()
+{
+ if grep -q "$1" "$3";then
+ /tmpRoot/usr/bin/sed -i "$3" -e "s/$1/$2/"
+ fi
+}
+
+_replace 'esataportcfg="ff000"' 'esataportcfg="0x0"' /tmpRoot/etc.defaults/synoinfo.conf
+_replace 'usbportcfg="0x300000"' 'usbportcfg="0x8700"' /tmpRoot/etc.defaults/synoinfo.conf
+_replace 'internalportcfg="0xfff"' 'internalportcfg="0x78FF"' /tmpRoot/etc.defaults/synoinfo.conf
+_replace 'maxdisks="12"' 'maxdisks="15"' /tmpRoot/etc.defaults/synoinfo.conf
+
+UPSTART="/tmpRoot/usr/share/init"
+
+if ! echo; then
+ _replace '^start on' '#start on' $UPSTART/tty.conf
+ _replace "console output" "console none" $UPSTART/syno_poweroff_task.conf
+ _replace "console output" "console none" $UPSTART/burnin_loader.conf
+ _replace "console output" "console none" $UPSTART/udevtrigger.conf
+ _replace "console output" "console none" $UPSTART/bs-poweroff.conf
+ _replace "console output" "console none" $UPSTART/udevd.conf
+else
+ _replace '^#start on' 'start on' $UPSTART/tty.conf
+fi
+
mkdir -p /tmpRoot/initrd
umount /proc &> /dev/null