-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathUC2_install.sh
633 lines (549 loc) · 17.4 KB
/
UC2_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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
#!/bin/sh
#set -x
self="$(basename "$0")"
info="[UC2] ${self}:"
OS_USER="$USER"
if [ "${OS_USER}" = "root" ]; then
OS_USER="${SUDO_USER}"
fi
echo "${info} Identified user is: ${OS_USER}"
#General variables
USER_HOME_DIR="/home/${OS_USER}"
WORKING_DIR="${USER_HOME_DIR}/UC2"
BACKUP_DIR="${WORKING_DIR}/backups"
IMAGES_DIR="${WORKING_DIR}/images"
INSERTS_FILE="${WORKING_DIR}/inserts"
PPS_APP_URL="none"
PPS_APP_DIR="${USER_HOME_DIR}/Programming"
APPS_PATH="${USER_HOME_DIR}/.local/share/applications"
APPLAUNCHER_FILE="${USER_HOME_DIR}/.config/lxpanel/LXDE-pi/panels/panel"
AUTOSTART_FILE="${USER_HOME_DIR}/.config/lxsession/LXDE-pi/autostart"
#AUTORUN_FILE="${WORKING_DIR}/autorun.sh"
DIR_NICs="/sys/class/net/"
IP_INFO=$(curl -s ipinfo.io)
ICON_URL='https://raw.githubusercontent.com/bionanoimaging/UC2-GIT/master/RASPBERRY-PI/images/uc2_logo.ico'
STATUS_URL='https://raw.githubusercontent.com/bionanoimaging/UC2-GIT/master/RASPBERRY-PI/status'
FUNCLIB_URL='https://raw.githubusercontent.com/bionanoimaging/UC2-GIT/master/RASPBERRY-PI/funclib'
INSERTS_URL='https://raw.githubusercontent.com/bionanoimaging/UC2-GIT/master/RASPBERRY-PI/inserts'
KIVY_UP_URL='https://raw.githubusercontent.com/bionanoimaging/UC2-GIT/master/RASPBERRY-PI/bring_kivy_up.py'
ICON_URL='https://raw.githubusercontent.com/bionanoimaging/UC2-GIT/master/RASPBERRY-PI/images/uc2_logo.ico'
# Create backup folder if not present
if [ ! -d $BACKUP_DIR ]; then mkdir -p ${BACKUP_DIR}; fi
# Create images folder if not present
if [ ! -d $IMAGES_DIR ]; then mkdir -p ${IMAGES_DIR}; fi
# Fetch status file if not present
target_file="${WORKING_DIR}/status"
if [ ! -f $target_file ]; then
wget -N -q --no-check-certificate --content-disposition ${STATUS_URL}
fi
# Fetch inserts file if not present
target_file="${WORKING_DIR}/inserts"
if [ ! -f $target_file ]; then
wget -N -q --no-check-certificate --content-disposition ${INSERTS_URL}
fi
# Fetch function library if not present
target_file="${WORKING_DIR}/funclib"
if [ ! -f $target_file ]; then
wget -N -q --no-check-certificate --content-disposition ${FUNCLIB_URL}
fi
# Fetch bring_kivy_up.py if not present
target_file="${WORKING_DIR}/bring_kivy_up.py"
if [ ! -f $target_file ]; then
wget -N -q --no-check-certificate --content-disposition ${KIVY_UP_URL}
sleep 5s
chmod a+x $target_file
fi
# Fetch icon file if not present
target_file="${IMAGES_DIR}/uc2_logo.ico"
if [ ! -f $target_file ]; then
wget -N -q --no-check-certificate --content-disposition ${ICON_URL} -P $target_file
fi
# import function library
. ${WORKING_DIR}/funclib
#Declare additional functions
update_state(){
sed -i "1s/.*/state: $1/" "${WORKING_DIR}/status"
current_state="$1"
}
add_to_autostart(){
local runfile="${WORKING_DIR}/run_install.sh"
if [ ! -f $runfile ]; then
touch $runfile
else
echo -n > $runfile
fi
cat > $runfile << EOF
#!/bin/sh
lxterminal --command="sudo /bin/sh -c '${WORKING_DIR}/UC2_install.sh; /bin/bash'"
EOF
sleep 5s
chmod a+x $runfile
check_is_present "run_install" $AUTOSTART_FILE
if [ ! $is_present ]; then
make_backup $AUTOSTART_FILE "lxde"
echo $runfile >> $AUTOSTART_FILE
echo "${info} Adding installation file to ${AUTOSTART_FILE}"
else
echo "${info} Installation autostart is active."
fi
}
remove_from_autostart(){
echo "$info this is remove from autostart function doing nothing"
}
todo(){
local diff=$(($current_state-$state))
if [ $diff -lt 0 ]; then echo true; else echo false; fi
}
# get current installation progress
current_state=$(head -n 1 "${WORKING_DIR}/status")
current_state=${current_state##*:}
echo "${info} current_state: ${current_state}"
state="0"
#Check for most recently created new user
if $(todo); then
template_autostart="/etc/xdg/lxsession/LXDE-pi/autostart"
template_panel="/etc/xdg/lxpanel/LXDE-pi/panels/panel"
if [ ! -f $APPLAUNCHER_FILE ]; then
parent_dir="$(dirname "$APPLAUNCHER_FILE")"
mkdir -p $parent_dir
cp -r $template_panel $APPLAUNCHER_FILE
fi
if [ ! -f $AUTOSTART_FILE ]; then
parent_dir="$(dirname "$AUTOSTART_FILE")"
mkdir -p $parent_dir
cp -r $template_autostart $AUTOSTART_FILE
fi
echo "${info} Checking for most recently created new user..."
target_file="/var/log/auth.log"
search_string=': new user: name='
check_is_present "$search_string" $target_file
if [ $is_present ]; then
newusername=$(tac $target_file | sed -n "/${search_string}/{p;q}")
newusername=${newusername##*$search_string}
newusername=${newusername%%, *}
newusername=$(echo $newusername | tr -d ' ')
echo "${info} Found user: ${newusername}"
echo "${info} Preparing installation for ${newusername}..."
usermod $newusername -a -G pi,adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio
target_file="/etc/sudoers"
make_backup $target_file "etc"
check_is_present "${newusername} ALL=(ALL) NOPASSWD:ALL" $target_file
if [ ! $is_present ]; then
echo "${newusername} ALL=(ALL) NOPASSWD:ALL" | sudo EDITOR='tee -a' visudo >/dev/null
fi
target_file="/etc/lightdm/lightdm.conf"
find_line_no 'autologin-user=pi' $target_file
if [ $line_no -gt 0 ]; then
sed -i "${line_no}s/.*/autologin-user=${newusername}/" $target_file
fi
target_file='/etc/systemd/system/[email protected]'
find_line_no 'ExecStart=-/sbin/agetty' $target_file
if [ $line_no -gt 0 ]; then
sed -i -e "${line_no}s/pi/${newusername}/g" $target_file
fi
source_file="${AUTOSTART_FILE}"
USER_HOME_DIR="/home/${newusername}"
cp -r ${WORKING_DIR} $USER_HOME_DIR
WORKING_DIR="${USER_HOME_DIR}/UC2"
AUTOSTART_FILE="${USER_HOME_DIR}/.config/lxsession/LXDE-pi/autostart"
AUTOSTART_DIR=$(dirname "${AUTOSTART_FILE}")
mkdir -p $AUTOSTART_DIR
chown -R $newusername $USER_HOME_DIR
cp -r $source_file $AUTOSTART_FILE
source_file="${APPLAUNCHER_FILE}"
APPLAUNCHER_FILE="${USER_HOME_DIR}/.config/lxpanel/LXDE-pi/panels/panel"
APPLAUNCHER_DIR=$(dirname "${APPLAUNCHER_FILE}")
mkdir -p $APPLAUNCHER_DIR
cp -r $source_file $APPLAUNCHER_FILE
else
echo "${info} No newly created user found. Proceeding with currently logged in user ${OS_USER} after reboot..."
fi
add_to_autostart
update_state $state
sleep 5s
reboot
fi
state="1"
if $(todo); then
datetime=$(date)
echo "${info} Updating and upgrading installed packages."
sleep 45s
echo "START: ${datetime}" | sudo tee --append "${WORKING_DIR}/status" > /dev/null
apt-get -y update
apt-get -y dist-upgrade
update_state $state
fi
#check python version
state="2"
if $(todo); then
echo "${info} Checking default Python version."
sleep 45s
user=$(echo $SUDO_USER)
target_version="2.7"
python_version=$(python --version 2>&1)
case $python_version in
*"$target_version"*) echo "${info} Python 2.7 is already default" ;;
*) echo "${info} Changing default Python version to Python 2.7"
make_backup "${WORKING_DIR}/.bashrc" "home"
echo "${info} alias python=\"/usr/bin/python\"" >> "/home/${OS_USER}/.bashrc" ;;
esac
update_state $state
echo "${info} Rebooting..."
sleep 5s
reboot
fi
#install Kivy dependencies
state="3"
if $(todo); then
echo "${info} Installing Kivy dependencies."
sleep 45s
apt-get -y install libsdl2-dev
apt-get -y install libsdl2-image-dev
apt-get -y install libsdl2-mixer-dev
apt-get -y install libsdl2-ttf-dev
apt-get -y install pkg-config
apt-get -y install libgl1-mesa-dev
apt-get -y install libgles2-mesa-dev
apt-get -y install python-setuptools
apt-get -y install libgstreamer1.0-dev
apt-get -y install git-core
apt-get -y install gstreamer1.0-plugins-bad
apt-get -y install gstreamer1.0-plugins-base
apt-get -y install gstreamer1.0-plugins-good
apt-get -y install gstreamer1.0-plugins-ugly
apt-get -y install gstreamer1.0-omx
apt-get -y install gstreamer1.0-alsa
apt-get -y install python-dev
apt-get -y install libmtdev-dev
apt-get -y install xclip
apt-get -y install xsel
update_state $state
echo "${info} Rebooting..."
sleep 5s
reboot
fi
#install Cython
state="4"
if $(todo); then
echo "${info} Updating and upgrading installed packages."
sleep 45s
apt autoremove -y
apt-get -y update
apt-get -y dist-upgrade
echo "${info} Installing Cython... (approx. 30min on RaspberryPi 3B+)"
pip install -U Cython==0.28.2
echo "${info} Forcing pip, virtualenv and setuptools update in pip"
pip install --upgrade pip
pip install --upgrade virtualenv
pip install --upgrade setuptools
echo "${info} Installing pygments and docutils via pip (prior to Kivy)"
#pip install -U pygments
#pip install -U docutils
update_state $state
echo "${info} Rebooting..."
sleep 5s
reboot
fi
#Preparation of Kivy installation
state="5"
if $(todo); then
echo "${info} Updating /boot/config.txt (required by Kivy/SDL2)"
sleep 45s
boot_config="/boot/config.txt"
make_backup $boot_config "boot"
#Deleting prior existing entries
search_and_delete 'dtparam=i2c_arm' $boot_config
search_and_delete 'dtparam=audio' $boot_config
search_and_delete 'start_x=' $boot_config
search_and_delete 'gpu_mem=' $boot_config
search_and_delete 'enable_uart=' $boot_config
#Insert new configurations at bottom of file
line_no=$(wc -l $boot_config | awk '{ print $1 }')
insert_text $INSERTS_FILE 19 23 $boot_config $line_no
update_state $state
echo "${info} Rebooting..."
sleep 5s
reboot
fi
#Installation of Kivy
state="6"
if $(todo); then
echo "${info} Installing Kivy... (approx. 30min on RaspberryPi 3B+)"
sleep 45s
pip install Kivy==1.10.1
update_state $state
echo "${info} Rebooting..."
sleep 5s
reboot
fi
#check kivy is correctly installed and callable for user
state="7"
if $(todo); then
echo "${info} Bringing Kivy up... (testing)"
sleep 45s
apt -y autoremove
sudo -H -u "${OS_USER}" python "${WORKING_DIR}/bring_kivy_up.py"
update_state $state
fi
state="8"
if $(todo); then
echo "${info} Adding touchscreen provider to Kivy config-file"
sleep 45s
kivy_config="${USER_HOME_DIR}/.kivy/config.ini"
make_backup $kivy_config "kivy"
search_string="\[input\]"
find_line_no "$search_string" $kivy_config
strt=$next_line_no
stop=$((next_line_no + 1))
delete_text $strt $stop $kivy_config
insert_text $INSERTS_FILE 14 16 $kivy_config $line_no
update_state $state
fi
state="9"
if $(todo); then
echo "${info} Fetching PPS-app specific dependencies from apt-get and pip..."
sleep 45s
apt-get -y install libffi-dev
#python -m pip install cffi
python -m pip install smbus-cffi
python -m pip install unipath
python -m pip install pyusb
python -m pip install safe-cast
python -m pip install ruamel.yaml
update_state $state
echo "${info} Rebooting..."
sleep 5s
reboot
fi
#install opencv
state="10"
if $(todo); then
echo "${info} Installing OpenCV and its dependencies..."
sleep 45s
apt autoremove -y
apt-get -y install libtiff5-dev
apt-get -y install libjasper-dev
apt-get -y install libpng12-dev
apt-get -y install libjpeg-dev
apt-get -y install libavcodec-dev
apt-get -y install libavformat-dev
apt-get -y install libswscale-dev
apt-get -y install libv4l-dev
apt-get -y install libgtk2.0-dev
apt-get -y install libatlas-base-dev
apt-get -y install gfortran
apt-get -y install libopencv-dev
apt-get -y install python-opencv
apt-get -y install python-picamera
update_state $state
echo "${info} Rebooting..."
sleep 5s
reboot
fi
state="11"
if $(todo); then
echo "${info} Scanning for WiFi-interfaces..."
sleep 45s
IP_INFO=$(curl -s ipinfo.io)
sleep 15s
COUNTRY=${IP_INFO##*country}
COUNTRY=${COUNTRY%%loc*}
COUNTRY=$(echo $COUNTRY | sed "s/[^a-zA-Z]//g")
COUNTRY=$(echo $COUNTRY | tr -d ' ')
echo "${info} Identified country code is: ${COUNTRY}"
interface="wlan"
interface_state="down"
for path in "${DIR_NICs}"*; do
folder=$(basename "${path}")
case "${folder}" in "${interface}"*) iface="${folder}" break;; *) iface="none";; esac
done
if [ "${iface}" = "none" ]; then
echo "${info} No active physical interface with name \"${interface}*\" in ${DIR_NICs} found."
echo "${info} Skipping virtual access point creation..."
update_state $state
else
interface_state=$(cat "${DIR_NICs}/${iface}/operstate")
interface_state=$(echo "${interface_state}"|tr '/a-z/' '/A-Z/')
i=$(echo -n "${iface}" | tail -c 1)
if $(todo); then
echo "Found active physical interface ${iface}. Virtual access point will be created upon interface ${iface}."
fi
IFACE="${iface}"
IFACE_IP=$(ip -o -f inet addr show "${IFACE}" | awk '/scope global/ {print $4}')
MACADDR=$(cat "${DIR_NICs}/${IFACE}/address")
#IFACE_CHANNEL=$(iwlist "${IFACE}" channel)
#IFACE_CHANNEL=$(echo "${IFACE_CHANNEL#*\(}" | sed 's/[^0-9]*//g')
NETMASK=$(echo "${IFACE_IP}" | tail -c 3)
AP="ap${i}"
AP_IP="192.168.50.1"
AP_BROADCAST=${AP_IP%.*}
#echo "${info} Setting up virtual access point..."
#target_file="/etc/udev/rules.d/70-persistent-net.rules"
#
#if [ ! -f $target_file ]; then
# touch $target_file
# printf "ACTION==\"add\", SUBSYSTEM==\"ieee80211\", KERNEL=\"phy0\", \\ \n" >> $target_file
# printf "RUN+=\"/sbin/iw phy %%k interface add ${AP} type __ap\", \\ \n" >> $target_file
mkdir -p /var/log/journal
systemd-tmpfiles --create --prefix /var/log/journal
apt -y install rng-tools
apt -y install hostapd
systemctl stop hostapd
systemctl stop networking.service
systemctl stop dhcpcd.service
systemctl mask networking.service
systemctl mask dhcpcd.service
target_file="/etc/network/interfaces"
make_backup $target_file "etc_net"
mv $target_file "${target_file}~"
target_file="/etc/resolvconf.conf"
make_backup $target_file "etc"
sed -i '1i resolvconf=NO' $target_file
systemctl enable systemd-networkd.service
systemctl enable systemd-resolved.service
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
target_file="/etc/systemd/network/08-${IFACE}.network"
cat > $target_file <<EOF
[Match]
Name=${IFACE}
[Network]
DHCP=ipv4
IPv6AcceptRA=no
LinkLocalAddressing=no
IPForward=yes
IPMasquerade=yes
DNS=8.8.8.8
[DHCP]
RouteMetric=20
UseDomains=yes
EOF
target_file="/etc/systemd/network/12-${AP}.network"
cat > $target_file <<EOF
[Match]
Name=${AP}
[Network]
DHCPServer=yes
LinkLocalAddressing=no
#IPv6AcceptRA=no
IPForward=yes
IPMasquerade=yes
[Address]
Address=${AP_IP}/${NETMASK}
Broadcast=${AP_BROADCAST}.255
[DHCPServer]
PoolOffset=10
PoolSize=100
EmitDNS=yes
DNS=8.8.8.8
EOF
# target_file="/etc/systemd/network/04-wired.network"
#
#cat > $target_file <<EOF
#[Match]
#Name=eth*
#
#[Network]
#DHCP=yes
#EOF
cp -r /etc/wpa_supplicant/wpa_supplicant.conf "/etc/wpa_supplicant/wpa_supplicant-${IFACE}.conf"
sleep 5s
chmod 600 "/etc/wpa_supplicant/wpa_supplicant-${IFACE}.conf"
systemctl disable wpa_supplicant.service
systemctl enable "wpa_supplicant@${IFACE}.service"
target_file="$APPLAUNCHER_FILE"
#replace (future inactive) dhcpcd-icon with netstat-icon
search_string="type=dhcpcdui"
check_is_present $search_string $target_file
if [ $is_present ]; then
make_backup $target_file "lxde"
find_line_no $search_string $target_file
del_strt=$((line_no - 1))
del_stop=$((line_no + 3))
delete_text $del_strt $del_stop $target_file
echo "${info} Removed \"Wireless & Wired Networks\" (dhcpcdui) icon from lxpanel."
ins_strt=$((del_strt - 1))
insert_text $INSERTS_FILE 7 11 $target_file $ins_strt
echo "${info} Added \"Manage Networks\" (netstat) icon to lxpanel."
else
echo "${info} No \"Wireless & Wired Network\" (dhcpcdui) entry in lxpanel found"
fi
target_file="/etc/hostapd/hostapd.conf"
rnd=$(shuf -i 0-100000 -n 1)
AP_network="UC2_RaspberryPi_AP${rnd}"
AP_pass="UCInsecurity2"
sleep 5s
cat > $target_file <<EOF
interface=${AP}
driver=nl80211
ssid=${AP_network}
country_code=${COUNTRY}
hw_mode=g
channel=1
auth_algs=1
wpa=2
wpa_passphrase=${AP_pass}
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF
sleep 5s
chmod 600 /etc/hostapd/hostapd.conf
sed -i 's/^#DAEMON_CONF=.*$/DAEMON_CONF="\/etc\/hostapd\/hostapd.conf"/' /etc/default/hostapd
sed -i 's/^\(# Should-Start:\s*$network\)$/#\1/' /etc/init.d/hostapd
target_file="/etc/systemd/system/hostapd.service.d/override.conf"
target_folder=$(dirname $target_file)
mkdir -p ${target_folder}
cat > $target_file <<EOF
[Unit]
Wants=wpa_supplicant@${IFACE}.service
[Service]
ExecStartPre=/sbin/iw dev ${IFACE} interface add ap0 type __ap
ExecStopPost=-/sbin/iw dev ${AP} del
EOF
target_file="/etc/systemd/system/[email protected]/override.conf"
target_folder=$(dirname $target_file)
mkdir -p ${target_folder}
cat > $target_file <<EOF
[Unit]
BindsTo=hostapd.service
After=hostapd.service
[Service]
ExecStartPost=/sbin/iptables -t nat -A POSTROUTING -o ${IFACE} -j MASQUERADE
ExecStopPost=-/sbin/iptables -t nat -D POSTROUTING -o ${IFACE} -j MASQUERADE
EOF
target_file="${WORKING_DIR}/reload_hostapd.sh"
cat > $target_file <<EOF
#!/bin/sh
sleep 45s
sudo systemctl stop hostapd
sleep 5s
sudo systemctl start hostapd
EOF
chmod a+x $target_file
{ crontab -l -u ${OS_USER} 2>/dev/null; echo "@reboot sh ${target_file} > ${target_file%.*}.log"; } | crontab -u ${OS_USER} -
update_state $state
echo "${info} Rebooting..."
sleep 5s
reboot
fi
fi
state="12"
if $(todo); then
sleep 45s
auto_file="${USER_HOME_DIR}/.config/lxsession/LXDE-pi/autostart"
check_is_present "run_install" $auto_file
if [ $is_present ]; then
echo "${info} Deleting autostart entries..."
find_line_no "run_install" $auto_file
delete_line $auto_file $line_no
else
echo "${info} No entry by UC2 found in $auto_file"
fi
sleep 5s
chown -R $OS_USER $AUTOSTART_FILE
echo "${info} INSTALLATION COMPLETE."
echo 'PLEASE RUN "SUDO RASPI-CONFIG" AND ENABLE INTERFACES SSH, CAMERA AND I2C!'
update_state $state
datetime=$(date)
echo "FINISH: ${datetime}" | sudo tee --append "${WORKING_DIR}/status" > /dev/null
fi