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