-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathinstall.sh
executable file
·184 lines (153 loc) · 4.15 KB
/
install.sh
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
#!/bin/sh
# Evan Widloski - 2019-03-21
# Modified Entware installer from http://bin.entware.net/armv7sf-k3.2/installer/generic.sh
set -e
HASH_LOCATION=/tmp/hash_remarkable_entware
cleanup() {
echo "Encountered error. Cleaning up and quitting..."
# get out of /opt so it can be unmounted
cd /home/root
if [ -d /home/root/.entware ]
then
rm /home/root/.entware -rf
fi
if [ -d /opt ]
then
umount /opt
rm /opt -rf
fi
if [ -d $HASH_LOCATION ]
then
rm $HASH_LOCATION -rf
fi
if [ -f /etc/systemd/system/opt.mount ]
then
rm /etc/systemd/system/opt.mount
fi
}
trap cleanup ERR
unset LD_LIBRARY_PATH
unset LD_PRELOAD
echo "Info: Checking for prerequisites and creating folders..."
if [ -d /opt ]
then
echo "Error: Folder /opt exists! Quitting..."
exit 1
else
if [ -d /home/root/.entware ]
then
echo "Error: Folder /home/root/.entware exists! Quitting..."
exit 1
else
mkdir /opt
# mount /opt in /home for more storage space
mkdir -p /home/root/.entware
mount --bind /home/root/.entware /opt
fi
fi
# create systemd mount unit to mount over /opt on reboot
cat >/etc/systemd/system/opt.mount <<EOF
[Unit]
Description=Bind mount over /opt to give entware more space
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
[Mount]
What=/home/root/.entware
Where=/opt
Type=none
Options=bind
[Install]
WantedBy=local-fs.target
EOF
systemctl daemon-reload
systemctl enable opt.mount
# no need to create many folders. entware-opt package creates most
for folder in bin etc lib tmp var/lock
do
if [ -d "/opt/$folder" ]
then
echo "Warning: Folder /opt/$folder exists!"
echo "Warning: If something goes wrong please clean /opt folder and try again."
else
mkdir -p /opt/$folder
fi
done
echo "Info: Opkg package manager deployment..."
DLOADER="ld-linux.so.3"
URL=http://bin.entware.net/armv7sf-k3.2/installer
REPO=Evidlo/remarkable_entware
mkdir -p $HASH_LOCATION
wget $URL/opkg -O $HASH_LOCATION/opkg
chmod 755 $HASH_LOCATION/opkg
wget $URL/opkg.conf -O $HASH_LOCATION/opkg.conf
wget $URL/ld-2.27.so -O $HASH_LOCATION/ld-2.27.so
wget $URL/libc-2.27.so -O $HASH_LOCATION/libc-2.27.so
wget $URL/libgcc_s.so.1 -O $HASH_LOCATION/libgcc_s.so.1
wget $URL/libpthread-2.27.so -O $HASH_LOCATION/libpthread-2.27.so
# validate integrity of downloaded files
precomputed_hash=$(wget -O - "http://raw.githubusercontent.com/$REPO/master/hash.txt")
hash=$(cat $HASH_LOCATION/* | md5sum)
if [ "$hash" = "$precomputed_hash" ]
then
echo pass
else
echo "Computed hash did not match."
exit 1
fi
mkdir -p /opt/lib/opkg
mv $HASH_LOCATION/opkg /opt/bin/
mv $HASH_LOCATION/opkg.conf /opt/etc/
mv $HASH_LOCATION/ld-2.27.so /opt/lib/
mv $HASH_LOCATION/libc-2.27.so /opt/lib/
mv $HASH_LOCATION/libgcc_s.so.1 /opt/lib/
mv $HASH_LOCATION/libpthread-2.27.so /opt/lib/
rm -rf $HASH_LOCATION
cd /opt/lib
chmod 755 ld-2.27.so
ln -s ld-2.27.so $DLOADER
ln -s libc-2.27.so libc.so.6
ln -s libpthread-2.27.so libpthread.so.0
/opt/bin/opkg update
/opt/bin/opkg install entware-opt wget wget-ssl ca-certificates
# switch to wget compiled w/ ssl for https
rm /opt/bin/wget
ln -s /opt/libexec/wget-ssl /opt/bin/wget
sed -i 's|http://|https://|g' /opt/etc/opkg.conf
# Fix for multiuser environment
chmod 777 /opt/tmp
# now try create symlinks - it is a std installation
if [ -f /etc/passwd ]
then
ln -sf /etc/passwd /opt/etc/passwd
else
cp /opt/etc/passwd.1 /opt/etc/passwd
fi
if [ -f /etc/group ]
then
ln -sf /etc/group /opt/etc/group
else
cp /opt/etc/group.1 /opt/etc/group
fi
if [ -f /etc/shells ]
then
ln -sf /etc/shells /opt/etc/shells
else
cp /opt/etc/shells.1 /opt/etc/shells
fi
if [ -f /etc/shadow ]
then
ln -sf /etc/shadow /opt/etc/shadow
fi
if [ -f /etc/gshadow ]
then
ln -sf /etc/gshadow /opt/etc/gshadow
fi
if [ -f /etc/localtime ]
then
ln -sf /etc/localtime /opt/etc/localtime
fi
echo ""
echo "Info: Congratulations! Entware has been installed."
echo "Info: Add /opt/bin & /opt/sbin to your PATH by executing"
echo 'ssh [email protected] echo '\\\'\''PATH=/opt/bin:/opt/sbin:$PATH'\'\\\'\'' >> ~/.bashrc'\'