-
Notifications
You must be signed in to change notification settings - Fork 22
/
make-kamikaze-2.0.8.sh
executable file
·318 lines (271 loc) · 8 KB
/
make-kamikaze-2.0.8.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
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#!/bin/bash
# TODO 2.1:
# PCA9685 in devicetree
# Make redeem dependencies built into redeem
# Remove xcb/X11 dependencies
# Add sources to clutter packages
# Slic3r support
# Edit Cura profiles
# Remove root access
# /dev/ttyGS0
# TODO 2.0:
# After boot,
# initrd img / depmod-a on new kernel.
# STAGING:
# Copy uboot files to /boot/uboot
# Restart commands on install for Redeem and Toggle
# Update to Clutter 1.26.0+dsfg-1
# DONE:
# consoleblank=0
# sgx-install after changing kernel
# Custom uboot
# redeem plugin
# Toggle plugin
# Install libyaml
# redeem starts after spidev2.1
# Adafruit lib disregard overlay (Swithed to spidev)
# cura engine
# iptables-persistenthttps://github.com/eliasbakken/Kamikaze2/releases/tag/v2.0.7rc1
# clear cache
# Update dogtag
# Update Redeem / Toggle
# Sync Redeem master with develop.
# Choose Toggle config
VERSION="Kamikaze 2.0.8"
DATE=`date`
echo "**Making ${VERSION}**"
export LC_ALL=C
remove_unneeded_packages() {
echo "** Remove unneded packages **"
rm -rf /etc/apache2/sites-enabled
rm -rf /root/.c9
rm -rf /usr/local/lib/node_modules
rm -rf /var/lib/cloud9
rm -rf /usr/lib/node_modules/
apt-get purge -y bone101
apt-get purge -y nodejs
apt-get purge -y apache2
apt-get purge -y apache2-bin
apt-get purge -y apache2-data
apt-get purge -y apache2-utils
apt-get purge -y vim
apt-get purge -y linux-headers-4.4.19-ti-r41
apt-get purge -y ti-pru-cgt-installer
apt-get purge -y doc-beaglebonegreen-getting-started
apt-get purge -y doc-seeed-bbgw-getting-started
apt-get purge -y doc-beaglebone-getting-started
}
upgrade_to_stretch() {
echo "** Upgrade to stretch **"
sed -i 's/jessie/stretch/' /etc/apt/sources.list
sed -i 's%deb https://deb.nodesource.com/node_0.12 stretch main%#deb https://deb.nodesource.com/node_0.12 stretch main%' /etc/apt/sources.list
cat >/etc/apt/sources.list.d/testing.list <<EOL
#### Kamikaze ####
deb [arch=armhf] http://kamikaze.thing-printer.com/debian/ stretch main
EOL
wget -q http://kamikaze.thing-printer.com/debian/public.gpg -O- | apt-key add -
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
}
port_forwarding() {
echo "** Port Forwarding **"
# Port forwarding
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 5000
mkdir -p /etc/iptables
iptables-save > /etc/iptables/rules
cat >/etc/network/if-pre-up.d/iptables <<EOL
#!/bin/sh
/sbin/iptables-restore < /etc/iptables/rules
EOL
chmod +x /etc/network/if-pre-up.d/iptables
}
install_dependencies(){
echo "** Install dependencies **"
apt-get install -y \
swig \
socat \
ti-sgx-es8-modules-4.4.20-bone13 \
libyaml-dev \
gir1.2-mash-0.3-0 \
gir1.2-mx-2.0 \
libclutter-imcontext-0.1-0 \
libcluttergesture-0.0.2-0 \
python-scipy \
python-smbus \
python-gi-cairo \
libavahi-compat-libdnssd1
pip install evdev
pip install spidev
apt-get purge -y \
linux-image-4.4.19-ti-r41 \
rtl8723bu-modules-4.4.19-ti-r41
}
install_redeem() {
echo "**install_octoprint_redeem**"
cd /usr/src/
if [ ! -d "redeem" ]; then
git clone https://bitbucket.org/intelligentagent/redeem
fi
cd redeem
git pull
make install
# Make profiles uploadable via Octoprint
touch /etc/redeem/local.cfg
chown -R octo:octo /etc/redeem/
chown -R octo:octo /usr/src/redeem/
cd /usr/src/Kamikaze2
# Install rules
cp scripts/spidev.rules /etc/udev/rules.d/
# Install Kamikaze2 specific systemd script
cp scripts/redeem.service /lib/systemd/system
systemctl enable redeem
systemctl start redeem
}
create_user() {
echo "** Create user **"
default_groups="admin,adm,dialout,i2c,kmem,spi,cdrom,floppy,audio,dip,video,netdev,plugdev,users,systemd-journal,tisdk,weston-launch,xenomai"
mkdir /home/octo/
mkdir /home/octo/.octoprint
useradd -G "${default_groups}" -s /bin/bash -m -p octo -c "OctoPrint" octo
chown -R octo:octo /home/octo
chown -R octo:octo /usr/local/lib/python2.7/dist-packages
chown -R octo:octo /usr/local/bin
chmod 755 -R /usr/local/lib/python2.7/dist-packages
}
install_octoprint() {
echo "** Install OctoPrint **"
cd /home/octo
if [ ! -d "OctoPrint" ]; then
su - octo -c 'git clone https://github.com/foosel/OctoPrint.git'
fi
su - octo -c 'cd OctoPrint && python setup.py clean install'
cd /usr/src/Kamikaze2
# Make config file for Octoprint
cp OctoPrint/config.yaml /home/octo/.octoprint/
chown octo:octo "/home/octo/.octoprint/config.yaml"
# Fix permissions for STL upload folder
mkdir -p /usr/share/models
chown octo:octo /usr/share/models
chmod 777 /usr/share/models
# Grant octo redeem restart rights
echo "%octo ALL=NOPASSWD: /bin/systemctl restart redeem.service" >> /etc/sudoers
echo "%octo ALL=NOPASSWD: /bin/systemctl restart toggle.service" >> /etc/sudoers
echo "%octo ALL=NOPASSWD: /usr/bin/make -C /usr/src/redeem install" >> /etc/sudoers
echo "%octo ALL=NOPASSWD: /usr/bin/make -C /usr/src/toggle install" >> /etc/sudoers
# Install systemd script
cp ./OctoPrint/octoprint.service /lib/systemd/system/
systemctl enable octoprint
systemctl start octoprint
}
install_octoprint_redeem() {
echo "**install_octoprint_redeem**"
cd /usr/src/
if [ ! -d "octoprint_redeem" ]; then
git clone https://github.com/eliasbakken/octoprint_redeem
fi
cd octoprint_redeem
python setup.py install
}
install_octoprint_toggle() {
echo "**install_octoprint_toggle**"
cd /usr/src
if [ ! -d "octoprint_toggle" ]; then
git clone https://github.com/eliasbakken/octoprint_toggle
fi
cd octoprint_toggle
python setup.py install
}
install_overlays() {
echo "**install_overlays**"
cd /usr/src/
if [ ! -d "bb.org-overlays" ]; then
git clone https://github.com/eliasbakken/bb.org-overlays
fi
cd bb.org-overlays
./install.sh
}
install_sgx() {
echo "** install SGX **"
cd /usr/src/Kamikaze2
tar xfv GFX_5.01.01.02_es8.x.tar.gz -C /
cd /opt/gfxinstall/
./sgx-install.sh
cd /usr/src/Kamikaze2/
cp scripts/sgx-startup.service /lib/systemd/system/
systemctl enable sgx-startup.service
depmod -a 4.4.20-bone13
ln -s /usr/lib/libEGL.so /usr/lib/libEGL.so.1
}
install_toggle() {
echo "** install toggle **"
cd /usr/src
if [ ! -d "toggle" ]; then
git clone https://bitbucket.org/intelligentagent/toggle
fi
cd toggle
make install
chown -R octo:octo /etc/toggle/
# Make it writable for updates
chown -R octo:octo /usr/src/toggle/
cp systemd/toggle.service /lib/systemd/system/
systemctl enable toggle
systemctl start toggle
}
install_cura() {
echo "** install Cura **"
cd /usr/src/
if [ ! -d "CuraEngine" ]; then
git clone https://github.com/Ultimaker/CuraEngine
fi
cd CuraEngine/
git checkout tags/15.04.6 -b tmp
# Do perimeters first
sed -i 's/SETTING(perimeterBeforeInfill, 0);/SETTING(perimeterBeforeInfill, 1);/' src/settings.cpp
make
cp build/CuraEngine /usr/bin/
# Copy profiles into Cura.
cd /usr/src/Kamikaze2
mkdir -p /home/octo/.octoprint/slicingProfiles/cura/
cp ./Cura/profiles/*.profile /home/octo/.octoprint/slicingProfiles/cura/
chown octo:octo /home/octo/.octoprint/slicingProfiles/cura/
}
install_uboot() {
echo "** install U-boot**"
cd /usr/src/Kamikaze2
export DISK=/dev/mmcblk0
dd if=./u-boot/MLO of=${DISK} count=1 seek=1 bs=128k
dd if=./u-boot/u-boot.img of=${DISK} count=2 seek=1 bs=384k
cp ./u-boot/MLO /boot/uboot/
cp ./u-boot/u-boot.img /boot/uboot/
}
other() {
sed -i 's/cape_universal=enable/consoleblank=0 fbcon=rotate:1 omap_wdt.nowayout=0/' /boot/uEnv.txt
sed -i 's/beaglebone/kamikaze/' /etc/hostname
sed -i 's/beaglebone/kamikaze/g' /etc/hosts
sed -i 's/AcceptEnv LANG LC_*/#AcceptEnv LANG LC_*/' /etc/ssh/sshd_config
chown -R octo:octo /usr/src/Kamikaze2
apt-get clean
apt-get autoclean
rm -rf /var/cache/doc*
apt-get -y autoremove
echo "$VERSION $DATE" > /etc/dogtag
}
dist() {
remove_unneeded_packages
upgrade_to_stretch
install_sgx
port_forwarding
install_dependencies
create_user
install_redeem
install_octoprint
install_octoprint_redeem
install_octoprint_toggle
install_overlays
install_toggle
install_cura
install_uboot
other
}
dist
echo "Now reboot!"