2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
5 # shellcheck source=/a/bin/ds/.bashrc
6 export LC_USEBASHRC
=t
; if [[ -s ~
/.bashrc
]]; then . ~
/.bashrc
; fi
9 source /a
/bin
/errhandle
/err
10 src
="$(readlink -f -- "${BASH_SOURCE[0]}")"; src
=${src%/*} # directory of this file
12 if [[ $EUID == 0 ]]; then
13 echo "$0: error: run as regular user" >&2
18 echo 1 >~
/.local
/distro-end
21 # shellcheck source=./pkgs
24 echo "$0: $(date) starting now)"
25 # see example of usage to understand.
28 IFS
= read -r -d '' y ||
:
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"
39 echo "$0: $(date): ending now)"
40 echo "exiting with status 0"
46 printf "$pre sudo %s\n" "$*"
47 SUDOD
="$PWD" command sudo
"$@";
49 m
() { printf "$pre %s\n" "$*"; "$@"; }
50 e
() { printf "$pre %s\n" "$*"; }
52 codename
=$
(debian-codename
)
53 codename_compat
=$
(debian-codename-compat
)
55 sed="sed --follow-symlinks"
57 # when we schroot, it will fail if we are in a directory that doesnt exist in the chroot
67 # get sudo pass cached right away
68 if ! sudo
-nv 2>/dev
/null
; then
74 # old repo. remove when all machines updated
75 sudo
rm -fv /etc
/apt
/sources.list.d
/wireguard-ubuntu-wireguard-bionic.list
77 sudo
rm -fv /etc
/apt
/preferences.d
/minetest
86 sudo debconf-set-selections
<<EOF
87 popularity-contest popularity-contest/participate boolean true
90 ########### begin section including vps ################
98 # no equivalent in other distros:
99 if isdeb
&& pcheck apt-file
; then
100 # this condition is just a speed optimization
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
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
128 # dogcam setup. not using atm
131 # /a/bin/webcam/install-server
134 # /a/bin/webcam/install-client
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
149 # AuthName "Authentication Required"
150 # # setup one time, with root:www-data, 640
151 # AuthUserFile "/etc/prometheus-htpasswd"
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
168 Pin: release o=Debian*
172 # needed for debootstrap scripts for fai since fai requires debian
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
178 Pin: release a=xenial
182 Pin: release a=xenial-updates
186 Pin: release a=xenial-security
190 Pin: release n=xenial
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
199 if ! apt-key list |
grep /C0B21F32
&>/dev
/null
; then
201 #sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
202 sd
/etc
/apt
/preferences.d
/flidas-bionic
<<EOF
204 Pin: release a=bionic
208 Pin: release a=bionic-updates
212 Pin: release a=bionic-security
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
224 Package: btrfs-progs libzstd1
225 Pin: release a=bionic-updates
228 Package: btrfs-progs libzstd1
229 Pin: release a=bionic-security
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
240 f
=/etc
/apt
/sources.list.d
/bionic.list
241 if ! diff -q $t $f; then
247 # no special reason, but its better for btrfs-progs to
248 # be closer to our kernel version
251 if [[ ! -e /usr
/share
/debootstrap
/scripts
/xenial
]]; then
254 m aptitude download debootstrap
/xenial
256 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
259 sd
/etc
/apt
/preferences.d
/flidas-etiona
<<EOF
261 Pin: release a=etiona
265 Pin: release a=etiona-updates
269 Pin: release a=etiona-security
273 Pin: release a=etiona-backports
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
284 f
=/etc
/apt
/sources.list.d
/etiona.list
285 if ! diff -q $t $f; then
291 sd
/etc
/apt
/preferences.d
/debian-goodies
<<EOF
292 Package: debian-goodies
293 Pin: release n=etiona
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
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";
307 f
=/etc
/apt
/sources.list.d
/buster.list
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.
315 sd
/etc
/apt
/preferences.d
/shellcheck
<<EOF
317 Pin: release a=etiona
321 Pin: release a=etiona-updates
325 Pin: release a=etiona-security
329 sd
/etc
/apt
/preferences.d
/bash
<<EOF
331 Pin: release a=etiona
335 Pin: release a=etiona-updates
339 Pin: release a=etiona-security
347 #p install --no-install-recommends minetest/buster libleveldb1d/buster libncursesw6/buster libtinfo6/buster
349 # shellcheck disable=SC2043 # in case we want more than 1 in the loop later.
350 for n
in bullseye
; do
351 f
=/etc
/apt
/sources.list.d
/$n.list
358 deb http://deb.debian.org/debian bullseye main
359 deb-src http://deb.debian.org/debian bullseye main
361 deb http://deb.debian.org/debian-security/ bullseye-security main
362 deb-src http://deb.debian.org/debian-security/ bullseye-security main
364 deb http://deb.debian.org/debian bullseye-updates main
365 deb-src http://deb.debian.org/debian bullseye-updates main
367 deb http://http.debian.net/debian bullseye-backports main
368 deb-src http://http.debian.net/debian bullseye-backports main
373 if ! diff -q $t $f; then
380 curl
-s https
://ftp-master.debian.org
/keys
/archive-key-10-security.asc | sudo apt-key add
-
381 curl
-s https
://ftp-master.debian.org
/keys
/archive-key-10.asc | sudo apt-key add
-
385 if [[ ! -e /usr
/share
/debootstrap
/scripts
/bullseye
]]; then
388 m aptitude download debootstrap
/bullseye
390 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
395 sd
/etc
/apt
/preferences.d
/focal
<<'EOF'
397 Pin: release n=focal,o=Ubuntu
401 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
402 Package: spamassassin sa-compile spamc
403 Pin: release n=focal,o=Ubuntu
406 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
407 Package: spamassassin sa-compile spamc
408 Pin: release n=focal,o=Ubuntu
411 sd
/etc
/apt
/preferences.d
/psd
<<'EOF'
412 Package: profile-sync-daemon
413 Pin: release n=focal,o=Ubuntu
417 f
=/etc
/apt
/sources.list.d
/focal.list
420 deb http://us.archive.ubuntu.com/ubuntu/ focal main universe
421 deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main universe
422 deb http://us.archive.ubuntu.com/ubuntu/ focal-security main universe
424 if ! diff -q $t $f; then
425 sudo
dd if=$t of
=$f status
=none
431 sd
/etc
/apt
/preferences.d
/nabia-etiona
<<'EOF'
433 Pin: release n=nabia*,o=Trisquel
437 f
=/etc
/apt
/sources.list.d
/nabia.list
440 deb http://mirror.fsf.org/trisquel/ nabia main
441 deb-src http://mirror.fsf.org/trisquel/ nabia main
443 deb http://mirror.fsf.org/trisquel/ nabia-updates main
444 deb-src http://mirror.fsf.org/trisquel/ nabia-updates main
446 deb http://archive.trisquel.info/trisquel/ nabia-security main
447 deb-src http://archive.trisquel.info/trisquel/ nabia-security main
449 # Uncomment this lines to enable the backports optional repository
450 deb http://mirror.fsf.org/trisquel/ nabia-backports main
451 deb-src http://mirror.fsf.org/trisquel/ nabia-backports main
453 if ! diff -q $t $f; then
454 sudo
dd if=$t of
=$f status
=none
458 # duplicated in fai. Pin for bionic + ubuntu so that ppas dont get
460 sd
/etc
/apt
/preferences.d
/etiona-bionic
<<'EOF'
462 Pin: release n=bionic,o=Ubuntu
465 Pin: release n=bionic,o=Ubuntu
469 sd
/etc
/apt
/preferences.d
/etiona-sa
<<'EOF'
471 Pin: release n=bionic,o=Ubuntu
477 sd
/etc
/apt
/preferences.d
/aramo-nabia
<<'EOF'
479 Pin: release n=aramo*,o=Trisquel
482 f
=/etc
/apt
/sources.list.d
/aramo.list
485 deb http://mirror.fsf.org/trisquel/ aramo main
486 deb-src http://mirror.fsf.org/trisquel/ aramo main
488 deb http://mirror.fsf.org/trisquel/ aramo-updates main
489 deb-src http://mirror.fsf.org/trisquel/ aramo-updates main
491 deb http://archive.trisquel.info/trisquel/ aramo-security main
492 deb-src http://archive.trisquel.info/trisquel/ aramo-security main
494 # Uncomment this lines to enable the backports optional repository
495 deb http://mirror.fsf.org/trisquel/ aramo-backports main
496 deb-src http://mirror.fsf.org/trisquel/ aramo-backports main
498 if ! diff -q $t $f; then
499 sudo
dd if=$t of
=$f status
=none
506 pi debian-goodies shellcheck
511 case $codename_compat in
513 s systemctl
enable --now ssh-agent-iank
517 case $codename_compat in
519 sd
/etc
/apt
/preferences.d
/nabia-btrfs-progs
<<'EOF'
521 Pin: release a=buster-backports
524 p
install btrfs-progs
529 # 2020-03-03 old file
530 s
rm -fv /etc
/apt
/preferences.d
/radicale
531 ######### end universal pinned packages ######
536 sd
/etc
/apt
/preferences.d
/obs
<<EOF
538 Pin: release n=bionic
541 sd
/etc
/apt
/preferences.d
/chromium
<<EOF
543 Pin: release n=bionic
548 # note, to get the latest, it would be n=bullseye*
549 # but that has conflicting package versions, so this does the old one.
550 # I only use it for special rare purposes. Just keep in mind it is an
551 # outdated insecure version.
552 sd
/etc
/apt
/preferences.d
/chromium-bullseye
<<EOF
553 Package: chromium chromium-* libicu67 libjpeg62-turbo libjsoncpp24 libre2-9 libwebpmux3
554 Pin: release o=Debian*,n=bullseye
559 # obs dependency not in trisquel
560 sd
/etc
/apt
/preferences.d
/obs
<<EOF
562 Pin: release n=jammy,o=Ubuntu
570 ##### begin automatic upgrades (after checkrestart has been installed) ####
571 # if apt-config-auto-update is installed,
572 # it also has similar config, in a file 10something,
573 # but i think his overrides it since its higher number.
574 # This file was part of the automatic-updates package,
575 # and it has a configu option to not get new package lists,
576 # which seems pretty stupid to me, you cant actually upgrade
577 # anything if you dont have the new package list.
578 sd
/etc
/apt
/apt.conf.d
/20auto-upgrades
<<'EOF'
579 APT::Periodic::Update-Package-Lists "1";
580 APT::Periodic::Download-Upgradeable-Packages "1";
581 APT::Periodic::AutocleanInterval "7";
582 APT::Periodic::Unattended-Upgrade "1";
585 # fyi: default file has comments about available options,
586 # you may want to read that, do pkx unattended-upgrades
587 # default is just security updates. this list found from reading
588 # match_whitelist_string() in $(which unattended-upgrades)
589 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
590 Unattended-Upgrade::Mail "root";
591 Unattended-Upgrade::MailOnlyOnError "true";
592 Unattended-Upgrade::Remove-Unused-Dependencies "true";
593 Unattended-Upgrade::Origins-Pattern {
594 "o=*,l=*,a=*,c=*,site=*,n=*";
599 sudo
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
/etc
/cron.d
/myupgrade
601 # myupgrade cron exists in /etc/cron.d/ian
603 ##### end automatic upgrades ####
606 # commented in case i want to use this sometime later
607 # sd /etc/apt/preferences.d/buster-backports <<EOF
609 # Pin: release a=buster-backports
614 ###### begin website setup
618 f
=/var
/lib
/bind
/db.b8.nz
619 if [[ ! -e $f ]]; then
623 pi prometheus-node-exporter
624 /a
/bin
/buildscripts
/prom-node-exporter
-l
627 web-conf
-p 9101 -f 9100 - apache2
${HOSTNAME}ex.b8.nz
<<'EOF'
630 AuthName "basic_auth"
632 # htpasswd -c prometheus-export-htpasswd USERNAME
633 AuthUserFile "/etc/prometheus-export-htpasswd"
642 # i just dont feel like setting up a special purpose ssh key to do this automatically.
644 # run this once for bk on local machine:
645 # only used for old openvpn setup
646 /a/exe/vpn-mk-client-cert -c bk.b8.nz -b expertpath -n mail li.iankelling.org
655 m
/a
/h
/setup.sh iankelling.org
657 # start mumble only when im going to use it, since i dont use it much
658 pi-nostart mumble-server
659 sudo
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
661 # do certificate to avoid warning about unsigned cert,
662 # which is overkill for my use, but hey, I'm cool, I know
664 m web-conf apache2 mumble.iankelling.org
665 sudo
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
667 # general vpn for as needed use
668 vpn-server-setup
-d -r -4 10.5.5 -p 443 -n hole
670 # todo: consider if this should exist for the
672 teeu
/etc
/openvpn
/server
/hole.conf
<<'EOF'
676 sd
/etc
/openvpn
/client-config-hole
/kd
<<'EOF'
677 ifconfig-push 10.5.5.2 255.255.255.0
679 sd
/etc
/openvpn
/client-config-hole
/tp
<<'EOF'
680 ifconfig-push 10.5.5.3 255.255.255.0
682 sd
/etc
/openvpn
/client-config-hole
/frodo
<<'EOF'
683 ifconfig-push 10.5.5.5 255.255.255.0
685 sd
/etc
/openvpn
/client-config-hole
/x2
<<'EOF'
686 ifconfig-push 10.5.5.7 255.255.255.0
688 sd
/etc
/openvpn
/client-config-hole
/x3
<<'EOF'
689 ifconfig-push 10.5.5.8 255.255.255.0
691 sd
/etc
/openvpn
/client-config-hole
/kw
<<'EOF'
692 ifconfig-push 10.5.5.9 255.255.255.0
694 sd
/etc
/openvpn
/client-config-hole
/sy
<<'EOF'
695 ifconfig-push 10.5.5.12 255.255.255.0
697 sd
/etc
/openvpn
/client-config-hole
/bo
<<'EOF'
698 ifconfig-push 10.5.5.13 255.255.255.0
700 sd
/etc
/openvpn
/client-config-hole
/onep9
<<'EOF'
701 ifconfig-push 10.5.5.14 255.255.255.0
706 # for adding cert to system with /p
709 #mkc /p/c/machine_specific/$host/filesystem/etc/openvpn/client
710 #vpn-mk-client-cert -b $host -n hole -r iankelling.org
711 #s chown -R iank:iank .
713 # example of adding to remote system 107,
714 # vpn-mk-client-cert -n hole -c 10.2.0.107 -b hd8 iankelling.org
716 # for wireguard hole vpn, use function:
719 # requested from linode via a support ticket.
720 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
721 # ipv6 stuff pieced together
722 # via slightly wrong information from
723 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
724 # https://community.openvpn.net/openvpn/wiki/IPv6
727 # This uses a public /64, but afaik, that is not needed for my
728 # current use case, since I'm doing ipv6 nat, they could be private
729 # and nat to a public address. I'm doing ipv6 nat in order to have 2
730 # vpn clients that externally share the same ip when sending so they
731 # share ip reputation. Note, the eth0 and tunx needed to be
732 # different subnets. On the same, I saw some neighbor packet go
733 # unanswered, tcpdump showed packets getting lost. I tried splitting the
734 # /64, it didn't work but I didn't investigate closely.
737 # not starting as i intend to replace it
738 m vpn-server-setup
-s -i tunmail
-n mail -d -6 2600:3c00
:e002
:3800::/64 2600:3c00
:e002
:3800::1/64
739 sudo
tee /etc
/openvpn
/client-config-mail
/mailclient
<<'EOF'
740 ifconfig-push 10.8.0.4 255.255.255.0
741 ifconfig-ipv6-push 2600:3c00:e002:3800::4/64
743 sudo
tee /etc
/openvpn
/client-config-mail
/expertpath
<<'EOF'
744 ifconfig-push 10.8.0.5 255.255.255.0
745 ifconfig-ipv6-push 2600:3c00:e002:3800::5/64
749 sudo
dd of
=/etc
/systemd
/system
/vpn-mail-forward.service
<<'EOF'
751 Description=Turns on iptables mail nat
752 BindsTo=openvpn-server@mail.service
757 ExecStart=/a/bin/distro-setup/vpn-mail-forward tunmail start
758 ExecStop=/a/bin/distro-setup/vpn-mail-forward tunmail stop
761 RequiredBy=openvpn-server@mail.service
766 # needed for li's local mail delivery.
767 tu
/etc
/hosts
<<<"10.8.0.4 mx.iankelling.org"
769 # wgmail handles this.
770 #sgo vpn-mail-forward.service
772 #sgo openvpn-server@mail
775 # setup let's encrypt cert
776 m web-conf apache2 mail.iankelling.org
777 # TODO, i expanded the above cert manually to mx.iankelling.org, this should be captured
778 # in the automation here. We use mail.iankelling.org as our ehlo name when sending mail
779 # but our mx record is mx.iankelling.org. Initially I was just using mail.iankelling.org,
780 # but the problem is I want multiple ips to be able to identify as mail.iankelling.org,
781 # but a subset to be mx.iankelling.org. Afaik, there is no problem with having
782 # our mail cert be for mail.iankelling.org, and have people connect to mx.ian...,
783 # but it doesn't make logical sense to do this.
784 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
787 a2enmod -q proxy proxy_http
788 domain=cal.iankelling.org
789 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
790 # https://radicale.org/2.1.html
791 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
792 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
794 # this doesn't exactly fit with the documentation.
795 # We need location / to do an auth, it cant be done outside,
796 # in order to pass on X-Remote-User. And we need
797 # the other location in order to remove the /radicale/ for
798 # requests which have it. This could be done with a rewrite,
799 # but i just get something working and call it a day.
804 AuthName "Authentication Required"
805 # setup one time, with root:www-data, 640
806 AuthUserFile "/etc/caldav-htpasswd"
808 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
810 <Location "/radicale/">
811 Options +FollowSymLinks +Multiviews -Indexes
812 RequestHeader set X-Script-Name /radicale/
813 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
814 ProxyPass "http://10.8.0.4:5232/" retry=0
815 ProxyPassReverse "http://10.8.0.4:5232/"
818 # nginx version of above would be:
819 # auth_basic "Not currently available";
820 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
824 ###### begin znc setup #####
827 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
828 # to get into the web interface,
829 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
830 # https://iankelling.org:12533/
831 # login as ian, pass is in pass store, the part after :
833 # znc config generated by doing
835 # selected port is also used in erc config
836 # comma separated channel list worked.
837 # while figuring things out, running znc -D for debug in foreground.
838 # to exit and save config:
839 # /msg *status shutdown
840 # configed auth on freenode by following
841 # https://wiki.znc.in/Sasl:
845 # Set MyNickservName pa$$w0rd
846 # created the system service after, and had to do
847 # mv /home/iank/.znc/* /var/lib/znc
848 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
849 # and made a copy of the config files into /p/c
850 # /msg *status LoadMod --type=global log -sanitize
851 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
852 # /msg *status LoadMod --type=network perform
853 # /query *perform add PRIVMSG ChanServ :invite #fsf-office
854 # /msg *perform add JOIN #fsf-office
855 # /msg *status LoadMod NickServ
858 # also ran /znc LoadMod clearbufferonmsg
859 # it would be nice if erc supported erc query buffers by doing
860 # /msg *status clearbuffer <name of the query/receiver
862 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
863 # if that was the case i could remove the module clearbufferonmsg
864 # also would be nice if erc supported
865 # https://wiki.znc.in/self-message
866 # https://wiki.znc.in/Query_buffers \
868 # for geekshed, there was no sasl support as far as I can tell,
869 # so I set to msg nickserv to identify upon connect.
870 if ! getent passwd znc > /dev/null; then
871 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
873 sudo chmod 700 /var/lib/znc
874 sudo chown -R znc:znc /var/lib/znc
875 # Avoid restarting if possible, reconnecting to irc is annoying.
876 # The unit file was made active with conflink.
877 # Note, avoid using ser here because we wrap sudo to prints the command first.
878 if [[ $(systemctl is-active znc) != active ]]; then
881 ###### stop znc setup #####
890 # todo, save the config
891 /etc/cron.daily/stream-cert
892 web-conf -c /etc/cert-live.fsf.org -p 443 -f 8000 apache2 live.fsf.org
896 ###### end website setup
898 ########### end section including li/lj ###############
903 ### system76 things ###
905 bo) # sy| sy doesnt seem to really need this.
906 # note, i stored the initial popos packages at /a/bin/data/popos-pkgs
907 if [[ ! -e /etc/apt/sources.list.d/system76.list ]]; then
908 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
909 sd /etc/apt/sources.list.d/system76.list <<EOF
910 deb http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
911 deb-src http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
913 # ubuntu keyserver is prone to intermittent failures
914 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5D1F3A80254F6AFBA254FED5ACD442D1C8B7748B
916 # https://support.system76.com/articles/install-ubuntu/
917 # but i'm hoping this is not needed
918 # sd /etc/apt/preferences.d/system76 <<'EOF'
920 # Pin: release o=LP-PPA-system76-dev-stable
924 # TODO: I had to uninstall linux-image-generic-hwe-20.04 because of a conflict
925 # about linux-firmware. Should probably install it to begin with in fai if
927 pi system76-driver system76-firmware
928 # if you get a notice about a firmware update, the notifier on i3
929 # is too dumb to do anything when you click it. so to see
931 # /var/cache/system76-firmware-daemon
932 # extract the xz files there, one will contain a changelog.
933 # then to install an update:
934 # s system76-firmware-cli schedule
938 ### end system76 things ###
943 # ppa:obsproject/obs-studio
944 if [[ ! -s /etc/apt/sources.list.d/obs.list ]]; then
945 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
946 sd /etc/apt/sources.list.d/obs.list <<EOF
947 deb http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
948 deb-src http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
950 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BC7345F522079769F5BBE987EFC71127F425E228
956 case $codename_compat in
958 # mate-indicator-applet and beyond are msc things I noticed diffing a
959 # standard install with mine.
960 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
966 # todo: figure out mate for buster
967 # pi task-gnome-desktop
970 # i had installing mate-indicator-applet, but im not sure why so i removed
971 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras anacron
974 # # apt-get update periodically fails with an appstream error.
975 # # this removes gnome-core, but its just a package for dependencies
976 # p -y remove appstream
979 # by default, it sleeps when not logged in to x/wayland and on ac power.
981 if id -u gdm &>/dev/null; then
982 sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
986 # lightdm startup fails without this. on etiona, we got unity-greeter installed automatically,
987 # it would probably work on nabia too, but google just lead me to this and it works fine.
988 pi lightdm-gtk-greeter
989 # ok, this is really weird
990 # normally this file has
991 sd /etc/X11/Xsession.d/99x11-common_start <<'EOF'
993 # this file normally just has: exec $STARTUP
994 # but then ~/.xsession-errors
995 # says $STARTUP is not found, which appears to be the real
996 # error, but normal bash doesnt operate that way.
997 # https://bugs.launchpad.net/ubuntu/+source/im-config/+bug/1879352
1000 # also, gdm wayland was default, had to do
1001 # dpkg-reconfigure gdm3
1002 # and choose lightdm.
1006 # not yet bothering with mate
1007 pi lightdm-gtk-greeter lightdm
1012 if [[ $codename_compat == flidas ]]; then
1013 # doesnt exist in newer
1022 # firefox would work here too, apt would select abrowser.
1023 # and the update-alternatives thing i think is becuz firefox is
1024 # generally available before abrowser and this helps fix things
1025 # up when we have both.
1027 s update-alternatives --set x-www-browser /usr/bin/abrowser
1039 # newer distros just use adb for package name it seems
1040 case $codename_compat in
1042 pi android-tools-adbd
1046 case $codename_compat in
1048 pi libext2fs-dev libzstd-dev
1049 cd /a/opt/btrfs-progs
1054 case $codename_compat in
1063 # not packaged in newer distros it seems
1064 case $codename_compat in
1065 bionic|buster|stretch)
1071 # TODO: some of the X programs can be removed from pall when using wayland
1073 # depends gcc is a way to install suggests. this is apparently the only
1074 # way to install suggests even if the main package is already
1075 # installed. reinstall doesn't work, uninstalling can cause removing
1076 # dependent packages.
1077 # shellcheck disable=SC2046 # word splitting is intended
1078 pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $($src/distro-pkgs)
1080 # schroot service will restart schroot sessions after reboot.
1084 # fix systemd unit failure. i dont know of any actual impact
1085 # other than systemd showing in degraded state. So, we dont bother
1086 # fixing the current state, let it fix on the next reboot.
1087 # https://gitlab.com/cjwatson/binfmt-support/-/commit/54f0e1af8a
1088 tmp=$(systemctl cat binfmt-support.service | grep ^After=)
1089 if [[ $tmp != *systemd-binfmt.service* ]]; then
1090 s u /etc/systemd/system/binfmt-support.service.d/override.conf <<EOF
1092 $tmp systemd-binfmt.service
1097 # commented, not worth the hassle i think.
1103 sudo rm -fv /etc/systemd/resolved.conf.d/iank.conf
1105 # website is dead june 14 2019. back in october, but meh
1106 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
1111 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
1114 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
1115 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
1117 # f=/etc/apt/sources.list.d/iridium-browser.list
1118 # if ! diff -q $t $f; then
1123 # pi iridium-browser
1129 if mountpoint /p &>/dev/null; then
1130 # note, see bashrc for more documentation.
1132 sd /etc/systemd/system/rss2email.service <<'EOF'
1134 Description=rss2email
1135 After=multi-user.target
1140 # about 24 hours of failures
1141 # it copies over its files without respecting symlinks, so
1142 # we pass options to use different location.
1143 ExecStart=/usr/local/bin/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
1145 sd /etc/systemd/system/rss2email.timer <<'EOF'
1147 Description=rss2email
1150 # for initial run. required.
1152 # for subsequent runs.
1153 OnUnitInactiveSec=300
1156 WantedBy=timers.target
1158 sudo systemctl daemon-reload
1162 ######### begin irc periodic backup #############
1163 if [[ $HOSTNAME == frodo ]]; then
1164 sd /etc/systemd/system/ircbackup.service <<'EOF'
1166 Description=irc li backup
1167 After=multi-user.target
1172 ExecStart=/usr/local/bin/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
1174 sd /etc/systemd/system/ircbackup.timer <<'EOF'
1176 Description=irc li backup hourly
1182 WantedBy=timers.target
1184 sudo systemctl daemon-reload
1189 ######### end irc periodic backup #############
1193 # pi-nostart does not disable
1197 if [[ -e /p/c/gen-fsf-vpn ]]; then
1201 if [[ -e /p/c/machine_specific/$HOSTNAME/filesystem/etc/openvpn/client/hole.crt ]]; then
1202 sgo openvpn-client@hole
1205 ############# begin syncthing setup ###########
1208 f=/usr/share/keyrings/syncthing-archive-keyring.gpg
1209 if [[ ! -e $f ]]; then
1210 s curl -s -o $f https://syncthing.net/release-key.gpg
1212 s="deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable"
1213 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
1214 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
1220 m lnf -T /w/syncthing /home/iank/.config/syncthing
1221 ser daemon-reload # syncthing likely not properly packaged
1222 sgo syncthing@iank # runs as iank
1226 # 1003 just happens to be what was on my system
1227 if ! getent passwd ziva; then
1228 s groupadd -g 1003 ziva
1229 # syncthing state / config / db are all in ~/.config/syncthing
1230 s useradd -g 1003 -u 1003 -d /d/ziva-home -c ziva -s /bin/bash ziva
1236 # user for short term use dropping of privileges
1238 if ! getent group zu &>/dev/null; then
1239 s groupadd -g 1023 zu
1241 if ! getent passwd zu &>/dev/null; then
1242 s useradd -g 1023 -u 1023 -c zu -s /bin/bash zu
1246 # these things persist in ~/.config/syncthing, which I save in
1247 # /w/syncthing (not in /p, because syncthing should continue to
1248 # run on home server even when using laptop as primary device)
1249 # open http://localhost:8384/
1250 # change listen address from default to tcp://:22001,
1251 # this is because we do port forward so it doesn\'t have to use
1252 # some external server, but the syncthing is broken for port forward,
1253 # you get a message, something "like connected to myself, this should not happen"
1254 # when connecting to other local devices, so I bump the port up by 1,
1256 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
1257 # Without this, it was being stuck syncing at 0%.
1258 # Set gui username and password.
1260 # install syncthing via f-droid,
1261 # folder setting, turn off send only.
1262 # on phone, add device, click bar code icon
1263 # on dekstop, top right, actions, device id
1264 # after adding, notification will appear on desktop to confirm
1266 # syncing folder. from phone to desktop: select desktop in the
1267 # folder on phone\'s sync options, notification will appear in
1268 # desktop\'s web ui within a minute. For the reverse, the
1269 # notification will appear in android\'s notifications, you have to
1270 # swipe down and tap it to add the folder. It won\'t appear in the
1271 # syncthing ui, which would be intuitive, but don\'t wait for it
1272 # there. The notification may not work, instead open the web gui
1273 # from in the app, there should be a notification within there.
1275 # On phone, set settings to run syncthing all the time, and
1276 # show no notification.
1278 # Folder versioning would make sense if I didn\'t already use btrfs
1279 # for backups. I would choose staggered, or trash can for more space.
1281 # if needed to install on a remote comp:
1282 # ssh -L 8384:localhost:8384 -N frodo
1283 # open http://localhost:8384/
1285 # Note, the other thing i did was port forward port 22000,
1286 # per https://docs.syncthing.net/users/firewall.html
1288 ############# end syncthing setup ###########
1292 ####### begin misc packages ###########
1301 sudo update-alternatives --set pinentry /usr/bin/pinentry-gtk-2
1304 # sakura config is owned by ian
1307 m sudo -u user2 -i reset-konsole
1308 # user2 xscreensaver we don't want to reset
1309 m reset-xscreensaver
1312 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
1313 # this is also in primary-setup
1314 # pi libxss-dev # dependency based on build failure
1316 # cabal install --upgrade-dependencies --force-reinstalls arbtt
1317 # also, i assume syncing this between machines somehow messed up the data.
1319 ## not using arbtt for now
1320 # if mountpoint /p &>/dev/null; then
1324 # # same as seru enable arbtt, but works over ssh when systemctl --user causes error:
1325 # # Failed to connect to bus: No such file or directory
1326 # lnf -T /a/bin/ds/subdir_files/.config/systemd/user/arbtt.service /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1328 # seru start arbtt ||:
1332 rm -fv /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1337 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
1338 m cp /p/.linphonerc-initial ~/.linphonerc
1341 # linphone in t10 wont do dns with systemd-resolved or something
1342 s teeu /etc/hosts <<'EOF'
1343 74.94.156.215 watson.fsf.org
1348 ### begin spd install
1349 if mountpoint /p &>/dev/null; then
1350 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
1352 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
1355 # this guesses at the appropriate directory, adjust if needed
1356 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
1357 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
1358 # newer distro had gpg2 as default, older one, flidas, need to make it that way
1359 gpgpath=$(which gpg2) ||:
1360 if [[ $gpgpath ]]; then
1361 sudo mkdir -p /usr/local/spdhackfix
1362 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
1368 # nagstamon setting which were set through the ui
1369 # monitor url https://klaxon.fsf.org/cgi-bin
1370 # monitor url cgi https://klaxon.fsf.org/cgi-bin
1372 # all unknown services
1373 # all warning services
1374 # acknowledged hosts & services
1375 # hosts & services down for maintenence
1376 # services on down hosts
1377 # services on hosts in maintenece
1378 # services on unreachable osts
1379 # hosts in soft state
1380 # services in soft state
1381 # in display tab: fullscreen
1383 # these translate to these settings I think
1384 # filter_acknowledged_hosts_services = True
1385 # filter_all_unknown_services = True
1386 # filter_all_warning_services = True
1387 # filter_hosts_in_soft_state = True
1388 # filter_hosts_services_maintenance = True
1389 # filter_services_in_soft_state = True
1390 # filter_services_on_down_hosts = True
1391 # filter_services_on_hosts_in_maintenance = True
1392 # filter_services_on_unreachable_hosts = True
1393 # notify_if_up = False
1394 # statusbar_floating = False
1396 # but i'm just going to rely on the webpage plus sms for now.
1399 # it asks if it should make users in it's group capture packets without root,
1400 # which is arguably more secure than running wireshark as root. default is no,
1401 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
1402 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
1404 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
1405 # listed in the default config as suggested.
1406 # /run/usr/1000 i noticed was missing for pulseaudio
1407 # /run/user/0 just seemed like a not bad idea, given the above
1408 tu /etc/schroot/desktop/fstab <<'EOF'
1409 /p /p none rw,bind 0 0
1410 /a /a none rw,bind 0 0
1411 /run /run none rw,bind 0 0
1412 /run/lock /run/lock none rw,bind 0 0
1413 /dev/shm /dev/shm none rw,bind 0 0
1414 /run/shm /run/shm none rw,bind 0 0
1415 /run/user/1000 /run/user/1000 none rw,bind 0 0
1416 /run/user/1001 /run/user/1001 none rw,bind 0 0
1417 /run/user/0 /run/user/0 none rw,bind 0 0
1420 # todo: consider if this should use the new sysd-prom-fail
1421 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1423 Description=schrootupdate
1424 After=multi-user.target
1428 ExecStart=/usr/local/bin/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1430 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1432 Description=schrootupdate
1435 OnCalendar=*-*-* 04:20:00 America/New_York
1438 WantedBy=timers.target
1441 sgo schrootupdate.timer
1448 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/bullseye.list/BULLSEYE_FREE \
1449 debian bullseye firefox-esr pulseaudio chromium anki
1450 case $(debian-codename) in
1452 # we have a lot of t8 stuff, useful to have
1453 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/flidas.list/FLIDAS \
1455 tu /nocow/schroot/flidas/etc/sudoers <<EOF
1456 $USER ALL=(ALL) NOPASSWD: ALL
1457 Defaults env_keep += SUDOD
1458 Defaults always_set_home
1461 sd /nocow/schroot/flidas//etc/locale.gen <<'EOF'
1464 s schroot -c flidas locale-gen
1465 s schroot -c flidas update-locale LANG=en_US.UTF-8
1467 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/testing.list/TESTING_NONFREE debian unstable debootstrap
1468 sudo cp -a /nocow/schroot/unstable/usr/share/debootstrap/scripts/* /usr/share/debootstrap/scripts
1470 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/impish.list/IMPISH ubuntu impish
1480 sudo mkdir -p /nocow/user
1481 sudo chown $USER:$USER /nocow/user
1485 ####### begin transmission
1495 tdir=/nocow/user/tor
1501 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1502 # 450 seems likely to be unused. we need to specify one or else
1503 # it won't be stable across installs.
1504 if ! getent passwd debian-transmission > /dev/null; then
1505 sudo groupadd -g 450 debian-transmission
1506 sudo adduser --quiet \
1511 --disabled-password \
1512 --home /var/lib/transmission-daemon \
1515 # We want group writable stuff from transmission.
1516 # However, after setting this, I learn that transmission sets it's
1517 # own umask based on it's settings file. Well, no harm leaving this
1518 # so it's set right from the beginning.
1519 sudo chfn debian-transmission -o umask=0002
1521 # note i had to do this, which is persistent:
1523 # s chgrp debian-transmission torrents partial-torrents
1525 # syslog says things like
1526 # 'Failed to set receive buffer: requested 4194304, got 425984'
1527 # google suggets giving it even more than that
1528 tu /etc/sysctl.conf<<'EOF'
1529 net.core.rmem_max = 67108864
1530 net.core.wmem_max = 16777216
1534 # some reason it doesn\'t seem to start automatically anyways
1535 pi-nostart transmission-daemon
1536 # be extra sure its not started
1537 ser disable transmission-daemon
1538 ser stop transmission-daemon
1540 # the folder was moved here after an install around 02/2017.
1541 # it contains runtime data,
1542 # plus a simple symlink to the config file which it\'s
1543 # not worth separating out.
1544 # between comps, the uid can change
1546 f=$tdir/transmission-daemon
1547 for d in $tdir/partial-torrents $tdir/torrents $f; do
1548 if [[ ! -d $d ]]; then
1551 sudo chown -R debian-transmission:user2 $d
1553 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1554 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1555 sudo chown -R debian-transmission:debian-transmission $f
1556 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1558 # config file documented here, and it\'s the same config
1559 # for daemon vs client, so it\'s documented in the gui.
1560 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1562 # I originaly setup rpc-whitelist, but after using
1563 # routing to a network namespace, it doesn\'t see the
1564 # real source address, so it\'s disabled.
1566 # Changed the cache-size to 256 mb, reduces disk use.
1567 # It is a read & write cache.
1568 if ! systemctl is-active transmission-daemon-nn &>/dev/null && \
1569 ! systemctl is-active transmission-daemon; then
1571 command sudo ruby <<EOF >$tmp
1573 p = '/etc/transmission-daemon/settings.json'
1575 'rpc-whitelist-enabled' => false,
1576 'rpc-authentication-required' => false,
1577 'incomplete-dir' => '$tdir/partial-torrents',
1578 'incomplete-dir-enabled' => true,
1579 'download-dir' => '$tdir/torrents',
1580 "speed-limit-up" => 800,
1581 "speed-limit-up-enabled" => true,
1582 "peer-port" => 61486,
1583 "cache-size-mb" => 256,
1584 "ratio-limit" => 5.0,
1585 "ratio-limit-enabled" => false,
1587 puts(JSON.pretty_generate(JSON.parse(File.read(p)).merge(s)))
1589 cat $tmp | sudo dd of=/etc/transmission-daemon/settings.json
1593 ####### end transmission
1597 # to persist upload/dl metadata. initially, moved all the stuff
1598 # in /var/lib/transmission-daemon to /d/tor
1599 s usermod --home /d/tor debian-transmission
1600 sgo transmission-daemon-nn
1606 ######### begin transmission client setup ######
1608 if [[ -e /p/transmission-rpc-pass ]]; then
1609 # arch had a default config,
1610 # debian had nothing until you start it.
1611 # With a little trial an error, here is a minimal config
1612 # taken from the generated one, plus changes that the
1613 # settings ui does, without a bunch of ui crap settings.
1615 # only settings I set were
1620 # the password is randomly generated on first run, i copied it out
1621 # so it could be used by other hosts.
1624 p = '/etc/transmission-daemon/settings.json'
1625 s = JSON.parse(File.read(p))
1626 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1627 # default is 0022 (18 in decimal)
1629 File.write p, JSON.pretty_generate(s)
1632 rpc_pass=$(</p/transmission-rpc-pass)
1633 for f in /home/*; do
1635 uid=$(id -u $u 2>/dev/null) || continue
1636 if [[ ! $uid -ge 1000 ]]; then
1639 d=$f/.config/transmission-remote-gtk
1640 sudo -u $u mkdir -p $d
1641 # i tried setting hostname to transmission.b8.nz, so i could dynamically change where
1642 # this connects to, but it said some 421 denied error when I did that. Then it
1643 # froze X when i ran it under strace. Whatever.
1644 sudo -u $u dd of=$d/config.json <<EOF
1648 "profile-name" : "Default",
1649 "hostname" : "10.173.0.2",
1650 "rpc-url-path" : "/transmission/rpc",
1652 "password" : "$rpc_pass",
1653 "auto-connect" : true,
1657 "update-active-only" : false,
1658 "activeonly-fullsync-enabled" : false,
1659 "activeonly-fullsync-every" : 2,
1660 "update-interval" : 3,
1661 "min-update-interval" : 3,
1662 "session-update-interval" : 60,
1663 "exec-commands" : [],
1668 "add-options-dialog" : false
1673 ######### end transmission client setup ######
1679 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1680 # goto http://127.0.0.1:631
1681 # administration tab, add new printer button.
1682 # In debian, I could use hte recommended driver,
1683 # in arch, I had to pick out the 6L driver.
1686 # bridge networking as user fails. google lead here, but it doesn\'t work:
1687 # oh well, I give up.
1688 # http://wiki.qemu.org/Features-Done/HelperNetworking
1690 # f=/etc/qemu/bridge.conf
1694 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1697 # general known for debian/ubuntu, not for fedora
1699 m /a/bin/buildscripts/go
1700 # only needed for rg. cargo takes up 11 gigs, filled up the disk on je.
1701 #m /a/bin/buildscripts/rust
1702 m /a/bin/buildscripts/misc
1703 m /a/bin/buildscripts/pithosfly
1704 #m /a/bin/buildscripts/alacritty
1705 #m /a/bin/buildscripts/kitty
1707 pi-nostart virtinst virt-manager
1709 # i cant if this is whats causing it to start even though
1710 # its disabled. note: it leaves around dnsmasq instances even
1711 # if you stop it. what the hell systemd?
1713 # allow user to run vms, from debian handbook. libvirt-qemu
1714 # based on https://www.whonix.org/wiki/KVM#First-time_User.3F
1715 for x in iank user2; do s usermod -a -G libvirt,kvm,libvirt-qemu $x; done
1718 pi --no-install-recommends kdeconnect
1719 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1720 ### but gnome + xmonad not working in flidas, so i disabled it
1721 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1722 # cd /a/opt/indicator-kdeconnect
1725 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1728 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1729 # # it seems, according to
1730 # # /etc/xdg/autostart/kdeconnectd.desktop
1731 # # I'm not seeing the icon, but the clipboard replication is working
1734 ### begin model 01 arduino support ###
1735 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1736 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1737 # set arduino var in bashrc,
1738 # have system config file setup too.
1739 sudo adduser $USER dialout
1742 # download arduino ide, extract in /a/opt, ignore the install script, run ./arduino,
1743 # toolbar, preferences, add board manager url:
1744 # https://raw.githubusercontent.com/keyboardio/boardsmanager/master/package_keyboardio_index.json
1745 # toolbar, board manager, add keyboardio
1746 # toolbar, select model01 board
1747 # toolbar, examples, model01, compile
1751 # this is for the mail command too. update-alternatives is kind of misleading
1752 # since at least it's main commands pretend mail does not exist.
1753 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1754 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1756 ######### end misc packages #########
1759 # packages I once used before and liked, but don\'t want installed now for
1761 # python-sqlite is used for offlineimap
1762 # lxappearance python-sqlite dolphin paman dconf-editor
1768 # todo, finish configuring smart.
1771 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1772 # turn on smart. background on options:
1773 # first line, -a = test everyting on all devices.
1774 # -S on, turn on disk internal saving of vendor specific info,
1775 # from google, seems like this is usually already on and fairly standard.
1776 # -o on, turn on 4 hour period non-performance degrading testing.
1777 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1778 sched="-s (S/../.././02|L/../../6/03)"
1779 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1780 DEVICESCAN -a -o on -S on -n standby,q $sched \
1781 -m root@mail.iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1783 # in the default configuration of at least ubuntu 14.04, resolvconf is
1784 # configured to order any nameservers associated with tun* or tap*
1785 # before the normal internet interfaces, which means they are always
1786 # consulted first. This is often slower and undesirable, ie. local dns
1787 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1789 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1790 # however, this breaks dns lookup for hosts on the openvpn lan.
1791 # I can\'t figure out why hosts on the normal lan would not be
1792 # broken under the default ordering, except the host I was
1793 # testing with previously had an entry in /etc/hosts.
1795 ############# end unfinished
1797 ########### misc stuff
1799 # pressing tab after sdf here:
1800 # scp sdfbash: set +o noglob: command not found
1801 # in t11, bash 5.1.16. this fixes it.
1802 sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
1804 rm -fv /home/iank/.mpv/watch_later
1805 rm -rf /home/iank/.mpv
1807 if [[ ! -e ~/.local/bin/pip ]]; then
1809 wget -O$tmp https://bootstrap.pypa.io/get-pip.py
1815 # soo, apt install beets fails due to wanting a pip package,
1816 # we find out why it wants this through
1817 # apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances beets | less
1818 # python-mediafile requires tox, which requires virtualenv, which requires pip.
1819 # but, python-mediafile doesn't really require tox, it is specified in
1820 # ./usr/lib/python3/dist-packages/mediafile-0.9.0.dist-info/METADATA
1821 # as being required only for testing, but the debian package
1822 # included it anyways, due to a mistake or bad tooling or something.
1823 # I don't plan to use tox, so, according to https://serverfault.com/a/251091,
1824 # we can create and install a dummy package by:
1826 # "equivs-control <name>, edit the file produced to provide the right
1827 # dependency and have a nice name, then run equivs-build <name> and
1828 # finally dpkg -i the resulting .deb file"
1829 # as of 2023-02, the tox dependency was removed in debian unstable, so
1830 # this hack will probably go away in t12.
1832 if pcheck beets; then
1833 tmpdir="$(mktemp -d)"
1835 # edited from output of equivs-control tox
1839 Standards-Version: 3.9.2
1841 Description: tox-dummy
1844 sudo dpkg -i tox_1.0_all.deb
1846 pi beets python3-discogs-client
1851 # get rid of annoying message
1852 s sed -ri "s/^([[:space:]]*ui.print_\('Playing)/#\1/" /usr/share/beets/beetsplug/play.py
1855 # notes about barrier
1856 # run barrier, do the gui config,
1857 # setup the 2 screens, using hostnames for the new screen.
1858 # save the server config
1859 # $HOME/.local/share/barrier/.barrier.conf
1862 # ssl errors, resolved via advice here: https://github.com/debauchee/barrier/issues/231
1863 # BARRIER_SSL_PATH=~/.local/share/barrier/SSL/
1864 # mkdir -p "${BARRIER_SSL_PATH}"
1865 # openssl req -x509 -nodes -days 365 -subj /CN=Barrier -newkey rsa:4096 -keyout ${BARRIER_SSL_PATH}/Barrier.pem -out ${BARRIER_SSL_PATH}/Barrier.pem
1866 # ran on both machines.
1867 # When pressing start in the gui, the cli options used are printed to the console,
1868 # they are useful. So on server, just run barriers, client run barrierc SERVER_IP
1870 ### begin timetrap setup
1871 if mountpoint /p &>/dev/null; then
1872 mkdir -p ~/.timetrap/
1873 ln -sf /a/opt/timetrap_formatters ~/.timetrap/formatters
1874 if ! type -p t &>/dev/null; then
1875 pi ruby-dev libsqlite3-dev
1876 gem install --user timetrap
1879 ### end timetrap setup
1881 # leftover cleanup for t9
1885 # needed for debootstrap scripts for fai since fai requires debian
1888 pi-nostart network-manager
1889 # i hate networkmanager. noo, of course disabling it doesnt work
1890 # unless you add a hack. found this by doing
1891 # systemd-analyze dot > x.dot
1895 soff NetworkManager-wait-online.service
1896 # make networkmanager use resolvconf instead of its own dnsmasq which
1897 # conflicts with the normal dnsmasq package.
1898 f=/etc/NetworkManager/NetworkManager.conf
1900 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1901 sudo sed -ri '/ *\[main\]/a dns=default' $f
1902 if [[ $m != $(md5sum $f) ]]; then
1903 srestart NetworkManager
1905 # networkmanager has this nasty behavior on flidas: if the machine
1906 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1907 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1909 # This can be manually fixed by stoping dnsmasq,
1910 # then based on whats in /run/dnsmasq/, i see we can run
1911 # s resolvconf -d NetworkManager
1912 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1913 ser disable NetworkManager
1917 # I have no use for avahi,
1918 # had to run this twice when doing manually, i dunno why
1919 soff avahi-daemon ||:
1923 # make my /etc/fonts/conf.d/ get used.
1924 # I have a new sans-serif font there because the default one
1925 # displays l and I as the same char, grrrrr.
1928 pi desktop-file-utils
1929 m /a/bin/distro-setup/mymimes
1931 if type -p dbus-launch >/dev/null; then
1932 # stop autopoping windows when i plug in an android phone.
1933 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1934 # with still 0 exit code.
1935 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1936 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1939 # on grub upgrade, we get prompts unless we do this
1941 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1942 devs+=("$(devbyid $dev),")
1944 devs[-1]=${devs[-1]%,} # jonied by commas
1945 sudo debconf-set-selections <<EOF
1946 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1950 sysd-prom-fail-install dynamicipupdate
1951 sysd-prom-fail-install systemstatus
1952 sysd-prom-fail-install btrfsmaintstop
1953 sgo btrfsmaint.timer
1959 if grep -xFq $HOSTNAME /a/bin/ds/machine_specific/btrbk.hosts; then
1962 if [[ $HOSTNAME == kd ]]; then
1963 sgo btrbk-spread.timer
1966 # note: to see when it was last run,
1975 ### begin prometheus ###
1979 pi prometheus-node-exporter-collectors
1982 # Font awesome is needed for the alertmanager ui.
1983 pi prometheus-alertmanager prometheus fonts-font-awesome
1984 /a/bin/buildscripts/prometheus
1985 web-conf -p 9091 -f 9090 - apache2 i.b8.nz <<'EOF'
1988 AuthName "basic_auth"
1990 # htpasswd -c prometheus-htpasswd USERNAME
1991 AuthUserFile "/etc/prometheus-htpasswd"
1996 web-conf -p 9094 -f 9093 - apache2 i.b8.nz <<'EOF'
1999 AuthName "basic_auth"
2001 # htpasswd -c prometheus-htpasswd USERNAME
2002 AuthUserFile "/etc/prometheus-htpasswd"
2007 # by default, the alertmanager web ui is not enabled other than a page
2008 # that suggests to use the amtool cli. that tool is good, but you cant
2009 # silence things nearly as easily as with the gui.
2010 if [[ ! -e /usr/share/prometheus/alertmanager/ui/index.html ]]; then
2011 # default script didnt work, required some changes to get elm 19.1,
2012 # which is a dependency of the latest alertmanager. I modified
2013 # and copied it into /b/ds. In future, might need some other
2015 #sudo /usr/share/prometheus/alertmanager/generate-ui.sh
2016 sudo /b/ds/generate-ui.sh
2017 ser restart prometheus-alertmanager
2020 /a/bin/buildscripts/prom-node-exporter -l
2022 for ser in prometheus-node-exporter prometheus-alertmanager prometheus; do
2023 sysd-prom-fail-install $ser
2028 /a/bin/buildscripts/prom-node-exporter
2032 # cleanup old files. 2023-02
2033 x=(/var/lib/prometheus/node-exporter/*.premerge)
2034 if [[ -e ${x[0]} ]]; then
2035 s rm /var/lib/prometheus/node-exporter/*
2040 # todo, for limiting node exporter http,
2041 # either use iptables or, in
2042 # /etc/default/prometheus-node-exporter
2043 # listen on the wireguard interface
2046 wgip=$(command sudo sed -rn 's,^ *Address *= *([^/]+).*,\1,p' /etc/wireguard/wghole.conf)
2047 # old filename. remove once all hosts are updated.
2048 s rm -fv /etc/apache2/sites-enabled/${HOSTNAME}wg.b8.nz.conf
2049 web-conf -i -a $wgip -p 9101 -f 9100 - apache2 ${HOSTNAME}wg.b8.nz <<'EOF'
2052 AuthName "basic_auth"
2054 # htpasswd -c prometheus-export-htpasswd USERNAME
2055 AuthUserFile "/etc/prometheus-export-htpasswd"
2059 # For work, i think we will just use the firewall for hosts in the main data center, and
2060 # vpn for hosts outside it.
2062 # TODO: figure out how to detect the ping failure and try again.
2064 # Binding to the wg interface, it might go down, so always restart, and wait for it on boot.
2065 s mkdir /etc/systemd/system/apache2.service.d
2066 sd /etc/systemd/system/apache2.service.d/restart.conf <<EOF
2068 After=wg-quick@wghole.service
2069 StartLimitIntervalSec=0
2079 ### end prometheus ###
2081 ### begin nagios ###
2086 s rm -fv /etc/apache2/conf-enabled/nagios4-cgi.conf
2088 # to add a password for admin:
2089 # htdigest /etc/nagios4/htdigest.users Nagios4 iank
2090 # now using the same pass as prometheus
2092 # nagstamon auth settings, set to digest instead of basic.
2094 web-conf -p 3005 - apache2 i.b8.nz <<'EOF'
2095 # adapted from /etc/apache2/conf-enabled/nagios4-cgi.conf
2097 ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4
2098 ScriptAlias /nagios4/cgi-bin /usr/lib/cgi-bin/nagios4
2100 # Where the stylesheets (config files) reside
2101 Alias /nagios4/stylesheets /etc/nagios4/stylesheets
2103 # Where the HTML pages live
2104 Alias /nagios4 /usr/share/nagios4/htdocs
2106 <DirectoryMatch (/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)>
2107 Options FollowSymLinks
2108 DirectoryIndex index.php index.html
2109 AllowOverride AuthConfig
2111 # The default Debian nagios4 install sets use_authentication=0 in
2112 # /etc/nagios4/cgi.cfg, which turns off nagos's internal authentication.
2113 # This is insecure. As a compromise this default apache2 configuration
2114 # only allows private IP addresses access.
2116 # The <Files>...</Files> below shows how you can secure the nagios4
2117 # web site so anybody can view it, but only authenticated users can issue
2118 # commands (such as silence notifications). To do that replace the
2119 # "Require all granted" with "Require valid-user", and use htdigest
2120 # program from the apache2-utils package to add users to
2121 # /etc/nagios4/htdigest.users.
2123 # A step up is to insist all users validate themselves by moving
2124 # the stanza's in the <Files>..<Files> into the <DirectoryMatch>.
2125 # Then by setting use_authentication=1 in /etc/nagios4/cgi.cfg you
2126 # can configure which people get to see a particular service from
2127 # within the nagios configuration.
2129 AuthDigestDomain "Nagios4"
2130 AuthDigestProvider file
2131 AuthUserFile "/etc/nagios4/htdigest.users"
2132 AuthGroupFile "/etc/group"
2138 <Directory /usr/share/nagios4/htdocs>
2145 # when you alter a service through the web, it changes vars in /var/lib/nagios4/status.dat. for example:
2146 # notifications_enabled=1
2147 # note, the same variable exists in the correspdonding "define service {"
2149 # in the default config, we have these definitions
2151 # 11 define command {
2152 # 2 define contact {
2153 # 1 define contactgroup {
2155 # 4 define hostgroup {
2156 # 23 define service {
2157 # 5 define timeperiod {
2162 # klaxon:/etc/nagios3 # grep -rho '^ *define [^{ ]*' | sort | uniq -c
2165 # 6 define contactgroup
2167 # 1 define hostextinfo
2168 # 16 define hostgroup
2169 # 3040 define service
2170 # 2 define servicedependency
2171 # 6 define timeperiod
2176 ### begin bitcoin ###
2181 sudo install -m 0755 -o root -g root -t /usr/bin /a/opt/bitcoin-23.0/bin/*
2183 sudo usermod -a -G bitcoin iank
2184 if [[ ! $(readlink -f /var/lib/bitcoind/wallets) == /q/wallets ]]; then
2185 sudo lnf /q/wallets /var/lib/bitcoind
2186 sudo chown -h bitcoin:bitcoin /var/lib/bitcoind/wallets
2188 # note, there exists
2189 # /a/bin/ds/disabled/bitcoin
2197 sd /etc/cups/client.conf <<'EOF'
2198 ServerName printserver0.office.fsf.org
2205 In mate settings settings, change scrolling to two-finger,
2206 because the default edge scroll doesn\'t work. Originally found this in debian.
2209 # Remove dep that came in with desktop to fix associations.
2210 m pu transmission-gtk
2214 lnf -T /d/vidshare /home/iank/Videos
2218 # # Based on guix manual instructions, also added code to profile.
2219 # # disabled since i'm not using it now.
2221 # if ! type -p guix >/dev/null; then
2223 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
2224 # # added some stuff to envonment.sh for profile based on
2225 # # manual instructions
2226 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
2227 # # echo is to get past prompt
2228 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
2229 # guix install glibc-utf8-locales
2230 # guix package --install guile
2236 m /a/bin/buildscripts/tor-browser
2237 # one root command needed to install
2238 s ln -sf /a/opt/tor-browser/Browser/start-tor-browser /usr/local/bin
2242 pi-nostart nfs-kernel-server
2244 # todo, this is old, probably needs removing
2245 if [[ $HOSTNAME == tp ]]; then
2246 sd /etc/wireguard/wg0.conf <<EOF
2248 PrivateKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.key)
2249 Address = 10.3.0.2/24, fdfd::2/64
2252 PresharedKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.psk)
2253 PublicKey = 9RnAsJB+ISrA/9lmDKBoT08oBiKwzA64exBBj+rO+ng=
2254 Endpoint = b8.nz:26000
2255 AllowedIPs = 10.3.0.1/24, fdfd::1/64
2256 PersistentKeepalive = 20
2258 sudo systemctl enable wg-quick@wg0
2259 sudo systemctl start wg-quick@wg0
2263 if [[ $HOSTNAME == kw ]]; then
2264 # hosts 1-199. 200+ are dynamic, avoid those
2265 tu /etc/exports <<'EOF'
2266 /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)
2267 /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)
2275 # if I was going to create a persistent vm, i might do it like this:
2276 # variant=something # from: virt-install --os-variant list
2277 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
2278 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
2279 # -n some_name --import --os-variant $variant --cpu host-model-only
2282 # for brother HL-2270DW, this worked:
2283 # https://askubuntu.com/questions/1067234/cant-use-wireless-brother-printer-2270dw-ubuntu-18-04
2284 # /a/opt/linux-brprinter-installer-2.2.2-1
2285 # answer n when it asks about uri.
2286 # Then go to cups, delete the existing printer, added on with dnssd url. browsed to
2287 # ppd at /usr/share/ppd/HL2270DW.ppd, which is duplicated at /usr/share/cups/model/HL2270DW.ppd
2288 # ppd file got installed from bash -x ./usr/local/Brother/Printer/HL2270DW/cupswrapper/cupswrap,
2289 # which I downloaded from their driver. but dont do that again, i copied it to /a/opt/HL2270DW.ppd,
2292 # 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.
2293 # Then it was already configured, but if i needed to, go to its web ui, default pass is "access".
2295 ######### begin stuff belonging at the end ##########