-
Notifications
You must be signed in to change notification settings - Fork 21
/
build_joininbox.sh
639 lines (585 loc) · 20.7 KB
/
build_joininbox.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
#!/bin/bash
########################################################################
# setup a Linux environment see:
# https://github.com/openoms/joininbox#tested-environments-for-joininbox
# login with SSH or boot directly
# run this script as root or with sudo
# can specify downloading from a branch or forked repo:
# bash build_joininbox.sh [branch] [github user]
########################################################################
# The JoininBox Build Script is partially based on:
# https://github.com/rootzoll/raspiblitz/blob/master/build_sdcard.sh
# command info
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "JoininBox Build Script"
echo "Usage: sudo bash build_joininbox.sh <github user> <branch> <tag|commit> <without-qt>"
echo "Example:"
echo "'sudo bash build_joininbox.sh openoms master commit without-qt'"
echo "to install from the master branch latest commit without the QT GUI"
echo "By default uses https://github.com/openoms/joininbox/tree/master and installs the QT GUI"
exit 1
fi
# check if sudo
if [ "$EUID" -ne 0 ]; then
echo "Please run as root or with sudo"
echo "Root access is needed to create the dedicated user and to install system dependencies"
exit 1
fi
echo
echo "##########################"
echo "# JOININBOX BUILD SCRIPT"
echo "##########################"
echo
githubUser="$1"
if [ ${#githubUser} -eq 0 ]; then
githubUser="openoms"
fi
echo "# Check the command options"
wantedBranch="$2"
if [ ${#wantedBranch} -eq 0 ]; then
wantedBranch="master"
fi
echo "
# Installing JoininBox from:
# https://github.com/${githubUser}/joininbox/tree/${wantedBranch}
# Press ENTER to confirm or CTRL+C to exit"
read
echo
echo "###################################"
echo "# Identify the CPU and base image"
echo "###################################"
echo
cpu=$(uname -m)
echo "# CPU: ${cpu}"
if [ $(cat /etc/os-release 2>/dev/null | grep -c 'Debian') -gt 0 ]; then
if [ $(uname -n | grep -c 'raspberrypi') -gt 0 ]; then
# default image for RaspberryPi 64 or 32bit
baseimage="raspios"
elif [ $(uname -n | grep -c 'rpi') -gt 0 ] && [ "${cpu}" = aarch64 ]; then
# a clean alternative image of debian for RaspberryPi
baseimage="debian_rpi64"
elif [ "${cpu}" = "arm" ] || [ "${cpu}" = "aarch64" ]; then
# experimental: fallback for all debian on arm
baseimage="armbian"
else
# experimental: fallback for all debian on other CPUs
baseimage="debian"
fi
elif [ $(cat /etc/os-release 2>/dev/null | grep -c 'Ubuntu') -gt 0 ]; then
baseimage="ubuntu"
else
echo "\n# FAIL: Base Image cannot be detected or is not supported."
cat /etc/os-release 2>/dev/null
uname -a
exit 1
fi
echo "baseimage=${baseimage}"
echo
echo "############################"
echo "# Preparing the base image"
echo "############################"
echo
echo "# Prevent sleep" # on all platforms https://wiki.debian.org/Suspend
systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
mkdir /etc/systemd/sleep.conf.d
echo "[Sleep]
AllowSuspend=no
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no" | tee /etc/systemd/sleep.conf.d/nosuspend.conf
mkdir /etc/systemd/logind.conf.d
echo "[Login]
HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore" | tee /etc/systemd/logind.conf.d/nosuspend.conf
# check if /etc/hosts already has debian entry
# prevent "unable to resolve host debian" error
isDebianInHosts=$(grep -c "debian" /etc/hosts)
if [ ${isDebianInHosts} -eq 0 ]; then
echo "# Adding debian to /etc/hosts"
echo "127.0.1.1 debian" | tee -a /etc/hosts > /dev/null
systemctl restart networking
fi
# special prepare on RPi
if [ "${baseimage}" = "raspios" ] || [ "${baseimage}" = "debian_rpi64" ] ||
[ "${baseimage}" = "armbian" ]; then
# fixing locales for build
# https://github.com/rootzoll/raspiblitz/issues/138
# https://daker.me/2014/10/how-to-fix-perl-warning-setting-locale-failed-in-raspbian.html
# https://stackoverflow.com/questions/38188762/generate-all-locales-in-a-docker-image
echo "# FIXING LOCALES FOR BUILD "
apt-get install -y locales
sed -i "s/^# en_US.UTF-8 UTF-8.*/en_US.UTF-8 UTF-8/g" /etc/locale.gen
sed -i "s/^# en_US ISO-8859-1.*/en_US ISO-8859-1/g" /etc/locale.gen
locale-gen
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
# https://github.com/rootzoll/raspiblitz/issues/684
sed -i "s/^ SendEnv LANG LC.*/# SendEnv LANG LC_*/g" /etc/ssh/ssh_config
fi
if [ "${baseimage}" = "raspios" ]; then
# only on RaspberryOS
# remove unnecessary files
rm -rf /home/pi/MagPi
# https://www.reddit.com/r/linux/comments/lbu0t1/microsoft_repo_installed_on_all_raspberry_pis/
rm -f /etc/apt/sources.list.d/vscode.list
rm -f /etc/apt/trusted.gpg.d/microsoft.gpg
fi
if [ "${baseimage}" = "raspios" ] || [ "${baseimage}" = "debian_rpi64" ]; then
echo -e "\n*** PREPARE RASPBERRY OS VARIANTS ***"
if apt-get list | grep "raspi-config"; then
apt-get install -y raspi-config
# do memory split (16MB)
raspi-config nonint do_memory_split 16
# set to wait until network is available on boot (0 seems to yes)
raspi-config nonint do_boot_wait 0
fi
configFile="/boot/config.txt"
max_usb_current="max_usb_current=1"
max_usb_currentDone=$(grep -c "$max_usb_current" $configFile)
if [ ${max_usb_currentDone} -eq 0 ]; then
echo | tee -a $configFile
echo "# JoininBox" | tee -a $configFile
echo "$max_usb_current" | tee -a $configFile
else
echo "$max_usb_current already in $configFile"
fi
# edit kernel parameters
kernelOptionsFile=/boot/cmdline.txt
fsOption1="fsck.mode=force"
fsOption2="fsck.repair=yes"
fsOption1InFile=$(grep -c ${fsOption1} ${kernelOptionsFile})
fsOption2InFile=$(grep -c ${fsOption2} ${kernelOptionsFile})
if [ ${fsOption1InFile} -eq 0 ]; then
sed -i "s/^/$fsOption1 /g" "$kernelOptionsFile"
echo "$fsOption1 added to $kernelOptionsFile"
else
echo "$fsOption1 already in $kernelOptionsFile"
fi
if [ ${fsOption2InFile} -eq 0 ]; then
sed -i "s/^/$fsOption2 /g" "$kernelOptionsFile"
echo "$fsOption2 added to $kernelOptionsFile"
else
echo "$fsOption2 already in $kernelOptionsFile"
fi
fi
echo
echo "# Change log rotates"
# see https://github.com/rootzoll/raspiblitz/issues/394#issuecomment-471535483
echo "/var/log/syslog" >>./rsyslog
echo "{" >>./rsyslog
echo " rotate 7" >>./rsyslog
echo " daily" >>./rsyslog
echo " missingok" >>./rsyslog
echo " notifempty" >>./rsyslog
echo " delaycompress" >>./rsyslog
echo " compress" >>./rsyslog
echo " postrotate" >>./rsyslog
echo " invoke-rc.d rsyslog rotate > /dev/null" >>./rsyslog
echo " endscript" >>./rsyslog
echo "}" >>./rsyslog
echo "" >>./rsyslog
echo "/var/log/mail.info" >>./rsyslog
echo "/var/log/mail.warn" >>./rsyslog
echo "/var/log/mail.err" >>./rsyslog
echo "/var/log/mail.log" >>./rsyslog
echo "/var/log/daemon.log" >>./rsyslog
echo "{" >>./rsyslog
echo " rotate 4" >>./rsyslog
echo " size=100M" >>./rsyslog
echo " missingok" >>./rsyslog
echo " notifempty" >>./rsyslog
echo " compress" >>./rsyslog
echo " delaycompress" >>./rsyslog
echo " sharedscripts" >>./rsyslog
echo " postrotate" >>./rsyslog
echo " invoke-rc.d rsyslog rotate > /dev/null" >>./rsyslog
echo " endscript" >>./rsyslog
echo "}" >>./rsyslog
echo "" >>./rsyslog
echo "/var/log/kern.log" >>./rsyslog
echo "/var/log/auth.log" >>./rsyslog
echo "{" >>./rsyslog
echo " rotate 4" >>./rsyslog
echo " size=100M" >>./rsyslog
echo " missingok" >>./rsyslog
echo " notifempty" >>./rsyslog
echo " compress" >>./rsyslog
echo " delaycompress" >>./rsyslog
echo " sharedscripts" >>./rsyslog
echo " postrotate" >>./rsyslog
echo " invoke-rc.d rsyslog rotate > /dev/null" >>./rsyslog
echo " endscript" >>./rsyslog
echo "}" >>./rsyslog
echo "" >>./rsyslog
echo "/var/log/user.log" >>./rsyslog
echo "/var/log/lpr.log" >>./rsyslog
echo "/var/log/cron.log" >>./rsyslog
echo "/var/log/debug" >>./rsyslog
echo "/var/log/messages" >>./rsyslog
echo "{" >>./rsyslog
echo " rotate 4" >>./rsyslog
echo " weekly" >>./rsyslog
echo " missingok" >>./rsyslog
echo " notifempty" >>./rsyslog
echo " compress" >>./rsyslog
echo " delaycompress" >>./rsyslog
echo " sharedscripts" >>./rsyslog
echo " postrotate" >>./rsyslog
echo " invoke-rc.d rsyslog rotate > /dev/null" >>./rsyslog
echo " endscript" >>./rsyslog
echo "}" >>./rsyslog
if [ -f /etc/logrotate.d/rsyslog ]; then
mv /etc/logrotate.d/rsyslog /dev/shm/rsyslog.ori
echo
echo "# Saved the original /etc/logrotate.d/rsyslog in the memory: /dev/shm/rsyslog.ori"
echo "# To restore original version run:"
echo "'sudo mv /dev/shm/rsyslog.ori /etc/logrotate.d/rsyslog'"
echo "'sudo service rsyslog restart'"
echo "# if not restored or copied before shutdown the /dev/shm/rsyslog.ori will be wiped."
echo
fi
mv ./rsyslog /etc/logrotate.d/rsyslog
chown root:root /etc/logrotate.d/rsyslog
service rsyslog restart
echo
echo "########################"
echo "# apt-get update & upgrade"
echo "########################"
echo
apt-get update -y
apt-get upgrade -f -y
echo
echo "##########"
echo "# Python"
echo "##########"
echo
# apt dependencies for python
apt-get install -y python3 virtualenv python3-venv python3-dev python3-wheel python3-jinja2 python3-pip
if [ -f "/usr/bin/python3.8" ]; then
# use python 3.8 if available
update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
echo "# python calls python3.8"
elif [ -f "/usr/bin/python3.9" ]; then
# use python 3.9 if available
update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
echo "# python calls python3.9"
elif [ -f "/usr/bin/python3.10" ]; then
# use python 3.10 if available
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
echo "# python calls python3.10"
elif [ -f "/usr/bin/python3.11" ]; then
# use python 3.11 if available
update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1
echo "# python calls python3.11"
else
echo "# FAIL- there is no tested version of python present"
exit 1
fi
# make sure /usr/bin/pip exists (and calls pip3)
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
# don't protect system packages from pip install
# tracking issue: https://github.com/raspiblitz/raspiblitz/issues/4170
for PYTHONDIR in /usr/lib/python3.*; do
if [ -f "$PYTHONDIR/EXTERNALLY-MANAGED" ]; then
rm "$PYTHONDIR/EXTERNALLY-MANAGED"
fi
done
# setuptools needed for Nyx
pip install setuptools
echo
echo "##########################"
echo "# apt-get packages"
echo "##########################"
echo
# system
apt-get install -y lsb-release
apt-get install -y htop git curl bash-completion vim jq bsdmainutils
# prepare for display graphics mode
# see https://github.com/rootzoll/raspiblitz/pull/334
apt-get install -y fbi
# check for dependencies on DietPi, Ubuntu, Armbian
apt-get install -y build-essential
# install ifconfig
apt-get install -y net-tools
# to display hex codes
apt-get install -y xxd
# netcat
apt-get install -y netcat
# install killall, fuser
apt-get install -y psmisc
# dialog
apt-get install -y dialog
# qrencode
apt-get install -y qrencode
# unzip for the pruned node snapshot
apt-get install -y unzip
# JoinMarket dependency https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/5bfa08c6f558458c9a93e8095ce9dc1b62412838/install.sh#L76C10-L76C21
apt-get install -y libltdl-dev
apt-get clean
apt-get -y autoremove
echo
echo "#############"
echo "# JoininBox"
echo "#############"
echo
echo "# add the 'joinmarket' user"
adduser --system --group --shell /bin/bash --home /home/joinmarket joinmarket
echo "Copy the skeleton files for login"
sudo -u joinmarket cp -r /etc/skel/. /home/joinmarket/
echo "# clone the joininbox repo and copy the scripts"
cd /home/joinmarket || exit 1
sudo -u joinmarket git clone -b ${wantedBranch} https://github.com/${githubUser}/joininbox.git
# related issue: https://github.com/openoms/joininbox/issues/102
sudo -u joinmarket git config --global --add safe.directory /home/joinmarket/joininbox
cd /home/joinmarket/joininbox || exit 1
if [ $# -lt 3 ] || [ "$3" = tag ]; then
# use the latest tag by default
tag=$(git tag | sort -V | tail -1)
# reset to the last release # be aware this is alphabetical (use one digit versions)
sudo -u joinmarket git reset --hard ${tag}
else
if [ $# -gt 2 ] && [ "$3" != commit ]; then
# reset to named commit if given
sudo -u joinmarket git reset --hard $3
fi
fi
echo "# Checking which key signed the last commit"
lastCommit=$(sudo -u joinmarket git log --show-signature --oneline | head -n6)
echo ${lastCommit}
if echo "${lastCommit}" | grep 13C688DB5B9C745DE4D2E4545BFB77609B081B65; then
PGPsigner="openoms"
PGPpubkeyLink="https://github.com/openoms.gpg"
PGPpubkeyFingerprint="13C688DB5B9C745DE4D2E4545BFB77609B081B65"
elif echo "${lastCommit}" | grep B5690EEEBB952194; then
echo "# The last commit was made on GitHub and is signed with the GitHub PGP key."
PGPsigner="web-flow"
PGPpubkeyLink="https://github.com/${PGPsigner}.gpg"
PGPpubkeyFingerprint="B5690EEEBB952194"
else
echo "# No known PGP key found"
exit 1
fi
command="sudo -u joinmarket bash /home/joinmarket/joininbox/scripts/verify.git.sh \
${PGPsigner} ${PGPpubkeyLink} ${PGPpubkeyFingerprint}"
echo "running: ${command}"
chmod 777 /dev/shm
${command} || exit 1
runuser joinmarket -c "cp /home/joinmarket/joininbox/scripts/* /home/joinmarket/"
runuser joinmarket -c "cp /home/joinmarket/joininbox/scripts/.* /home/joinmarket/ 2>/dev/null"
chmod +x /home/joinmarket/*.sh
runuser joinmarket -c "cp -r /home/joinmarket/joininbox/scripts/standalone /home/joinmarket/"
chmod +x /home/joinmarket/standalone/*.sh
echo "# set the default password 'joininbox' for the users 'pi', \
'joinmarket' and 'root'"
adduser joinmarket sudo
# chsh joinmarket -s /bin/bash
# configure for usage without password entry for the joinmarket user
# https://www.tecmint.com/run-sudo-command-without-password-linux/
echo 'joinmarket ALL=(ALL) NOPASSWD:ALL' | EDITOR='tee -a' visudo
echo "root:joininbox" | chpasswd
echo "joinmarket:joininbox" | chpasswd
if [ $(grep -c pi </etc/passwd) -gt 0 ]; then
echo "pi:joininbox" | chpasswd
fi
echo "# create the joinin.conf"
runuser joinmarket -c "touch /home/joinmarket/joinin.conf"
echo
echo "#######"
echo "# Tor"
echo "#######"
echo
# add default value to joinin config if needed
checkTorEntry=$(runuser joinmarket -c "cat /home/joinmarket/joinin.conf |
grep -c runBehindTor")
if [ ${checkTorEntry} -eq 0 ]; then
echo "runBehindTor=off" | tee -a /home/joinmarket/joinin.conf
fi
torTest=$(curl --socks5 localhost:9050 --socks5-hostname localhost:9050 -s \
https://check.torproject.org/ | cat | grep -m 1 Congratulations | xargs)
if [ "$torTest" != "Congratulations. This browser is configured to use Tor." ]; then
echo "# install the Tor repo"
echo
echo "# Install dirmngr"
apt-get install -y dirmngr apt-transport-https
echo
echo "# Adding KEYS deb.torproject.org "
torKeyAvailable=$(gpg --list-keys | grep -c \
"A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89")
echo "torKeyAvailable=${torKeyAvailable}"
if [ ${torKeyAvailable} -eq 0 ]; then
# https://support.torproject.org/apt/tor-deb-repo/
wget --prefer-family=ipv4 -qO- https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --import
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add -
echo "OK"
else
echo "# Tor key is available"
fi
echo "# Adding Tor Sources to sources.list"
torSourceListAvailable=$(cat /etc/apt/sources.list | grep -c \
'https://deb.torproject.org/torproject.org')
echo "torSourceListAvailable=${torSourceListAvailable}"
if [ ${torSourceListAvailable} -eq 0 ]; then
echo "Adding Tor sources ..."
arch=$(dpkg --print-architecture)
distro=$(lsb_release -sc)
echo "\
deb [arch=${arch}] https://deb.torproject.org/torproject.org ${distro} main
deb-src [arch=${arch}] https://deb.torproject.org/torproject.org ${distro} main" |
tee /etc/apt/sources.list.d/tor.list
echo "OK"
else
echo "Tor sources are available"
fi
apt-get update
if [ "${arch}" = "armhf" ]; then
# https://2019.www.torproject.org/docs/debian#source
echo "# running on armv6l - need to compile Tor from source"
apt-get install -y build-essential fakeroot devscripts
apt-get build-dep -y tor deb.torproject.org-keyring
mkdir ~/debian-packages
cd ~/debian-packages || exit 1
apt-get source tor
cd tor-* || exit 1
debuild -rfakeroot -uc -us
cd .. || exit 1
dpkg -i tor_*.deb
# setup Tor in the background
# TODO - test if remains in the background after the Tor service is started
tor &
else
echo "# Install Tor"
apt-get install -y tor
fi
fi
echo "# Install torsocks and nyx"
apt-get install -y torsocks tor-arm
# Tor config
# torrc
if ! grep -Eq "^DataDirectory" /etc/tor/torrc; then
echo "DataDirectory /var/lib/tor" | tee -a /etc/tor/torrc
fi
if ! grep -Eq "^ControlPort 9051" /etc/tor/torrc; then
echo "ControlPort 9051" | tee -a /etc/tor/torrc
fi
if ! grep -Eq "^CookieAuthentication 1" /etc/tor/torrc; then
echo "CookieAuthentication 1" | tee -a /etc/tor/torrc
fi
sed -i "s:^CookieAuthFile*:#CookieAuthFile:g" /etc/tor/torrc
# torsocks.conf
if ! grep -Eq "^AllowOutboundLocalhost 1" /etc/tor/torsocks.conf; then
echo "AllowOutboundLocalhost 1" | tee -a /etc/tor/torsocks.conf
fi
# add the joinmarket user to the tor group
usermod -a -G debian-tor joinmarket
# setting value in joinin config
sed -i "s/^runBehindTor=.*/runBehindTor=on/g" /home/joinmarket/joinin.conf
echo
echo "#############"
echo "# Hardening"
echo "#############"
echo
# install packages
apt-get install -y fail2ban ufw
# autostart fail2ban
systemctl enable fail2ban
touch /var/log/auth.log
# set up the firewall
ufw default deny incoming
ufw default allow outgoing
ufw allow 22 comment 'allow SSH'
old_kernel=$(uname -a | grep -c "4.14.165")
if [ $old_kernel -gt 0 ]; then
# due to the old kernel iptables needs to be configured
# https://superuser.com/questions/1480986/iptables-1-8-2-failed-to-initialize-nft-protocol-not-supported
echo "switching to iptables-legacy"
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
fi
echo "# enabling the firewall"
ufw --force enable
systemctl enable ufw
ufw status
# make a folder for authorized keys
runuser joinmarket -c "mkdir -p /home/joinmarket/.ssh"
chmod -R 700 /home/joinmarket/.ssh
# deny root login via ssh
if grep -Eq "^PermitRootLogin" /etc/ssh/sshd_config; then
sed -i "s/^PermitRootLogin.*/PermitRootLogin no/g" /etc/ssh/sshd_config
else
echo "PermitRootLogin no" >>/etc/ssh/sshd_config
fi
systemctl restart ssh
echo
echo "##########"
echo "# Extras"
echo "##########"
echo
# install a command-line fuzzy finder (https://github.com/junegunn/fzf)
apt-get -y install fzf
bash -c "echo 'source /usr/share/doc/fzf/examples/key-bindings.bash' >> \
/home/joinmarket/.bashrc"
# install tmux
apt-get -y install tmux
echo
echo "#############"
echo "# Autostart"
echo "#############"
echo "
if [ -f \"/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate\" ]; then
. /home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate
cd /home/joinmarket/joinmarket-clientserver/scripts/
fi
# shortcut commands
source /home/joinmarket/_commands.sh
# automatically start main menu for joinmarket unless
# when running in a tmux session
if [ -z \"\$TMUX\" ]; then
/home/joinmarket/menu.sh
fi
" | runuser joinmarket -c "tee -a /home/joinmarket/.bashrc"
echo "#########################"
echo "# Download Bitcoin Core"
echo "#########################"
echo
sudo -u joinmarket bash /home/joinmarket/install.bitcoincore.sh downloadCoreOnly || exit 1
echo
echo "######################"
echo "# Install JoinMarket"
echo "######################"
if [ "${cpu}" = x86_64 ]; then
qtgui=true
else
# no qtgui on arm
qtgui=false
fi
checkEntry=$(runuser joinmarket -c "cat /home/joinmarket/joinin.conf | grep -c qtgui")
if [ ${checkEntry} -eq 0 ]; then
echo "qtgui=$qtgui" | tee -a /home/joinmarket/joinin.conf
fi
if [ "$4" = "without-qt" ]; then
qtgui="false"
sed -i "s/^qtgui=.*/qtgui=false/g" /home/joinmarket/joinin.conf
fi
sudo -u joinmarket bash /home/joinmarket/install.joinmarket.sh -i install -q $qtgui || exit 1
echo "###################"
echo "# bootstrap.service"
echo "###################"
chmod +x /home/joinmarket/standalone/bootstrap.sh
cp /home/joinmarket/joininbox/scripts/standalone/bootstrap.service \
/etc/systemd/system/bootstrap.service
systemctl enable bootstrap
echo
echo "###########################"
echo "# The base image is ready"
echo "###########################"
echo
echo "Look through / save this output and continue with:"
echo "'su - joinmarket'"
echo
echo "To make an SDcard image safe to share use:"
echo "'/home/joinmarket/standalone/prepare.release.sh'"
echo
echo "the ssh login credentials are until the first login:"
echo "user:joinmarket"
echo "password:joininbox"
echo