forked from outdoorbits/little-backup-box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-little-backup-box.sh
executable file
·648 lines (522 loc) · 22.3 KB
/
install-little-backup-box.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
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
#!/usr/bin/env bash
# Author: Stefan Saam, [email protected]
# Original author: Dmitri Popov, [email protected]
#######################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#######################################################################
# accepts one optional argument: branch
# IMPORTANT for developers:
# All actions have to be sufficient for modes install and update!
# To differ between both modes, use variable SCRIPT_MODE:
# if [ "${SCRIPT_MODE}" = "install" ]; then ...
# if [ "${SCRIPT_MODE}" = "update" ]; then ...
# Don't start as root
if [[ $EUID -eq 0 ]]; then
echo "Run the script as a regular user"
exit 1
fi
# get OS release version
OS_RELEASE=$(lsb_release -a | grep 'Release:' | cut -d':' -f 2 | xargs)
# check arguments
if [ $# -gt 0 ]; then
branch=${1}
else
branch="main"
fi
echo "Selected branch: ${branch}"
# internet-connection required
ping -c1 google.com &>/dev/null
INTERNET_STATUS=$?
if [ "${INTERNET_STATUS}" != "0" ]; then
echo "No internet-connection detected. Exit."
exit 0
fi
# define users
USER_WWW_DATA="www-data"
USER_SAMBA="lbb"
# change into actual user-dir
cd
# Definitions
BACKTITLE="Little Backup Box"
const_WEB_ROOT_LBB="/var/www/little-backup-box"
# define DIRs
INSTALLER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ ! "${INSTALLER_DIR}" =~ "little-backup-box" ]]; then
# in case it is called by regular install command (curl ...)
INSTALLER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/little-backup-box"
fi
# configure unconfigured/broken packages (=safety)
sudo dpkg --configure -a
# running as installer or as updater?
if [ -d "${const_WEB_ROOT_LBB}" ]; then
SCRIPT_MODE="update"
echo "Installer-script running as UPDATER"
else
SCRIPT_MODE="install"
echo "Installer-script running as INSTALLER"
sudo DEBIAN_FRONTEND=noninteractive \
apt \
-o "Dpkg::Options::=--force-confold" \
-o "Dpkg::Options::=--force-confdef" \
install -y -q --allow-downgrades --allow-remove-essential --allow-change-held-packages \
dialog
fi
# Do all user-interactions
## Prompt to choose the default backup mode
CHOICE_BACKUP_MODE=1
if [ "${SCRIPT_MODE}" = "install" ]; then
OPTIONS=(
1 "none"
2 "USB-source -> USB-target storage"
3 "USB-source -> internal storage"
4 "Camera -> USB-target storage"
5 "Camera -> internal storage"
)
CHOICE_BACKUP_MODE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "Backup Mode" \
--menu "Select the default backup mode:" \
20 50 7 \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
fi
## Prompt to install comitup
CHOICE_COMITUP=1
if [ "${SCRIPT_MODE}" = "install" ]; then
read -r -d '' COMITUP_INSTALL_QUESTION << EOM
\Zb\ZuInstall comitup?\Zn
Do you want to allow Little-Backup-Box to work as a WiFi-access-point and make yourself independent of other WiFi-networks?
Do you want zu connect your Little-Backup-Box flexible to any WiFi, managed conveniently by web-gui?
Comitup provides all these capabilities.
EOM
dialog --clear \
--colors \
--title "comitup" \
--backtitle "$BACKTITLE" \
--yesno "${COMITUP_INSTALL_QUESTION}" \
14 80
CHOICE_COMITUP=$?
clear
fi
# Update source and perform the full system upgrade
echo "apt update..."
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive \
apt \
-o "Dpkg::Options::=--force-confold" \
-o "Dpkg::Options::=--force-confdef" \
full-upgrade -y -q --allow-downgrades --allow-remove-essential --allow-change-held-packages
# Install the required packages
echo "apt install..."
sudo DEBIAN_FRONTEND=noninteractive \
apt \
-o "Dpkg::Options::=--force-confold" \
-o "Dpkg::Options::=--force-confdef" \
install -y -q --allow-downgrades --allow-remove-essential --allow-change-held-packages \
acl git screen rsync exfat-fuse exfatprogs ntfs-3g acl bindfs gphoto2 libimage-exiftool-perl php php-cli samba samba-common-bin vsftpd imagemagick curl dos2unix libimobiledevice6 ifuse sshpass apache2 apache2-utils libapache2-mod-php bc f3 sqlite3 php-sqlite3 ffmpeg libheif-examples libraw-bin openvpn wireguard openresolv hfsprogs fuse3 python3 python3-pip python3-pil python3-configobj python3-gpiozero python3-qrcode
# Remove packages not needed anymore
if [ "${SCRIPT_MODE}" = "update" ]; then
echo "apt purge..."
sudo DEBIAN_FRONTEND=noninteractive \
apt purge minidlna -y
fi
# Remove obsolete packages
sudo DEBIAN_FRONTEND=noninteractive \
apt autoremove -y
# disable services
sudo systemctl disable openvpn.service
# raspberry pi 5: usb_max_current_enable
if (( ${OS_RELEASE} > 11 )); then
# older os cant be used with raspberry pi 5
CONFIG_TXT="/boot/firmware/config.txt"
VAR="usb_max_current_enable"
VALUE=1
if ! grep -q "${VAR}" "${CONFIG_TXT}"; then
echo "${VAR}=${VALUE}" | sudo tee -a "${CONFIG_TXT}"
else
sudo sed -i "/^${VAR}/s/\(.[^=]*\)\([ \t]*=[ \t]*\)\(.[^=]*\)/\1\2${VALUE}/" "${CONFIG_TXT}"
fi
fi
# Clone Little Backup Box
echo "Cloning Little Backup Box"
cd
rm -R ${INSTALLER_DIR}
git clone --branch "${branch}" https://github.com/outdoorbits/little-backup-box.git
GIT_CLONE=$?
if [ "${GIT_CLONE}" -gt 0 ]; then
echo "Cloning little-backup-box from github.com failed. Please try again later."
exit 0
fi
#write branch into constants
echo "const_SOFTWARE_VERSION='${branch}'" | sudo tee -a "${INSTALLER_DIR}/scripts/constants.sh"
# read new constants
source "${INSTALLER_DIR}/scripts/constants.sh"
# keep config file
if [ "${SCRIPT_MODE}" = "update" ]; then
if [ -f "${const_WEB_ROOT_LBB}/config.cfg" ]; then
echo "keep config..."
yes | sudo cp -f "${const_WEB_ROOT_LBB}/config.cfg" "${INSTALLER_DIR}/scripts/"
fi
if [ -f "${const_CMD_RUNNER_LOCKFILE}" ]; then
yes | sudo cp -f "${const_CMD_RUNNER_LOCKFILE}" "${INSTALLER_DIR}/scripts/"
fi
sudo rm -R ${const_WEB_ROOT_LBB}/*
fi
# install little-backup-box-files
sudo mkdir -p "${const_WEB_ROOT_LBB}"
yes | sudo cp -Rf "${INSTALLER_DIR}/scripts/"* "${const_WEB_ROOT_LBB}/"
# rewrite config files
sudo python3 "${const_WEB_ROOT_LBB}/lib_setup.py"
# set file permissions in const_WEB_ROOT_LBB
sudo chown ${USER_WWW_DATA}:${USER_WWW_DATA} "${const_WEB_ROOT_LBB}" -R
sudo chmod 777 ${const_WEB_ROOT_LBB}/*
# read config file
CONFIG="${const_WEB_ROOT_LBB}/config.cfg"
echo "Loading old settings from ${CONFIG}"
source "${CONFIG}"
# Install rclone
curl https://rclone.org/install.sh | sudo bash
## Install rclone gui (needs to start gui, random password for this session to prevent login)
sudo rclone rcd --rc-web-gui --rc-web-gui-force-update --rc-web-gui-no-open-browser --rc-addr :5572 --rc-user lbb --rc-pass "$(echo $RANDOM | md5sum | head -c 20)" &
# create linux-user for samba
sudo useradd --create-home -s /bin/bash ${USER_SAMBA}
sudo usermod -aG ${USER_WWW_DATA} ${USER_SAMBA}
# Create the required media-directories
echo "Creating the required media-directories"
sudo mkdir -p "${const_MEDIA_DIR}"
sudo umount "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_LOCAL_TARGET}" > /dev/null 2>&1
sudo umount "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_LOCAL_SOURCE}" > /dev/null 2>&1
sudo umount "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_CLOUD_TARGET}" > /dev/null 2>&1
sudo umount "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_CLOUD_SOURCE}" > /dev/null 2>&1
sudo mkdir -p "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_LOCAL_TARGET}"
sudo mkdir -p "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_LOCAL_SOURCE}"
sudo mkdir -p "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_CLOUD_TARGET}"
sudo mkdir -p "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_CLOUD_SOURCE}"
sudo mkdir -p "${const_MEDIA_DIR}/${const_INTERNAL_BACKUP_DIR}"
sudo mkdir -p "${const_MEDIA_DIR}/${const_BACKGROUND_IMAGES_DIR}/lbb"
sudo chown -R ${USER_WWW_DATA}:${USER_WWW_DATA} "${const_MEDIA_DIR}"
sudo chmod -R 777 "${const_MEDIA_DIR}"
sudo setfacl -Rdm u:${USER_WWW_DATA}:rwX,g:${USER_WWW_DATA}:rwX "${const_MEDIA_DIR}"
sudo setfacl -Rdm u:${USER_SAMBA}:rwX,g:${USER_SAMBA}:rwX "${const_MEDIA_DIR}"
# move background images in place
mv "${INSTALLER_DIR}/scripts/img/backgrounds/"* "${const_MEDIA_DIR}/${const_BACKGROUND_IMAGES_DIR}/lbb/"
# add user www-data to sudoers
sudo usermod -aG sudo ${USER_WWW_DATA}
yes | sudo cp -f "${INSTALLER_DIR}/etc_sudoers_d_www-data" "/etc/sudoers.d/www-data"
sudo chmod 0440 "/etc/sudoers.d/www-data"
# change owner and make installer scripts executable
sudo chmod 777 ${INSTALLER_DIR}/*.sh
# prevent SSH freeze
if [ -z "$(cat /etc/ssh/sshd_config | grep 'IPQos cs0 cs0')" ]; then
echo 'IPQos cs0 cs0' | sudo tee -a /etc/ssh/sshd_config
fi
# Display
## activate i2c and spi
sudo raspi-config nonint do_i2c 0
sudo raspi-config nonint do_spi 0
if (( ${OS_RELEASE} > 11 )); then
# bookworm or later
sudo DEBIAN_FRONTEND=noninteractive \
apt \
-o "Dpkg::Options::=--force-confold" \
-o "Dpkg::Options::=--force-confdef" \
install -y -q --allow-downgrades --allow-remove-essential --allow-change-held-packages \
libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff6 i2c-tools python3-luma.core python3-luma.emulator python3-luma.lcd python3-luma.led-matrix python3-luma.oled
else
sudo DEBIAN_FRONTEND=noninteractive \
apt \
-o "Dpkg::Options::=--force-confold" \
-o "Dpkg::Options::=--force-confdef" \
install -y -q --allow-downgrades --allow-remove-essential --allow-change-held-packages \
libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff5 i2c-tools
sudo -H pip3 install luma.oled
fi
## Raspberry Pi 5 workaround
sudo python3 "${INSTALLER_DIR}/luma/install_workaround.py"
# Enable OLED screen support if available
## append new line to config-file
echo -e '' | sudo tee -a "${CONFIG}"
## activate display if detected (may not works in install-mode, i2c is not always available on primary install.)
if [ "${SCRIPT_MODE}" = "install" ]; then
I2C_DETECT=$(sudo i2cdetect -y 1)
I2C_LIST=("3c" "3d")
for I2C in "${I2C_LIST[@]}"; do
if [[ "${I2C_DETECT}" =~ " ${I2C}" ]]; then
sudo sed -i '/conf_DISP=/d' "${CONFIG}"
echo -e 'conf_DISP=true' | sudo tee -a "${CONFIG}"
sudo sed -i '/conf_DISP_I2C_ADDRESS=/d' "${CONFIG}"
echo -e "conf_DISP_I2C_ADDRESS=\"${I2C}\"" | sudo tee -a "${CONFIG}"
break
fi
done
fi
# set the default backup mode
if [ "${SCRIPT_MODE}" = "install" ]; then
## append new line to config-file
echo -e '' | sudo tee -a "${CONFIG}"
# write new default-backup-method
conf_BACKUP_DEFAULT_SOURCE="none"
conf_BACKUP_DEFAULT_TARGET="none"
case $CHOICE_BACKUP_MODE in
1)
conf_BACKUP_DEFAULT_SOURCE="none"
conf_BACKUP_DEFAULT_TARGET="none"
;;
2)
conf_BACKUP_DEFAULT_SOURCE="usb"
conf_BACKUP_DEFAULT_TARGET="usb"
;;
3)
conf_BACKUP_DEFAULT_SOURCE="usb"
conf_BACKUP_DEFAULT_TARGET="internal"
;;
4)
conf_BACKUP_DEFAULT_SOURCE="camera"
conf_BACKUP_DEFAULT_TARGET="usb"
;;
5)
conf_BACKUP_DEFAULT_SOURCE="camera"
conf_BACKUP_DEFAULT_TARGET="internal"
;;
esac
else
if [ -z "${conf_BACKUP_DEFAULT_SOURCE}" ]; then
conf_BACKUP_DEFAULT_SOURCE="none"
fi
if [ -z "${conf_BACKUP_DEFAULT_TARGET}" ]; then
conf_BACKUP_DEFAULT_TARGET="none"
fi
fi
sudo sed -i '/conf_BACKUP_DEFAULT_SOURCE=/d' "${CONFIG}"
echo "conf_BACKUP_DEFAULT_SOURCE=\"${conf_BACKUP_DEFAULT_SOURCE}\"" | sudo tee -a "${CONFIG}"
sudo sed -i '/conf_BACKUP_DEFAULT_TARGET=/d' "${CONFIG}"
echo "conf_BACKUP_DEFAULT_TARGET=\"${conf_BACKUP_DEFAULT_TARGET}\"" | sudo tee -a "${CONFIG}"
# set the default SECONDARY backup mode
## append new line to config-file
echo -e '' | sudo tee -a "${CONFIG}"
if [ "${SCRIPT_MODE}" = "install" ]; then
# write new default-backup-method
conf_BACKUP_DEFAULT_SOURCE2="none"
conf_BACKUP_DEFAULT_TARGET2="none"
else
if [ -z "${conf_BACKUP_DEFAULT_SOURCE2}" ]; then
conf_BACKUP_DEFAULT_SOURCE2="none"
fi
if [ -z "${conf_BACKUP_DEFAULT_TARGET2}" ]; then
conf_BACKUP_DEFAULT_TARGET2="none"
fi
fi
sudo sed -i '/conf_BACKUP_DEFAULT_SOURCE2=/d' "${CONFIG}"
echo "conf_BACKUP_DEFAULT_SOURCE2=\"${conf_BACKUP_DEFAULT_SOURCE2}\"" | sudo tee -a "${CONFIG}"
sudo sed -i '/conf_BACKUP_DEFAULT_TARGET2=/d' "${CONFIG}"
echo "conf_BACKUP_DEFAULT_TARGET2=\"${conf_BACKUP_DEFAULT_TARGET2}\"" | sudo tee -a "${CONFIG}"
# remove all from crontab
crontab -r
# write basic crontab
crontab -l | {
cat
echo "@reboot sudo python3 ${const_WEB_ROOT_LBB}/backup-autorun.py"
} | crontab
crontab -l | {
cat
echo "@reboot sudo python3 ${const_WEB_ROOT_LBB}/start-rclone-gui.py"
} | crontab
crontab -l | {
cat
echo "*/1 * * * * sudo python3 ${const_WEB_ROOT_LBB}/lib_cron_ip.py"
} | crontab
crontab -l | {
cat
echo "*/1 * * * * sudo python3 ${const_WEB_ROOT_LBB}/cron_idletime.py"
} | crontab
# tinyfilemanager
source "${INSTALLER_DIR}/install-tinyfilemanager.sh"
# Change php.ini defaults
sudo find /etc/php/ -name "php.ini" -exec sudo sed -i "s/^\(max_file_uploads\s*=\s*\).*\$/\1100/" {} \;
sudo find /etc/php/ -name "php.ini" -exec sudo sed -i "s/^\(post_max_size\s*=\s*\).*\$/\10/" {} \;
sudo find /etc/php/ -name "php.ini" -exec sudo sed -i "s/^\(upload_max_filesize\s*=\s*\).*\$/\1256M/" {} \;
# Create Apache-Configuration
sudo openssl req -x509 -nodes -days 3650 -subj '/C=OW/ST=MilkyWay/L=Earth/CN=10.42.0.1' -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
# Apache-config-files
if [ "${SCRIPT_MODE}" = "install" ]; then
echo "ServerName little-backup-box" | sudo tee -a "/etc/apache2/apache2.conf"
fi
yes | sudo cp -f "${INSTALLER_DIR}/etc_apache2_ports.conf" "/etc/apache2/ports.conf"
yes | sudo cp -f "${INSTALLER_DIR}/etc_apache2_conf-available_ssl-params.conf" "/etc/apache2/conf-available/ssl-params.conf"
yes | sudo cp -f "${INSTALLER_DIR}/etc_apache2_sites-available_little-backup-box.conf" "/etc/apache2/sites-available/little-backup-box.conf"
sudo mkdir -p /etc/apache2/includes
sudo touch /etc/apache2/includes/password.conf
sudo a2enmod ssl
sudo a2enmod headers
sudo a2enmod proxy
sudo a2enmod proxy_http
# sudo a2enconf ssl-params # forces https
sudo a2dissite 000-default
sudo a2ensite little-backup-box
sudo systemctl reload apache2
# Configure Samba
if [ "${SCRIPT_MODE}" = "update" ]; then
yes | sudo cp -f /etc/samba/smb.conf.orig /etc/samba/smb.conf
else
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orig
fi
sudo sh -c "echo '' >> /etc/samba/smb.conf"
sudo sh -c "echo '### Global Settings ###' > /etc/samba/smb.conf"
sudo sh -c "echo '[global]' >> /etc/samba/smb.conf"
sudo sh -c "echo 'workgroup = WORKGROUP' >> /etc/samba/smb.conf"
sudo sh -c "echo 'wide links = yes' >> /etc/samba/smb.conf"
sudo sh -c "echo 'unix extensions = no' >> /etc/samba/smb.conf"
sudo sh -c "echo 'dns proxy = no' >> /etc/samba/smb.conf"
sudo sh -c "echo '' >> /etc/samba/smb.conf"
sudo sh -c "echo '### Debugging/Accounting ###' >> /etc/samba/smb.conf"
sudo sh -c "echo 'log file = /var/log/samba/log.%m' >> /etc/samba/smb.conf"
sudo sh -c "echo 'max log size = 1000' >> /etc/samba/smb.conf"
sudo sh -c "echo 'syslog = 0' >> /etc/samba/smb.conf"
sudo sh -c "echo 'panic action = /usr/share/samba/panic-action %d' >> /etc/samba/smb.conf"
sudo sh -c "echo '' >> /etc/samba/smb.conf"
sudo sh -c "echo '### Authentication ###' >> /etc/samba/smb.conf"
sudo sh -c "echo 'security = user' >> /etc/samba/smb.conf"
sudo sh -c "echo 'map to guest = Bad User' >> /etc/samba/smb.conf"
sudo sh -c "echo 'guest account = ${USER_WWW_DATA}' >> /etc/samba/smb.conf"
sudo sh -c "echo '' >> /etc/samba/smb.conf"
sudo sh -c "echo '### Better Mac OS X support ###' >> /etc/samba/smb.conf"
sudo sh -c "echo 'vfs objects = fruit streams_xattr' >> /etc/samba/smb.conf"
sudo sh -c "echo 'fruit:metadata = stream' >> /etc/samba/smb.conf"
sudo sh -c "echo 'fruit:model = MacSamba' >> /etc/samba/smb.conf"
sudo sh -c "echo 'fruit:posix_rename = yes' >> /etc/samba/smb.conf"
sudo sh -c "echo 'fruit:veto_appledouble = no' >> /etc/samba/smb.conf"
sudo sh -c "echo 'fruit:nfs_aces = no' >> /etc/samba/smb.conf"
sudo sh -c "echo 'fruit:wipe_intentionally_left_blank_rfork = yes' >> /etc/samba/smb.conf"
sudo sh -c "echo 'fruit:delete_empty_adfiles = yes' >> /etc/samba/smb.conf"
sudo sh -c "echo '' >> /etc/samba/smb.conf"
sudo sh -c "echo '### Share Definitions ###' >> /etc/samba/smb.conf"
DIRECTORIES=("${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_LOCAL_TARGET}" "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_LOCAL_SOURCE}" "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_CLOUD_TARGET}" "${const_MEDIA_DIR}/${const_MOUNTPOINT_SUBPATH_CLOUD_SOURCE}" "${const_MEDIA_DIR}/${const_INTERNAL_BACKUP_DIR}")
for DIRECTORY in "${DIRECTORIES[@]}"; do
PATHNAME=$(basename ${DIRECTORY})
sudo sh -c "echo '' >> /etc/samba/smb.conf"
sudo sh -c "echo '[${PATHNAME}]' >> /etc/samba/smb.conf"
sudo sh -c "echo 'comment = Little Backup Box ${PATHNAME}' >> /etc/samba/smb.conf"
sudo sh -c "echo 'include = /etc/samba/login.conf' >> /etc/samba/smb.conf"
sudo sh -c "echo 'path = ${DIRECTORY}' >> /etc/samba/smb.conf"
sudo sh -c "echo 'browseable = yes' >> /etc/samba/smb.conf"
sudo sh -c "echo 'force user = ${USER_WWW_DATA}' >> /etc/samba/smb.conf"
sudo sh -c "echo 'force group = ${USER_WWW_DATA}' >> /etc/samba/smb.conf"
sudo sh -c "echo 'admin users = ${USER_WWW_DATA}' >> /etc/samba/smb.conf"
sudo sh -c "echo 'writeable = yes' >> /etc/samba/smb.conf"
sudo sh -c "echo 'read only = no' >> /etc/samba/smb.conf"
sudo sh -c "echo 'create mask = 0777' >> /etc/samba/smb.conf"
sudo sh -c "echo 'directory mask = 0777' >> /etc/samba/smb.conf"
done
echo "guest ok = yes" | sudo tee "/etc/samba/login.conf"
sudo samba restart
cd
# Configure vsftpd
if [ "${SCRIPT_MODE}" = "install" ]; then
sudo sh -c "echo 'write_enable=YES' >> /etc/vsftpd.conf"
fi
sudo service vsftpd restart
# setup graphical environment
source "${INSTALLER_DIR}/setup-graphical-environment.sh"
# install comitup
## re-install (update) if installed
if [ "$(dpkg-query -W --showformat='${db:Status-Status}' "comitup" 2>&1)" = "installed" ]; then
CHOICE_COMITUP="0"
fi
if [ "${SCRIPT_MODE}" = "install" ] || [ "${CHOICE_COMITUP}" = "0" ]; then
case $CHOICE_COMITUP in
0)
if [ "${SCRIPT_MODE}" = "install" ]; then
read -r -d '' COMITUP_INSTALL_MESSAGE << EOM
\Zb\ZuIMPORTANT INFORMATION\Zn
\ZbPlease read this carefully, if your raspberry pi is connected by wifi.\Zn
\Zb\Z1Next (and last) step of the installation is to install comitup. When comitup starts, it takes over control about the raspberry pi's wifi-connections.
That's why your pi's wifi-connection may break during this last step of the installation.
BUT DON'T WORRY!\Zn
The installation will finish seconds later, but maybe you won't see that progress on screen anymore. Your raspberry pi will reboot when setup is finished. Have a look at the action-LED.
\ZuWhat's going on?\Zn
Your raspberrys wifi-configuration has been removed by comitup now. Because comitup has no
access-data for your wifi yet, it can't connect to it and will start as a wifi-hotspot:
ssid=little-backup-box-nnnn (nnnn is a random number).
Please connect your mobile or notebook to this wifi.
\ZuThere are two options now:\Zn
1. If you want to configure comitup now, navigate to \Zb\Z1http\Zn://10.41.0.1 (http, not https!)
and connect your lbb to your wifi.
Connect your mobile or notbook to the same wifi. If you use a display on your lbb, it will
tell you its new IP. Connect to lbb:
\Zb\Z1https\Zn://IP.IN.YOUR.WIFI (secure, certificate can't be verified automatically, please confirm it)
\Zb\Z1http\Zn://IP.IN.YOUR.WIFI:8000 (insecure)
2. Alternatively can reach the web UI of Little Backup Box when you are connected to its
hotspot as follows:
\Zb\Z1https\Zn://10.41.0.1 (secure, certificate can't be verified automatically, please confirm it)
\Zb\Z1http\Zn://10.41.0.1:8000 (insecure)
Please use the settings of the web UI to optimally adapt the Little Backup Box for you.
If you have further questions, please check the wiki first:
https://github.com/outdoorbits/little-backup-box/wiki
We are always happy to receive your feedback!
Press OK to proceed...
EOM
dialog --colors --msgbox "${COMITUP_INSTALL_MESSAGE}" 40 80
clear
fi
source "${INSTALLER_DIR}/install-comitup.sh";
;;
1)
echo "You can install comitup later by script install-comitup.sh"
;;
255)
echo "You can install comitup later by script install-comitup.sh"
;;
esac
fi
# re-establish passwords
if [ "${SCRIPT_MODE}" = "update" ]; then
echo "Restore password-protection"
sudo python3 "${const_WEB_ROOT_LBB}/lib_password.py" "${conf_PASSWORD}"
fi
# setup hardware
source "${const_WEB_ROOT_LBB}/set_hardware.sh"
# post-install-information
IP=$(python3 "${const_WEB_ROOT_LBB}/lib_network.py" ip)
echo ""
echo "********************************************************************************************"
echo "*** How to proceed:"
echo "*** Assuming your Little Backup Box gets the same IP address again after the reboot,"
echo "*** you can then reach the web UI as follows:"
echo "*** "
echo "*** https://${IP} (secure, certificate cannot be verified automatically, please confirm it)"
echo "*** http://${IP}:8000 (insecure)"
echo "*** "
echo "*** Please use the settings of the web UI to optimally adapt the Little Backup Box for you."
echo "***"
echo "*** If you have further questions, please check the wiki first:"
echo "*** https://github.com/outdoorbits/little-backup-box/wiki"
echo "***"
echo "*** IF YOU ARE USING COMITUP: READ ALSO %quot;How to proceed%quot; in README/Installation!"
echo "***"
echo "*** We are always happy to receive your feedback!"
echo "********************************************************************************************"
echo ""
# finished
echo "Little Backup Box: Setup finished." | tee "${INSTALLER_DIR}/SETUP_FINISHED.TXT"
echo "Mode=${SCRIPT_MODE}" | tee -a "${INSTALLER_DIR}/SETUP_FINISHED.TXT"
date | tee -a "${INSTALLER_DIR}/SETUP_FINISHED.TXT"
# show installation errors
if [ -f './install-error.log' ]; then
echo 'Installation errors:'
echo "To see all error messages, please execute 'cat ./install-error.log'."
echo
fi
# reboot
echo "All done! Rebooting..."
sleep 3
sudo python3 "${const_WEB_ROOT_LBB}/lib_poweroff.py" reboot