fixes
[distro-setup] / distro-end
1 #!/bin/bash
2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4
5 # shellcheck source=/a/bin/ds/.bashrc
6 export LC_USEBASHRC=t; if [[ -s ~/.bashrc ]]; then . ~/.bashrc; fi
7
8 ### setup
9 source /a/bin/errhandle/err
10 src="$(readlink -f -- "${BASH_SOURCE[0]}")"; src=${src%/*} # directory of this file
11
12 if [[ $EUID == 0 ]]; then
13 echo "$0: error: run as regular user" >&2
14 exit 1
15 fi
16
17 err-cleanup() {
18 echo 1 >~/.local/distro-end
19 }
20
21 # shellcheck source=./pkgs
22 source $src/pkgs
23
24 echo "$0: $(date) starting now)"
25 # see example of usage to understand.
26 end_msg() {
27 local y
28 IFS= read -r -d '' y ||:
29 end_msg_var+="$y"
30 }
31 end() {
32 e "$end_msg_var"
33 echo 0 >~/.local/distro-end
34 if $pending_reboot; then
35 echo "$0: pending reboot and then finished. doing it now."
36 echo "exiting with status 0"
37 sudo reboot now
38 else
39 echo "$0: $(date): ending now)"
40 echo "exiting with status 0"
41 fi
42 exit 0
43 }
44 pre="${0##*/}:"
45 sudo() {
46 printf "$pre %s\n" "$*"
47 SUDOD="$PWD" command sudo "$@";
48 }
49 m() { printf "$pre %s\n" "$*"; "$@"; }
50 e() { printf "$pre %s\n" "$*"; }
51 distro=$(distro-name)
52 codename=$(debian-codename)
53 codename_compat=$(debian-codename-compat)
54 pending_reboot=false
55 sed="sed --follow-symlinks"
56
57 # when we schroot, it will fail if we are in a directory that doesnt exist in the chroot
58 cd /
59
60 ## template:
61 # case $distro in
62 # esac
63
64 case $HOSTNAME in
65 li|bk|je) : ;;
66 *)
67 # get sudo pass cached right away
68 if ! sudo -nv 2>/dev/null; then
69 sudo -v
70 fi
71 ;;
72 esac
73
74 # old repo. remove when all machines updated
75 sudo rm -fv /etc/apt/sources.list.d/wireguard-ubuntu-wireguard-bionic.list
76 # remove old file
77 sudo rm -fv /etc/apt/preferences.d/minetest
78
79 #### initial packages
80 pup
81 if isdeb; then
82 pi aptitude
83 fi
84
85 # avoid prompts
86 sudo debconf-set-selections <<EOF
87 popularity-contest popularity-contest/participate boolean true
88 EOF
89
90 ########### begin section including vps ################
91 pi ${p2[@]}
92
93
94 conflink
95
96 sudo rm -fv
97
98 # no equivalent in other distros:
99 if isdeb && pcheck apt-file; then
100 # this condition is just a speed optimization
101 pi apt-file
102 sudo apt-file update
103 fi
104
105
106 # disable motd junk.
107 case $distro in
108 debian)
109 # allows me to pipe with ssh -t, and gets rid of spam
110 # http://forums.debian.net/viewtopic.php?f=5&t=85822
111 # i'd rather disable the service than comment the init file
112 # this says disabling the service, it will still get restarted
113 # but this script doesn't do anything on restart, so it should be fine
114 sudo truncate -s0 /var/run/motd.dynamic
115 ;;
116 trisquel|ubuntu)
117 # this isn't a complete solution. It still shows me when updates are available,
118 # but it's no big deal.
119 sudo rm -fv /etc/update-motd.d/10-help-text /etc/update-motd.d/00-header
120 ;;
121 esac
122
123
124
125
126
127
128 # dogcam setup. not using atm
129 # case $HOSTNAME in
130 # lj|li)
131 # /a/bin/webcam/install-server
132 # ;;
133 # kw)
134 # /a/bin/webcam/install-client
135 # ;;
136 # esac
137
138
139 ## not actually using prometheus just yet
140 # # office is not exposed to internet yet
141 # if [[ $HOSTNAME != kw ]]; then
142 # ## prometheus node exporter setup
143 # web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF'
144 # #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
145 # # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
146 # <Location />
147 # AllowOverride None
148 # AuthType basic
149 # AuthName "Authentication Required"
150 # # setup one time, with root:www-data, 640
151 # AuthUserFile "/etc/prometheus-htpasswd"
152 # Require valid-user
153 # </Location>
154 # EOF
155 # fi
156
157
158 pi debootstrap
159 ######### begin universal pinned packages ######
160 case $(debian-codename) in
161 nabia|etiona|flidas)
162 sudo rm -fv /etc/apt/preferences.d/etiona-buster
163 sd /etc/apt/preferences.d/trisquel-debian <<EOF
164 Explanation: Debian* includes Debian + Debian Backports
165 Package: *
166 Pin: release o=Debian*
167 Pin-Priority: -100
168 EOF
169 ;;&
170 # needed for debootstrap scripts for fai since fai requires debian
171 flidas)
172 # moved to fai
173 #curl http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg | s apt-key add -
174 sd /etc/apt/preferences.d/flidas-xenial <<EOF
175 Package: *
176 Pin: release a=xenial
177 Pin-Priority: -100
178
179 Package: *
180 Pin: release a=xenial-updates
181 Pin-Priority: -100
182
183 Package: *
184 Pin: release a=xenial-security
185 Pin-Priority: -100
186
187 Package: firefox
188 Pin: release n=xenial
189 Pin-Priority: 500
190 EOF
191 sd /etc/apt/sources.list.d/xenial.list 2>/dev/null <<EOF
192 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
193 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
194 deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
195 EOF
196
197 if ! apt-key list | grep /C0B21F32 &>/dev/null; then
198 # moved to fai
199 #sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
200 sd /etc/apt/preferences.d/flidas-bionic <<EOF
201 Package: *
202 Pin: release a=bionic
203 Pin-Priority: -100
204
205 Package: *
206 Pin: release a=bionic-updates
207 Pin-Priority: -100
208
209 Package: *
210 Pin: release a=bionic-security
211 Pin-Priority: -100
212 EOF
213 fi
214
215 # better to run btrfs-progs which matches our kernel version
216 # (note, renamed from btrfs-tools)
217 sd /etc/apt/preferences.d/btrfs-progs <<EOF
218 Package: btrfs-progs libzstd1
219 Pin: release a=bionic
220 Pin-Priority: 1005
221
222 Package: btrfs-progs libzstd1
223 Pin: release a=bionic-updates
224 Pin-Priority: 1005
225
226 Package: btrfs-progs libzstd1
227 Pin: release a=bionic-security
228 Pin-Priority: 1005
229 EOF
230
231
232 t=$(mktemp)
233 cat >$t <<EOF
234 deb http://us.archive.ubuntu.com/ubuntu/ bionic main
235 deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main
236 deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main
237 EOF
238 f=/etc/apt/sources.list.d/bionic.list
239 if ! diff -q $t $f; then
240 sudo cp $t $f
241 sudo chmod 644 $f
242 m p update
243 fi
244
245 # no special reason, but its better for btrfs-progs to
246 # be closer to our kernel version
247 pi btrfs-progs
248
249 if [[ ! -e /usr/share/debootstrap/scripts/xenial ]]; then
250 t=$(mktemp -d)
251 cd $t
252 m aptitude download debootstrap/xenial
253 m ex ./*
254 sudo cp ./usr/share/debootstrap/scripts/* /usr/share/debootstrap/scripts
255 fi
256
257 sd /etc/apt/preferences.d/flidas-etiona <<EOF
258 Package: *
259 Pin: release a=etiona
260 Pin-Priority: -100
261
262 Package: *
263 Pin: release a=etiona-updates
264 Pin-Priority: -100
265
266 Package: *
267 Pin: release a=etiona-security
268 Pin-Priority: -100
269
270 Package: *
271 Pin: release a=etiona-backports
272 Pin-Priority: -100
273 EOF
274
275 t=$(mktemp)
276 cat >$t <<EOF
277 deb http://mirror.fsf.org/trisquel/ etiona main
278 deb http://mirror.fsf.org/trisquel/ etiona-updates main
279 deb http://archive.trisquel.info/trisquel/ etiona-security main
280 deb http://mirror.fsf.org/trisquel/ etiona-backports main
281 EOF
282 f=/etc/apt/sources.list.d/etiona.list
283 if ! diff -q $t $f; then
284 sudo cp $t $f
285 n s chmod 644 $f
286 m p update
287 fi
288
289 sd /etc/apt/preferences.d/debian-goodies <<EOF
290 Package: debian-goodies
291 Pin: release n=etiona
292 Pin-Priority: 1005
293 EOF
294
295
296 # dont use buster because it causes dist-upgrade to think its downgrading
297 # packages while really just reinstalling the same version.
298 f=/etc/apt/apt.conf.d/01iank
299 sudo rm -fv $f
300 # # stupid buster uses some key algorithm not supported by flidas gpg that apt uses.
301 # sd /etc/apt/apt.conf.d/01iank <<'EOF'
302 # Acquire::AllowInsecureRepositories "true";
303 # EOF
304
305 f=/etc/apt/sources.list.d/buster.list
306 sudo rm -fv $f
307
308 # newer version needed for false positive in checkrestart.
309 # I did buster at first, but other problem above with having
310 # buster repos. not sure if the false positive exists in etiona.
311 pi debian-goodies
312
313 sd /etc/apt/preferences.d/shellcheck <<EOF
314 Package: shellcheck
315 Pin: release a=etiona
316 Pin-Priority: 1005
317
318 Package: shellcheck
319 Pin: release a=etiona-updates
320 Pin-Priority: 1005
321
322 Package: shellcheck
323 Pin: release a=etiona-security
324 Pin-Priority: 1005
325 EOF
326
327 sd /etc/apt/preferences.d/bash <<EOF
328 Package: bash
329 Pin: release a=etiona
330 Pin-Priority: 1005
331
332 Package: bash
333 Pin: release a=etiona-updates
334 Pin-Priority: 1005
335
336 Package: bash
337 Pin: release a=etiona-security
338 Pin-Priority: 1005
339 EOF
340
341
342 ;;&
343 nabia|etiona)
344 # for ziva
345 #p install --no-install-recommends minetest/buster libleveldb1d/buster libncursesw6/buster libtinfo6/buster
346 doupdate=false
347 for n in buster bullseye; do
348 f=/etc/apt/sources.list.d/$n.list
349 t=$(mktemp)
350 case $n in
351 buster)
352 cat >$t <<'EOF'
353 deb http://http.us.debian.org/debian buster main
354 deb-src http://http.us.debian.org/debian buster main
355
356 deb http://security.debian.org/ buster/updates main
357 deb-src http://security.debian.org/ buster/updates main
358
359 deb http://http.us.debian.org/debian buster-updates main
360 deb-src http://http.us.debian.org/debian buster-updates main
361
362 deb http://http.debian.net/debian buster-backports main
363 deb-src http://http.debian.net/debian buster-backports main
364 EOF
365 ;;
366 bullseye)
367 cat >$t <<'EOF'
368 EOF
369 cat >$t <<EOF
370 deb http://deb.debian.org/debian bullseye main
371 deb-src http://deb.debian.org/debian bullseye main
372
373 deb http://deb.debian.org/debian-security/ bullseye-security main
374 deb-src http://deb.debian.org/debian-security/ bullseye-security main
375
376 deb http://deb.debian.org/debian bullseye-updates main
377 deb-src http://deb.debian.org/debian bullseye-updates main
378
379 deb http://http.debian.net/debian bullseye-backports main
380 deb-src http://http.debian.net/debian bullseye-backports main
381 EOF
382 ;;
383 esac
384
385 if ! diff -q $t $f; then
386 doupdate=true
387 s cp $t $f
388 s chmod 644 $f
389 fi
390 done
391 if $doupdate; then
392 curl -s https://ftp-master.debian.org/keys/archive-key-10-security.asc | sudo apt-key add -
393 curl -s https://ftp-master.debian.org/keys/archive-key-10.asc | sudo apt-key add -
394 p update
395 fi
396
397 if [[ ! -e /usr/share/debootstrap/scripts/bullseye ]]; then
398 t=$(mktemp -d)
399 cd $t
400 m aptitude download debootstrap/bullseye
401 m ex ./*
402 sudo cp ./usr/share/debootstrap/scripts/* /usr/share/debootstrap/scripts
403 fi
404
405 ;;&
406 etiona)
407 sd /etc/apt/preferences.d/focal <<'EOF'
408 Package: *
409 Pin: release n=focal,o=Ubuntu
410 Pin-Priority: -100
411 EOF
412
413 sd /etc/apt/preferences.d/spamassassin <<'EOF'
414 Package: spamassassin sa-compile spamc
415 Pin: release n=focal,o=Ubuntu
416 Pin-Priority: 500
417 EOF
418 sd /etc/apt/preferences.d/spamassassin <<'EOF'
419 Package: spamassassin sa-compile spamc
420 Pin: release n=focal,o=Ubuntu
421 Pin-Priority: 500
422 EOF
423 sd /etc/apt/preferences.d/psd <<'EOF'
424 Package: profile-sync-daemon
425 Pin: release n=focal,o=Ubuntu
426 Pin-Priority: 500
427 EOF
428
429 f=/etc/apt/sources.list.d/focal.list
430 t=$(mktemp)
431 cat >$t <<'EOF'
432 deb http://us.archive.ubuntu.com/ubuntu/ focal main universe
433 deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main universe
434 deb http://us.archive.ubuntu.com/ubuntu/ focal-security main universe
435 EOF
436 if ! diff -q $t $f; then
437 sudo dd if=$t of=$f 2>/dev/null
438 p update
439 fi
440
441
442
443 sd /etc/apt/preferences.d/nabia-etiona <<'EOF'
444 Package: *
445 Pin: release n=nabia*,o=Trisquel
446 Pin-Priority: -100
447 EOF
448
449 f=/etc/apt/sources.list.d/nabia.list
450 t=$(mktemp)
451 cat >$t <<'EOF'
452 deb http://mirror.fsf.org/trisquel/ nabia main
453 deb-src http://mirror.fsf.org/trisquel/ nabia main
454
455 deb http://mirror.fsf.org/trisquel/ nabia-updates main
456 deb-src http://mirror.fsf.org/trisquel/ nabia-updates main
457
458 deb http://archive.trisquel.info/trisquel/ nabia-security main
459 deb-src http://archive.trisquel.info/trisquel/ nabia-security main
460
461 # Uncomment this lines to enable the backports optional repository
462 deb http://mirror.fsf.org/trisquel/ nabia-backports main
463 deb-src http://mirror.fsf.org/trisquel/ nabia-backports main
464 EOF
465 if ! diff -q $t $f; then
466 sudo dd if=$t of=$f 2>/dev/null
467 p update
468 fi
469
470 # duplicated in fai. Pin for bionic + ubuntu so that ppas dont get
471 # matched.
472 sd /etc/apt/preferences.d/etiona-bionic <<'EOF'
473 Package: *
474 Pin: release n=bionic,o=Ubuntu
475 Pin-Priority: -100
476 Package: firefox
477 Pin: release n=bionic,o=Ubuntu
478 Pin-Priority: 500
479 EOF
480
481 sd /etc/apt/preferences.d/etiona-sa <<'EOF'
482 Package: *
483 Pin: release n=bionic,o=Ubuntu
484 Pin-Priority: -100
485 EOF
486
487 ;;&
488 *)
489 if isdeb; then
490 pi debian-goodies shellcheck
491 fi
492 ;;
493 esac
494
495
496
497 case $codename_compat in
498 focal)
499 sd /etc/apt/preferences.d/nabia-btrfs-progs <<'EOF'
500 Package: btrfs-progs
501 Pin: release a=buster-backports
502 Pin-Priority: 500
503 EOF
504 p install btrfs-progs
505 ;;
506 esac
507
508
509 # 2020-03-03 old file
510 s rm -fv /etc/apt/preferences.d/radicale
511 ######### end universal pinned packages ######
512
513
514 case $codename in
515 etiona)
516 sd /etc/apt/preferences.d/obs <<EOF
517 Package: libfdk-aac1
518 Pin: release n=bionic
519 Pin-Priority: 500
520 EOF
521 sd /etc/apt/preferences.d/chromium <<EOF
522 Package: chromium-*
523 Pin: release n=bionic
524 Pin-Priority: 500
525 EOF
526 ;;
527 nabia)
528 sd /etc/apt/preferences.d/chromium-bullseye <<EOF
529 Package: chromium chromium-* libicu67 libjpeg62-turbo libjsoncpp24 libre2-9 libwebpmux3
530 Pin: release o=Debian*,n=bullseye*
531 Pin-Priority: 500
532 EOF
533 ;;
534 esac
535
536
537
538 ##### begin automatic upgrades (after checkrestart has been installed) ####
539 # if apt-config-auto-update is installed,
540 # it also has similar config, in a file 10something,
541 # but i think his overrides it since its higher number.
542 # This file was part of the automatic-updates package,
543 # and it has a configu option to not get new package lists,
544 # which seems pretty stupid to me, you cant actually upgrade
545 # anything if you dont have the new package list.
546 sd /etc/apt/apt.conf.d/20auto-upgrades <<'EOF'
547 APT::Periodic::Update-Package-Lists "1";
548 APT::Periodic::Download-Upgradeable-Packages "1";
549 APT::Periodic::AutocleanInterval "7";
550 APT::Periodic::Unattended-Upgrade "1";
551 EOF
552
553 # fyi: default file has comments about available options,
554 # you may want to read that, do pkx unattended-upgrades
555 # default is just security updates. this list found from reading
556 # match_whitelist_string() in $(which unattended-upgrades)
557 sd /etc/apt/apt.conf.d/50unattended-upgrades <<EOF
558 Unattended-Upgrade::Mail "root";
559 Unattended-Upgrade::MailOnlyOnError "true";
560 Unattended-Upgrade::Remove-Unused-Dependencies "true";
561 Unattended-Upgrade::Origins-Pattern {
562 "o=*,l=*,a=*,c=*,site=*,n=*";
563 };
564 EOF
565
566 # old files
567 sudo rm -f /etc/cron.d/unattended-upgrade-reboot /usr/local/bin/zelous-unattended-reboot /etc/cron.d/myupgrade
568
569 # myupgrade cron exists in /etc/cron.d/ian
570
571 ##### end automatic upgrades ####
572
573
574 # commented in case i want to use this sometime later
575 # sd /etc/apt/preferences.d/buster-backports <<EOF
576 # Package: *
577 # Pin: release a=buster-backports
578 # Pin-Priority: 500
579 # EOF
580
581 if [[ -e /etc/wireguard/wghole.conf ]]; then
582 reload=false
583 if [[ ! -e /etc/systemd/system/wg-quick@wghole.service.d/override.conf ]]; then
584 reload=true
585 fi
586 sudo mkdir -p /etc/systemd/system/wg-quick@wghole.service.d
587 sd /etc/systemd/system/wg-quick@wghole.service.d/override.conf <<'EOF'
588 [Unit]
589 StartLimitIntervalSec=0
590
591 [Service]
592 Restart=on-failure
593 RestartSec=20
594 EOF
595 if $reload; then ser daemon-reload; fi
596 sgo wg-quick@wghole
597 fi
598
599 ###### begin website setup
600 case $HOSTNAME in
601 li|bk|je)
602 pi bind9
603 f=/var/lib/bind/db.b8.nz
604 if [[ ! -e $f ]]; then
605 dnsb8
606 fi
607
608 pi prometheus-node-exporter
609
610 # ex for exporter
611 web-conf -p 9101 -f 9100 - apache2 ${HOSTNAME}ex.b8.nz <<'EOF'
612 <Location "/">
613 AuthType Basic
614 AuthName "basic_auth"
615 # created with
616 # htpasswd -c prometheus-export-htpasswd USERNAME
617 AuthUserFile "/etc/prometheus-export-htpasswd"
618 Require valid-user
619 </Location>
620 EOF
621 ;;&
622
623 bk)
624 sgo wg-quick@wgmail
625
626 # i just dont feel like setting up a special purpose ssh key to do this automatically.
627 end_msg <<'EOF'
628 # run this once for bk on local machine:
629 # only used for old openvpn setup
630 /a/exe/vpn-mk-client-cert -c bk.b8.nz -b expertpath -n mail li.iankelling.org
631 EOF
632 end
633 ;;
634 je)
635 end
636 ;;
637 li)
638
639 m /a/h/setup.sh iankelling.org
640
641 # start mumble only when im going to use it, since i dont use it much
642 pi-nostart mumble-server
643 sudo $sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc/mumble-server.ini
644
645 # do certificate to avoid warning about unsigned cert,
646 # which is overkill for my use, but hey, I'm cool, I know
647 # how to do this.
648 m web-conf apache2 mumble.iankelling.org
649 sudo rm -fv /etc/apache2/sites-enabled/mumble.iankelling.org
650
651 # general vpn for as needed use
652 vpn-server-setup -d -r -4 10.5.5 -p 443 -n hole
653
654 # todo: consider if this should exist for the
655 # other vpn server
656 teeu /etc/openvpn/server/hole.conf <<'EOF'
657 client-to-client
658 EOF
659
660 # sullivan d8
661 sd /etc/openvpn/client-config-hole/sd8 <<'EOF'
662 ifconfig-push 10.5.5.41 255.255.255.0
663 EOF
664 # hsieh d8
665 sd /etc/openvpn/client-config-hole/hd8 <<'EOF'
666 ifconfig-push 10.5.5.42 255.255.255.0
667 EOF
668
669 sd /etc/openvpn/client-config-hole/onep9 <<'EOF'
670 ifconfig-push 10.5.5.14 255.255.255.0
671 EOF
672 sd /etc/openvpn/client-config-hole/bo <<'EOF'
673 ifconfig-push 10.5.5.13 255.255.255.0
674 EOF
675 sd /etc/openvpn/client-config-hole/sy <<'EOF'
676 ifconfig-push 10.5.5.12 255.255.255.0
677 EOF
678 sd /etc/openvpn/client-config-hole/kw <<'EOF'
679 ifconfig-push 10.5.5.9 255.255.255.0
680 EOF
681 sd /etc/openvpn/client-config-hole/x3 <<'EOF'
682 ifconfig-push 10.5.5.8 255.255.255.0
683 EOF
684 sd /etc/openvpn/client-config-hole/x2 <<'EOF'
685 ifconfig-push 10.5.5.7 255.255.255.0
686 EOF
687 sd /etc/openvpn/client-config-hole/wclient <<'EOF'
688 ifconfig-push 10.5.5.6 255.255.255.0
689 EOF
690 sd /etc/openvpn/client-config-hole/frodo <<'EOF'
691 ifconfig-push 10.5.5.5 255.255.255.0
692 EOF
693 sd /etc/openvpn/client-config-hole/amy <<'EOF'
694 ifconfig-push 10.5.5.3 255.255.255.0
695 EOF
696 sd /etc/openvpn/client-config-hole/kd <<'EOF'
697 ifconfig-push 10.5.5.2 255.255.255.0
698 EOF
699
700 # for adding to current system:
701 #vpn-mk-client-cert -s "" -n hole 72.14.176.105
702 # adding to remove system 107,
703 #vpn-mk-client-cert -s "" -n hole -c 10.2.0.107 -b hd8 iankelling.org
704 #
705 # for wireguard hole vpn
706 # wghole
707
708 # requested from linode via a support ticket.
709 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
710 # ipv6 stuff pieced together
711 # via slightly wrong information from
712 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
713 # https://community.openvpn.net/openvpn/wiki/IPv6
714 # and man openvpn.
715 #
716 # This uses a public /64, but afaik, that is not needed for my
717 # current use case, since I'm doing ipv6 nat, they could be private
718 # and nat to a public address. I'm doing ipv6 nat in order to have 2
719 # vpn clients that externally share the same ip when sending so they
720 # share ip reputation. Note, the eth0 and tunx needed to be
721 # different subnets. On the same, I saw some neighbor packet go
722 # unanswered, tcpdump showed packets getting lost. I tried splitting the
723 # /64, it didn't work but I didn't investigate closely.
724
725
726 # not starting as i intend to replace it
727 m vpn-server-setup -s -i tunmail -n mail -d -6 2600:3c00:e002:3800::/64 2600:3c00:e002:3800::1/64
728 sudo tee /etc/openvpn/client-config-mail/mailclient <<'EOF'
729 ifconfig-push 10.8.0.4 255.255.255.0
730 ifconfig-ipv6-push 2600:3c00:e002:3800::4/64
731 EOF
732 sudo tee /etc/openvpn/client-config-mail/expertpath <<'EOF'
733 ifconfig-push 10.8.0.5 255.255.255.0
734 ifconfig-ipv6-push 2600:3c00:e002:3800::5/64
735 EOF
736
737
738 sudo dd of=/etc/systemd/system/vpn-mail-forward.service <<'EOF'
739 [Unit]
740 Description=Turns on iptables mail nat
741 BindsTo=openvpn-server@mail.service
742
743 [Service]
744 Type=oneshot
745 RemainAfterExit=yes
746 ExecStart=/a/bin/distro-setup/vpn-mail-forward tunmail start
747 ExecStop=/a/bin/distro-setup/vpn-mail-forward tunmail stop
748
749 [Install]
750 RequiredBy=openvpn-server@mail.service
751 EOF
752 ser daemon-reload
753
754
755 # needed for li's local mail delivery.
756 tu /etc/hosts <<<"10.8.0.4 mx.iankelling.org"
757
758 # wgmail handles this.
759 #sgo vpn-mail-forward.service
760 # old:
761 #sgo openvpn-server@mail
762 sgo wg-quick@wgmail
763
764 # setup let's encrypt cert
765 m web-conf apache2 mail.iankelling.org
766 # TODO, i expanded the above cert manually to mx.iankelling.org, this should be captured
767 # in the automation here. We use mail.iankelling.org as our ehlo name when sending mail
768 # but our mx record is mx.iankelling.org. Initially I was just using mail.iankelling.org,
769 # but the problem is I want multiple ips to be able to identify as mail.iankelling.org,
770 # but a subset to be mx.iankelling.org. Afaik, there is no problem with having
771 # our mail cert be for mail.iankelling.org, and have people connect to mx.ian...,
772 # but it doesn't make logical sense to do this.
773 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
774 ser reload apache2
775
776 a2enmod -q proxy proxy_http
777 domain=cal.iankelling.org
778 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
779 # https://radicale.org/2.1.html
780 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
781 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
782 <Location /radicale/>
783 Options +FollowSymLinks +Multiviews +Indexes
784 AllowOverride None
785 AuthType basic
786 AuthName "Authentication Required"
787 # setup one time, with root:www-data, 640
788 AuthUserFile "/etc/caldav-htpasswd"
789 Require valid-user
790 RequestHeader set X-Script-Name /radicale/
791 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
792 ProxyPass "http://10.8.0.4:5232/" retry=0
793 ProxyPassReverse "http://10.8.0.4:5232/"
794 </Location>
795 EOF
796 # nginx version of above would be:
797 # auth_basic "Not currently available";
798 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
799
800
801
802 ###### begin znc setup #####
803 pi znc
804
805 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
806 # to get into the web interface,
807 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
808 # https://iankelling.org:12533/
809 # login as ian, pass is in pass store, the part after :
810
811 # znc config generated by doing
812 # znc --makeconf
813 # selected port is also used in erc config
814 # comma separated channel list worked.
815 # while figuring things out, running znc -D for debug in foreground.
816 # to exit and save config:
817 # /msg *status shutdown
818 # configed auth on freenode by following
819 # https://wiki.znc.in/Sasl:
820 # /query *sasl
821 # RequireAuth yes
822 # Mechanism PLAIN
823 # Set MyNickservName pa$$w0rd
824 # created the system service after, and had to do
825 # mv /home/iank/.znc/* /var/lib/znc
826 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
827 # and made a copy of the config files into /p/c
828 # /msg *status LoadMod --type=global log -sanitize
829 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
830 # /msg *status LoadMod --type=network perform
831 # /query *perform add PRIVMSG ChanServ :invite #fsf-office
832 # /msg *perform add JOIN #fsf-office
833 # /msg *status LoadMod NickServ
834 #
835 # i set Buffer = 500
836 # also ran /znc LoadMod clearbufferonmsg
837 # it would be nice if erc supported erc query buffers by doing
838 # /msg *status clearbuffer <name of the query/receiver
839 # on killing the,
840 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
841 # if that was the case i could remove the module clearbufferonmsg
842 # also would be nice if erc supported
843 # https://wiki.znc.in/self-message
844 # https://wiki.znc.in/Query_buffers \
845 #
846 # for geekshed, there was no sasl support as far as I can tell,
847 # so I set to msg nickserv to identify upon connect.
848 if ! getent passwd znc > /dev/null; then
849 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
850 fi
851 sudo chmod 700 /var/lib/znc
852 sudo chown -R znc:znc /var/lib/znc
853 # Avoid restarting if possible, reconnecting to irc is annoying.
854 # The unit file was made active with conflink.
855 # Note, avoid using ser here because we wrap sudo to prints the command first.
856 if [[ $(systemctl is-active znc) != active ]]; then
857 sgo znc
858 fi
859 ###### stop znc setup #####
860
861 end
862 ;;
863 esac
864 ###### end website setup
865
866 ########### end section including li/lj ###############
867
868
869 #### desktop stuff
870
871 ### system76 things ###
872 case $HOSTNAME in
873 sy|bo)
874 # note, i stored the initial popos packages at /a/bin/data/popos-pkgs
875 if [[ ! -e /etc/apt/sources.list.d/system76.list ]]; then
876 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
877 sd /etc/apt/sources.list.d/system76.list <<EOF
878 deb http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
879 deb-src http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
880 EOF
881 # ubuntu keyserver is prone to intermittent failures
882 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5D1F3A80254F6AFBA254FED5ACD442D1C8B7748B
883 p update
884 # https://support.system76.com/articles/install-ubuntu/
885 # but i'm hoping this is not needed
886 # sd /etc/apt/preferences.d/system76 <<'EOF'
887 # Package: *
888 # Pin: release o=LP-PPA-system76-dev-stable
889 # Pin-Priority: 1001
890 # EOF
891 #
892 # TODO: I had to uninstall linux-image-generic-hwe-20.04 because of a conflict
893 # about linux-firmware. Should probably install it to begin with in fai if
894 # i'm going to use.
895 pi system76-driver system76-firmware
896 # if you get a notice about a firmware update, the notifier on i3
897 # is too dumb to do anything when you click it. so to see
898 # a changelog, cd to
899 # /var/cache/system76-firmware-daemon
900 # extract the xz files there, one will contain a changelog.
901 # then to install an update:
902 # s system76-firmware-cli schedule
903 fi
904 ;;
905 esac
906
907 case $distro in
908 trisquel|ubuntu)
909
910 # ppa:obsproject/obs-studio
911 if [[ ! -s /etc/apt/sources.list.d/obs.list ]]; then
912 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
913 sd /etc/apt/sources.list.d/obs.list <<EOF
914 deb http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
915 deb-src http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
916 EOF
917 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BC7345F522079769F5BBE987EFC71127F425E228
918 p update
919 fi
920 ;;
921 esac
922
923 case $codename_compat in
924 xenial)
925 # mate-indicator-applet and beyond are msc things I noticed diffing a
926 # standard install with mine.
927 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
928 ;;
929 stretch)
930 pi task-mate-desktop
931 ;;
932 buster)
933 # todo: figure out mate for buster
934 # pi task-gnome-desktop
935 ;;
936 bionic|focal)
937 # i had installing mate-indicator-applet, but im not sure why so i removed
938 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras anacron
939
940 # pi gnome-core
941 # # apt-get update periodically fails with an appstream error.
942 # # this removes gnome-core, but its just a package for dependencies
943 # p -y remove appstream
944
945
946 # by default, it sleeps when not logged in to x/wayland and on ac power.
947 # stop that.
948 if id -u gdm &>/dev/null; then
949 sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
950 fi
951 ;;&
952 focal)
953 # lightdm startup fails without this. on etiona, we got unity-greeter installed automatically,
954 # it would probably work on nabia too, but google just lead me to this and it works fine.
955 pi lightdm-gtk-greeter
956 # ok, this is really weird
957 # normally this file has
958 sd /etc/X11/Xsession.d/99x11-common_start <<'EOF'
959 # this is very odd.
960 # this file normally just has: exec $STARTUP
961 # but then ~/.xsession-errors
962 # says $STARTUP is not found, which appears to be the real
963 # error, but normal bash doesnt operate that way.
964 # https://bugs.launchpad.net/ubuntu/+source/im-config/+bug/1879352
965 eval exec $STARTUP
966 EOF
967 # also, gdm wayland was default, had to do
968 # dpkg-reconfigure gdm3
969 # and choose lightdm.
970 #
971 ;;
972 esac
973
974
975 if [[ $codename_compat == flidas ]]; then
976 # doesnt exist in newer
977 pi gnupg-doc
978 fi
979
980
981 case $distro in
982 trisquel)
983 case $codename in
984 *)
985 # firefox would work here too, apt would select abrowser.
986 # and the update-alternatives thing i think is becuz firefox is
987 # generally available before abrowser and this helps fix things
988 # up when we have both.
989 pi abrowser
990 s update-alternatives --set x-www-browser /usr/bin/abrowser
991 ;;
992 esac
993 ;;
994 ubuntu)
995 pi firefox
996 ;;
997 debian)
998 pi firefox-esr
999 ;;
1000 esac
1001
1002 # newer distros just use adb for package name it seems
1003 case $codename_compat in
1004 bionic|stretch)
1005 pi android-tools-adbd
1006 ;;
1007 esac
1008
1009 case $codename_compat in
1010 focal)
1011 pi libext2fs-dev libzstd-dev
1012 cd /a/opt/btrfs-progs
1013 ;;
1014 esac
1015
1016
1017 case $codename_compat in
1018 bionic)
1019 pi python-vte
1020 ;;
1021 *)
1022 pi reportbug-gtk
1023 ;;
1024 esac
1025
1026 # not packaged in newer distros it seems
1027 case $codename_compat in
1028 bionic|buster|stretch)
1029 pi dtrx
1030 ;;
1031 esac
1032
1033
1034 # TODO: some of the X programs can be removed from pall when using wayland
1035
1036 # depends gcc is a way to install suggests. this is apparently the only
1037 # way to install suggests even if the main package is already
1038 # installed. reinstall doesn't work, uninstalling can cause removing
1039 # dependent packages.
1040 pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $($src/distro-pkgs)
1041
1042
1043 # commented, not worth the hassle i think.
1044 #seru enable psd
1045 #seru start psd
1046
1047
1048 # old filename
1049 sudo rm -fv /etc/systemd/resolved.conf.d/iank.conf
1050
1051 # website is dead june 14 2019. back in october, but meh
1052 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
1053 # case $distro in
1054 # debian)
1055 # pi chromium ;;
1056 # trisquel|ubuntu)
1057 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
1058 # t=$(mktemp)
1059 # cat >$t <<EOF
1060 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
1061 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
1062 # EOF
1063 # f=/etc/apt/sources.list.d/iridium-browser.list
1064 # if ! diff -q $t $f; then
1065 # s cp $t $f
1066 # s chmod 644 $f
1067 # p update
1068 # fi
1069 # pi iridium-browser
1070 # ;;
1071 # esac
1072
1073
1074 ### begin home vpn server setup
1075
1076
1077 # # this section done initially to make persistent keys.
1078 # # Also note, I temporarily set /etc/hosts so my host was
1079 # # b8.nz when running this, since the vpn client config
1080 # # generator assumes we need to go to that server to get
1081 # # server keys.
1082 # vpn-server-setup -rds
1083 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
1084 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
1085 # # kw = kgpe work machine.
1086 # for host in x2 x3 kw; do
1087 # vpn-mk-client-cert -b $host -n home b8.nz 1196
1088 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
1089 # mkdir -p $dir
1090 # s bash -c "cp /etc/openvpn/client/home* $dir"
1091 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
1092 # done
1093
1094 # key already exists, so this won't generate one, just the configs.
1095 # m vpn-server-setup -rds
1096 # sudo tee -a /etc/openvpn/server/server.conf <<'EOF'
1097 # push "dhcp-option DNS 10.0.0.1"
1098 # push "route 10.0.0.0 255.255.0.0"
1099 # client-connect /a/bin/distro-setup/vpn-client-connect
1100 # EOF
1101 # sudo sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
1102
1103 # if [[ $HOSTNAME == tp ]]; then
1104 # if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
1105 # vpn_service=openvpn-server@server
1106 # else
1107 # vpn_service=openvpn@server
1108 # fi
1109 # sgo $vpn_service
1110 # fi
1111 ### end vpn server setup
1112
1113 ##### rss2email
1114 if mountpoint /p &>/dev/null; then
1115 # note, see bashrc for more documentation.
1116 pi rss2email
1117 sd /etc/systemd/system/rss2email.service <<'EOF'
1118 [Unit]
1119 Description=rss2email
1120 After=multi-user.target
1121
1122 [Service]
1123 User=iank
1124 Type=oneshot
1125 # about 24 hours of failures
1126 # it copies over its files without respecting symlinks, so
1127 # we pass options to use different location.
1128 ExecStart=/usr/local/bin/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
1129 EOF
1130 sd /etc/systemd/system/rss2email.timer <<'EOF'
1131 [Unit]
1132 Description=rss2email
1133
1134 [Timer]
1135 # for initial run. required.
1136 OnActiveSec=30
1137 # for subsequent runs.
1138 OnUnitInactiveSec=300
1139
1140 [Install]
1141 WantedBy=timers.target
1142 EOF
1143 sudo systemctl daemon-reload
1144 fi
1145
1146
1147 ######### begin irc periodic backup #############
1148 if [[ $HOSTNAME == frodo ]]; then
1149 sd /etc/systemd/system/ircbackup.service <<'EOF'
1150 [Unit]
1151 Description=irc li backup
1152 After=multi-user.target
1153
1154 [Service]
1155 User=iank
1156 Type=oneshot
1157 ExecStart=/usr/local/bin/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
1158 EOF
1159 sd /etc/systemd/system/ircbackup.timer <<'EOF'
1160 [Unit]
1161 Description=irc li backup hourly
1162
1163 [Timer]
1164 OnCalendar=hourly
1165
1166 [Install]
1167 WantedBy=timers.target
1168 EOF
1169 sudo systemctl daemon-reload
1170 sgo ircbackup.timer
1171 fi
1172
1173
1174 ######### end irc periodic backup #############
1175
1176
1177 pi-nostart openvpn
1178 # pi-nostart does not disable
1179 ser disable openvpn
1180
1181
1182 if [[ -e /p/c/gen-fsf-vpn ]]; then
1183 /p/c/gen-fsf-vpn
1184 fi
1185
1186 if [[ -e /p/c/machine_specific/$HOSTNAME/filesystem/etc/openvpn/client/hole.crt ]]; then
1187 sgo openvpn-client@hole
1188 fi
1189
1190 if [[ $HOSTNAME == frodo ]]; then
1191 vpn-mk-client-cert -b frodo -n hole iankelling.org
1192 fi
1193
1194 ############# begin syncthing setup ###########
1195 case $HOSTNAME in
1196 kd|frodo)
1197 f=/usr/share/keyrings/syncthing-archive-keyring.gpg
1198 if [[ ! -e $f ]]; then
1199 s curl -s -o $f https://syncthing.net/release-key.gpg
1200 fi
1201 s="deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable"
1202 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
1203 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
1204 p update
1205 fi
1206 pi syncthing
1207 ;;&
1208 frodo)
1209 m lnf -T /w/syncthing /home/iank/.config/syncthing
1210 ser daemon-reload # syncthing likely not properly packaged
1211 sgo syncthing@iank # runs as iank
1212 ;;
1213 kd)
1214
1215 # 1003 just happens to be what was on my system
1216 if ! getent passwd ziva; then
1217 s groupadd -g 1003 ziva
1218 # syncthing state / config / db are all in ~/.config/syncthing
1219 s useradd -g 1003 -u 1003 -d /d/ziva-home -c ziva -s /bin/bash ziva
1220 fi
1221 sgo syncthing@ziva
1222 ;;
1223 esac
1224
1225 # user for short term use dropping of privileges
1226
1227 if ! getent group zu &>/dev/null; then
1228 s groupadd -g 1023 zu
1229 fi
1230 if ! getent passwd zu &>/dev/null; then
1231 s useradd -g 1023 -u 1023 -c zu -s /bin/bash zu
1232 fi
1233
1234
1235 # these things persist in ~/.config/syncthing, which I save in
1236 # /w/syncthing (not in /p, because syncthing should continue to
1237 # run on home server even when using laptop as primary device)
1238 # open http://localhost:8384/
1239 # change listen address from default to tcp://:22001,
1240 # this is because we do port forward so it doesn\'t have to use
1241 # some external server, but the syncthing is broken for port forward,
1242 # you get a message, something "like connected to myself, this should not happen"
1243 # when connecting to other local devices, so I bump the port up by 1,
1244 # based on
1245 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
1246 # Without this, it was being stuck syncing at 0%.
1247 # Set gui username and password.
1248 #
1249 # install syncthing via f-droid,
1250 # folder setting, turn off send only.
1251 # on phone, add device, click bar code icon
1252 # on dekstop, top right, actions, device id
1253 # after adding, notification will appear on desktop to confirm
1254 #
1255 # syncing folder. from phone to desktop: select desktop in the
1256 # folder on phone\'s sync options, notification will appear in
1257 # desktop\'s web ui within a minute. For the reverse, the
1258 # notification will appear in android\'s notifications, you have to
1259 # swipe down and tap it to add the folder. It won\'t appear in the
1260 # syncthing ui, which would be intuitive, but don\'t wait for it
1261 # there. The notification may not work, instead open the web gui
1262 # from in the app, there should be a notification within there.
1263 #
1264 # On phone, set settings to run syncthing all the time, and
1265 # show no notification.
1266 #
1267 # Folder versioning would make sense if I didn\'t already use btrfs
1268 # for backups. I would choose staggered, or trash can for more space.
1269 #
1270 # if needed to install on a remote comp:
1271 # ssh -L 8384:localhost:8384 -N frodo
1272 # open http://localhost:8384/
1273 #
1274 # Note, the other thing i did was port forward port 22000,
1275 # per https://docs.syncthing.net/users/firewall.html
1276
1277 ############# end syncthing setup ###########
1278
1279
1280
1281 ####### begin misc packages ###########
1282
1283 # template
1284 case $codename in
1285 flidas)
1286 :
1287 ;;
1288 esac
1289
1290 sudo update-alternatives --set pinentry /usr/bin/pinentry-gtk-2
1291
1292
1293 # sakura config is owned by ian
1294 m reset-sakura
1295 m reset-konsole
1296 m sudo -u user2 -i reset-konsole
1297 # user2 xscreensaver we don't want to reset
1298 m reset-xscreensaver
1299
1300
1301 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
1302 # this is also in primary-setup
1303 # pi libxss-dev # dependency based on build failure
1304 # cabal update
1305 # cabal install --upgrade-dependencies --force-reinstalls arbtt
1306 # also, i assume syncing this between machines somehow messed up the data.
1307 if mountpoint /p &>/dev/null; then
1308 case $codename in
1309 etiona|nabia)
1310 pi arbtt
1311 # same as seru enable arbtt, but works over ssh when systemctl --user causes error:
1312 # Failed to connect to bus: No such file or directory
1313 lnf -T /a/bin/ds/subdir_files/.config/systemd/user/arbtt.service /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1314 # allow failure
1315 seru start arbtt ||:
1316 ;;
1317 esac
1318 fi
1319
1320
1321 m primary-setup
1322
1323 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
1324 m cp /p/.linphonerc-initial ~/.linphonerc
1325 fi
1326
1327 # linphone in t10 wont do dns with systemd-resolved or something
1328 s teeu /etc/hosts <<'EOF'
1329 74.94.156.215 watson.fsf.org
1330 EOF
1331
1332
1333
1334 ### begin spd install
1335 if mountpoint /p &>/dev/null; then
1336 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
1337 t=$(mktemp)
1338 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
1339 sudo dpkg -i $t
1340 m rm $t
1341 # this guesses at the appropriate directory, adjust if needed
1342 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
1343 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
1344 # newer distro had gpg2 as default, older one, flidas, need to make it that way
1345 gpgpath=$(which gpg2) ||:
1346 if [[ $gpgpath ]]; then
1347 sudo mkdir -p /usr/local/spdhackfix
1348 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
1349 fi
1350 fi
1351 ### end spd install
1352
1353
1354 # nagstamon setting which were set through the ui
1355 # monitor url https://klaxon.fsf.org/cgi-bin
1356 # monitor url cgi https://klaxon.fsf.org/cgi-bin
1357 # in filters tab:
1358 # all unknown services
1359 # all warning services
1360 # acknowledged hosts & services
1361 # hosts & services down for maintenence
1362 # services on down hosts
1363 # services on hosts in maintenece
1364 # services on unreachable osts
1365 # hosts in soft state
1366 # services in soft state
1367 # in display tab: fullscreen
1368
1369 # these translate to these settings I think
1370 # filter_acknowledged_hosts_services = True
1371 # filter_all_unknown_services = True
1372 # filter_all_warning_services = True
1373 # filter_hosts_in_soft_state = True
1374 # filter_hosts_services_maintenance = True
1375 # filter_services_in_soft_state = True
1376 # filter_services_on_down_hosts = True
1377 # filter_services_on_hosts_in_maintenance = True
1378 # filter_services_on_unreachable_hosts = True
1379 # notify_if_up = False
1380 # statusbar_floating = False
1381 # fullscreen = True
1382 # but i'm just going to rely on the webpage plus sms for now.
1383
1384
1385 # it asks if it should make users in it's group capture packets without root,
1386 # which is arguably more secure than running wireshark as root. default is no,
1387 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
1388 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
1389
1390 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
1391 # listed in the default config as suggested.
1392 # /run/usr/1000 i noticed was missing for pulseaudio
1393 # /run/user/0 just seemed like a not bad idea, given the above
1394 tu /etc/schroot/desktop/fstab <<'EOF'
1395 /p /p none rw,bind 0 0
1396 /a /a none rw,bind 0 0
1397 /run /run none rw,bind 0 0
1398 /run/lock /run/lock none rw,bind 0 0
1399 /dev/shm /dev/shm none rw,bind 0 0
1400 /run/shm /run/shm none rw,bind 0 0
1401 /run/user/1000 /run/user/1000 none rw,bind 0 0
1402 /run/user/1001 /run/user/1001 none rw,bind 0 0
1403 /run/user/0 /run/user/0 none rw,bind 0 0
1404 EOF
1405
1406 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1407 [Unit]
1408 Description=schrootupdate
1409 After=multi-user.target
1410
1411 [Service]
1412 Type=oneshot
1413 ExecStart=/usr/local/bin/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1414 EOF
1415 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1416 [Unit]
1417 Description=schrootupdate
1418
1419 [Timer]
1420 OnCalendar=*-*-* 04:20:00 America/New_York
1421
1422 [Install]
1423 WantedBy=timers.target
1424 EOF
1425 ser daemon-reload
1426 sgo schrootupdate.timer
1427
1428
1429
1430 # for my roommate
1431 case $distro in
1432 trisquel)
1433 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/bullseye.list/BULLSEYE_FREE \
1434 debian bullseye firefox-esr pulseaudio chromium anki
1435 case $(debian-codename) in
1436 etiona|nabia)
1437 # we have a lot of t8 stuff, useful to have
1438 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/flidas.list/FLIDAS \
1439 trisquel flidas
1440 tu /nocow/schroot/flidas/etc/sudoers <<EOF
1441 $USER ALL=(ALL) NOPASSWD: ALL
1442 Defaults env_keep += SUDOD
1443 Defaults always_set_home
1444 Defaults !umask
1445 EOF
1446 sd /nocow/schroot/flidas//etc/locale.gen <<'EOF'
1447 en_US.UTF-8 UTF-8
1448 EOF
1449 s schroot -c flidas locale-gen
1450 s schroot -c flidas update-locale LANG=en_US.UTF-8
1451
1452 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/testing.list/TESTING_NONFREE debian unstable debootstrap
1453 sudo cp -a /nocow/schroot/unstable/usr/share/debootstrap/scripts/* /usr/share/debootstrap/scripts
1454
1455 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/impish.list/IMPISH ubuntu impish
1456
1457 ;;
1458 esac
1459 ;;
1460 debian)
1461 pi chromium
1462 ;;
1463 esac
1464
1465 sudo mkdir -p /nocow/user
1466 sudo chown $USER:$USER /nocow/user
1467 pi anki
1468
1469
1470 ####### begin transmission
1471
1472 case $HOSTNAME in
1473 frodo)
1474 tdir=/i/k
1475 ;;
1476 kd)
1477 tdir=/d/tor
1478 ;;
1479 *)
1480 tdir=/nocow/user/tor
1481 ;;
1482 esac
1483
1484 mkdir -p $tdir
1485
1486 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1487 # 450 seems likely to be unused. we need to specify one or else
1488 # it won't be stable across installs.
1489 if ! getent passwd debian-transmission > /dev/null; then
1490 sudo groupadd -g 450 debian-transmission
1491 sudo adduser --quiet \
1492 --gid 450 \
1493 --uid 450 \
1494 --system \
1495 --no-create-home \
1496 --disabled-password \
1497 --home /var/lib/transmission-daemon \
1498 debian-transmission
1499 fi
1500 # We want group writable stuff from transmission.
1501 # However, after setting this, I learn that transmission sets it's
1502 # own umask based on it's settings file. Well, no harm leaving this
1503 # so it's set right from the beginning.
1504 sudo chfn debian-transmission -o umask=0002
1505
1506 # note i had to do this, which is persistent:
1507 # cd /i/k
1508 # s chgrp debian-transmission torrents partial-torrents
1509
1510 # syslog says things like
1511 # 'Failed to set receive buffer: requested 4194304, got 425984'
1512 # google suggets giving it even more than that
1513 tu /etc/sysctl.conf<<'EOF'
1514 net.core.rmem_max = 67108864
1515 net.core.wmem_max = 16777216
1516 EOF
1517 sudo sysctl -p
1518
1519 # some reason it doesn\'t seem to start automatically anyways
1520 pi-nostart transmission-daemon
1521 # be extra sure its not started
1522 ser disable transmission-daemon
1523 ser stop transmission-daemon
1524
1525 # the folder was moved here after an install around 02/2017.
1526 # it contains runtime data,
1527 # plus a simple symlink to the config file which it\'s
1528 # not worth separating out.
1529 # between comps, the uid can change
1530
1531 f=$tdir/transmission-daemon
1532 for d in $tdir/partial-torrents $tdir/torrents $f; do
1533 if [[ ! -d $d ]]; then
1534 mkdir $d
1535 fi
1536 sudo chown -R debian-transmission:user2 $d
1537 done
1538 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1539 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1540 sudo chown -R debian-transmission:debian-transmission $f
1541 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1542 #
1543 # config file documented here, and it\'s the same config
1544 # for daemon vs client, so it\'s documented in the gui.
1545 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1546 #
1547 # I originaly setup rpc-whitelist, but after using
1548 # routing to a network namespace, it doesn\'t see the
1549 # real source address, so it\'s disabled.
1550 #
1551 # Changed the cache-size to 256 mb, reduces disk use.
1552 # It is a read & write cache.
1553 if ! systemctl is-active transmission-daemon-nn &>/dev/null && \
1554 ! systemctl is-active transmission-daemon; then
1555 sudo ruby <<EOF | sponge /etc/transmission-daemon/settings.json
1556 require 'json'
1557 p = '/etc/transmission-daemon/settings.json'
1558 s = {
1559 'rpc-whitelist-enabled' => false,
1560 'rpc-authentication-required' => false,
1561 'incomplete-dir' => '$tdir/partial-torrents',
1562 'incomplete-dir-enabled' => true,
1563 'download-dir' => '$tdir/torrents',
1564 "speed-limit-up" => 800,
1565 "speed-limit-up-enabled" => true,
1566 "peer-port" => 61486,
1567 "cache-size-mb" => 256,
1568 "ratio-limit" => 5.0,
1569 "ratio-limit-enabled" => false,
1570 }
1571 puts(JSON.pretty_generate(JSON.parse(File.read(p)).merge()))
1572 EOF
1573 fi
1574
1575 ####### end transmission
1576
1577 case $HOSTNAME in
1578 kd)
1579 # to persist upload/dl metadata. initially, moved all the stuff
1580 # in /var/lib/transmission-daemon to /d/tor
1581 s usermod --home /d/tor debian-transmission
1582 sgo transmission-daemon-nn
1583
1584 ;;
1585 esac
1586
1587
1588 ######### begin transmission client setup ######
1589
1590 if [[ -e /p/transmission-rpc-pass ]]; then
1591 # arch had a default config,
1592 # debian had nothing until you start it.
1593 # With a little trial an error, here is a minimal config
1594 # taken from the generated one, plus changes that the
1595 # settings ui does, without a bunch of ui crap settings.
1596 #
1597 # only settings I set were
1598 # hostname
1599 # auto-connect
1600 # password
1601
1602 # the password is randomly generated on first run, i copied it out
1603 # so it could be used by other hosts.
1604 sudo ruby <<'EOF'
1605 require 'json'
1606 p = '/etc/transmission-daemon/settings.json'
1607 s = JSON.parse(File.read(p))
1608 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1609 # default is 0022 (18 in decimal)
1610 s["umask"] = 2
1611 File.write p, JSON.pretty_generate(s)
1612 EOF
1613
1614 rpc_pass=$(</p/transmission-rpc-pass)
1615 for f in /home/*; do
1616 u=${f##*/}
1617 uid=$(id -u $u 2>/dev/null) || continue
1618 if [[ ! $uid -ge 1000 ]]; then
1619 continue
1620 fi
1621 d=$f/.config/transmission-remote-gtk
1622 sudo -u $u mkdir -p $d
1623 # i tried setting hostname to transmission.b8.nz, so i could dynamically change where
1624 # this connects to, but it said some 421 denied error when I did that. Then it
1625 # froze X when i ran it under strace. Whatever.
1626 sudo -u $u dd of=$d/config.json <<EOF
1627 {
1628 "profiles" : [
1629 {
1630 "profile-name" : "Default",
1631 "hostname" : "10.173.0.2",
1632 "rpc-url-path" : "/transmission/rpc",
1633 "username" : "",
1634 "password" : "$rpc_pass",
1635 "auto-connect" : true,
1636 "ssl" : false,
1637 "timeout" : 40,
1638 "retries" : 3,
1639 "update-active-only" : false,
1640 "activeonly-fullsync-enabled" : false,
1641 "activeonly-fullsync-every" : 2,
1642 "update-interval" : 3,
1643 "min-update-interval" : 3,
1644 "session-update-interval" : 60,
1645 "exec-commands" : [],
1646 "destinations" : []
1647 }
1648 ],
1649 "profile-id" : 0,
1650 "add-options-dialog" : false
1651 }
1652 EOF
1653 done
1654 fi
1655 ######### end transmission client setup ######
1656
1657
1658 ### printer setup
1659 pi cups
1660
1661 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1662 # goto http://127.0.0.1:631
1663 # administration tab, add new printer button.
1664 # In debian, I could use hte recommended driver,
1665 # in arch, I had to pick out the 6L driver.
1666
1667
1668 # bridge networking as user fails. google lead here, but it doesn\'t work:
1669 # oh well, I give up.
1670 # http://wiki.qemu.org/Features-Done/HelperNetworking
1671 # s mkdir /etc/qemu
1672 # f=/etc/qemu/bridge.conf
1673 # sd $f <<'EOF'
1674 # allow br0
1675 # EOF
1676 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1677 # s chmod 640 $f
1678
1679 # general known for debian/ubuntu, not for fedora
1680
1681 m /a/bin/buildscripts/go
1682 m /a/bin/buildscripts/rust
1683 m /a/bin/buildscripts/misc
1684 m /a/bin/buildscripts/pithosfly
1685 #m /a/bin/buildscripts/alacritty
1686 #m /a/bin/buildscripts/kitty
1687
1688 pi-nostart virtinst virt-manager
1689 soff libvirtd
1690 # i cant if this is whats causing it to start even though
1691 # its disabled. note: it leaves around dnsmasq instances even
1692 # if you stop it. what the hell systemd?
1693 soff libvirt-guests
1694 # allow user to run vms, from debian handbook. libvirt-qemu
1695 # based on https://www.whonix.org/wiki/KVM#First-time_User.3F
1696 for x in iank user2; do s usermod -a -G libvirt,kvm,libvirt-qemu $x; done
1697
1698
1699 pi --no-install-recommends kdeconnect
1700 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1701 ### but gnome + xmonad not working in flidas, so i disabled it
1702 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1703 # cd /a/opt/indicator-kdeconnect
1704 # mkdir -p build
1705 # cd build
1706 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1707 # make
1708 # sudo make install
1709 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1710 # # it seems, according to
1711 # # /etc/xdg/autostart/kdeconnectd.desktop
1712 # # I'm not seeing the icon, but the clipboard replication is working
1713
1714
1715 ### model 01 arduino support ###
1716 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1717 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1718 # set arduino var in bashrc,
1719 # have system config file setup too.
1720 sudo adduser $USER dialout
1721
1722 # this is for the mail command too. update-alternatives is kind of misleading
1723 # since at least it's main commands pretend mail does not exist.
1724 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1725 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1726
1727 ######### end misc packages #########
1728
1729
1730 # packages I once used before and liked, but don\'t want installed now for
1731 # various reasons:
1732 # python-sqlite is used for offlineimap
1733 # lxappearance python-sqlite dolphin paman dconf-editor
1734
1735
1736
1737 ######## unfinished
1738
1739 # todo, finish configuring smart.
1740
1741 pi smartmontools
1742 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1743 # turn on smart. background on options:
1744 # first line, -a = test everyting on all devices.
1745 # -S on, turn on disk internal saving of vendor specific info,
1746 # from google, seems like this is usually already on and fairly standard.
1747 # -o on, turn on 4 hour period non-performance degrading testing.
1748 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1749 sched="-s (S/../.././02|L/../../6/03)"
1750 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1751 DEVICESCAN -a -o on -S on -n standby,q $sched \
1752 -m root@mail.iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1753
1754 # in the default configuration of at least ubuntu 14.04, resolvconf is
1755 # configured to order any nameservers associated with tun* or tap*
1756 # before the normal internet interfaces, which means they are always
1757 # consulted first. This is often slower and undesirable, ie. local dns
1758 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1759 # can do:
1760 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1761 # however, this breaks dns lookup for hosts on the openvpn lan.
1762 # I can\'t figure out why hosts on the normal lan would not be
1763 # broken under the default ordering, except the host I was
1764 # testing with previously had an entry in /etc/hosts.
1765
1766 ############# end unfinished
1767
1768 ########### misc stuff
1769
1770 if [[ $HOSTNAME != frodo ]]; then
1771 # remove. i moved this into dns
1772 echo | s cedit hole /etc/hosts ||:
1773 fi
1774
1775 if [[ ! -e ~/.local/bin/pip ]]; then
1776 tmp=$(mktemp)
1777 wget -O$tmp https://bootstrap.pypa.io/get-pip.py
1778 python3 $tmp --user
1779 hash -r
1780 fi
1781
1782
1783 ### begin timetrap setup
1784 if mountpoint /p &>/dev/null; then
1785 mkdir -p ~/.timetrap/
1786 ln -sf /a/opt/timetrap_formatters ~/.timetrap/formatters
1787 if ! type -p t &>/dev/null; then
1788 pi ruby-dev libsqlite3-dev
1789 gem install --user timetrap
1790 fi
1791 fi
1792 ### end timetrap setup
1793
1794 # leftover cleanup for t9
1795 pu resolvconf
1796
1797 case $codename in
1798 # needed for debootstrap scripts for fai since fai requires debian
1799 flidas)
1800 pi dnsmasq
1801 pi-nostart network-manager
1802 # i hate networkmanager. noo, of course disabling it doesnt work
1803 # unless you add a hack. found this by doing
1804 # systemd-analyze dot > x.dot
1805 # less x.dot
1806 # /networkman
1807 soff NetworkManager
1808 soff NetworkManager-wait-online.service
1809 # make networkmanager use resolvconf instead of its own dnsmasq which
1810 # conflicts with the normal dnsmasq package.
1811 f=/etc/NetworkManager/NetworkManager.conf
1812 m=$(md5sum $f)
1813 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1814 sudo sed -ri '/ *\[main\]/a dns=default' $f
1815 if [[ $m != $(md5sum $f) ]]; then
1816 srestart NetworkManager
1817 fi
1818 # networkmanager has this nasty behavior on flidas: if the machine
1819 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1820 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1821 # nameservers.
1822 # This can be manually fixed by stoping dnsmasq,
1823 # then based on whats in /run/dnsmasq/, i see we can run
1824 # s resolvconf -d NetworkManager
1825 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1826 ser disable NetworkManager
1827 ;;
1828 esac
1829
1830 # I have no use for avahi,
1831 # had to run this twice when doing manually, i dunno why
1832 soff avahi-daemon ||:
1833 sleep 1
1834 soff avahi-daemon
1835
1836 # make my /etc/fonts/conf.d/ get used.
1837 # I have a new sans-serif font there because the default one
1838 # displays l and I as the same char, grrrrr.
1839 sudo fc-cache
1840
1841 pi desktop-file-utils
1842 m /a/bin/distro-setup/mymimes
1843
1844
1845 # stop autopoping windows when i plug in an android phone.
1846 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1847 # with still 0 exit code.
1848 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1849 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1850
1851
1852 # on grub upgrade, we get prompts unless we do this
1853 devs=()
1854 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1855 devs+=("$(devbyid $dev),")
1856 done
1857 devs[-1]=${devs[-1]%,} # jonied by commas
1858 sudo debconf-set-selections <<EOF
1859 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1860 EOF
1861
1862
1863 sysd-prom-fail-install dynamicipupdate
1864 sysd-prom-fail-install systemstatus
1865 sysd-prom-fail-install btrfsmaintstop
1866 sgo btrfsmaint.timer
1867 sgo btrfsmaintstop
1868 sgo systemstatus
1869 sgo dynamicipupdate
1870
1871
1872 if grep -xFq $HOSTNAME /a/bin/ds/machine_specific/btrbk.hosts; then
1873 sgo btrbk.timer
1874 fi
1875 # note: to see when it was last run,
1876 # ser list-timers
1877
1878 case $HOSTNAME in
1879 kd)
1880 sgo btrbkrust.timer
1881 ;;
1882 esac
1883
1884 ### begin prometheus ###
1885
1886 case $HOSTNAME in
1887 kd)
1888 # ive got these + a needed dependency pinned to bullseye, just to get
1889 # versions more in line with the main docs.
1890 # Font awesome is needed for the alertmanager ui.
1891 pi prometheus-alertmanager prometheus prometheus-node-exporter fonts-font-awesome
1892 web-conf -p 9091 -f 9090 - apache2 i.b8.nz <<'EOF'
1893 <Location "/">
1894 AuthType Basic
1895 AuthName "basic_auth"
1896 # created with
1897 # htpasswd -c prometheus-htpasswd USERNAME
1898 AuthUserFile "/etc/prometheus-htpasswd"
1899 Require valid-user
1900 </Location>
1901 EOF
1902 # by default, the alertmanager web ui is not enabled other than a page
1903 # that suggests to use the amtool cli. that tool is good, but you cant
1904 # silence things nearly as fast.
1905 if [[ ! -e /usr/share/prometheus/alertmanager/ui/index.html ]]; then
1906 sudo chroot /nocow/schroot/bullseye prometheus-alertmanager
1907 sudo chroot /nocow/schroot/bullseye /usr/share/prometheus/alertmanager/generate-ui.sh
1908 sudo rsync -avih /nocow/schroot/bullseye/usr/share/prometheus/alertmanager/ui/ /usr/share/prometheus/alertmanager/ui
1909 ser restart prometheus-alertmanager
1910 fi
1911
1912 for ser in prometheus-node-exporter prometheus-alertmanager prometheus; do
1913 sysd-prom-fail-install $ser
1914 done
1915
1916 ;;
1917 *)
1918 pi prometheus-node-exporter
1919 ;;
1920 esac
1921
1922 case $HOSTNAME in
1923 # frodo needs upgrade first.
1924 frodo) : ;;
1925 # todo, for limiting node exporter http,
1926 # either use iptables or, in
1927 # /etc/default/prometheus-node-exporter
1928 # listen on the wireguard interface
1929 *)
1930 wgip=$(command sudo sed -rn 's,^ *Address *= *([^/]+).*,\1,p' /etc/wireguard/wghole.conf)
1931 # old filename. remove once all hosts are updated.
1932 s rm -fv /etc/apache2/sites-enabled/${HOSTNAME}wg.b8.nz.conf
1933 web-conf -i -a $wgip -p 9101 -f 9100 - apache2 ${HOSTNAME}wg.b8.nz <<'EOF'
1934 <Location "/">
1935 AuthType Basic
1936 AuthName "basic_auth"
1937 # created with
1938 # htpasswd -c prometheus-export-htpasswd USERNAME
1939 AuthUserFile "/etc/prometheus-export-htpasswd"
1940 Require valid-user
1941 </Location>
1942 EOF
1943 # For work, i think we will just use the firewall for hosts in the main data center, and
1944 # apache/nginx + tls + basic auth outside of it. or consider stunnel.
1945
1946
1947 # TODO: figure out how to detect the ping failure and try again.
1948
1949 # Binding to the wg interface, it might go down, so always restart, and wait for it on boot.
1950 s mkdir /etc/systemd/system/apache2.service.d
1951 sd /etc/systemd/system/apache2.service.d/restart.conf <<EOF
1952 [Unit]
1953 After=wg-quick@wghole.service
1954 StartLimitIntervalSec=0
1955
1956 [Service]
1957 Restart=always
1958 RestartSec=30
1959 EOF
1960
1961 ;;
1962 esac
1963
1964 ### end prometheus ###
1965
1966
1967 end_msg <<'EOF'
1968 In mate settings settings, change scrolling to two-finger,
1969 because the default edge scroll doesn\'t work. Originally found this in debian.
1970 EOF
1971
1972 # Remove dep that came in with desktop to fix associations.
1973 m pu transmission-gtk
1974
1975 case $HOSTNAME in
1976 kd)
1977 lnf -T /d/vidshare /home/iank/Videos
1978 ;;
1979 esac
1980
1981 # # Based on guix manual instructions, also added code to profile.
1982 # # disabled since i'm not using it now.
1983 # pi nscd
1984 # if ! type -p guix >/dev/null; then
1985 # cd $(mktemp -d)
1986 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1987 # # added some stuff to envonment.sh for profile based on
1988 # # manual instructions
1989 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1990 # # echo is to get past prompt
1991 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1992 # guix install glibc-utf8-locales
1993 # guix package --install guile
1994 # fi
1995
1996 lnf -T /a/opt ~/src
1997
1998 pi tor
1999 m /a/bin/buildscripts/tor-browser
2000 # one root command needed to install
2001 s ln -sf /a/opt/tor-browser_en-US/Browser/start-tor-browser /usr/local/bin
2002
2003
2004 # nfs server
2005 pi-nostart nfs-kernel-server
2006
2007 # todo, this is old, probably needs removing
2008 if [[ $HOSTNAME == tp ]]; then
2009 sd /etc/wireguard/wg0.conf <<EOF
2010 [Interface]
2011 PrivateKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.key)
2012 Address = 10.3.0.2/24, fdfd::2/64
2013
2014 [Peer]
2015 PresharedKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.psk)
2016 PublicKey = 9RnAsJB+ISrA/9lmDKBoT08oBiKwzA64exBBj+rO+ng=
2017 Endpoint = b8.nz:26000
2018 AllowedIPs = 10.3.0.1/24, fdfd::1/64
2019 PersistentKeepalive = 20
2020 EOF
2021 sudo systemctl enable wg-quick@wg0
2022 sudo systemctl start wg-quick@wg0
2023 fi
2024
2025
2026 if [[ $HOSTNAME == kw ]]; then
2027 # hosts 1-199. 200+ are dynamic, avoid those
2028 tu /etc/exports <<'EOF'
2029 /root/.ianktrisquel_9/.iank/e/e 192.168.0.0/25(rw,no_root_squash,async,no_subtree_check) 192.168.0.128/26(rw,no_root_squash,async,no_subtree_check) 192.168.0.192/29(rw,no_root_squash,async,no_subtree_check)
2030 /home/iank/.iank/e/e 192.168.0.0/25(rw,no_root_squash,async,no_subtree_check) 192.168.0.128/26(rw,no_root_squash,async,no_subtree_check) 192.168.0.192/29(rw,no_root_squash,async,no_subtree_check)
2031 EOF
2032 ekw
2033 sgo nfs-server
2034 sudo exportfs -rav
2035 fi
2036
2037
2038 # if I was going to create a persistent vm, i might do it like this:
2039 # variant=something # from: virt-install --os-variant list
2040 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
2041 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
2042 # -n some_name --import --os-variant $variant --cpu host-model-only
2043
2044
2045 # for brother HL-2270DW, this worked:
2046 # https://askubuntu.com/questions/1067234/cant-use-wireless-brother-printer-2270dw-ubuntu-18-04
2047 # /a/opt/linux-brprinter-installer-2.2.2-1
2048 # answer n when it asks about uri.
2049 # Then go to cups, delete the existing printer, added on with dnssd url. browsed to
2050 # ppd at /usr/share/ppd/HL2270DW.ppd, which is duplicated at /usr/share/cups/model/HL2270DW.ppd
2051 # ppd file got installed from bash -x ./usr/local/Brother/Printer/HL2270DW/cupswrapper/cupswrap,
2052 # which I downloaded from their driver. but dont do that again, i copied it to /a/opt/HL2270DW.ppd,
2053 # use that.
2054
2055 # I had to reset it to use wired instead of wifi. it only uses 1 at a time. boot with go button held, after lights turn off, tap go 6 times.
2056 # Then it was already configured, but if i needed to, go to its web ui, default pass is "access".
2057
2058 ######### begin stuff belonging at the end ##########
2059
2060 end