3 # Setup Ian's computers
4 # Copyright (C) 2024 Ian Kelling
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # SPDX-License-Identifier: GPL-3.0-or-later
21 # shellcheck disable=SC2317 # false positive
23 source /a
/bin
/ds
/.bashrc
26 source /a
/bin
/bash-bear-trap
/bash-bear
27 src
="$(readlink -f -- "${BASH_SOURCE[0]}")"; src
=${src%/*} # directory of this file
29 if [[ $EUID == 0 ]]; then
30 echo "$0: error: run as regular user" >&2
35 echo 1 >~
/.local
/distro-end
38 # shellcheck source=./pkgs
41 echo "$0: $(date) starting now)"
42 # see example of usage to understand.
45 IFS
= read -r -d '' y ||
:
50 echo 0 >~
/.local
/distro-end
51 if $pending_reboot; then
52 echo "$0: pending reboot and then finished. doing it now."
53 echo "exiting with status 0"
56 echo "$0: $(date): ending now)"
57 echo "exiting with status 0"
63 printf "$pre sudo %s\n" "$*"
64 SUDOD
="$PWD" command sudo
"$@";
66 m
() { printf "$pre %s\n" "$*"; "$@"; }
67 e
() { printf "$pre %s\n" "$*"; }
69 codename
=$
(debian-codename
)
70 codename_compat
=$
(debian-codename-compat
)
72 sed="sed --follow-symlinks"
74 # when we schroot, it will fail if we are in a directory that doesnt exist in the chroot
84 # get sudo pass cached right away
85 if ! sudo
-nv 2>/dev
/null
; then
91 # old repo. remove when all machines updated
92 sudo
rm -fv /etc
/apt
/sources.list.d
/wireguard-ubuntu-wireguard-bionic.list
94 sudo
rm -fv /etc
/apt
/preferences.d
/minetest
103 sudo debconf-set-selections
<<EOF
104 popularity-contest popularity-contest/participate boolean true
107 ########### begin section including vps ################
114 # no equivalent in other distros:
115 if isdeb
&& pcheck apt-file
; then
116 # this condition is just a speed optimization
125 # allows me to pipe with ssh -t, and gets rid of spam
126 # http://forums.debian.net/viewtopic.php?f=5&t=85822
127 # i'd rather disable the service than comment the init file
128 # this says disabling the service, it will still get restarted
129 # but this script doesn't do anything on restart, so it should be fine
130 sudo truncate
-s0 /var
/run
/motd.dynamic
133 # this isn't a complete solution. It still shows me when updates are available,
134 # but it's no big deal.
135 sudo
rm -fv /etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
144 ######### begin universal pinned packages ######
145 case $
(debian-codename
) in
146 etiona|flidas|nabia|aramo
)
147 sudo
rm -fv /etc
/apt
/preferences.d
/etiona-buster
148 sd
/etc
/apt
/preferences.d
/trisquel-debian
<<EOF
149 Explanation: Debian* includes Debian + Debian Backports
151 Pin: release o=Debian*
154 Explanation: ubuntu's version is outdated
155 Package: debian-archive-keyring
156 Pin: release o=Debian*
163 #p install --no-install-recommends minetest/buster libleveldb1d/buster libncursesw6/buster libtinfo6/buster
165 # shellcheck disable=SC2043 # in case we want more than 1 in the loop later.
166 for n
in bookworm
; do
167 f
=/etc
/apt
/sources.list.d
/$n.list
172 deb http://deb.debian.org/debian bookworm main
173 deb-src http://deb.debian.org/debian bookworm main
175 deb http://deb.debian.org/debian-security/ bookworm-security main
176 deb-src http://deb.debian.org/debian-security/ bookworm-security main
178 deb http://deb.debian.org/debian bookworm-updates main
179 deb-src http://deb.debian.org/debian bookworm-updates main
181 deb http://http.debian.net/debian bookworm-backports main
182 deb-src http://http.debian.net/debian bookworm-backports main
187 if ! diff -q $t $f; then
197 # cant apt get the keyring without doing an update, can't update
198 # without the keyring, this is a stupid chicken and egg problem
199 # that apt should have some feature to solve, but doesn't as far
201 f
=debian-archive-keyring_2023.3
+deb12u1_all.deb
202 wget http
://ftp.debian.org
/debian
/pool
/main
/d
/debian-archive-keyring
/$f
209 if [[ ! -e /usr
/share
/debootstrap
/scripts
/noble
]]; then
212 m aptitude download debootstrap
/noble
214 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
219 sd
/etc
/apt
/preferences.d
/focal
<<'EOF'
221 Pin: release n=focal,o=Ubuntu
225 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
226 Package: spamassassin sa-compile spamc
227 Pin: release n=focal,o=Ubuntu
230 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
231 Package: spamassassin sa-compile spamc
232 Pin: release n=focal,o=Ubuntu
235 sd
/etc
/apt
/preferences.d
/psd
<<'EOF'
236 Package: profile-sync-daemon
237 Pin: release n=focal,o=Ubuntu
241 f
=/etc
/apt
/sources.list.d
/focal.list
244 deb http://us.archive.ubuntu.com/ubuntu/ focal main universe
245 deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main universe
246 deb http://us.archive.ubuntu.com/ubuntu/ focal-security main universe
248 if ! diff -q $t $f; then
249 sudo
dd if=$t of
=$f status
=none
255 sd
/etc
/apt
/preferences.d
/nabia-etiona
<<'EOF'
257 Pin: release n=nabia*,o=Trisquel
261 f
=/etc
/apt
/sources.list.d
/nabia.list
264 deb http://mirror.fsf.org/trisquel/ nabia main
265 deb-src http://mirror.fsf.org/trisquel/ nabia main
267 deb http://mirror.fsf.org/trisquel/ nabia-updates main
268 deb-src http://mirror.fsf.org/trisquel/ nabia-updates main
270 deb http://archive.trisquel.info/trisquel/ nabia-security main
271 deb-src http://archive.trisquel.info/trisquel/ nabia-security main
273 # Uncomment this lines to enable the backports optional repository
274 deb http://mirror.fsf.org/trisquel/ nabia-backports main
275 deb-src http://mirror.fsf.org/trisquel/ nabia-backports main
277 if ! diff -q $t $f; then
278 sudo
dd if=$t of
=$f status
=none
282 # duplicated in fai. Pin for bionic + ubuntu so that ppas dont get
284 sd
/etc
/apt
/preferences.d
/etiona-bionic
<<'EOF'
286 Pin: release n=bionic,o=Ubuntu
289 Pin: release n=bionic,o=Ubuntu
293 sd
/etc
/apt
/preferences.d
/etiona-sa
<<'EOF'
295 Pin: release n=bionic,o=Ubuntu
301 sd
/etc
/apt
/preferences.d
/aramo-nabia
<<'EOF'
303 Pin: release n=aramo*,o=Trisquel
306 f
=/etc
/apt
/sources.list.d
/aramo.list
309 deb http://mirror.fsf.org/trisquel/ aramo main
310 deb-src http://mirror.fsf.org/trisquel/ aramo main
312 deb http://mirror.fsf.org/trisquel/ aramo-updates main
313 deb-src http://mirror.fsf.org/trisquel/ aramo-updates main
315 deb http://archive.trisquel.info/trisquel/ aramo-security main
316 deb-src http://archive.trisquel.info/trisquel/ aramo-security main
318 # Uncomment this lines to enable the backports optional repository
319 deb http://mirror.fsf.org/trisquel/ aramo-backports main
320 deb-src http://mirror.fsf.org/trisquel/ aramo-backports main
322 if ! diff -q $t $f; then
323 sudo
dd if=$t of
=$f status
=none
330 pi debian-goodies shellcheck
335 case $codename_compat in
337 s systemctl
enable --now ssh-agent-iank
341 case $codename_compat in
343 sd
/etc
/apt
/preferences.d
/nabia-btrfs-progs
<<'EOF'
345 Pin: release a=buster-backports
348 p
install btrfs-progs
353 # 2020-03-03 old file
354 s
rm -fv /etc
/apt
/preferences.d
/radicale
355 ######### end universal pinned packages ######
360 sd
/etc
/apt
/preferences.d
/obs
<<EOF
362 Pin: release n=bionic
365 sd
/etc
/apt
/preferences.d
/chromium
<<EOF
367 Pin: release n=bionic
372 # note, to get the latest, it would be n=bullseye*
373 # but that has conflicting package versions, so this does the old one.
374 # I only use it for special rare purposes. Just keep in mind it is an
375 # outdated insecure version.
376 sd
/etc
/apt
/preferences.d
/chromium-bullseye
<<EOF
377 Package: chromium chromium-* libicu67 libjpeg62-turbo libjsoncpp24 libre2-9 libwebpmux3
378 Pin: release o=Debian*,n=bullseye
383 # obs dependency not in trisquel
384 sd
/etc
/apt
/preferences.d
/obs
<<EOF
386 Pin: release n=jammy,o=Ubuntu
394 ##### begin automatic upgrades (after checkrestart has been installed) ####
395 # if apt-config-auto-update is installed,
396 # it also has similar config, in a file 10something,
397 # but i think this overrides it since its higher number.
398 # This file was part of the automatic-updates package,
399 # and it has a config option to not get new package lists,
400 # which seems pretty stupid to me, you cant actually upgrade
401 # anything if you dont have the new package list.
402 sd
/etc
/apt
/apt.conf.d
/20auto-upgrades
<<'EOF'
403 # note: man apt.conf says
404 # /usr/share/doc/apt/examples/configure-index.gz is a configuration file showing
405 # example values for all possible options.
406 # but that is a incorrect.
407 # Periodic and other options are only documented in
408 # /usr/lib/apt/apt.systemd.daily
409 # That filename can be found through poking around in apt daily cronjob.
410 APT::Periodic::Update-Package-Lists "1";
411 APT::Periodic::Download-Upgradeable-Packages "1";
412 # 0 means disabled. I used to set this to 7, however, trisquel doesn't
413 # have an archive of old package versions, so I want to
414 # keep around old versions so I can easily downgrade.
415 APT::Periodic::AutocleanInterval "0";
416 # daily expire old files /var/cache/apt if it gets above this MB
417 APT::Periodic::MaxSize "50000";
418 APT::Periodic::Unattended-Upgrade "1";
421 # fyi: default file has comments about available options,
422 # you may want to read that, do pkx unattended-upgrades
423 # default is just security updates. this list found from reading
424 # match_whitelist_string() in $(which unattended-upgrades)
425 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
426 Unattended-Upgrade::Mail "root";
427 Unattended-Upgrade::MailOnlyOnError "true";
428 Unattended-Upgrade::Remove-Unused-Dependencies "true";
429 Unattended-Upgrade::Origins-Pattern {
430 "o=*,l=*,a=*,c=*,site=*,n=*";
435 sudo
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
/etc
/cron.d
/myupgrade
437 # myupgrade cron exists in /etc/cron.d/ian
439 ##### end automatic upgrades ####
442 # commented in case i want to use this sometime later
443 # sd /etc/apt/preferences.d/buster-backports <<EOF
445 # Pin: release a=buster-backports
450 ###### begin website setup
454 f
=/var
/lib
/bind
/db.b8.nz
455 if [[ ! -e $f ]]; then
459 sudo
/c
/roles
/prom_export
/files
/simple
/usr
/local
/bin
/fsf-install-node-exporter
-l 127.0.0.1
462 web-conf
-p 9101 -f 9100 - apache2
${HOSTNAME}ex.b8.nz
<<'EOF'
465 AuthName "basic_auth"
467 # htpasswd -c prometheus-export-htpasswd USERNAME
468 AuthUserFile "/etc/prometheus-export-htpasswd"
477 # i just dont feel like setting up a special purpose ssh key to do this automatically.
479 # run this once for bk on local machine:
480 # only used for old openvpn setup
481 /a/exe/vpn-mk-client-cert -c bk.b8.nz -b expertpath -n mail li.iankelling.org
491 if [[ ! -L ~
/eggdrop
/eggdrop
]]; then
493 git clone https
://github.com
/eggheads
/eggdrop eggdrop-src
501 # dunno if this is really needed. it was part of the documented eggdrop systemd install script
502 sudo loginctl enable-linger
503 systemctl
--user enable fsysbot
504 systemctl
--user start fsysbot
506 m
/a
/h
/setup.sh iankelling.org
508 # start mumble only when im going to use it, since i dont use it much
509 pi-nostart mumble-server
510 sudo
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
512 # do certificate to avoid warning about unsigned cert,
513 # which is overkill for my use, but hey, I'm cool, I know
515 m web-conf apache2 mumble.iankelling.org
516 sudo
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
518 # general vpn for as needed use
519 vpn-server-setup
-d -r -4 10.5.5 -p 443 -n hole
521 # todo: consider if this should exist for the
523 teeu
/etc
/openvpn
/server
/hole.conf
<<'EOF'
527 # note client-config files are setup in brc2 update-host-info
530 # for adding cert to system with /p
533 #mkc /p/c/machine_specific/$host/filesystem/etc/openvpn/client
534 #vpn-mk-client-cert -b $host -n hole -r iankelling.org
535 #s chown -R iank:iank .
537 # example of adding to remote system 107,
538 # vpn-mk-client-cert -n hole -c 10.2.0.107 -b hd8 iankelling.org
540 # for wireguard hole vpn, use function:
544 # if it is going to want to connect to transmission-daemon on ok
545 # wghole bo 28 10.174.2.2/32
547 # requested from linode via a support ticket.
548 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
549 # ipv6 stuff pieced together
550 # via slightly wrong information from
551 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
552 # https://community.openvpn.net/openvpn/wiki/IPv6
555 # This uses a public /64, but afaik, that is not needed for my
556 # current use case, since I'm doing ipv6 nat, they could be private
557 # and nat to a public address. I'm doing ipv6 nat in order to have 2
558 # vpn clients that externally share the same ip when sending so they
559 # share ip reputation. Note, the eth0 and tunx needed to be
560 # different subnets. On the same, I saw some neighbor packet go
561 # unanswered, tcpdump showed packets getting lost. I tried splitting the
562 # /64, it didn't work but I didn't investigate closely.
565 # not starting as i intend to replace it
566 m vpn-server-setup
-s -i tunmail
-n mail -d -6 2600:3c00
:e002
:3800::/64 2600:3c00
:e002
:3800::1/64
567 sudo
tee /etc
/openvpn
/client-config-mail
/mailclient
<<'EOF'
568 ifconfig-push 10.8.0.4 255.255.255.0
569 ifconfig-ipv6-push 2600:3c00:e002:3800::4/64
571 sudo
tee /etc
/openvpn
/client-config-mail
/expertpath
<<'EOF'
572 ifconfig-push 10.8.0.5 255.255.255.0
573 ifconfig-ipv6-push 2600:3c00:e002:3800::5/64
577 sudo
dd of
=/etc
/systemd
/system
/vpn-mail-forward.service
<<'EOF'
579 Description=Turns on iptables mail nat
580 BindsTo=openvpn-server@mail.service
585 ExecStart=/a/bin/distro-setup/vpn-mail-forward tunmail start
586 ExecStop=/a/bin/distro-setup/vpn-mail-forward tunmail stop
589 RequiredBy=openvpn-server@mail.service
594 # needed for li's local mail delivery.
595 tu
/etc
/hosts
<<<"10.8.0.4 mx.iankelling.org"
597 # wgmail handles this.
598 #sgo vpn-mail-forward.service
600 #sgo openvpn-server@mail
603 # setup let's encrypt cert
604 m web-conf apache2 mail.iankelling.org
605 # TODO, i expanded the above cert manually to mx.iankelling.org, this should be captured
606 # in the automation here. We use mail.iankelling.org as our ehlo name when sending mail
607 # but our mx record is mx.iankelling.org. Initially I was just using mail.iankelling.org,
608 # but the problem is I want multiple ips to be able to identify as mail.iankelling.org,
609 # but a subset to be mx.iankelling.org. Afaik, there is no problem with having
610 # our mail cert be for mail.iankelling.org, and have people connect to mx.ian...,
611 # but it doesn't make logical sense to do this.
612 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
615 a2enmod -q proxy proxy_http
616 domain=cal.iankelling.org
617 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
618 # https://radicale.org/2.1.html
619 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
620 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
622 # this doesn't exactly fit with the documentation.
623 # We need location / to do an auth, it cant be done outside,
624 # in order to pass on X-Remote-User. And we need
625 # the other location in order to remove the /radicale/ for
626 # requests which have it. This could be done with a rewrite,
627 # but i just get something working and call it a day.
632 AuthName "Authentication Required"
633 # setup one time, with root:www-data, 640
634 AuthUserFile "/etc/caldav-htpasswd"
636 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
638 <Location "/radicale/">
639 Options +FollowSymLinks +Multiviews -Indexes
640 RequestHeader set X-Script-Name /radicale/
641 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
642 ProxyPass "http://10.8.0.4:5232/" retry=0
643 ProxyPassReverse "http://10.8.0.4:5232/"
646 # nginx version of above would be:
647 # auth_basic "Not currently available";
648 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
652 ###### begin znc setup #####
655 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
656 # to get into the web interface,
657 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
658 # https://iankelling.org:12533/
659 # login as ian, pass is in pass store, the part after :
661 # znc config generated by doing
663 # selected port is also used in erc config
664 # comma separated channel list worked.
665 # while figuring things out, running znc -D for debug in foreground.
666 # to exit and save config:
667 # /msg *status shutdown
668 # configed auth on freenode by following
669 # https://wiki.znc.in/Sasl:
673 # Set MyNickservName pa$$w0rd
674 # created the system service after, and had to do
675 # mv /home/iank/.znc/* /var/lib/znc
676 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
677 # and made a copy of the config files into /p/c
678 # /msg *status LoadMod --type=global log -sanitize
679 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
680 # /msg *status LoadMod --type=network perform
681 # /query *perform add PRIVMSG ChanServ :invite #fsf-office
682 # /msg *perform add JOIN #fsf-office
683 # /msg *status LoadMod NickServ
686 # also ran /znc LoadMod clearbufferonmsg
687 # it would be nice if erc supported erc query buffers by doing
688 # /msg *status clearbuffer <name of the query/receiver
690 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
691 # if that was the case i could remove the module clearbufferonmsg
692 # also would be nice if erc supported
693 # https://wiki.znc.in/self-message
694 # https://wiki.znc.in/Query_buffers \
696 # for geekshed, there was no sasl support as far as I can tell,
697 # so I set to msg nickserv to identify upon connect.
698 if ! getent passwd znc > /dev/null; then
699 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
701 sudo chmod 700 /var/lib/znc
702 sudo chown -R znc:znc /var/lib/znc
703 # Avoid restarting if possible, reconnecting to irc is annoying.
704 # The unit file was made active with conflink.
705 # Note, avoid using ser here because we wrap sudo to prints the command first.
706 if [[ $(systemctl is-active znc) != active ]]; then
709 ###### stop znc setup #####
718 # todo, save the config
719 /etc/cron.daily/stream-cert
720 web-conf -c /etc/cert-live.fsf.org -p 443 -f 8000 apache2 live.fsf.org
724 ###### end website setup
726 ########### end section including li/lj ###############
731 ### system76 things ###
733 bo) # sy| sy doesnt seem to really need this.
734 # note, i stored the initial popos packages at /a/bin/data/popos-pkgs
735 if [[ ! -e /etc/apt/sources.list.d/system76.list ]]; then
736 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
737 sd /etc/apt/sources.list.d/system76.list <<EOF
738 deb http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
739 deb-src http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
741 # ubuntu keyserver is prone to intermittent failures
742 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5D1F3A80254F6AFBA254FED5ACD442D1C8B7748B
744 # https://support.system76.com/articles/install-ubuntu/
745 # but i'm hoping this is not needed
746 # sd /etc/apt/preferences.d/system76 <<'EOF'
748 # Pin: release o=LP-PPA-system76-dev-stable
752 # s fwupdmgr get-updates
753 # says I have 3 "devices with no available firmware updates"
754 # if there were updates, install with: s fwupdmgr update
756 check_downgrade=false
757 if [[ ! -e /etc/apt/preferences.d/system76-apt-preferences ]]; then
760 pi system76-firmware system76-driver fwupd
761 if $check_downgrade && [[ -e /etc/apt/preferences.d/system76-apt-preferences ]]; then
762 # driver installs a preferences file to give s76 packages
763 # priority so we may need to downgrade here.
764 pup --allow-downgrades
766 # system76-driver: on a modern kernel, it seems to mainly just do
767 # some power settings, I haven't looked entirely through it. it
768 # might also change fan speed. Of its recommended packages,
769 # system76-power is the only one I haven't looked at, the others
770 # do nothing for laptops i have. they have models hardcoded in
771 # source, so you can just grep for it. pkx package; caf | less.
773 # if you get a notice about a firmware update, the notifier on i3
774 # is too dumb to do anything when you click it.
775 # to manually get new firmware,
776 # system76-firmware-cli schedule --open
777 # to see a changelog, cd to
778 # /var/cache/system76-firmware-daemon
779 # extract the xz files there, one will contain a changelog.
780 # then to install an update:
781 # s system76-firmware-cli schedule
785 ### end system76 things ###
791 ## one time setup thing I did
793 # cargo build --release
794 # cp target/release/obs-cmd ../bin
796 ## in obs, tools -> websocket server settings -> generate/copy password
798 # note: obs-studio on gnu does not support webrtc, it seems mainly because
799 # libdatachannel is not packaged. If it was, it would just need to do
800 # apt source obs-studio, obs-studio-30.1.1/debian/rules set -DENABLE_WEBRTC=ON
802 # I did manage to build libdatachannel following its instructions, then make install,
803 # then obs failed due to nvidia. found those options to disable with
804 # rg 'option\(ENABLE' | gr nv, then build obs like so:
806 # cmake -DLINUX_PORTABLE=ON -DCMAKE_INSTALL_PREFIX="${HOME}/obs-studio-portable" -DENABLE_BROWSER=OFF -DENABLE_AJA=OFF -DENABLE_NEW_MPEGTS_OUTPUT=OFF -DENABLE_WEBRTC=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DENABLE_NVVFX=OFF -DENABLE_NVAFX=OFF -DENABLE_NATIVE_NVENC=OFF ..
810 # however, I didn't end up trying it out.
812 # note, in terminal source, i setup a transform so it would show the
813 # bottom 1080p section of the terminal instead of the top if the
814 # screen was bigger. click like 2 times in the preview so the red
815 # lines show up, right click, edit transform (or ctrl-e). bounding
816 # box type: scale to width of bounds. alignment in bounding box:
817 # bottom left. bounding box size 1920 x 1080.
819 # as of 2024-06, noble repo doesn't exist yet
820 if [[ $codename_compat != noble ]]; then
821 # ppa:obsproject/obs-studio
822 if [[ ! -s /etc/apt/sources.list.d/obs.list ]]; then
823 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
824 sd /etc/apt/sources.list.d/obs.list <<EOF
825 deb http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
826 deb-src http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
828 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BC7345F522079769F5BBE987EFC71127F425E228
836 case $codename_compat in
838 # mate-indicator-applet and beyond are msc things I noticed diffing a
839 # standard install with mine.
840 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
846 # todo: figure out mate for buster
847 # pi task-gnome-desktop
850 # i had installing mate-indicator-applet, but im not sure why so i removed
851 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras anacron
854 # # apt-get update periodically fails with an appstream error.
855 # # this removes gnome-core, but its just a package for dependencies
856 # p -y remove appstream
859 # by default, it sleeps when not logged in to x/wayland and on ac power.
861 if id -u gdm &>/dev/null; then
862 sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
866 # lightdm startup fails without this. on etiona, we got unity-greeter installed automatically,
867 # it would probably work on nabia too, but google just lead me to this and it works fine.
868 pi lightdm-gtk-greeter
869 # ok, this is really weird
870 # normally this file has
871 sd /etc/X11/Xsession.d/99x11-common_start <<'EOF'
873 # this file normally just has: exec $STARTUP
874 # but then ~/.xsession-errors
875 # says $STARTUP is not found, which appears to be the real
876 # error, but normal bash doesnt operate that way.
877 # https://bugs.launchpad.net/ubuntu/+source/im-config/+bug/1879352
880 # also, gdm wayland was default, had to do
881 # dpkg-reconfigure gdm3
882 # and choose lightdm.
886 # not yet bothering with mate
887 pi lightdm-gtk-greeter lightdm
890 # todo: try removing this. also, see if system76-driver fixes this.
892 # on newer laptop, this config makes xorg load an intel module
893 # in Xorg.0.log and display nothing. background:
895 # I dropped lightdm as I was trying to figure this out, why xorg was
896 # displaying nothing. I did a diff of a working Xorg.0.log from a
897 # popos is, which is in ~/.local/share/xorg/Xorg.0.log if it runs as
898 # a regular user. I noticed 2 differences, on the failing one it was
899 # loading the intel xorg module. On the successful one, it had a
900 # line systemd-logind: got fd for /dev/dri/card1 226:1, on the
901 # failing one it had a line about systemd-logind not knowing the
902 # seat or session or something. There was no search results about
903 # that, switching to xinit made that go away. Note: gpg-agent seems
904 # to be working ok as an ssh agent. xsession has an option
905 # use-ssh-agent but perhaps it decides to leave gpg agent in charge.
906 cat >/etc/X11/xorg.conf.d/20-intel.conf <<'EOF'
908 # https://forums.linuxmint.com/viewtopic.php?f=208&t=224942#p1197049
909 # prevents konsole from being borderline unusable on system76 intel graphics + i3
911 Identifier "Intel Graphics"
913 Option "TearFree" "true"
925 if [[ $codename_compat == flidas ]]; then
926 # doesnt exist in newer
935 # firefox would work here too, apt would select abrowser.
936 # and the update-alternatives thing i think is becuz firefox is
937 # generally available before abrowser and this helps fix things
938 # up when we have both.
940 s update-alternatives --set x-www-browser /usr/bin/abrowser
947 if pcheck ubuntu-system-adjustments; then
948 # mint firefox has a dependency which is totally not really
949 # needed, just some mint branding and maybe a random firefox
951 tmpdir="$(mktemp -d)"
952 # it puts the deb in .., so use a subdir to stay contained
955 # edited from output of equivs-control ubuntu-system-adjustments
956 cat >ubuntu-system-adjustments <<'EOF'
960 Standards-Version: 3.9.2
961 Package: ubuntu-system-adjustments
962 Description: ubuntu-system-adjustments-dummy
964 equivs-build ubuntu-system-adjustments
965 sudo dpkg -i ../ubuntu-system-adjustments_2030_all.deb
978 # newer distros just use adb for package name it seems
979 case $codename_compat in
981 pi android-tools-adbd
985 case $codename_compat in
987 pi libext2fs-dev libzstd-dev
988 cd /a/opt/btrfs-progs
993 case $codename_compat in
1002 # not packaged in newer distros it seems
1003 case $codename_compat in
1004 bionic|buster|stretch)
1010 case $codename_compat in
1012 # https://wiki.archlinux.org/title/bluetooth
1013 pi pavucontrol paprefs pulseaudio-module-bluetooth pulsemixer
1017 # having pipewire installed prevents the recommends in these from installing pulse
1018 pi pulsemixer pavucontrol
1023 # TODO: some of the X programs can be removed from pall when using wayland
1025 # depends gcc is a way to install suggests. this is apparently the only
1026 # way to install suggests even if the main package is already
1027 # installed. reinstall doesn't work, uninstalling can cause removing
1028 # dependent packages.
1029 # shellcheck disable=SC2046 # word splitting is intended
1030 pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $($src/distro-pkgs)
1032 # schroot service will restart schroot sessions after reboot.
1036 ## note: this bug doesn't exist in t12+
1037 # fix systemd unit failure. i dont know of any actual impact
1038 # other than systemd showing in degraded state. So, we dont bother
1039 # fixing the current state, let it fix on the next reboot.
1040 # https://gitlab.com/cjwatson/binfmt-support/-/commit/54f0e1af8a
1041 if pcheck binfmt-support; then
1042 tmp=$(systemctl cat binfmt-support.service | grep ^After=)
1043 if [[ $tmp != *systemd-binfmt.service* ]]; then
1044 s u /etc/systemd/system/binfmt-support.service.d/override.conf <<EOF
1046 $tmp systemd-binfmt.service
1051 # commented, not worth the hassle i think.
1057 sudo rm -fv /etc/systemd/resolved.conf.d/iank.conf
1059 # website is dead june 14 2019. back in october, but meh
1060 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
1065 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
1068 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
1069 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
1071 # f=/etc/apt/sources.list.d/iridium-browser.list
1072 # if ! diff -q $t $f; then
1077 # pi iridium-browser
1083 if mountpoint /p &>/dev/null; then
1084 # note, see bashrc for more documentation.
1086 sd /etc/systemd/system/rss2email.service <<'EOF'
1088 Description=rss2email
1089 After=multi-user.target
1094 # about 24 hours of failures
1095 # it copies over its files without respecting symlinks, so
1096 # we pass options to use different location.
1097 ExecStart=/usr/local/bin/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
1099 sd /etc/systemd/system/rss2email.timer <<'EOF'
1101 Description=rss2email
1104 # for initial run. required.
1106 # for subsequent runs.
1107 OnUnitInactiveSec=300
1110 WantedBy=timers.target
1112 sudo systemctl daemon-reload
1116 ######### begin irc periodic backup #############
1117 if [[ $HOSTNAME == frodo ]]; then
1118 sd /etc/systemd/system/ircbackup.service <<'EOF'
1120 Description=irc li backup
1121 After=multi-user.target
1126 ExecStart=/usr/local/bin/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
1128 sd /etc/systemd/system/ircbackup.timer <<'EOF'
1130 Description=irc li backup hourly
1136 WantedBy=timers.target
1138 sudo systemctl daemon-reload
1143 ######### end irc periodic backup #############
1147 # pi-nostart does not disable
1151 if [[ -e /p/c/gen-fsf-vpn ]]; then
1155 if [[ -e /p/c/machine_specific/$HOSTNAME/filesystem/etc/openvpn/client/hole.crt ]]; then
1156 sgo openvpn-client@hole
1159 ############# begin syncthing setup ###########
1162 f=/usr/share/keyrings/syncthing-archive-keyring.gpg
1163 if [[ ! -e $f ]]; then
1164 s curl -s -o $f https://syncthing.net/release-key.gpg
1166 s="deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable"
1167 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
1168 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
1174 m lnf -T /w/syncthing /home/iank/.config/syncthing
1175 ser daemon-reload # syncthing likely not properly packaged
1176 sgo syncthing@iank # runs as iank
1180 # 1003 just happens to be what was on my system
1181 if ! getent passwd ziva; then
1182 s groupadd -g 1003 ziva
1183 # syncthing state / config / db are all in ~/.config/syncthing
1184 s useradd -g 1003 -u 1003 -d /d/ziva-home -c ziva -s /bin/bash ziva
1190 # user for short term use dropping of privileges
1192 if ! getent group zu &>/dev/null; then
1193 s groupadd -g 1023 zu
1195 if ! getent passwd zu &>/dev/null; then
1196 s useradd -g 1023 -u 1023 -c zu -s /bin/bash zu
1200 # these things persist in ~/.config/syncthing, which I save in
1201 # /w/syncthing (not in /p, because syncthing should continue to
1202 # run on home server even when using laptop as primary device)
1203 # open http://localhost:8384/
1204 # change listen address from default to tcp://:22001,
1205 # this is because we do port forward so it doesn\'t have to use
1206 # some external server, but the syncthing is broken for port forward,
1207 # you get a message, something "like connected to myself, this should not happen"
1208 # when connecting to other local devices, so I bump the port up by 1,
1210 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
1211 # Without this, it was being stuck syncing at 0%.
1212 # Set gui username and password.
1214 # install syncthing via f-droid,
1215 # folder setting, turn off send only.
1216 # on phone, add device, click bar code icon
1217 # on dekstop, top right, actions, device id
1218 # after adding, notification will appear on desktop to confirm
1220 # syncing folder. from phone to desktop: select desktop in the
1221 # folder on phone\'s sync options, notification will appear in
1222 # desktop\'s web ui within a minute. For the reverse, the
1223 # notification will appear in android\'s notifications, you have to
1224 # swipe down and tap it to add the folder. It won\'t appear in the
1225 # syncthing ui, which would be intuitive, but don\'t wait for it
1226 # there. The notification may not work, instead open the web gui
1227 # from in the app, there should be a notification within there.
1229 # On phone, set settings to run syncthing all the time, and
1230 # show no notification.
1232 # Folder versioning would make sense if I didn\'t already use btrfs
1233 # for backups. I would choose staggered, or trash can for more space.
1235 # if needed to install on a remote comp:
1236 # ssh -L 8384:localhost:8384 -N frodo
1237 # open http://localhost:8384/
1239 # Note, the other thing i did was port forward port 22000,
1240 # per https://docs.syncthing.net/users/firewall.html
1242 ############# end syncthing setup ###########
1246 ####### begin misc packages ###########
1248 # old location, 2023.
1249 sudo rm -fv /etc/systemd/system/profanity.service
1252 ln -sfT /d/p/profanity ~/.local/share/profanity
1253 ln -sfT /d/p/profanity-config ~/.config/profanity
1254 source /a/bin/bash_unpublished/source-state
1255 if [[ $HOSTNAME == "$HOST2" || ! -e /p/profanity-here ]]; then
1256 systemctl --user --now enable profanity
1261 ln -sfT /p/profanity ~/.local/share/profanity
1262 ln -sfT /p/profanity-config ~/.config/profanity
1273 sudo update-alternatives --set pinentry /usr/bin/pinentry-gtk-2
1276 # sakura config is owned by ian
1279 m sudo -u user2 -i reset-konsole
1280 # user2 xscreensaver we don't want to reset
1281 m reset-xscreensaver
1284 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
1285 # this is also in primary-setup
1286 # pi libxss-dev # dependency based on build failure
1288 # cabal install --upgrade-dependencies --force-reinstalls arbtt
1289 # also, i assume syncing this between machines somehow messed up the data.
1291 ## not using arbtt for now
1292 # if mountpoint /p &>/dev/null; then
1296 # # same as seru enable arbtt, but works over ssh when systemctl --user causes error:
1297 # # Failed to connect to bus: No such file or directory
1298 # lnf -T /a/bin/ds/subdir_files/.config/systemd/user/arbtt.service /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1300 # seru start arbtt ||:
1304 rm -fv /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1309 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
1310 m cp /p/.linphonerc-initial ~/.linphonerc
1313 # linphone in t10 wont do dns with systemd-resolved or something
1314 s teeu /etc/hosts <<'EOF'
1315 74.94.156.215 watson.fsf.org
1320 ### begin spd install
1321 if mountpoint /p &>/dev/null; then
1322 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
1324 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
1327 # this guesses at the appropriate directory, adjust if needed
1328 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
1329 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
1330 # newer distro had gpg2 as default, older one, flidas, need to make it that way
1331 gpgpath=$(which gpg2) ||:
1332 if [[ $gpgpath ]]; then
1333 sudo mkdir -p /usr/local/spdhackfix
1334 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
1340 # nagstamon setting which were set through the ui
1341 # monitor url https://klaxon.fsf.org/cgi-bin
1342 # monitor url cgi https://klaxon.fsf.org/cgi-bin
1344 # all unknown services
1345 # all warning services
1346 # acknowledged hosts & services
1347 # hosts & services down for maintenence
1348 # services on down hosts
1349 # services on hosts in maintenece
1350 # services on unreachable osts
1351 # hosts in soft state
1352 # services in soft state
1353 # in display tab: fullscreen
1355 # these translate to these settings I think
1356 # filter_acknowledged_hosts_services = True
1357 # filter_all_unknown_services = True
1358 # filter_all_warning_services = True
1359 # filter_hosts_in_soft_state = True
1360 # filter_hosts_services_maintenance = True
1361 # filter_services_in_soft_state = True
1362 # filter_services_on_down_hosts = True
1363 # filter_services_on_hosts_in_maintenance = True
1364 # filter_services_on_unreachable_hosts = True
1365 # notify_if_up = False
1366 # statusbar_floating = False
1368 # but i'm just going to rely on the webpage plus sms for now.
1371 # it asks if it should make users in it's group capture packets without root,
1372 # which is arguably more secure than running wireshark as root. default is no,
1373 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
1374 # note: t10 called this wireshark-gtk, i don't care about t10 anymore.
1375 s DEBIAN_FRONTEND=noninteractive pi wireshark
1377 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
1378 # listed in the default config as suggested.
1379 # /run/usr/1000 i noticed was missing for pulseaudio
1380 # /run/user/0 just seemed like a not bad idea, given the above
1381 tu /etc/schroot/desktop/fstab <<'EOF'
1382 /p /p none rw,bind 0 0
1383 /a /a none rw,bind 0 0
1384 /run /run none rw,bind 0 0
1385 /run/lock /run/lock none rw,bind 0 0
1386 /dev/shm /dev/shm none rw,bind 0 0
1387 /run/shm /run/shm none rw,bind 0 0
1388 /run/user/1000 /run/user/1000 none rw,bind 0 0
1389 /run/user/1001 /run/user/1001 none rw,bind 0 0
1390 /run/user/0 /run/user/0 none rw,bind 0 0
1393 # todo: consider if this should use the new sysd-prom-fail
1394 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1396 Description=schrootupdate
1397 After=multi-user.target
1401 ExecStart=/usr/local/bin/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1403 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1405 Description=schrootupdate
1408 OnCalendar=*-*-* 04:20:00 America/New_York
1411 WantedBy=timers.target
1414 sgo schrootupdate.timer
1421 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/bookworm.list/BOOKWORM_FREE \
1422 debian bookworm firefox-esr pulseaudio chromium
1429 sudo mkdir -p /nocow/user
1430 sudo chown $USER:$USER /nocow/user
1434 ####### begin transmission
1444 tdir=/nocow/user/tor
1450 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1451 # 450 seems likely to be unused. we need to specify one or else
1452 # it won't be stable across installs.
1453 if ! getent passwd debian-transmission > /dev/null; then
1454 sudo groupadd -g 450 debian-transmission
1455 sudo adduser --quiet \
1460 --disabled-password \
1461 --home /var/lib/transmission-daemon \
1464 # We want group writable stuff from transmission.
1465 # However, after setting this, I learn that transmission sets it's
1466 # own umask based on it's settings file. Well, no harm leaving this
1467 # so it's set right from the beginning.
1468 sudo chfn debian-transmission -o umask=0002
1470 # note i had to do this, which is persistent:
1472 # s chgrp debian-transmission torrents partial-torrents
1474 # syslog says things like
1475 # 'Failed to set receive buffer: requested 4194304, got 425984'
1476 # google suggets giving it even more than that
1477 tu /etc/sysctl.conf<<'EOF'
1478 net.core.rmem_max = 67108864
1479 net.core.wmem_max = 16777216
1483 # some reason it doesn\'t seem to start automatically anyways
1484 pi-nostart transmission-daemon
1485 # be extra sure its not started
1486 ser disable transmission-daemon
1487 ser stop transmission-daemon
1489 # the folder was moved here after an install around 02/2017.
1490 # it contains runtime data,
1491 # plus a simple symlink to the config file which it\'s
1492 # not worth separating out.
1493 # between comps, the uid can change
1495 f=$tdir/transmission-daemon
1496 for d in $tdir/partial-torrents $tdir/torrents $f; do
1497 if [[ ! -d $d ]]; then
1500 sudo chown -R debian-transmission:user2 $d
1502 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1503 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1504 sudo chown -R debian-transmission:debian-transmission $f
1505 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1507 # config file documented here, and it\'s the same config
1508 # for daemon vs client, so it\'s documented in the gui.
1509 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1511 # I originaly setup rpc-whitelist, but after using
1512 # routing to a network namespace, it doesn\'t see the
1513 # real source address, so it\'s disabled.
1515 # Changed the cache-size to 256 mb, reduces disk use.
1516 # It is a read & write cache.
1518 # just fyi: default rpc port is 9091
1519 if ! systemctl is-active transmission-daemon-nn &>/dev/null && \
1520 ! systemctl is-active transmission-daemon; then
1522 command sudo ruby <<EOF >$tmp
1524 p = '/etc/transmission-daemon/settings.json'
1526 'rpc-whitelist-enabled' => false,
1527 'rpc-authentication-required' => false,
1528 'incomplete-dir' => '$tdir/partial-torrents',
1529 'incomplete-dir-enabled' => true,
1530 'download-dir' => '$tdir/torrents',
1531 "speed-limit-up" => 800,
1532 "speed-limit-up-enabled" => true,
1533 "peer-port" => 61486,
1534 "cache-size-mb" => 256,
1535 "ratio-limit" => 5.0,
1536 "ratio-limit-enabled" => false,
1538 puts(JSON.pretty_generate(JSON.parse(File.read(p)).merge(s)))
1540 cat $tmp | sudo dd of=/etc/transmission-daemon/settings.json
1544 ####### end transmission
1548 # to persist upload/dl metadata. initially, moved all the stuff
1549 # in /var/lib/transmission-daemon to /d/tor
1550 s usermod --home /d/tor debian-transmission
1551 sgo transmission-daemon-nn
1557 ######### begin transmission client setup ######
1559 # to connect from a remote client, trans-remote-route in brc2
1562 if [[ -e /p/transmission-rpc-pass ]]; then
1563 # arch had a default config,
1564 # debian had nothing until you start it.
1565 # With a little trial an error, here is a minimal config
1566 # taken from the generated one, plus changes that the
1567 # settings ui does, without a bunch of ui crap settings.
1569 # only settings I set were
1574 # the password is randomly generated on first run, i copied it out
1575 # so it could be used by other hosts.
1578 p = '/etc/transmission-daemon/settings.json'
1579 s = JSON.parse(File.read(p))
1580 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1581 # default is 0022 (18 in decimal)
1583 File.write p, JSON.pretty_generate(s)
1586 rpc_pass=$(</p/transmission-rpc-pass)
1587 for f in /home/*; do
1589 uid=$(id -u $u 2>/dev/null) || continue
1590 if [[ ! $uid -ge 1000 ]]; then
1593 d=$f/.config/transmission-remote-gtk
1594 sudo -u $u mkdir -p $d
1595 # i tried setting hostname to transmission.b8.nz, so i could dynamically change where
1596 # this connects to, but it said some 421 denied error when I did that. Then it
1597 # froze X when i ran it under strace. Whatever.
1598 sudo -u $u dd of=$d/config.json <<EOF
1602 "profile-name" : "Default",
1603 "hostname" : "10.174.2.2",
1604 "rpc-url-path" : "/transmission/rpc",
1606 "password" : "$rpc_pass",
1607 "auto-connect" : true,
1611 "update-active-only" : false,
1612 "activeonly-fullsync-enabled" : false,
1613 "activeonly-fullsync-every" : 2,
1614 "update-interval" : 3,
1615 "min-update-interval" : 3,
1616 "session-update-interval" : 60,
1617 "exec-commands" : [],
1622 "add-options-dialog" : false
1627 ######### end transmission client setup ######
1633 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1634 # goto http://127.0.0.1:631
1635 # administration tab, add new printer button.
1636 # In debian, I could use hte recommended driver,
1637 # in arch, I had to pick out the 6L driver.
1640 # bridge networking as user fails. google lead here, but it doesn\'t work:
1641 # oh well, I give up.
1642 # http://wiki.qemu.org/Features-Done/HelperNetworking
1644 # f=/etc/qemu/bridge.conf
1648 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1651 # general known for debian/ubuntu, not for fedora
1653 m /a/bin/buildscripts/go
1654 # only needed for rg. cargo takes up 11 gigs, filled up the disk on je.
1655 m /a/bin/buildscripts/rust
1656 m /a/bin/buildscripts/misc
1658 #m /a/bin/buildscripts/pithosfly
1659 #m /a/bin/buildscripts/alacritty
1660 #m /a/bin/buildscripts/kitty
1662 pi-nostart virtinst virt-manager
1664 # i cant if this is whats causing it to start even though
1665 # its disabled. note: it leaves around dnsmasq instances even
1666 # if you stop it. what the hell systemd?
1668 # allow user to run vms, from debian handbook. libvirt-qemu
1669 # based on https://www.whonix.org/wiki/KVM#First-time_User.3F
1670 for x in iank user2; do s usermod -a -G libvirt,kvm,libvirt-qemu $x; done
1673 pi --no-install-recommends kdeconnect
1674 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1675 ### but gnome + xmonad not working in flidas, so i disabled it
1676 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1677 # cd /a/opt/indicator-kdeconnect
1680 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1683 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1684 # # it seems, according to
1685 # # /etc/xdg/autostart/kdeconnectd.desktop
1686 # # I'm not seeing the icon, but the clipboard replication is working
1689 ### begin model 01 arduino support ###
1690 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1691 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1692 # set arduino var in bashrc,
1693 # have system config file setup too.
1694 sudo adduser $USER dialout
1697 # download arduino ide, extract in /a/opt, ignore the install script, run ./arduino,
1698 # toolbar, preferences, add board manager url:
1699 # https://raw.githubusercontent.com/keyboardio/boardsmanager/master/package_keyboardio_index.json
1700 # toolbar, board manager, add keyboardio
1701 # toolbar, select model01 board
1702 # toolbar, examples, model01, compile
1706 # this is for the mail command too. update-alternatives is kind of misleading
1707 # since at least it's main commands pretend mail does not exist.
1708 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1709 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1711 ######### end misc packages #########
1714 # packages I once used before and liked, but don\'t want installed now for
1716 # python-sqlite is used for offlineimap
1717 # lxappearance python-sqlite dolphin paman dconf-editor
1723 # todo, finish configuring smart.
1726 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1727 # turn on smart. background on options:
1728 # first line, -a = test everyting on all devices.
1729 # -S on, turn on disk internal saving of vendor specific info,
1730 # from google, seems like this is usually already on and fairly standard.
1731 # -o on, turn on 4 hour period non-performance degrading testing.
1732 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1733 sched="-s (S/../.././02|L/../../6/03)"
1734 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1735 DEVICESCAN -a -o on -S on -n standby,q $sched \
1736 -m root@mail.iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1738 # in the default configuration of at least ubuntu 14.04, resolvconf is
1739 # configured to order any nameservers associated with tun* or tap*
1740 # before the normal internet interfaces, which means they are always
1741 # consulted first. This is often slower and undesirable, ie. local dns
1742 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1744 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1745 # however, this breaks dns lookup for hosts on the openvpn lan.
1746 # I can\'t figure out why hosts on the normal lan would not be
1747 # broken under the default ordering, except the host I was
1748 # testing with previously had an entry in /etc/hosts.
1750 ############# end unfinished
1752 ########### misc stuff
1756 # xdg-settings get default-web-browser
1757 # not sure this is needed. will add other distros if necessary
1760 xdg-settings set default-web-browser abrowser.desktop
1765 # pressing tab after sdf here:
1766 # scp sdfbash: set +o noglob: command not found
1767 # in t11, bash 5.1.16. this fixes it.
1768 sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
1770 rm -fv /home/iank/.mpv/watch_later
1771 rm -rf /home/iank/.mpv
1773 # apparently pip is deprecated in debian. try venv or pipx.
1774 ## begin u24 message upon pip install
1775 # If you wish to install a non-Debian-packaged Python package,
1776 # create a virtual environment using python3 -m venv path/to/venv.
1777 # Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
1778 # sure you have python3-full installed.
1780 # If you wish to install a non-Debian packaged Python application,
1781 # it may be easiest to use pipx install xyz, which will manage a
1782 # virtual environment for you. Make sure you have pipx installed.
1784 # See /usr/share/doc/python3.12/README.venv for more information.
1787 # if [[ ! -e ~/.local/bin/pip ]]; then
1789 # wget -O$tmp https://bootstrap.pypa.io/get-pip.py
1790 # python3 $tmp --user
1796 # soo, apt install beets fails due to wanting a pip package,
1797 # we find out why it wants this through
1798 # apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances beets | less
1799 # python-mediafile requires tox, which requires virtualenv, which requires pip.
1800 # but, python-mediafile doesn't really require tox, it is specified in
1801 # ./usr/lib/python3/dist-packages/mediafile-0.9.0.dist-info/METADATA
1802 # as being required only for testing, but the debian package
1803 # included it anyways, due to a mistake or bad tooling or something.
1804 # I don't plan to use tox, so, according to https://serverfault.com/a/251091,
1805 # we can create and install a dummy package by:
1807 # "equivs-control <name>, edit the file produced to provide the right
1808 # dependency and have a nice name, then run equivs-build <name> and
1809 # finally dpkg -i the resulting .deb file"
1810 # as of 2023-02, the tox dependency was removed in debian unstable, so
1811 # this hack will probably go away in t12.
1813 case $(debian-codename) in
1816 tmpdir="$(mktemp -d)"
1818 # edited from output of equivs-control tox
1822 Standards-Version: 3.9.2
1824 Description: tox-dummy
1827 sudo dpkg -i tox_1.0_all.deb
1836 # get rid of annoying message
1837 s sed -ri "s/^([[:space:]]*ui.print_\('Playing)/#\1/" /usr/share/beets/beetsplug/play.py
1840 # notes about barrier
1841 # run barrier, do the gui config,
1842 # setup the 2 screens, using hostnames for the new screen.
1843 # save the server config
1844 # $HOME/.local/share/barrier/.barrier.conf
1847 # ssl errors, resolved via advice here: https://github.com/debauchee/barrier/issues/231
1848 # BARRIER_SSL_PATH=~/.local/share/barrier/SSL/
1849 # mkdir -p "${BARRIER_SSL_PATH}"
1850 # openssl req -x509 -nodes -days 365 -subj /CN=Barrier -newkey rsa:4096 -keyout ${BARRIER_SSL_PATH}/Barrier.pem -out ${BARRIER_SSL_PATH}/Barrier.pem
1851 # ran on both machines.
1852 # When pressing start in the gui, the cli options used are printed to the console,
1853 # they are useful. So on server, just run barriers, client run barrierc SERVER_IP
1855 ### begin timetrap setup
1856 if mountpoint /p &>/dev/null; then
1857 mkdir -p ~/.timetrap/
1858 ln -sf /a/opt/timetrap_formatters ~/.timetrap/formatters
1859 if ! type -p t &>/dev/null; then
1860 pi ruby-dev libsqlite3-dev
1861 gem install --user timetrap
1864 ### end timetrap setup
1866 # leftover cleanup for t9
1870 # needed for debootstrap scripts for fai since fai requires debian
1873 pi-nostart network-manager
1874 # i hate networkmanager. noo, of course disabling it doesnt work
1875 # unless you add a hack. found this by doing
1876 # systemd-analyze dot > x.dot
1880 soff NetworkManager-wait-online.service
1881 # make networkmanager use resolvconf instead of its own dnsmasq which
1882 # conflicts with the normal dnsmasq package.
1883 f=/etc/NetworkManager/NetworkManager.conf
1885 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1886 sudo sed -ri '/ *\[main\]/a dns=default' $f
1887 if [[ $m != $(md5sum $f) ]]; then
1888 srestart NetworkManager
1890 # networkmanager has this nasty behavior on flidas: if the machine
1891 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1892 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1894 # This can be manually fixed by stoping dnsmasq,
1895 # then based on whats in /run/dnsmasq/, i see we can run
1896 # s resolvconf -d NetworkManager
1897 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1898 ser disable NetworkManager
1902 # I have no use for avahi,
1903 # had to run this twice when doing manually, i dunno why
1904 soff avahi-daemon ||:
1908 # make my /etc/fonts/conf.d/ get used.
1909 # I have a new sans-serif font there because the default one
1910 # displays l and I as the same char, grrrrr.
1913 pi desktop-file-utils
1914 m /a/bin/distro-setup/mymimes
1916 if type -p dbus-launch >/dev/null; then
1917 # stop autopoping windows when i plug in an android phone.
1918 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1919 # with still 0 exit code.
1920 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1921 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1924 # on grub upgrade, we get prompts unless we do this
1926 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1927 devs+=("$(devbyid $dev),")
1929 devs[-1]=${devs[-1]%,} # jonied by commas
1930 sudo debconf-set-selections <<EOF
1931 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1935 sysd-prom-fail-install dynamicipupdate
1936 sysd-prom-fail-install systemstatus
1937 sysd-prom-fail-install btrfsmaintstop
1938 sgo btrfsmaint.timer
1944 if grep -xFq $HOSTNAME /a/bin/ds/machine_specific/btrbk.hosts; then
1948 # note: to see when a timer was last run,
1952 ### begin prometheus ###
1956 # Font awesome is needed for the alertmanager ui.
1957 pi prometheus-alertmanager prometheus fonts-font-awesome
1958 /c/roles/prom/files/simple/usr/local/bin/fsf-install-prometheus
1960 # make it available for other machines
1961 rsync -a /usr/local/bin/amtool /a/opt/bin
1962 web-conf -p 9091 -f 9090 - apache2 b8.nz <<'EOF'
1965 AuthName "basic_auth"
1967 # htpasswd -c prometheus-htpasswd USERNAME
1968 AuthUserFile "/etc/prometheus-htpasswd"
1973 web-conf -p 9094 -f 9093 - apache2 b8.nz <<'EOF'
1976 AuthName "basic_auth"
1978 # htpasswd -c prometheus-htpasswd USERNAME
1979 AuthUserFile "/etc/prometheus-htpasswd"
1984 # by default, the alertmanager web ui is not enabled other than a page
1985 # that suggests to use the amtool cli. that tool is good, but you cant
1986 # silence things nearly as easily as with the gui.
1987 if [[ ! -e /usr/share/prometheus/alertmanager/ui/index.html ]]; then
1988 # default script didnt work, required some changes to get elm 19.1,
1989 # which is a dependency of the latest alertmanager. I modified
1990 # and copied it into /b/ds. In future, might need some other
1992 #sudo /usr/share/prometheus/alertmanager/generate-ui.sh
1993 sudo /b/ds/generate-ui.sh
1994 ser restart prometheus-alertmanager
1997 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter -l 127.0.0.1
1999 for ser in prometheus-node-exporter prometheus-alertmanager prometheus; do
2000 sysd-prom-fail-install $ser
2005 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter
2009 # user specific file isn't installed until the user exists
2010 if [[ ! -e /etc/prometheus/ssl/prom_node_key.pem ]]; then
2016 # todo, for limiting node exporter http,
2017 # either use iptables or, in
2018 # /etc/default/prometheus-node-exporter
2019 # listen on the wireguard interface
2022 if [[ -e /etc/wireguard/wghole.conf ]]; then
2023 wgip=$(command sudo sed -rn 's,^ *Address *= *([^/]+).*,\1,p' /etc/wireguard/wghole.conf)
2024 # old filename. remove once all hosts are updated.
2025 s rm -fv /etc/apache2/sites-enabled/${HOSTNAME}wg.b8.nz.conf
2026 s bash -x web-conf -i -a $wgip -p 9101 -f 9100 - apache2 ${HOSTNAME}wg.b8.nz <<'EOF'
2029 AuthName "basic_auth"
2031 # htpasswd -c prometheus-export-htpasswd USERNAME
2032 AuthUserFile "/etc/prometheus-export-htpasswd"
2036 # For work, i think we will just use the firewall for hosts in the main data center, and
2037 # vpn for hosts outside it.
2039 # TODO: figure out how to detect the ping failure and try again.
2041 # Binding to the wg interface, it might go down, so always restart, and wait for it on boot.
2042 s mkdir /etc/systemd/system/apache2.service.d
2043 sd /etc/systemd/system/apache2.service.d/restart.conf <<EOF
2045 After=wg-quick@wghole.service
2046 StartLimitIntervalSec=0
2057 ### end prometheus ###
2060 # ### begin bitcoin ###
2064 # sudo install -m 0755 -o root -g root -t /usr/bin /a/opt/bitcoin-27.0/bin/*
2065 # # Note: i leave it to system-status to start and stop bitcoin.
2066 # # note: the bitcoin user & group are setup in fai
2067 # sudo usermod -a -G bitcoin iank
2068 # # todo: make bitcoin have a stable uid/gid
2069 # sudo mkdir -p /var/lib/bitcoind
2070 # sudo chown bitcoin:bitcoin /var/lib/bitcoind
2071 # # 710 comes from the upstream bitcoin unit file
2072 # sudo chmod 710 /var/lib/bitcoind
2073 # # note, there exists
2074 # # /a/bin/ds/disabled/bitcoin
2080 ### begin live streaming ###
2082 # comparing nginx rtmp to icecast
2083 # `mpv --cache=no` had about 2.5 sec latency vs 4 seconds.
2084 # Then I discovered this command which had about .5 sec latency:
2085 #ffplay -f live_flv -fast -x 1280 -y 720 -fflags nobuffer -flags low_delay -strict experimental -vf "setpts=N/60/TB" -af "asetpts=N/60/TB" -noframedrop -i rtmp://url_here
2086 ## a lot of those args arent needed, here is what I ended up with:
2087 # #ffplay -f live_flv -fflags nobuffer -flags low_delay -i rtmp://localhost/live
2089 # A problem with rtmp is that it doesn't support vp8/vp9, requiring the partly patent encumbered h264.
2090 # Looking at alternative protocols: dash & hls are both high latency, I tested dash with the nginx-rtmp
2091 # module and got about 5 seconds of latency, web results imply that is normal.
2093 # Webrtc is what jitsi & bbb use, but an annoying thing is that
2094 # generally requires a web browser with javascript, or some special
2095 # client, and afaik, it has a smaller limit on number of clients.
2097 # Another option is to try rtp/rtsp, there are some servers here:
2098 # https://en.wikipedia.org/wiki/Real-Time_Streaming_Protocol
2101 ## reference for setting up rtmp
2102 # pi nginx libnginx-mod-rtmp
2103 # cat >/etc/nginx/modules-enabled/rtmp.conf <<'EOF'
2104 ## based on https://opensource.com/article/19/1/basic-live-video-streaming-server#comments
2105 ## and https://github.com/arut/nginx-rtmp-module/wiki/Directives
2108 # allow publish 127.0.0.1;
2112 # application live {
2120 ### end live streaming ###
2124 # from https://raw.githubusercontent.com/cli/cli/trunk/docs/install_linux.md
2125 # One time setup afterwards:
2128 # When it gets to the page where it asks to authorize github, the button
2129 # is grayed out. You can just open browser dev tools, inspect the
2130 # button, remove disabled="", then click it and it works.
2132 # Auth token gets saved into /p/c/subdir_files/.local/share/keyrings/
2134 # initial config goes to /home/iank/.config/gh
2135 curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
2136 && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
2137 && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
2138 && sudo apt update \
2139 && sudo apt install gh -y
2144 # remove trisquel banner. it is cool but takes up too much space.
2145 sudo rm -f /etc/update-motd.d/01-banner
2149 sd /etc/cups/client.conf <<'EOF'
2150 ServerName printserver1.office.fsf.org
2157 In mate settings settings, change scrolling to two-finger,
2158 because the default edge scroll doesn\'t work. Originally found this in debian.
2161 # Remove dep that came in with desktop to fix associations.
2162 m pu transmission-gtk
2166 lnf -T /d/vidshare /home/iank/Videos
2170 # # Based on guix manual instructions, also added code to profile.
2171 # # disabled since i'm not using it now.
2173 # if ! type -p guix >/dev/null; then
2175 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
2176 # # added some stuff to envonment.sh for profile based on
2177 # # manual instructions
2178 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
2179 # # echo is to get past prompt
2180 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
2181 # guix install glibc-utf8-locales
2182 # guix package --install guile
2188 m /a/bin/buildscripts/tor-browser
2189 # one root command needed to install
2190 s ln -sf /a/opt/tor-browser/Browser/start-tor-browser /usr/local/bin
2195 web-conf -p 4500 -f 4533 -e ian@iankelling.org apache2 b8.nz
2201 pi-nostart nfs-kernel-server
2203 # todo, this is old, probably needs removing
2204 if [[ $HOSTNAME == tp ]]; then
2205 sd /etc/wireguard/wg0.conf <<EOF
2207 PrivateKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.key)
2208 Address = 10.3.0.2/24, fdfd::2/64
2211 PresharedKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.psk)
2212 PublicKey = 9RnAsJB+ISrA/9lmDKBoT08oBiKwzA64exBBj+rO+ng=
2213 Endpoint = b8.nz:26000
2214 AllowedIPs = 10.3.0.1/24, fdfd::1/64
2215 PersistentKeepalive = 20
2217 sudo systemctl enable wg-quick@wg0
2218 sudo systemctl start wg-quick@wg0
2222 if [[ $HOSTNAME == kw ]]; then
2223 # hosts 1-199. 200+ are dynamic, avoid those
2224 tu /etc/exports <<'EOF'
2225 /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)
2226 /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)
2233 # very temporary fix.
2234 # should be gone in a few days
2235 # https://bugs.launchpad.net/ubuntu/+source/fail2ban/+bug/2055114
2236 case $codename_compat in
2238 if [[ ! -e ~/fail2ban_1.1.0-1_all.deb ]]; then
2240 wget https://launchpad.net/ubuntu/+source/fail2ban/1.1.0-1/+build/28291332/+files/fail2ban_1.1.0-1_all.deb
2241 sudo dpkg -i fail2ban_1.1.0-1_all.deb
2246 case $codename_compat in
2248 # this fails on startup. i don't use resolvconf, so it is totally pointless.
2249 soff unbound-resolvconf.service
2255 # if I was going to create a persistent vm, i might do it like this:
2256 # variant=something # from: virt-install --os-variant list
2257 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
2258 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
2259 # -n some_name --import --os-variant $variant --cpu host-model-only
2262 # for brother HL-2270DW, this worked:
2263 # https://askubuntu.com/questions/1067234/cant-use-wireless-brother-printer-2270dw-ubuntu-18-04
2264 # /a/opt/linux-brprinter-installer-2.2.2-1
2265 # answer n when it asks about uri.
2266 # Then go to cups, delete the existing printer, added on with dnssd url. browsed to
2267 # ppd at /usr/share/ppd/HL2270DW.ppd, which is duplicated at /usr/share/cups/model/HL2270DW.ppd
2268 # ppd file got installed from bash -x ./usr/local/Brother/Printer/HL2270DW/cupswrapper/cupswrap,
2269 # which I downloaded from their driver. but dont do that again, i copied it to /a/opt/HL2270DW.ppd,
2272 # 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.
2273 # Then it was already configured, but if i needed to, go to its web ui, default pass is "access".
2275 ######### begin stuff belonging at the end ##########