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 ################
97 # no equivalent in other distros:
98 if isdeb
&& pcheck apt-file
; then
99 # this condition is just a speed optimization
108 # allows me to pipe with ssh -t, and gets rid of spam
109 # http://forums.debian.net/viewtopic.php?f=5&t=85822
110 # i'd rather disable the service than comment the init file
111 # this says disabling the service, it will still get restarted
112 # but this script doesn't do anything on restart, so it should be fine
113 sudo truncate
-s0 /var
/run
/motd.dynamic
116 # this isn't a complete solution. It still shows me when updates are available,
117 # but it's no big deal.
118 sudo
rm -fv /etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
127 # dogcam setup. not using atm
130 # /a/bin/webcam/install-server
133 # /a/bin/webcam/install-client
138 ## not actually using prometheus just yet
139 # # office is not exposed to internet yet
140 # if [[ $HOSTNAME != kw ]]; then
141 # ## prometheus node exporter setup
142 # web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF'
143 # #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
144 # # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
148 # AuthName "Authentication Required"
149 # # setup one time, with root:www-data, 640
150 # AuthUserFile "/etc/prometheus-htpasswd"
160 ######### begin universal pinned packages ######
161 case $
(debian-codename
) in
162 etiona|flidas|nabia|aramo
)
163 sudo
rm -fv /etc
/apt
/preferences.d
/etiona-buster
164 sd
/etc
/apt
/preferences.d
/trisquel-debian
<<EOF
165 Explanation: Debian* includes Debian + Debian Backports
167 Pin: release o=Debian*
171 # needed for debootstrap scripts for fai since fai requires debian
174 #curl http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg | s apt-key add -
175 sd
/etc
/apt
/preferences.d
/flidas-xenial
<<EOF
177 Pin: release a=xenial
181 Pin: release a=xenial-updates
185 Pin: release a=xenial-security
189 Pin: release n=xenial
192 sd
/etc
/apt
/sources.list.d
/xenial.list
2>/dev
/null
<<EOF
193 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
194 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
195 deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
198 if ! apt-key list |
grep /C0B21F32
&>/dev
/null
; then
200 #sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
201 sd
/etc
/apt
/preferences.d
/flidas-bionic
<<EOF
203 Pin: release a=bionic
207 Pin: release a=bionic-updates
211 Pin: release a=bionic-security
216 # better to run btrfs-progs which matches our kernel version
217 # (note, renamed from btrfs-tools)
218 sd
/etc
/apt
/preferences.d
/btrfs-progs
<<EOF
219 Package: btrfs-progs libzstd1
220 Pin: release a=bionic
223 Package: btrfs-progs libzstd1
224 Pin: release a=bionic-updates
227 Package: btrfs-progs libzstd1
228 Pin: release a=bionic-security
235 deb http://us.archive.ubuntu.com/ubuntu/ bionic main
236 deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main
237 deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main
239 f
=/etc
/apt
/sources.list.d
/bionic.list
240 if ! diff -q $t $f; then
246 # no special reason, but its better for btrfs-progs to
247 # be closer to our kernel version
250 if [[ ! -e /usr
/share
/debootstrap
/scripts
/xenial
]]; then
253 m aptitude download debootstrap
/xenial
255 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
258 sd
/etc
/apt
/preferences.d
/flidas-etiona
<<EOF
260 Pin: release a=etiona
264 Pin: release a=etiona-updates
268 Pin: release a=etiona-security
272 Pin: release a=etiona-backports
278 deb http://mirror.fsf.org/trisquel/ etiona main
279 deb http://mirror.fsf.org/trisquel/ etiona-updates main
280 deb http://archive.trisquel.info/trisquel/ etiona-security main
281 deb http://mirror.fsf.org/trisquel/ etiona-backports main
283 f
=/etc
/apt
/sources.list.d
/etiona.list
284 if ! diff -q $t $f; then
290 sd
/etc
/apt
/preferences.d
/debian-goodies
<<EOF
291 Package: debian-goodies
292 Pin: release n=etiona
297 # dont use buster because it causes dist-upgrade to think its downgrading
298 # packages while really just reinstalling the same version.
299 f
=/etc
/apt
/apt.conf.d
/01iank
301 # # stupid buster uses some key algorithm not supported by flidas gpg that apt uses.
302 # sd /etc/apt/apt.conf.d/01iank <<'EOF'
303 # Acquire::AllowInsecureRepositories "true";
306 f
=/etc
/apt
/sources.list.d
/buster.list
309 # newer version needed for false positive in checkrestart.
310 # I did buster at first, but other problem above with having
311 # buster repos. not sure if the false positive exists in etiona.
314 sd
/etc
/apt
/preferences.d
/shellcheck
<<EOF
316 Pin: release a=etiona
320 Pin: release a=etiona-updates
324 Pin: release a=etiona-security
328 sd
/etc
/apt
/preferences.d
/bash
<<EOF
330 Pin: release a=etiona
334 Pin: release a=etiona-updates
338 Pin: release a=etiona-security
346 #p install --no-install-recommends minetest/buster libleveldb1d/buster libncursesw6/buster libtinfo6/buster
348 # shellcheck disable=SC2043 # in case we want more than 1 in the loop later.
349 for n
in bullseye
; do
350 f
=/etc
/apt
/sources.list.d
/$n.list
357 deb http://deb.debian.org/debian bullseye main
358 deb-src http://deb.debian.org/debian bullseye main
360 deb http://deb.debian.org/debian-security/ bullseye-security main
361 deb-src http://deb.debian.org/debian-security/ bullseye-security main
363 deb http://deb.debian.org/debian bullseye-updates main
364 deb-src http://deb.debian.org/debian bullseye-updates main
366 deb http://http.debian.net/debian bullseye-backports main
367 deb-src http://http.debian.net/debian bullseye-backports main
372 if ! diff -q $t $f; then
379 curl
-s https
://ftp-master.debian.org
/keys
/archive-key-10-security.asc | sudo apt-key add
-
380 curl
-s https
://ftp-master.debian.org
/keys
/archive-key-10.asc | sudo apt-key add
-
384 if [[ ! -e /usr
/share
/debootstrap
/scripts
/bullseye
]]; then
387 m aptitude download debootstrap
/bullseye
389 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
394 sd
/etc
/apt
/preferences.d
/focal
<<'EOF'
396 Pin: release n=focal,o=Ubuntu
400 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
401 Package: spamassassin sa-compile spamc
402 Pin: release n=focal,o=Ubuntu
405 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
406 Package: spamassassin sa-compile spamc
407 Pin: release n=focal,o=Ubuntu
410 sd
/etc
/apt
/preferences.d
/psd
<<'EOF'
411 Package: profile-sync-daemon
412 Pin: release n=focal,o=Ubuntu
416 f
=/etc
/apt
/sources.list.d
/focal.list
419 deb http://us.archive.ubuntu.com/ubuntu/ focal main universe
420 deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main universe
421 deb http://us.archive.ubuntu.com/ubuntu/ focal-security main universe
423 if ! diff -q $t $f; then
424 sudo
dd if=$t of
=$f status
=none
430 sd
/etc
/apt
/preferences.d
/nabia-etiona
<<'EOF'
432 Pin: release n=nabia*,o=Trisquel
436 f
=/etc
/apt
/sources.list.d
/nabia.list
439 deb http://mirror.fsf.org/trisquel/ nabia main
440 deb-src http://mirror.fsf.org/trisquel/ nabia main
442 deb http://mirror.fsf.org/trisquel/ nabia-updates main
443 deb-src http://mirror.fsf.org/trisquel/ nabia-updates main
445 deb http://archive.trisquel.info/trisquel/ nabia-security main
446 deb-src http://archive.trisquel.info/trisquel/ nabia-security main
448 # Uncomment this lines to enable the backports optional repository
449 deb http://mirror.fsf.org/trisquel/ nabia-backports main
450 deb-src http://mirror.fsf.org/trisquel/ nabia-backports main
452 if ! diff -q $t $f; then
453 sudo
dd if=$t of
=$f status
=none
457 # duplicated in fai. Pin for bionic + ubuntu so that ppas dont get
459 sd
/etc
/apt
/preferences.d
/etiona-bionic
<<'EOF'
461 Pin: release n=bionic,o=Ubuntu
464 Pin: release n=bionic,o=Ubuntu
468 sd
/etc
/apt
/preferences.d
/etiona-sa
<<'EOF'
470 Pin: release n=bionic,o=Ubuntu
476 sd
/etc
/apt
/preferences.d
/aramo-nabia
<<'EOF'
478 Pin: release n=aramo*,o=Trisquel
481 f
=/etc
/apt
/sources.list.d
/aramo.list
484 deb http://mirror.fsf.org/trisquel/ aramo main
485 deb-src http://mirror.fsf.org/trisquel/ aramo main
487 deb http://mirror.fsf.org/trisquel/ aramo-updates main
488 deb-src http://mirror.fsf.org/trisquel/ aramo-updates main
490 deb http://archive.trisquel.info/trisquel/ aramo-security main
491 deb-src http://archive.trisquel.info/trisquel/ aramo-security main
493 # Uncomment this lines to enable the backports optional repository
494 deb http://mirror.fsf.org/trisquel/ aramo-backports main
495 deb-src http://mirror.fsf.org/trisquel/ aramo-backports main
497 if ! diff -q $t $f; then
498 sudo
dd if=$t of
=$f status
=none
505 pi debian-goodies shellcheck
510 case $codename_compat in
512 s systemctl
enable --now ssh-agent-iank
516 case $codename_compat in
518 sd
/etc
/apt
/preferences.d
/nabia-btrfs-progs
<<'EOF'
520 Pin: release a=buster-backports
523 p
install btrfs-progs
528 # 2020-03-03 old file
529 s
rm -fv /etc
/apt
/preferences.d
/radicale
530 ######### end universal pinned packages ######
535 sd
/etc
/apt
/preferences.d
/obs
<<EOF
537 Pin: release n=bionic
540 sd
/etc
/apt
/preferences.d
/chromium
<<EOF
542 Pin: release n=bionic
547 # note, to get the latest, it would be n=bullseye*
548 # but that has conflicting package versions, so this does the old one.
549 # I only use it for special rare purposes. Just keep in mind it is an
550 # outdated insecure version.
551 sd
/etc
/apt
/preferences.d
/chromium-bullseye
<<EOF
552 Package: chromium chromium-* libicu67 libjpeg62-turbo libjsoncpp24 libre2-9 libwebpmux3
553 Pin: release o=Debian*,n=bullseye
558 # obs dependency not in trisquel
559 sd
/etc
/apt
/preferences.d
/obs
<<EOF
561 Pin: release n=jammy,o=Ubuntu
569 ##### begin automatic upgrades (after checkrestart has been installed) ####
570 # if apt-config-auto-update is installed,
571 # it also has similar config, in a file 10something,
572 # but i think his overrides it since its higher number.
573 # This file was part of the automatic-updates package,
574 # and it has a configu option to not get new package lists,
575 # which seems pretty stupid to me, you cant actually upgrade
576 # anything if you dont have the new package list.
577 sd
/etc
/apt
/apt.conf.d
/20auto-upgrades
<<'EOF'
578 APT::Periodic::Update-Package-Lists "1";
579 APT::Periodic::Download-Upgradeable-Packages "1";
580 APT::Periodic::AutocleanInterval "7";
581 APT::Periodic::Unattended-Upgrade "1";
584 # fyi: default file has comments about available options,
585 # you may want to read that, do pkx unattended-upgrades
586 # default is just security updates. this list found from reading
587 # match_whitelist_string() in $(which unattended-upgrades)
588 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
589 Unattended-Upgrade::Mail "root";
590 Unattended-Upgrade::MailOnlyOnError "true";
591 Unattended-Upgrade::Remove-Unused-Dependencies "true";
592 Unattended-Upgrade::Origins-Pattern {
593 "o=*,l=*,a=*,c=*,site=*,n=*";
598 sudo
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
/etc
/cron.d
/myupgrade
600 # myupgrade cron exists in /etc/cron.d/ian
602 ##### end automatic upgrades ####
605 # commented in case i want to use this sometime later
606 # sd /etc/apt/preferences.d/buster-backports <<EOF
608 # Pin: release a=buster-backports
613 ###### begin website setup
617 f
=/var
/lib
/bind
/db.b8.nz
618 if [[ ! -e $f ]]; then
622 s
/c
/roles
/prom_export
/files
/simple
/usr
/local
/bin
/fsf-install-node-exporter
-l 127.0.0.1
625 web-conf
-p 9101 -f 9100 - apache2
${HOSTNAME}ex.b8.nz
<<'EOF'
628 AuthName "basic_auth"
630 # htpasswd -c prometheus-export-htpasswd USERNAME
631 AuthUserFile "/etc/prometheus-export-htpasswd"
640 # i just dont feel like setting up a special purpose ssh key to do this automatically.
642 # run this once for bk on local machine:
643 # only used for old openvpn setup
644 /a/exe/vpn-mk-client-cert -c bk.b8.nz -b expertpath -n mail li.iankelling.org
653 m
/a
/h
/setup.sh iankelling.org
655 # start mumble only when im going to use it, since i dont use it much
656 pi-nostart mumble-server
657 sudo
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
659 # do certificate to avoid warning about unsigned cert,
660 # which is overkill for my use, but hey, I'm cool, I know
662 m web-conf apache2 mumble.iankelling.org
663 sudo
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
665 # general vpn for as needed use
666 vpn-server-setup
-d -r -4 10.5.5 -p 443 -n hole
668 # todo: consider if this should exist for the
670 teeu
/etc
/openvpn
/server
/hole.conf
<<'EOF'
676 files
=(/etc
/openvpn
/client-config-hole
/*)
677 if (( ${#files[@]} >= 1 )); then
681 for host in ${!vpn_ips[@]}; do
682 sd
/etc
/openvpn
/client-config-hole
/$host <<EOF
683 ifconfig-push 10.5.5.${vpn_ips[$host]} 255.255.255.0
688 # for adding cert to system with /p
691 #mkc /p/c/machine_specific/$host/filesystem/etc/openvpn/client
692 #vpn-mk-client-cert -b $host -n hole -r iankelling.org
693 #s chown -R iank:iank .
695 # example of adding to remote system 107,
696 # vpn-mk-client-cert -n hole -c 10.2.0.107 -b hd8 iankelling.org
698 # for wireguard hole vpn, use function:
702 # if it is going to want to connect to transmission-daemon on ok
703 # wghole bo 28 10.174.2.2/32
705 # requested from linode via a support ticket.
706 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
707 # ipv6 stuff pieced together
708 # via slightly wrong information from
709 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
710 # https://community.openvpn.net/openvpn/wiki/IPv6
713 # This uses a public /64, but afaik, that is not needed for my
714 # current use case, since I'm doing ipv6 nat, they could be private
715 # and nat to a public address. I'm doing ipv6 nat in order to have 2
716 # vpn clients that externally share the same ip when sending so they
717 # share ip reputation. Note, the eth0 and tunx needed to be
718 # different subnets. On the same, I saw some neighbor packet go
719 # unanswered, tcpdump showed packets getting lost. I tried splitting the
720 # /64, it didn't work but I didn't investigate closely.
723 # not starting as i intend to replace it
724 m vpn-server-setup
-s -i tunmail
-n mail -d -6 2600:3c00
:e002
:3800::/64 2600:3c00
:e002
:3800::1/64
725 sudo
tee /etc
/openvpn
/client-config-mail
/mailclient
<<'EOF'
726 ifconfig-push 10.8.0.4 255.255.255.0
727 ifconfig-ipv6-push 2600:3c00:e002:3800::4/64
729 sudo
tee /etc
/openvpn
/client-config-mail
/expertpath
<<'EOF'
730 ifconfig-push 10.8.0.5 255.255.255.0
731 ifconfig-ipv6-push 2600:3c00:e002:3800::5/64
735 sudo
dd of
=/etc
/systemd
/system
/vpn-mail-forward.service
<<'EOF'
737 Description=Turns on iptables mail nat
738 BindsTo=openvpn-server@mail.service
743 ExecStart=/a/bin/distro-setup/vpn-mail-forward tunmail start
744 ExecStop=/a/bin/distro-setup/vpn-mail-forward tunmail stop
747 RequiredBy=openvpn-server@mail.service
752 # needed for li's local mail delivery.
753 tu
/etc
/hosts
<<<"10.8.0.4 mx.iankelling.org"
755 # wgmail handles this.
756 #sgo vpn-mail-forward.service
758 #sgo openvpn-server@mail
761 # setup let's encrypt cert
762 m web-conf apache2 mail.iankelling.org
763 # TODO, i expanded the above cert manually to mx.iankelling.org, this should be captured
764 # in the automation here. We use mail.iankelling.org as our ehlo name when sending mail
765 # but our mx record is mx.iankelling.org. Initially I was just using mail.iankelling.org,
766 # but the problem is I want multiple ips to be able to identify as mail.iankelling.org,
767 # but a subset to be mx.iankelling.org. Afaik, there is no problem with having
768 # our mail cert be for mail.iankelling.org, and have people connect to mx.ian...,
769 # but it doesn't make logical sense to do this.
770 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
773 a2enmod -q proxy proxy_http
774 domain=cal.iankelling.org
775 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
776 # https://radicale.org/2.1.html
777 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
778 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
780 # this doesn't exactly fit with the documentation.
781 # We need location / to do an auth, it cant be done outside,
782 # in order to pass on X-Remote-User. And we need
783 # the other location in order to remove the /radicale/ for
784 # requests which have it. This could be done with a rewrite,
785 # but i just get something working and call it a day.
790 AuthName "Authentication Required"
791 # setup one time, with root:www-data, 640
792 AuthUserFile "/etc/caldav-htpasswd"
794 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
796 <Location "/radicale/">
797 Options +FollowSymLinks +Multiviews -Indexes
798 RequestHeader set X-Script-Name /radicale/
799 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
800 ProxyPass "http://10.8.0.4:5232/" retry=0
801 ProxyPassReverse "http://10.8.0.4:5232/"
804 # nginx version of above would be:
805 # auth_basic "Not currently available";
806 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
810 ###### begin znc setup #####
813 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
814 # to get into the web interface,
815 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
816 # https://iankelling.org:12533/
817 # login as ian, pass is in pass store, the part after :
819 # znc config generated by doing
821 # selected port is also used in erc config
822 # comma separated channel list worked.
823 # while figuring things out, running znc -D for debug in foreground.
824 # to exit and save config:
825 # /msg *status shutdown
826 # configed auth on freenode by following
827 # https://wiki.znc.in/Sasl:
831 # Set MyNickservName pa$$w0rd
832 # created the system service after, and had to do
833 # mv /home/iank/.znc/* /var/lib/znc
834 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
835 # and made a copy of the config files into /p/c
836 # /msg *status LoadMod --type=global log -sanitize
837 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
838 # /msg *status LoadMod --type=network perform
839 # /query *perform add PRIVMSG ChanServ :invite #fsf-office
840 # /msg *perform add JOIN #fsf-office
841 # /msg *status LoadMod NickServ
844 # also ran /znc LoadMod clearbufferonmsg
845 # it would be nice if erc supported erc query buffers by doing
846 # /msg *status clearbuffer <name of the query/receiver
848 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
849 # if that was the case i could remove the module clearbufferonmsg
850 # also would be nice if erc supported
851 # https://wiki.znc.in/self-message
852 # https://wiki.znc.in/Query_buffers \
854 # for geekshed, there was no sasl support as far as I can tell,
855 # so I set to msg nickserv to identify upon connect.
856 if ! getent passwd znc > /dev/null; then
857 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
859 sudo chmod 700 /var/lib/znc
860 sudo chown -R znc:znc /var/lib/znc
861 # Avoid restarting if possible, reconnecting to irc is annoying.
862 # The unit file was made active with conflink.
863 # Note, avoid using ser here because we wrap sudo to prints the command first.
864 if [[ $(systemctl is-active znc) != active ]]; then
867 ###### stop znc setup #####
876 # todo, save the config
877 /etc/cron.daily/stream-cert
878 web-conf -c /etc/cert-live.fsf.org -p 443 -f 8000 apache2 live.fsf.org
882 ###### end website setup
884 ########### end section including li/lj ###############
889 ### system76 things ###
891 bo) # sy| sy doesnt seem to really need this.
892 # note, i stored the initial popos packages at /a/bin/data/popos-pkgs
893 if [[ ! -e /etc/apt/sources.list.d/system76.list ]]; then
894 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
895 sd /etc/apt/sources.list.d/system76.list <<EOF
896 deb http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
897 deb-src http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
899 # ubuntu keyserver is prone to intermittent failures
900 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5D1F3A80254F6AFBA254FED5ACD442D1C8B7748B
902 # https://support.system76.com/articles/install-ubuntu/
903 # but i'm hoping this is not needed
904 # sd /etc/apt/preferences.d/system76 <<'EOF'
906 # Pin: release o=LP-PPA-system76-dev-stable
910 # TODO: I had to uninstall linux-image-generic-hwe-20.04 because of a conflict
911 # about linux-firmware. Should probably install it to begin with in fai if
913 pi system76-driver system76-firmware
914 # if you get a notice about a firmware update, the notifier on i3
915 # is too dumb to do anything when you click it. so to see
917 # /var/cache/system76-firmware-daemon
918 # extract the xz files there, one will contain a changelog.
919 # then to install an update:
920 # s system76-firmware-cli schedule
924 ### end system76 things ###
929 # ppa:obsproject/obs-studio
930 if [[ ! -s /etc/apt/sources.list.d/obs.list ]]; then
931 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
932 sd /etc/apt/sources.list.d/obs.list <<EOF
933 deb http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
934 deb-src http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
936 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BC7345F522079769F5BBE987EFC71127F425E228
942 case $codename_compat in
944 # mate-indicator-applet and beyond are msc things I noticed diffing a
945 # standard install with mine.
946 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
952 # todo: figure out mate for buster
953 # pi task-gnome-desktop
956 # i had installing mate-indicator-applet, but im not sure why so i removed
957 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras anacron
960 # # apt-get update periodically fails with an appstream error.
961 # # this removes gnome-core, but its just a package for dependencies
962 # p -y remove appstream
965 # by default, it sleeps when not logged in to x/wayland and on ac power.
967 if id -u gdm &>/dev/null; then
968 sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
972 # lightdm startup fails without this. on etiona, we got unity-greeter installed automatically,
973 # it would probably work on nabia too, but google just lead me to this and it works fine.
974 pi lightdm-gtk-greeter
975 # ok, this is really weird
976 # normally this file has
977 sd /etc/X11/Xsession.d/99x11-common_start <<'EOF'
979 # this file normally just has: exec $STARTUP
980 # but then ~/.xsession-errors
981 # says $STARTUP is not found, which appears to be the real
982 # error, but normal bash doesnt operate that way.
983 # https://bugs.launchpad.net/ubuntu/+source/im-config/+bug/1879352
986 # also, gdm wayland was default, had to do
987 # dpkg-reconfigure gdm3
988 # and choose lightdm.
992 # not yet bothering with mate
993 pi lightdm-gtk-greeter lightdm
998 if [[ $codename_compat == flidas ]]; then
999 # doesnt exist in newer
1008 # firefox would work here too, apt would select abrowser.
1009 # and the update-alternatives thing i think is becuz firefox is
1010 # generally available before abrowser and this helps fix things
1011 # up when we have both.
1013 s update-alternatives --set x-www-browser /usr/bin/abrowser
1025 # newer distros just use adb for package name it seems
1026 case $codename_compat in
1028 pi android-tools-adbd
1032 case $codename_compat in
1034 pi libext2fs-dev libzstd-dev
1035 cd /a/opt/btrfs-progs
1040 case $codename_compat in
1049 # not packaged in newer distros it seems
1050 case $codename_compat in
1051 bionic|buster|stretch)
1057 # TODO: some of the X programs can be removed from pall when using wayland
1059 # depends gcc is a way to install suggests. this is apparently the only
1060 # way to install suggests even if the main package is already
1061 # installed. reinstall doesn't work, uninstalling can cause removing
1062 # dependent packages.
1063 # shellcheck disable=SC2046 # word splitting is intended
1064 pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $($src/distro-pkgs)
1066 # schroot service will restart schroot sessions after reboot.
1070 # fix systemd unit failure. i dont know of any actual impact
1071 # other than systemd showing in degraded state. So, we dont bother
1072 # fixing the current state, let it fix on the next reboot.
1073 # https://gitlab.com/cjwatson/binfmt-support/-/commit/54f0e1af8a
1074 tmp=$(systemctl cat binfmt-support.service | grep ^After=)
1075 if [[ $tmp != *systemd-binfmt.service* ]]; then
1076 s u /etc/systemd/system/binfmt-support.service.d/override.conf <<EOF
1078 $tmp systemd-binfmt.service
1083 # commented, not worth the hassle i think.
1089 sudo rm -fv /etc/systemd/resolved.conf.d/iank.conf
1091 # website is dead june 14 2019. back in october, but meh
1092 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
1097 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
1100 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
1101 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
1103 # f=/etc/apt/sources.list.d/iridium-browser.list
1104 # if ! diff -q $t $f; then
1109 # pi iridium-browser
1115 if mountpoint /p &>/dev/null; then
1116 # note, see bashrc for more documentation.
1118 sd /etc/systemd/system/rss2email.service <<'EOF'
1120 Description=rss2email
1121 After=multi-user.target
1126 # about 24 hours of failures
1127 # it copies over its files without respecting symlinks, so
1128 # we pass options to use different location.
1129 ExecStart=/usr/local/bin/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
1131 sd /etc/systemd/system/rss2email.timer <<'EOF'
1133 Description=rss2email
1136 # for initial run. required.
1138 # for subsequent runs.
1139 OnUnitInactiveSec=300
1142 WantedBy=timers.target
1144 sudo systemctl daemon-reload
1148 ######### begin irc periodic backup #############
1149 if [[ $HOSTNAME == frodo ]]; then
1150 sd /etc/systemd/system/ircbackup.service <<'EOF'
1152 Description=irc li backup
1153 After=multi-user.target
1158 ExecStart=/usr/local/bin/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
1160 sd /etc/systemd/system/ircbackup.timer <<'EOF'
1162 Description=irc li backup hourly
1168 WantedBy=timers.target
1170 sudo systemctl daemon-reload
1175 ######### end irc periodic backup #############
1179 # pi-nostart does not disable
1183 if [[ -e /p/c/gen-fsf-vpn ]]; then
1187 if [[ -e /p/c/machine_specific/$HOSTNAME/filesystem/etc/openvpn/client/hole.crt ]]; then
1188 sgo openvpn-client@hole
1191 ############# begin syncthing setup ###########
1194 f=/usr/share/keyrings/syncthing-archive-keyring.gpg
1195 if [[ ! -e $f ]]; then
1196 s curl -s -o $f https://syncthing.net/release-key.gpg
1198 s="deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable"
1199 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
1200 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
1206 m lnf -T /w/syncthing /home/iank/.config/syncthing
1207 ser daemon-reload # syncthing likely not properly packaged
1208 sgo syncthing@iank # runs as iank
1212 # 1003 just happens to be what was on my system
1213 if ! getent passwd ziva; then
1214 s groupadd -g 1003 ziva
1215 # syncthing state / config / db are all in ~/.config/syncthing
1216 s useradd -g 1003 -u 1003 -d /d/ziva-home -c ziva -s /bin/bash ziva
1222 # user for short term use dropping of privileges
1224 if ! getent group zu &>/dev/null; then
1225 s groupadd -g 1023 zu
1227 if ! getent passwd zu &>/dev/null; then
1228 s useradd -g 1023 -u 1023 -c zu -s /bin/bash zu
1232 # these things persist in ~/.config/syncthing, which I save in
1233 # /w/syncthing (not in /p, because syncthing should continue to
1234 # run on home server even when using laptop as primary device)
1235 # open http://localhost:8384/
1236 # change listen address from default to tcp://:22001,
1237 # this is because we do port forward so it doesn\'t have to use
1238 # some external server, but the syncthing is broken for port forward,
1239 # you get a message, something "like connected to myself, this should not happen"
1240 # when connecting to other local devices, so I bump the port up by 1,
1242 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
1243 # Without this, it was being stuck syncing at 0%.
1244 # Set gui username and password.
1246 # install syncthing via f-droid,
1247 # folder setting, turn off send only.
1248 # on phone, add device, click bar code icon
1249 # on dekstop, top right, actions, device id
1250 # after adding, notification will appear on desktop to confirm
1252 # syncing folder. from phone to desktop: select desktop in the
1253 # folder on phone\'s sync options, notification will appear in
1254 # desktop\'s web ui within a minute. For the reverse, the
1255 # notification will appear in android\'s notifications, you have to
1256 # swipe down and tap it to add the folder. It won\'t appear in the
1257 # syncthing ui, which would be intuitive, but don\'t wait for it
1258 # there. The notification may not work, instead open the web gui
1259 # from in the app, there should be a notification within there.
1261 # On phone, set settings to run syncthing all the time, and
1262 # show no notification.
1264 # Folder versioning would make sense if I didn\'t already use btrfs
1265 # for backups. I would choose staggered, or trash can for more space.
1267 # if needed to install on a remote comp:
1268 # ssh -L 8384:localhost:8384 -N frodo
1269 # open http://localhost:8384/
1271 # Note, the other thing i did was port forward port 22000,
1272 # per https://docs.syncthing.net/users/firewall.html
1274 ############# end syncthing setup ###########
1278 ####### begin misc packages ###########
1282 ln -sfT /d/p/profanity ~/.local/share/profanity
1283 ln -sfT /d/p/profanity-config ~/.config/profanity
1284 source /a/bin/bash_unpublished/source-state
1285 if [[ $HOSTNAME == "$HOST2" ]]; then
1286 systemctl --now enable profanity
1291 ln -sfT /p/profanity ~/.local/share/profanity
1292 ln -sfT /p/profanity-config ~/.config/profanity
1303 sudo update-alternatives --set pinentry /usr/bin/pinentry-gtk-2
1306 # sakura config is owned by ian
1309 m sudo -u user2 -i reset-konsole
1310 # user2 xscreensaver we don't want to reset
1311 m reset-xscreensaver
1314 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
1315 # this is also in primary-setup
1316 # pi libxss-dev # dependency based on build failure
1318 # cabal install --upgrade-dependencies --force-reinstalls arbtt
1319 # also, i assume syncing this between machines somehow messed up the data.
1321 ## not using arbtt for now
1322 # if mountpoint /p &>/dev/null; then
1326 # # same as seru enable arbtt, but works over ssh when systemctl --user causes error:
1327 # # Failed to connect to bus: No such file or directory
1328 # lnf -T /a/bin/ds/subdir_files/.config/systemd/user/arbtt.service /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1330 # seru start arbtt ||:
1334 rm -fv /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1339 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
1340 m cp /p/.linphonerc-initial ~/.linphonerc
1343 # linphone in t10 wont do dns with systemd-resolved or something
1344 s teeu /etc/hosts <<'EOF'
1345 74.94.156.215 watson.fsf.org
1350 ### begin spd install
1351 if mountpoint /p &>/dev/null; then
1352 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
1354 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
1357 # this guesses at the appropriate directory, adjust if needed
1358 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
1359 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
1360 # newer distro had gpg2 as default, older one, flidas, need to make it that way
1361 gpgpath=$(which gpg2) ||:
1362 if [[ $gpgpath ]]; then
1363 sudo mkdir -p /usr/local/spdhackfix
1364 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
1370 # nagstamon setting which were set through the ui
1371 # monitor url https://klaxon.fsf.org/cgi-bin
1372 # monitor url cgi https://klaxon.fsf.org/cgi-bin
1374 # all unknown services
1375 # all warning services
1376 # acknowledged hosts & services
1377 # hosts & services down for maintenence
1378 # services on down hosts
1379 # services on hosts in maintenece
1380 # services on unreachable osts
1381 # hosts in soft state
1382 # services in soft state
1383 # in display tab: fullscreen
1385 # these translate to these settings I think
1386 # filter_acknowledged_hosts_services = True
1387 # filter_all_unknown_services = True
1388 # filter_all_warning_services = True
1389 # filter_hosts_in_soft_state = True
1390 # filter_hosts_services_maintenance = True
1391 # filter_services_in_soft_state = True
1392 # filter_services_on_down_hosts = True
1393 # filter_services_on_hosts_in_maintenance = True
1394 # filter_services_on_unreachable_hosts = True
1395 # notify_if_up = False
1396 # statusbar_floating = False
1398 # but i'm just going to rely on the webpage plus sms for now.
1401 # it asks if it should make users in it's group capture packets without root,
1402 # which is arguably more secure than running wireshark as root. default is no,
1403 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
1404 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
1406 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
1407 # listed in the default config as suggested.
1408 # /run/usr/1000 i noticed was missing for pulseaudio
1409 # /run/user/0 just seemed like a not bad idea, given the above
1410 tu /etc/schroot/desktop/fstab <<'EOF'
1411 /p /p none rw,bind 0 0
1412 /a /a none rw,bind 0 0
1413 /run /run none rw,bind 0 0
1414 /run/lock /run/lock none rw,bind 0 0
1415 /dev/shm /dev/shm none rw,bind 0 0
1416 /run/shm /run/shm none rw,bind 0 0
1417 /run/user/1000 /run/user/1000 none rw,bind 0 0
1418 /run/user/1001 /run/user/1001 none rw,bind 0 0
1419 /run/user/0 /run/user/0 none rw,bind 0 0
1422 # todo: consider if this should use the new sysd-prom-fail
1423 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1425 Description=schrootupdate
1426 After=multi-user.target
1430 ExecStart=/usr/local/bin/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1432 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1434 Description=schrootupdate
1437 OnCalendar=*-*-* 04:20:00 America/New_York
1440 WantedBy=timers.target
1443 sgo schrootupdate.timer
1450 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/bullseye.list/BULLSEYE_FREE \
1451 debian bullseye firefox-esr pulseaudio chromium anki
1452 case $(debian-codename) in
1454 # we have a lot of t8 stuff, useful to have
1455 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/flidas.list/FLIDAS \
1457 tu /nocow/schroot/flidas/etc/sudoers <<EOF
1458 $USER ALL=(ALL) NOPASSWD: ALL
1459 Defaults env_keep += SUDOD
1460 Defaults always_set_home
1463 sd /nocow/schroot/flidas//etc/locale.gen <<'EOF'
1466 s schroot -c flidas locale-gen
1467 s schroot -c flidas update-locale LANG=en_US.UTF-8
1469 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/testing.list/TESTING_NONFREE debian unstable debootstrap
1470 sudo cp -a /nocow/schroot/unstable/usr/share/debootstrap/scripts/* /usr/share/debootstrap/scripts
1472 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/impish.list/IMPISH ubuntu impish
1482 sudo mkdir -p /nocow/user
1483 sudo chown $USER:$USER /nocow/user
1487 ####### begin transmission
1497 tdir=/nocow/user/tor
1503 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1504 # 450 seems likely to be unused. we need to specify one or else
1505 # it won't be stable across installs.
1506 if ! getent passwd debian-transmission > /dev/null; then
1507 sudo groupadd -g 450 debian-transmission
1508 sudo adduser --quiet \
1513 --disabled-password \
1514 --home /var/lib/transmission-daemon \
1517 # We want group writable stuff from transmission.
1518 # However, after setting this, I learn that transmission sets it's
1519 # own umask based on it's settings file. Well, no harm leaving this
1520 # so it's set right from the beginning.
1521 sudo chfn debian-transmission -o umask=0002
1523 # note i had to do this, which is persistent:
1525 # s chgrp debian-transmission torrents partial-torrents
1527 # syslog says things like
1528 # 'Failed to set receive buffer: requested 4194304, got 425984'
1529 # google suggets giving it even more than that
1530 tu /etc/sysctl.conf<<'EOF'
1531 net.core.rmem_max = 67108864
1532 net.core.wmem_max = 16777216
1536 # some reason it doesn\'t seem to start automatically anyways
1537 pi-nostart transmission-daemon
1538 # be extra sure its not started
1539 ser disable transmission-daemon
1540 ser stop transmission-daemon
1542 # the folder was moved here after an install around 02/2017.
1543 # it contains runtime data,
1544 # plus a simple symlink to the config file which it\'s
1545 # not worth separating out.
1546 # between comps, the uid can change
1548 f=$tdir/transmission-daemon
1549 for d in $tdir/partial-torrents $tdir/torrents $f; do
1550 if [[ ! -d $d ]]; then
1553 sudo chown -R debian-transmission:user2 $d
1555 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1556 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1557 sudo chown -R debian-transmission:debian-transmission $f
1558 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1560 # config file documented here, and it\'s the same config
1561 # for daemon vs client, so it\'s documented in the gui.
1562 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1564 # I originaly setup rpc-whitelist, but after using
1565 # routing to a network namespace, it doesn\'t see the
1566 # real source address, so it\'s disabled.
1568 # Changed the cache-size to 256 mb, reduces disk use.
1569 # It is a read & write cache.
1571 # just fyi: default rpc port is 9091
1572 if ! systemctl is-active transmission-daemon-nn &>/dev/null && \
1573 ! systemctl is-active transmission-daemon; then
1575 command sudo ruby <<EOF >$tmp
1577 p = '/etc/transmission-daemon/settings.json'
1579 'rpc-whitelist-enabled' => false,
1580 'rpc-authentication-required' => false,
1581 'incomplete-dir' => '$tdir/partial-torrents',
1582 'incomplete-dir-enabled' => true,
1583 'download-dir' => '$tdir/torrents',
1584 "speed-limit-up" => 800,
1585 "speed-limit-up-enabled" => true,
1586 "peer-port" => 61486,
1587 "cache-size-mb" => 256,
1588 "ratio-limit" => 5.0,
1589 "ratio-limit-enabled" => false,
1591 puts(JSON.pretty_generate(JSON.parse(File.read(p)).merge(s)))
1593 cat $tmp | sudo dd of=/etc/transmission-daemon/settings.json
1597 ####### end transmission
1601 # to persist upload/dl metadata. initially, moved all the stuff
1602 # in /var/lib/transmission-daemon to /d/tor
1603 s usermod --home /d/tor debian-transmission
1604 sgo transmission-daemon-nn
1610 ######### begin transmission client setup ######
1612 # to connect from a remote client, trans-remote-route in brc2
1615 if [[ -e /p/transmission-rpc-pass ]]; then
1616 # arch had a default config,
1617 # debian had nothing until you start it.
1618 # With a little trial an error, here is a minimal config
1619 # taken from the generated one, plus changes that the
1620 # settings ui does, without a bunch of ui crap settings.
1622 # only settings I set were
1627 # the password is randomly generated on first run, i copied it out
1628 # so it could be used by other hosts.
1631 p = '/etc/transmission-daemon/settings.json'
1632 s = JSON.parse(File.read(p))
1633 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1634 # default is 0022 (18 in decimal)
1636 File.write p, JSON.pretty_generate(s)
1639 rpc_pass=$(</p/transmission-rpc-pass)
1640 for f in /home/*; do
1642 uid=$(id -u $u 2>/dev/null) || continue
1643 if [[ ! $uid -ge 1000 ]]; then
1646 d=$f/.config/transmission-remote-gtk
1647 sudo -u $u mkdir -p $d
1648 # i tried setting hostname to transmission.b8.nz, so i could dynamically change where
1649 # this connects to, but it said some 421 denied error when I did that. Then it
1650 # froze X when i ran it under strace. Whatever.
1651 sudo -u $u dd of=$d/config.json <<EOF
1655 "profile-name" : "Default",
1656 "hostname" : "10.174.2.2",
1657 "rpc-url-path" : "/transmission/rpc",
1659 "password" : "$rpc_pass",
1660 "auto-connect" : true,
1664 "update-active-only" : false,
1665 "activeonly-fullsync-enabled" : false,
1666 "activeonly-fullsync-every" : 2,
1667 "update-interval" : 3,
1668 "min-update-interval" : 3,
1669 "session-update-interval" : 60,
1670 "exec-commands" : [],
1675 "add-options-dialog" : false
1680 ######### end transmission client setup ######
1686 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1687 # goto http://127.0.0.1:631
1688 # administration tab, add new printer button.
1689 # In debian, I could use hte recommended driver,
1690 # in arch, I had to pick out the 6L driver.
1693 # bridge networking as user fails. google lead here, but it doesn\'t work:
1694 # oh well, I give up.
1695 # http://wiki.qemu.org/Features-Done/HelperNetworking
1697 # f=/etc/qemu/bridge.conf
1701 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1704 # general known for debian/ubuntu, not for fedora
1706 m /a/bin/buildscripts/go
1707 # only needed for rg. cargo takes up 11 gigs, filled up the disk on je.
1708 m /a/bin/buildscripts/rust
1709 m /a/bin/buildscripts/misc
1710 m /a/bin/buildscripts/pithosfly
1711 #m /a/bin/buildscripts/alacritty
1712 #m /a/bin/buildscripts/kitty
1714 pi-nostart virtinst virt-manager
1716 # i cant if this is whats causing it to start even though
1717 # its disabled. note: it leaves around dnsmasq instances even
1718 # if you stop it. what the hell systemd?
1720 # allow user to run vms, from debian handbook. libvirt-qemu
1721 # based on https://www.whonix.org/wiki/KVM#First-time_User.3F
1722 for x in iank user2; do s usermod -a -G libvirt,kvm,libvirt-qemu $x; done
1725 pi --no-install-recommends kdeconnect
1726 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1727 ### but gnome + xmonad not working in flidas, so i disabled it
1728 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1729 # cd /a/opt/indicator-kdeconnect
1732 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1735 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1736 # # it seems, according to
1737 # # /etc/xdg/autostart/kdeconnectd.desktop
1738 # # I'm not seeing the icon, but the clipboard replication is working
1741 ### begin model 01 arduino support ###
1742 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1743 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1744 # set arduino var in bashrc,
1745 # have system config file setup too.
1746 sudo adduser $USER dialout
1749 # download arduino ide, extract in /a/opt, ignore the install script, run ./arduino,
1750 # toolbar, preferences, add board manager url:
1751 # https://raw.githubusercontent.com/keyboardio/boardsmanager/master/package_keyboardio_index.json
1752 # toolbar, board manager, add keyboardio
1753 # toolbar, select model01 board
1754 # toolbar, examples, model01, compile
1758 # this is for the mail command too. update-alternatives is kind of misleading
1759 # since at least it's main commands pretend mail does not exist.
1760 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1761 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1763 ######### end misc packages #########
1766 # packages I once used before and liked, but don\'t want installed now for
1768 # python-sqlite is used for offlineimap
1769 # lxappearance python-sqlite dolphin paman dconf-editor
1775 # todo, finish configuring smart.
1778 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1779 # turn on smart. background on options:
1780 # first line, -a = test everyting on all devices.
1781 # -S on, turn on disk internal saving of vendor specific info,
1782 # from google, seems like this is usually already on and fairly standard.
1783 # -o on, turn on 4 hour period non-performance degrading testing.
1784 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1785 sched="-s (S/../.././02|L/../../6/03)"
1786 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1787 DEVICESCAN -a -o on -S on -n standby,q $sched \
1788 -m root@mail.iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1790 # in the default configuration of at least ubuntu 14.04, resolvconf is
1791 # configured to order any nameservers associated with tun* or tap*
1792 # before the normal internet interfaces, which means they are always
1793 # consulted first. This is often slower and undesirable, ie. local dns
1794 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1796 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1797 # however, this breaks dns lookup for hosts on the openvpn lan.
1798 # I can\'t figure out why hosts on the normal lan would not be
1799 # broken under the default ordering, except the host I was
1800 # testing with previously had an entry in /etc/hosts.
1802 ############# end unfinished
1804 ########### misc stuff
1806 # pressing tab after sdf here:
1807 # scp sdfbash: set +o noglob: command not found
1808 # in t11, bash 5.1.16. this fixes it.
1809 sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
1811 rm -fv /home/iank/.mpv/watch_later
1812 rm -rf /home/iank/.mpv
1814 if [[ ! -e ~/.local/bin/pip ]]; then
1816 wget -O$tmp https://bootstrap.pypa.io/get-pip.py
1822 # soo, apt install beets fails due to wanting a pip package,
1823 # we find out why it wants this through
1824 # apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances beets | less
1825 # python-mediafile requires tox, which requires virtualenv, which requires pip.
1826 # but, python-mediafile doesn't really require tox, it is specified in
1827 # ./usr/lib/python3/dist-packages/mediafile-0.9.0.dist-info/METADATA
1828 # as being required only for testing, but the debian package
1829 # included it anyways, due to a mistake or bad tooling or something.
1830 # I don't plan to use tox, so, according to https://serverfault.com/a/251091,
1831 # we can create and install a dummy package by:
1833 # "equivs-control <name>, edit the file produced to provide the right
1834 # dependency and have a nice name, then run equivs-build <name> and
1835 # finally dpkg -i the resulting .deb file"
1836 # as of 2023-02, the tox dependency was removed in debian unstable, so
1837 # this hack will probably go away in t12.
1839 if pcheck beets; then
1840 tmpdir="$(mktemp -d)"
1842 # edited from output of equivs-control tox
1846 Standards-Version: 3.9.2
1848 Description: tox-dummy
1851 sudo dpkg -i tox_1.0_all.deb
1853 pi beets python3-discogs-client
1858 # get rid of annoying message
1859 s sed -ri "s/^([[:space:]]*ui.print_\('Playing)/#\1/" /usr/share/beets/beetsplug/play.py
1862 # notes about barrier
1863 # run barrier, do the gui config,
1864 # setup the 2 screens, using hostnames for the new screen.
1865 # save the server config
1866 # $HOME/.local/share/barrier/.barrier.conf
1869 # ssl errors, resolved via advice here: https://github.com/debauchee/barrier/issues/231
1870 # BARRIER_SSL_PATH=~/.local/share/barrier/SSL/
1871 # mkdir -p "${BARRIER_SSL_PATH}"
1872 # openssl req -x509 -nodes -days 365 -subj /CN=Barrier -newkey rsa:4096 -keyout ${BARRIER_SSL_PATH}/Barrier.pem -out ${BARRIER_SSL_PATH}/Barrier.pem
1873 # ran on both machines.
1874 # When pressing start in the gui, the cli options used are printed to the console,
1875 # they are useful. So on server, just run barriers, client run barrierc SERVER_IP
1877 ### begin timetrap setup
1878 if mountpoint /p &>/dev/null; then
1879 mkdir -p ~/.timetrap/
1880 ln -sf /a/opt/timetrap_formatters ~/.timetrap/formatters
1881 if ! type -p t &>/dev/null; then
1882 pi ruby-dev libsqlite3-dev
1883 gem install --user timetrap
1886 ### end timetrap setup
1888 # leftover cleanup for t9
1892 # needed for debootstrap scripts for fai since fai requires debian
1895 pi-nostart network-manager
1896 # i hate networkmanager. noo, of course disabling it doesnt work
1897 # unless you add a hack. found this by doing
1898 # systemd-analyze dot > x.dot
1902 soff NetworkManager-wait-online.service
1903 # make networkmanager use resolvconf instead of its own dnsmasq which
1904 # conflicts with the normal dnsmasq package.
1905 f=/etc/NetworkManager/NetworkManager.conf
1907 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1908 sudo sed -ri '/ *\[main\]/a dns=default' $f
1909 if [[ $m != $(md5sum $f) ]]; then
1910 srestart NetworkManager
1912 # networkmanager has this nasty behavior on flidas: if the machine
1913 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1914 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1916 # This can be manually fixed by stoping dnsmasq,
1917 # then based on whats in /run/dnsmasq/, i see we can run
1918 # s resolvconf -d NetworkManager
1919 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1920 ser disable NetworkManager
1924 # I have no use for avahi,
1925 # had to run this twice when doing manually, i dunno why
1926 soff avahi-daemon ||:
1930 # make my /etc/fonts/conf.d/ get used.
1931 # I have a new sans-serif font there because the default one
1932 # displays l and I as the same char, grrrrr.
1935 pi desktop-file-utils
1936 m /a/bin/distro-setup/mymimes
1938 if type -p dbus-launch >/dev/null; then
1939 # stop autopoping windows when i plug in an android phone.
1940 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1941 # with still 0 exit code.
1942 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1943 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1946 # on grub upgrade, we get prompts unless we do this
1948 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1949 devs+=("$(devbyid $dev),")
1951 devs[-1]=${devs[-1]%,} # jonied by commas
1952 sudo debconf-set-selections <<EOF
1953 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1957 sysd-prom-fail-install dynamicipupdate
1958 sysd-prom-fail-install systemstatus
1959 sysd-prom-fail-install btrfsmaintstop
1960 sgo btrfsmaint.timer
1966 if grep -xFq $HOSTNAME /a/bin/ds/machine_specific/btrbk.hosts; then
1970 # note: to see when a timer was last run,
1974 ### begin prometheus ###
1978 # Font awesome is needed for the alertmanager ui.
1979 pi prometheus-alertmanager prometheus fonts-font-awesome
1980 /c/roles/prom/files/simple/usr/local/bin/fsf-install-prometheus
1981 # make it available for other machines
1982 rsync -a /usr/local/bin/amtool /a/opt/bin
1983 web-conf -p 9091 -f 9090 - apache2 i.b8.nz <<'EOF'
1986 AuthName "basic_auth"
1988 # htpasswd -c prometheus-htpasswd USERNAME
1989 AuthUserFile "/etc/prometheus-htpasswd"
1994 web-conf -p 9094 -f 9093 - apache2 i.b8.nz <<'EOF'
1997 AuthName "basic_auth"
1999 # htpasswd -c prometheus-htpasswd USERNAME
2000 AuthUserFile "/etc/prometheus-htpasswd"
2005 # by default, the alertmanager web ui is not enabled other than a page
2006 # that suggests to use the amtool cli. that tool is good, but you cant
2007 # silence things nearly as easily as with the gui.
2008 if [[ ! -e /usr/share/prometheus/alertmanager/ui/index.html ]]; then
2009 # default script didnt work, required some changes to get elm 19.1,
2010 # which is a dependency of the latest alertmanager. I modified
2011 # and copied it into /b/ds. In future, might need some other
2013 #sudo /usr/share/prometheus/alertmanager/generate-ui.sh
2014 sudo /b/ds/generate-ui.sh
2015 ser restart prometheus-alertmanager
2018 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter -l 127.0.0.1
2020 for ser in prometheus-node-exporter prometheus-alertmanager prometheus; do
2021 sysd-prom-fail-install $ser
2026 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter
2030 # cleanup old files. 2023-02
2031 x=(/var/lib/prometheus/node-exporter/*.premerge)
2032 if [[ -e ${x[0]} ]]; then
2033 s rm /var/lib/prometheus/node-exporter/*
2038 # todo, for limiting node exporter http,
2039 # either use iptables or, in
2040 # /etc/default/prometheus-node-exporter
2041 # listen on the wireguard interface
2044 wgip=$(command sudo sed -rn 's,^ *Address *= *([^/]+).*,\1,p' /etc/wireguard/wghole.conf)
2045 # old filename. remove once all hosts are updated.
2046 s rm -fv /etc/apache2/sites-enabled/${HOSTNAME}wg.b8.nz.conf
2047 web-conf -i -a $wgip -p 9101 -f 9100 - apache2 ${HOSTNAME}wg.b8.nz <<'EOF'
2050 AuthName "basic_auth"
2052 # htpasswd -c prometheus-export-htpasswd USERNAME
2053 AuthUserFile "/etc/prometheus-export-htpasswd"
2057 # For work, i think we will just use the firewall for hosts in the main data center, and
2058 # vpn for hosts outside it.
2060 # TODO: figure out how to detect the ping failure and try again.
2062 # Binding to the wg interface, it might go down, so always restart, and wait for it on boot.
2063 s mkdir /etc/systemd/system/apache2.service.d
2064 sd /etc/systemd/system/apache2.service.d/restart.conf <<EOF
2066 After=wg-quick@wghole.service
2067 StartLimitIntervalSec=0
2077 ### end prometheus ###
2079 ### begin nagios ###
2081 pi nagios-nrpe-server
2085 # the backport is for this bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800345
2086 pi nagios4 nagios-nrpe-plugin monitoring-plugins-basic/bullseye-backports
2087 s rm -fv /etc/apache2/conf-enabled/nagios4-cgi.conf
2089 # to add a password for admin:
2090 # htdigest /etc/nagios4/htdigest.users Nagios4 iank
2091 # now using the same pass as prometheus
2093 # nagstamon auth settings, set to digest instead of basic.
2095 web-conf -p 3005 - apache2 i.b8.nz <<'EOF'
2096 # adapted from /etc/apache2/conf-enabled/nagios4-cgi.conf
2098 ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4
2099 ScriptAlias /nagios4/cgi-bin /usr/lib/cgi-bin/nagios4
2101 # Where the stylesheets (config files) reside
2102 Alias /nagios4/stylesheets /etc/nagios4/stylesheets
2104 # Where the HTML pages live
2105 Alias /nagios4 /usr/share/nagios4/htdocs
2107 <DirectoryMatch (/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)>
2108 Options FollowSymLinks
2109 DirectoryIndex index.php index.html
2110 AllowOverride AuthConfig
2112 # The default Debian nagios4 install sets use_authentication=0 in
2113 # /etc/nagios4/cgi.cfg, which turns off nagos's internal authentication.
2114 # This is insecure. As a compromise this default apache2 configuration
2115 # only allows private IP addresses access.
2117 # The <Files>...</Files> below shows how you can secure the nagios4
2118 # web site so anybody can view it, but only authenticated users can issue
2119 # commands (such as silence notifications). To do that replace the
2120 # "Require all granted" with "Require valid-user", and use htdigest
2121 # program from the apache2-utils package to add users to
2122 # /etc/nagios4/htdigest.users.
2124 # A step up is to insist all users validate themselves by moving
2125 # the stanza's in the <Files>..<Files> into the <DirectoryMatch>.
2126 # Then by setting use_authentication=1 in /etc/nagios4/cgi.cfg you
2127 # can configure which people get to see a particular service from
2128 # within the nagios configuration.
2130 AuthDigestDomain "Nagios4"
2131 AuthDigestProvider file
2132 AuthUserFile "/etc/nagios4-htdigest.users"
2133 AuthGroupFile "/etc/group"
2139 <Directory /usr/share/nagios4/htdocs>
2146 # when you alter a service through the web, it changes vars in /var/lib/nagios4/status.dat. for example:
2147 # notifications_enabled=1
2148 # note, the same variable exists in the correspdonding "define service {"
2150 # in the default config, we have these definitions
2152 # 11 define command {
2153 # 2 define contact {
2154 # 1 define contactgroup {
2156 # 4 define hostgroup {
2157 # 23 define service {
2158 # 5 define timeperiod {
2163 # klaxon:/etc/nagios3 # grep -rho '^ *define [^{ ]*' | sort | uniq -c
2166 # 6 define contactgroup
2168 # 1 define hostextinfo
2169 # 16 define hostgroup
2170 # 3040 define service
2171 # 2 define servicedependency
2172 # 6 define timeperiod
2179 ### begin bitcoin ###
2183 sudo install -m 0755 -o root -g root -t /usr/bin /a/opt/bitcoin-24.0.1/bin/*
2185 # note: the bitcoin user & group are setup in fai
2186 sudo usermod -a -G bitcoin iank
2187 # todo: make bitcoin have a stable uid/gid
2188 if [[ ! $(readlink -f /var/lib/bitcoind/wallets) == /q/wallets ]]; then
2189 mkdir -p /var/lib/bitcoind
2190 chown bitcoin:bitcoin /var/lib/bitcoind
2191 # 710 comes from the upstream bitcoin unit file
2192 chmod 710 /var/lib/bitcoind
2193 s lnf /q/wallets /var/lib/bitcoind
2194 sudo chown -h bitcoin:bitcoin /var/lib/bitcoind/wallets
2196 # note, there exists
2197 # /a/bin/ds/disabled/bitcoin
2205 sd /etc/cups/client.conf <<'EOF'
2206 ServerName printserver1.office.fsf.org
2213 In mate settings settings, change scrolling to two-finger,
2214 because the default edge scroll doesn\'t work. Originally found this in debian.
2217 # Remove dep that came in with desktop to fix associations.
2218 m pu transmission-gtk
2222 lnf -T /d/vidshare /home/iank/Videos
2226 # # Based on guix manual instructions, also added code to profile.
2227 # # disabled since i'm not using it now.
2229 # if ! type -p guix >/dev/null; then
2231 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
2232 # # added some stuff to envonment.sh for profile based on
2233 # # manual instructions
2234 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
2235 # # echo is to get past prompt
2236 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
2237 # guix install glibc-utf8-locales
2238 # guix package --install guile
2244 m /a/bin/buildscripts/tor-browser
2245 # one root command needed to install
2246 s ln -sf /a/opt/tor-browser/Browser/start-tor-browser /usr/local/bin
2250 pi-nostart nfs-kernel-server
2252 # todo, this is old, probably needs removing
2253 if [[ $HOSTNAME == tp ]]; then
2254 sd /etc/wireguard/wg0.conf <<EOF
2256 PrivateKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.key)
2257 Address = 10.3.0.2/24, fdfd::2/64
2260 PresharedKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.psk)
2261 PublicKey = 9RnAsJB+ISrA/9lmDKBoT08oBiKwzA64exBBj+rO+ng=
2262 Endpoint = b8.nz:26000
2263 AllowedIPs = 10.3.0.1/24, fdfd::1/64
2264 PersistentKeepalive = 20
2266 sudo systemctl enable wg-quick@wg0
2267 sudo systemctl start wg-quick@wg0
2271 if [[ $HOSTNAME == kw ]]; then
2272 # hosts 1-199. 200+ are dynamic, avoid those
2273 tu /etc/exports <<'EOF'
2274 /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)
2275 /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)
2283 # if I was going to create a persistent vm, i might do it like this:
2284 # variant=something # from: virt-install --os-variant list
2285 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
2286 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
2287 # -n some_name --import --os-variant $variant --cpu host-model-only
2290 # for brother HL-2270DW, this worked:
2291 # https://askubuntu.com/questions/1067234/cant-use-wireless-brother-printer-2270dw-ubuntu-18-04
2292 # /a/opt/linux-brprinter-installer-2.2.2-1
2293 # answer n when it asks about uri.
2294 # Then go to cups, delete the existing printer, added on with dnssd url. browsed to
2295 # ppd at /usr/share/ppd/HL2270DW.ppd, which is duplicated at /usr/share/cups/model/HL2270DW.ppd
2296 # ppd file got installed from bash -x ./usr/local/Brother/Printer/HL2270DW/cupswrapper/cupswrap,
2297 # which I downloaded from their driver. but dont do that again, i copied it to /a/opt/HL2270DW.ppd,
2300 # 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.
2301 # Then it was already configured, but if i needed to, go to its web ui, default pass is "access".
2303 ######### begin stuff belonging at the end ##########