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