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
22 source /a
/bin
/ds
/.bashrc
25 source /a
/bin
/bash-bear-trap
/bash-bear
26 src
="$(readlink -f -- "${BASH_SOURCE[0]}")"; src
=${src%/*} # directory of this file
28 if [[ $EUID == 0 ]]; then
29 echo "$0: error: run as regular user" >&2
34 echo 1 >~
/.local
/distro-end
37 # shellcheck source=./pkgs
40 echo "$0: $(date) starting now)"
41 # see example of usage to understand.
44 IFS
= read -r -d '' y ||
:
49 echo 0 >~
/.local
/distro-end
50 if $pending_reboot; then
51 echo "$0: pending reboot and then finished. doing it now."
52 echo "exiting with status 0"
55 echo "$0: $(date): ending now)"
56 echo "exiting with status 0"
62 printf "$pre sudo %s\n" "$*"
63 SUDOD
="$PWD" command sudo
"$@";
65 m
() { printf "$pre %s\n" "$*"; "$@"; }
66 e
() { printf "$pre %s\n" "$*"; }
68 codename
=$
(debian-codename
)
69 codename_compat
=$
(debian-codename-compat
)
71 sed="sed --follow-symlinks"
73 # when we schroot, it will fail if we are in a directory that doesnt exist in the chroot
83 # get sudo pass cached right away
84 if ! sudo
-nv 2>/dev
/null
; then
90 # old repo. remove when all machines updated
91 sudo
rm -fv /etc
/apt
/sources.list.d
/wireguard-ubuntu-wireguard-bionic.list
93 sudo
rm -fv /etc
/apt
/preferences.d
/minetest
102 sudo debconf-set-selections
<<EOF
103 popularity-contest popularity-contest/participate boolean true
106 ########### begin section including vps ################
113 # no equivalent in other distros:
114 if isdeb
&& pcheck apt-file
; then
115 # this condition is just a speed optimization
124 # allows me to pipe with ssh -t, and gets rid of spam
125 # http://forums.debian.net/viewtopic.php?f=5&t=85822
126 # i'd rather disable the service than comment the init file
127 # this says disabling the service, it will still get restarted
128 # but this script doesn't do anything on restart, so it should be fine
129 sudo truncate
-s0 /var
/run
/motd.dynamic
132 # this isn't a complete solution. It still shows me when updates are available,
133 # but it's no big deal.
134 sudo
rm -fv /etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
143 ######### begin universal pinned packages ######
144 case $
(debian-codename
) in
145 etiona|flidas|nabia|aramo
)
146 sudo
rm -fv /etc
/apt
/preferences.d
/etiona-buster
147 sd
/etc
/apt
/preferences.d
/trisquel-debian
<<EOF
148 Explanation: Debian* includes Debian + Debian Backports
150 Pin: release o=Debian*
153 Explanation: ubuntu's version is outdated
154 Package: debian-archive-keyring
155 Pin: release o=Debian*
162 #p install --no-install-recommends minetest/buster libleveldb1d/buster libncursesw6/buster libtinfo6/buster
164 # shellcheck disable=SC2043 # in case we want more than 1 in the loop later.
165 for n
in bookworm
; do
166 f
=/etc
/apt
/sources.list.d
/$n.list
171 deb http://deb.debian.org/debian bookworm main
172 deb-src http://deb.debian.org/debian bookworm main
174 deb http://deb.debian.org/debian-security/ bookworm-security main
175 deb-src http://deb.debian.org/debian-security/ bookworm-security main
177 deb http://deb.debian.org/debian bookworm-updates main
178 deb-src http://deb.debian.org/debian bookworm-updates main
180 deb http://http.debian.net/debian bookworm-backports main
181 deb-src http://http.debian.net/debian bookworm-backports main
186 if ! diff -q $t $f; then
196 # cant apt get the keyring without doing an update, can't update
197 # without the keyring, this is a stupid chicken and egg problem
198 # that apt should have some feature to solve, but doesn't as far
200 f
=debian-archive-keyring_2023.3
+deb12u1_all.deb
201 wget http
://ftp.debian.org
/debian
/pool
/main
/d
/debian-archive-keyring
/$f
208 if [[ ! -e /usr
/share
/debootstrap
/scripts
/bookworm
]]; then
211 m aptitude download debootstrap
/bookworm
213 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
218 sd
/etc
/apt
/preferences.d
/focal
<<'EOF'
220 Pin: release n=focal,o=Ubuntu
224 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
225 Package: spamassassin sa-compile spamc
226 Pin: release n=focal,o=Ubuntu
229 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
230 Package: spamassassin sa-compile spamc
231 Pin: release n=focal,o=Ubuntu
234 sd
/etc
/apt
/preferences.d
/psd
<<'EOF'
235 Package: profile-sync-daemon
236 Pin: release n=focal,o=Ubuntu
240 f
=/etc
/apt
/sources.list.d
/focal.list
243 deb http://us.archive.ubuntu.com/ubuntu/ focal main universe
244 deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main universe
245 deb http://us.archive.ubuntu.com/ubuntu/ focal-security main universe
247 if ! diff -q $t $f; then
248 sudo
dd if=$t of
=$f status
=none
254 sd
/etc
/apt
/preferences.d
/nabia-etiona
<<'EOF'
256 Pin: release n=nabia*,o=Trisquel
260 f
=/etc
/apt
/sources.list.d
/nabia.list
263 deb http://mirror.fsf.org/trisquel/ nabia main
264 deb-src http://mirror.fsf.org/trisquel/ nabia main
266 deb http://mirror.fsf.org/trisquel/ nabia-updates main
267 deb-src http://mirror.fsf.org/trisquel/ nabia-updates main
269 deb http://archive.trisquel.info/trisquel/ nabia-security main
270 deb-src http://archive.trisquel.info/trisquel/ nabia-security main
272 # Uncomment this lines to enable the backports optional repository
273 deb http://mirror.fsf.org/trisquel/ nabia-backports main
274 deb-src http://mirror.fsf.org/trisquel/ nabia-backports main
276 if ! diff -q $t $f; then
277 sudo
dd if=$t of
=$f status
=none
281 # duplicated in fai. Pin for bionic + ubuntu so that ppas dont get
283 sd
/etc
/apt
/preferences.d
/etiona-bionic
<<'EOF'
285 Pin: release n=bionic,o=Ubuntu
288 Pin: release n=bionic,o=Ubuntu
292 sd
/etc
/apt
/preferences.d
/etiona-sa
<<'EOF'
294 Pin: release n=bionic,o=Ubuntu
300 sd
/etc
/apt
/preferences.d
/aramo-nabia
<<'EOF'
302 Pin: release n=aramo*,o=Trisquel
305 f
=/etc
/apt
/sources.list.d
/aramo.list
308 deb http://mirror.fsf.org/trisquel/ aramo main
309 deb-src http://mirror.fsf.org/trisquel/ aramo main
311 deb http://mirror.fsf.org/trisquel/ aramo-updates main
312 deb-src http://mirror.fsf.org/trisquel/ aramo-updates main
314 deb http://archive.trisquel.info/trisquel/ aramo-security main
315 deb-src http://archive.trisquel.info/trisquel/ aramo-security main
317 # Uncomment this lines to enable the backports optional repository
318 deb http://mirror.fsf.org/trisquel/ aramo-backports main
319 deb-src http://mirror.fsf.org/trisquel/ aramo-backports main
321 if ! diff -q $t $f; then
322 sudo
dd if=$t of
=$f status
=none
329 pi debian-goodies shellcheck
334 case $codename_compat in
336 s systemctl
enable --now ssh-agent-iank
340 case $codename_compat in
342 sd
/etc
/apt
/preferences.d
/nabia-btrfs-progs
<<'EOF'
344 Pin: release a=buster-backports
347 p
install btrfs-progs
352 # 2020-03-03 old file
353 s
rm -fv /etc
/apt
/preferences.d
/radicale
354 ######### end universal pinned packages ######
359 sd
/etc
/apt
/preferences.d
/obs
<<EOF
361 Pin: release n=bionic
364 sd
/etc
/apt
/preferences.d
/chromium
<<EOF
366 Pin: release n=bionic
371 # note, to get the latest, it would be n=bullseye*
372 # but that has conflicting package versions, so this does the old one.
373 # I only use it for special rare purposes. Just keep in mind it is an
374 # outdated insecure version.
375 sd
/etc
/apt
/preferences.d
/chromium-bullseye
<<EOF
376 Package: chromium chromium-* libicu67 libjpeg62-turbo libjsoncpp24 libre2-9 libwebpmux3
377 Pin: release o=Debian*,n=bullseye
382 # obs dependency not in trisquel
383 sd
/etc
/apt
/preferences.d
/obs
<<EOF
385 Pin: release n=jammy,o=Ubuntu
393 ##### begin automatic upgrades (after checkrestart has been installed) ####
394 # if apt-config-auto-update is installed,
395 # it also has similar config, in a file 10something,
396 # but i think this overrides it since its higher number.
397 # This file was part of the automatic-updates package,
398 # and it has a config option to not get new package lists,
399 # which seems pretty stupid to me, you cant actually upgrade
400 # anything if you dont have the new package list.
401 sd
/etc
/apt
/apt.conf.d
/20auto-upgrades
<<'EOF'
402 # note: man apt.conf says
403 # /usr/share/doc/apt/examples/configure-index.gz is a configuration file showing
404 # example values for all possible options.
405 # but that is a incorrect.
406 # Periodic and other options are only documented in
407 # /usr/lib/apt/apt.systemd.daily
408 # That filename can be found through poking around in apt daily cronjob.
409 APT::Periodic::Update-Package-Lists "1";
410 APT::Periodic::Download-Upgradeable-Packages "1";
411 # 0 means disabled. I used to set this to 7, however, trisquel doesn't
412 # have an archive of old package versions, so I want to
413 # keep around old versions so I can easily downgrade.
414 APT::Periodic::AutocleanInterval "0";
415 # daily expire old files /var/cache/apt if it gets above this MB
416 APT::Periodic::MaxSize "50000";
417 APT::Periodic::Unattended-Upgrade "1";
420 # fyi: default file has comments about available options,
421 # you may want to read that, do pkx unattended-upgrades
422 # default is just security updates. this list found from reading
423 # match_whitelist_string() in $(which unattended-upgrades)
424 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
425 Unattended-Upgrade::Mail "root";
426 Unattended-Upgrade::MailOnlyOnError "true";
427 Unattended-Upgrade::Remove-Unused-Dependencies "true";
428 Unattended-Upgrade::Origins-Pattern {
429 "o=*,l=*,a=*,c=*,site=*,n=*";
434 sudo
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
/etc
/cron.d
/myupgrade
436 # myupgrade cron exists in /etc/cron.d/ian
438 ##### end automatic upgrades ####
441 # commented in case i want to use this sometime later
442 # sd /etc/apt/preferences.d/buster-backports <<EOF
444 # Pin: release a=buster-backports
449 ###### begin website setup
453 f
=/var
/lib
/bind
/db.b8.nz
454 if [[ ! -e $f ]]; then
458 sudo
/c
/roles
/prom_export
/files
/simple
/usr
/local
/bin
/fsf-install-node-exporter
-l 127.0.0.1
461 web-conf
-p 9101 -f 9100 - apache2
${HOSTNAME}ex.b8.nz
<<'EOF'
464 AuthName "basic_auth"
466 # htpasswd -c prometheus-export-htpasswd USERNAME
467 AuthUserFile "/etc/prometheus-export-htpasswd"
476 # i just dont feel like setting up a special purpose ssh key to do this automatically.
478 # run this once for bk on local machine:
479 # only used for old openvpn setup
480 /a/exe/vpn-mk-client-cert -c bk.b8.nz -b expertpath -n mail li.iankelling.org
490 if [[ ! -L ~
/eggdrop
/eggdrop
]]; then
492 git clone https
://github.com
/eggheads
/eggdrop eggdrop-src
500 # dunno if this is really needed. it was part of the documented eggdrop systemd install script
501 sudo loginctl enable-linger
502 systemctl
--user enable fsysbot
503 systemctl
--user start fsysbot
505 m
/a
/h
/setup.sh iankelling.org
507 # start mumble only when im going to use it, since i dont use it much
508 pi-nostart mumble-server
509 sudo
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
511 # do certificate to avoid warning about unsigned cert,
512 # which is overkill for my use, but hey, I'm cool, I know
514 m web-conf apache2 mumble.iankelling.org
515 sudo
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
517 # general vpn for as needed use
518 vpn-server-setup
-d -r -4 10.5.5 -p 443 -n hole
520 # todo: consider if this should exist for the
522 teeu
/etc
/openvpn
/server
/hole.conf
<<'EOF'
526 # note client-config files are setup in brc2 update-host-info
529 # for adding cert to system with /p
532 #mkc /p/c/machine_specific/$host/filesystem/etc/openvpn/client
533 #vpn-mk-client-cert -b $host -n hole -r iankelling.org
534 #s chown -R iank:iank .
536 # example of adding to remote system 107,
537 # vpn-mk-client-cert -n hole -c 10.2.0.107 -b hd8 iankelling.org
539 # for wireguard hole vpn, use function:
543 # if it is going to want to connect to transmission-daemon on ok
544 # wghole bo 28 10.174.2.2/32
546 # requested from linode via a support ticket.
547 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
548 # ipv6 stuff pieced together
549 # via slightly wrong information from
550 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
551 # https://community.openvpn.net/openvpn/wiki/IPv6
554 # This uses a public /64, but afaik, that is not needed for my
555 # current use case, since I'm doing ipv6 nat, they could be private
556 # and nat to a public address. I'm doing ipv6 nat in order to have 2
557 # vpn clients that externally share the same ip when sending so they
558 # share ip reputation. Note, the eth0 and tunx needed to be
559 # different subnets. On the same, I saw some neighbor packet go
560 # unanswered, tcpdump showed packets getting lost. I tried splitting the
561 # /64, it didn't work but I didn't investigate closely.
564 # not starting as i intend to replace it
565 m vpn-server-setup
-s -i tunmail
-n mail -d -6 2600:3c00
:e002
:3800::/64 2600:3c00
:e002
:3800::1/64
566 sudo
tee /etc
/openvpn
/client-config-mail
/mailclient
<<'EOF'
567 ifconfig-push 10.8.0.4 255.255.255.0
568 ifconfig-ipv6-push 2600:3c00:e002:3800::4/64
570 sudo
tee /etc
/openvpn
/client-config-mail
/expertpath
<<'EOF'
571 ifconfig-push 10.8.0.5 255.255.255.0
572 ifconfig-ipv6-push 2600:3c00:e002:3800::5/64
576 sudo
dd of
=/etc
/systemd
/system
/vpn-mail-forward.service
<<'EOF'
578 Description=Turns on iptables mail nat
579 BindsTo=openvpn-server@mail.service
584 ExecStart=/a/bin/distro-setup/vpn-mail-forward tunmail start
585 ExecStop=/a/bin/distro-setup/vpn-mail-forward tunmail stop
588 RequiredBy=openvpn-server@mail.service
593 # needed for li's local mail delivery.
594 tu
/etc
/hosts
<<<"10.8.0.4 mx.iankelling.org"
596 # wgmail handles this.
597 #sgo vpn-mail-forward.service
599 #sgo openvpn-server@mail
602 # setup let's encrypt cert
603 m web-conf apache2 mail.iankelling.org
604 # TODO, i expanded the above cert manually to mx.iankelling.org, this should be captured
605 # in the automation here. We use mail.iankelling.org as our ehlo name when sending mail
606 # but our mx record is mx.iankelling.org. Initially I was just using mail.iankelling.org,
607 # but the problem is I want multiple ips to be able to identify as mail.iankelling.org,
608 # but a subset to be mx.iankelling.org. Afaik, there is no problem with having
609 # our mail cert be for mail.iankelling.org, and have people connect to mx.ian...,
610 # but it doesn't make logical sense to do this.
611 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
614 a2enmod -q proxy proxy_http
615 domain=cal.iankelling.org
616 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
617 # https://radicale.org/2.1.html
618 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
619 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
621 # this doesn't exactly fit with the documentation.
622 # We need location / to do an auth, it cant be done outside,
623 # in order to pass on X-Remote-User. And we need
624 # the other location in order to remove the /radicale/ for
625 # requests which have it. This could be done with a rewrite,
626 # but i just get something working and call it a day.
631 AuthName "Authentication Required"
632 # setup one time, with root:www-data, 640
633 AuthUserFile "/etc/caldav-htpasswd"
635 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
637 <Location "/radicale/">
638 Options +FollowSymLinks +Multiviews -Indexes
639 RequestHeader set X-Script-Name /radicale/
640 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
641 ProxyPass "http://10.8.0.4:5232/" retry=0
642 ProxyPassReverse "http://10.8.0.4:5232/"
645 # nginx version of above would be:
646 # auth_basic "Not currently available";
647 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
651 ###### begin znc setup #####
654 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
655 # to get into the web interface,
656 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
657 # https://iankelling.org:12533/
658 # login as ian, pass is in pass store, the part after :
660 # znc config generated by doing
662 # selected port is also used in erc config
663 # comma separated channel list worked.
664 # while figuring things out, running znc -D for debug in foreground.
665 # to exit and save config:
666 # /msg *status shutdown
667 # configed auth on freenode by following
668 # https://wiki.znc.in/Sasl:
672 # Set MyNickservName pa$$w0rd
673 # created the system service after, and had to do
674 # mv /home/iank/.znc/* /var/lib/znc
675 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
676 # and made a copy of the config files into /p/c
677 # /msg *status LoadMod --type=global log -sanitize
678 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
679 # /msg *status LoadMod --type=network perform
680 # /query *perform add PRIVMSG ChanServ :invite #fsf-office
681 # /msg *perform add JOIN #fsf-office
682 # /msg *status LoadMod NickServ
685 # also ran /znc LoadMod clearbufferonmsg
686 # it would be nice if erc supported erc query buffers by doing
687 # /msg *status clearbuffer <name of the query/receiver
689 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
690 # if that was the case i could remove the module clearbufferonmsg
691 # also would be nice if erc supported
692 # https://wiki.znc.in/self-message
693 # https://wiki.znc.in/Query_buffers \
695 # for geekshed, there was no sasl support as far as I can tell,
696 # so I set to msg nickserv to identify upon connect.
697 if ! getent passwd znc > /dev/null; then
698 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
700 sudo chmod 700 /var/lib/znc
701 sudo chown -R znc:znc /var/lib/znc
702 # Avoid restarting if possible, reconnecting to irc is annoying.
703 # The unit file was made active with conflink.
704 # Note, avoid using ser here because we wrap sudo to prints the command first.
705 if [[ $(systemctl is-active znc) != active ]]; then
708 ###### stop znc setup #####
717 # todo, save the config
718 /etc/cron.daily/stream-cert
719 web-conf -c /etc/cert-live.fsf.org -p 443 -f 8000 apache2 live.fsf.org
723 ###### end website setup
725 ########### end section including li/lj ###############
730 ### system76 things ###
732 bo) # sy| sy doesnt seem to really need this.
733 # note, i stored the initial popos packages at /a/bin/data/popos-pkgs
734 if [[ ! -e /etc/apt/sources.list.d/system76.list ]]; then
735 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
736 sd /etc/apt/sources.list.d/system76.list <<EOF
737 deb http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
738 deb-src http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
740 # ubuntu keyserver is prone to intermittent failures
741 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5D1F3A80254F6AFBA254FED5ACD442D1C8B7748B
743 # https://support.system76.com/articles/install-ubuntu/
744 # but i'm hoping this is not needed
745 # sd /etc/apt/preferences.d/system76 <<'EOF'
747 # Pin: release o=LP-PPA-system76-dev-stable
751 # TODO: I had to uninstall linux-image-generic-hwe-20.04 because of a conflict
752 # about linux-firmware. Should probably install it to begin with in fai if
754 pi system76-driver system76-firmware
755 # if you get a notice about a firmware update, the notifier on i3
756 # is too dumb to do anything when you click it. so to see
758 # /var/cache/system76-firmware-daemon
759 # extract the xz files there, one will contain a changelog.
760 # then to install an update:
761 # s system76-firmware-cli schedule
765 ### end system76 things ###
771 ## one time setup thing I did
773 # cargo build --release
774 # cp target/release/obs-cmd ../bin
776 ## in obs, tools -> websocket server settings -> generate/copy password
778 # note: obs-studio on gnu does not support webrtc, it seems mainly because
779 # libdatachannel is not packaged. If it was, it would just need to do
780 # apt source obs-studio, obs-studio-30.1.1/debian/rules set -DENABLE_WEBRTC=ON
782 # I did manage to build libdatachannel following its instructions, then make install,
783 # then obs failed due to nvidia. found those options to disable with
784 # rg 'option\(ENABLE' | gr nv, then build obs like so:
786 # 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 ..
790 # however, I didn't end up trying it out.
792 # note, in terminal source, i setup a transform so it would show the
793 # bottom 1080p section of the terminal instead of the top if the
794 # screen was bigger. click like 2 times in the preview so the red
795 # lines show up, right click, edit transform (or ctrl-e). bounding
796 # box type: scale to width of bounds. alignment in bounding box:
797 # bottom left. bounding box size 1920 x 1080.
799 # ppa:obsproject/obs-studio
800 if [[ ! -s /etc/apt/sources.list.d/obs.list ]]; then
801 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
802 sd /etc/apt/sources.list.d/obs.list <<EOF
803 deb http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
804 deb-src http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
806 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BC7345F522079769F5BBE987EFC71127F425E228
813 case $codename_compat in
815 # mate-indicator-applet and beyond are msc things I noticed diffing a
816 # standard install with mine.
817 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
823 # todo: figure out mate for buster
824 # pi task-gnome-desktop
827 # i had installing mate-indicator-applet, but im not sure why so i removed
828 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras anacron
831 # # apt-get update periodically fails with an appstream error.
832 # # this removes gnome-core, but its just a package for dependencies
833 # p -y remove appstream
836 # by default, it sleeps when not logged in to x/wayland and on ac power.
838 if id -u gdm &>/dev/null; then
839 sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
843 # lightdm startup fails without this. on etiona, we got unity-greeter installed automatically,
844 # it would probably work on nabia too, but google just lead me to this and it works fine.
845 pi lightdm-gtk-greeter
846 # ok, this is really weird
847 # normally this file has
848 sd /etc/X11/Xsession.d/99x11-common_start <<'EOF'
850 # this file normally just has: exec $STARTUP
851 # but then ~/.xsession-errors
852 # says $STARTUP is not found, which appears to be the real
853 # error, but normal bash doesnt operate that way.
854 # https://bugs.launchpad.net/ubuntu/+source/im-config/+bug/1879352
857 # also, gdm wayland was default, had to do
858 # dpkg-reconfigure gdm3
859 # and choose lightdm.
863 # not yet bothering with mate
864 pi lightdm-gtk-greeter lightdm
869 if [[ $codename_compat == flidas ]]; then
870 # doesnt exist in newer
879 # firefox would work here too, apt would select abrowser.
880 # and the update-alternatives thing i think is becuz firefox is
881 # generally available before abrowser and this helps fix things
882 # up when we have both.
884 s update-alternatives --set x-www-browser /usr/bin/abrowser
896 # newer distros just use adb for package name it seems
897 case $codename_compat in
899 pi android-tools-adbd
903 case $codename_compat in
905 pi libext2fs-dev libzstd-dev
906 cd /a/opt/btrfs-progs
911 case $codename_compat in
920 # not packaged in newer distros it seems
921 case $codename_compat in
922 bionic|buster|stretch)
928 # TODO: some of the X programs can be removed from pall when using wayland
930 # depends gcc is a way to install suggests. this is apparently the only
931 # way to install suggests even if the main package is already
932 # installed. reinstall doesn't work, uninstalling can cause removing
933 # dependent packages.
934 # shellcheck disable=SC2046 # word splitting is intended
935 pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $($src/distro-pkgs)
937 # schroot service will restart schroot sessions after reboot.
941 # fix systemd unit failure. i dont know of any actual impact
942 # other than systemd showing in degraded state. So, we dont bother
943 # fixing the current state, let it fix on the next reboot.
944 # https://gitlab.com/cjwatson/binfmt-support/-/commit/54f0e1af8a
945 tmp=$(systemctl cat binfmt-support.service | grep ^After=)
946 if [[ $tmp != *systemd-binfmt.service* ]]; then
947 s u /etc/systemd/system/binfmt-support.service.d/override.conf <<EOF
949 $tmp systemd-binfmt.service
954 # commented, not worth the hassle i think.
960 sudo rm -fv /etc/systemd/resolved.conf.d/iank.conf
962 # website is dead june 14 2019. back in october, but meh
963 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
968 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
971 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
972 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
974 # f=/etc/apt/sources.list.d/iridium-browser.list
975 # if ! diff -q $t $f; then
986 if mountpoint /p &>/dev/null; then
987 # note, see bashrc for more documentation.
989 sd /etc/systemd/system/rss2email.service <<'EOF'
991 Description=rss2email
992 After=multi-user.target
997 # about 24 hours of failures
998 # it copies over its files without respecting symlinks, so
999 # we pass options to use different location.
1000 ExecStart=/usr/local/bin/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
1002 sd /etc/systemd/system/rss2email.timer <<'EOF'
1004 Description=rss2email
1007 # for initial run. required.
1009 # for subsequent runs.
1010 OnUnitInactiveSec=300
1013 WantedBy=timers.target
1015 sudo systemctl daemon-reload
1019 ######### begin irc periodic backup #############
1020 if [[ $HOSTNAME == frodo ]]; then
1021 sd /etc/systemd/system/ircbackup.service <<'EOF'
1023 Description=irc li backup
1024 After=multi-user.target
1029 ExecStart=/usr/local/bin/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
1031 sd /etc/systemd/system/ircbackup.timer <<'EOF'
1033 Description=irc li backup hourly
1039 WantedBy=timers.target
1041 sudo systemctl daemon-reload
1046 ######### end irc periodic backup #############
1050 # pi-nostart does not disable
1054 if [[ -e /p/c/gen-fsf-vpn ]]; then
1058 if [[ -e /p/c/machine_specific/$HOSTNAME/filesystem/etc/openvpn/client/hole.crt ]]; then
1059 sgo openvpn-client@hole
1062 ############# begin syncthing setup ###########
1065 f=/usr/share/keyrings/syncthing-archive-keyring.gpg
1066 if [[ ! -e $f ]]; then
1067 s curl -s -o $f https://syncthing.net/release-key.gpg
1069 s="deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable"
1070 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
1071 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
1077 m lnf -T /w/syncthing /home/iank/.config/syncthing
1078 ser daemon-reload # syncthing likely not properly packaged
1079 sgo syncthing@iank # runs as iank
1083 # 1003 just happens to be what was on my system
1084 if ! getent passwd ziva; then
1085 s groupadd -g 1003 ziva
1086 # syncthing state / config / db are all in ~/.config/syncthing
1087 s useradd -g 1003 -u 1003 -d /d/ziva-home -c ziva -s /bin/bash ziva
1093 # user for short term use dropping of privileges
1095 if ! getent group zu &>/dev/null; then
1096 s groupadd -g 1023 zu
1098 if ! getent passwd zu &>/dev/null; then
1099 s useradd -g 1023 -u 1023 -c zu -s /bin/bash zu
1103 # these things persist in ~/.config/syncthing, which I save in
1104 # /w/syncthing (not in /p, because syncthing should continue to
1105 # run on home server even when using laptop as primary device)
1106 # open http://localhost:8384/
1107 # change listen address from default to tcp://:22001,
1108 # this is because we do port forward so it doesn\'t have to use
1109 # some external server, but the syncthing is broken for port forward,
1110 # you get a message, something "like connected to myself, this should not happen"
1111 # when connecting to other local devices, so I bump the port up by 1,
1113 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
1114 # Without this, it was being stuck syncing at 0%.
1115 # Set gui username and password.
1117 # install syncthing via f-droid,
1118 # folder setting, turn off send only.
1119 # on phone, add device, click bar code icon
1120 # on dekstop, top right, actions, device id
1121 # after adding, notification will appear on desktop to confirm
1123 # syncing folder. from phone to desktop: select desktop in the
1124 # folder on phone\'s sync options, notification will appear in
1125 # desktop\'s web ui within a minute. For the reverse, the
1126 # notification will appear in android\'s notifications, you have to
1127 # swipe down and tap it to add the folder. It won\'t appear in the
1128 # syncthing ui, which would be intuitive, but don\'t wait for it
1129 # there. The notification may not work, instead open the web gui
1130 # from in the app, there should be a notification within there.
1132 # On phone, set settings to run syncthing all the time, and
1133 # show no notification.
1135 # Folder versioning would make sense if I didn\'t already use btrfs
1136 # for backups. I would choose staggered, or trash can for more space.
1138 # if needed to install on a remote comp:
1139 # ssh -L 8384:localhost:8384 -N frodo
1140 # open http://localhost:8384/
1142 # Note, the other thing i did was port forward port 22000,
1143 # per https://docs.syncthing.net/users/firewall.html
1145 ############# end syncthing setup ###########
1149 ####### begin misc packages ###########
1151 # old location, 2023.
1152 sudo rm -fv /etc/systemd/system/profanity.service
1155 ln -sfT /d/p/profanity ~/.local/share/profanity
1156 ln -sfT /d/p/profanity-config ~/.config/profanity
1157 source /a/bin/bash_unpublished/source-state
1158 if [[ $HOSTNAME == "$HOST2" || ! -e /p/profanity-here ]]; then
1159 systemctl --user --now enable profanity
1164 ln -sfT /p/profanity ~/.local/share/profanity
1165 ln -sfT /p/profanity-config ~/.config/profanity
1176 sudo update-alternatives --set pinentry /usr/bin/pinentry-gtk-2
1179 # sakura config is owned by ian
1182 m sudo -u user2 -i reset-konsole
1183 # user2 xscreensaver we don't want to reset
1184 m reset-xscreensaver
1187 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
1188 # this is also in primary-setup
1189 # pi libxss-dev # dependency based on build failure
1191 # cabal install --upgrade-dependencies --force-reinstalls arbtt
1192 # also, i assume syncing this between machines somehow messed up the data.
1194 ## not using arbtt for now
1195 # if mountpoint /p &>/dev/null; then
1199 # # same as seru enable arbtt, but works over ssh when systemctl --user causes error:
1200 # # Failed to connect to bus: No such file or directory
1201 # lnf -T /a/bin/ds/subdir_files/.config/systemd/user/arbtt.service /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1203 # seru start arbtt ||:
1207 rm -fv /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1212 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
1213 m cp /p/.linphonerc-initial ~/.linphonerc
1216 # linphone in t10 wont do dns with systemd-resolved or something
1217 s teeu /etc/hosts <<'EOF'
1218 74.94.156.215 watson.fsf.org
1223 ### begin spd install
1224 if mountpoint /p &>/dev/null; then
1225 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
1227 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
1230 # this guesses at the appropriate directory, adjust if needed
1231 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
1232 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
1233 # newer distro had gpg2 as default, older one, flidas, need to make it that way
1234 gpgpath=$(which gpg2) ||:
1235 if [[ $gpgpath ]]; then
1236 sudo mkdir -p /usr/local/spdhackfix
1237 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
1243 # nagstamon setting which were set through the ui
1244 # monitor url https://klaxon.fsf.org/cgi-bin
1245 # monitor url cgi https://klaxon.fsf.org/cgi-bin
1247 # all unknown services
1248 # all warning services
1249 # acknowledged hosts & services
1250 # hosts & services down for maintenence
1251 # services on down hosts
1252 # services on hosts in maintenece
1253 # services on unreachable osts
1254 # hosts in soft state
1255 # services in soft state
1256 # in display tab: fullscreen
1258 # these translate to these settings I think
1259 # filter_acknowledged_hosts_services = True
1260 # filter_all_unknown_services = True
1261 # filter_all_warning_services = True
1262 # filter_hosts_in_soft_state = True
1263 # filter_hosts_services_maintenance = True
1264 # filter_services_in_soft_state = True
1265 # filter_services_on_down_hosts = True
1266 # filter_services_on_hosts_in_maintenance = True
1267 # filter_services_on_unreachable_hosts = True
1268 # notify_if_up = False
1269 # statusbar_floating = False
1271 # but i'm just going to rely on the webpage plus sms for now.
1274 # it asks if it should make users in it's group capture packets without root,
1275 # which is arguably more secure than running wireshark as root. default is no,
1276 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
1277 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
1279 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
1280 # listed in the default config as suggested.
1281 # /run/usr/1000 i noticed was missing for pulseaudio
1282 # /run/user/0 just seemed like a not bad idea, given the above
1283 tu /etc/schroot/desktop/fstab <<'EOF'
1284 /p /p none rw,bind 0 0
1285 /a /a none rw,bind 0 0
1286 /run /run none rw,bind 0 0
1287 /run/lock /run/lock none rw,bind 0 0
1288 /dev/shm /dev/shm none rw,bind 0 0
1289 /run/shm /run/shm none rw,bind 0 0
1290 /run/user/1000 /run/user/1000 none rw,bind 0 0
1291 /run/user/1001 /run/user/1001 none rw,bind 0 0
1292 /run/user/0 /run/user/0 none rw,bind 0 0
1295 # todo: consider if this should use the new sysd-prom-fail
1296 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1298 Description=schrootupdate
1299 After=multi-user.target
1303 ExecStart=/usr/local/bin/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1305 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1307 Description=schrootupdate
1310 OnCalendar=*-*-* 04:20:00 America/New_York
1313 WantedBy=timers.target
1316 sgo schrootupdate.timer
1323 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/bookworm.list/BOOKWORM_FREE \
1324 debian bookworm firefox-esr pulseaudio chromium
1331 sudo mkdir -p /nocow/user
1332 sudo chown $USER:$USER /nocow/user
1336 ####### begin transmission
1346 tdir=/nocow/user/tor
1352 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1353 # 450 seems likely to be unused. we need to specify one or else
1354 # it won't be stable across installs.
1355 if ! getent passwd debian-transmission > /dev/null; then
1356 sudo groupadd -g 450 debian-transmission
1357 sudo adduser --quiet \
1362 --disabled-password \
1363 --home /var/lib/transmission-daemon \
1366 # We want group writable stuff from transmission.
1367 # However, after setting this, I learn that transmission sets it's
1368 # own umask based on it's settings file. Well, no harm leaving this
1369 # so it's set right from the beginning.
1370 sudo chfn debian-transmission -o umask=0002
1372 # note i had to do this, which is persistent:
1374 # s chgrp debian-transmission torrents partial-torrents
1376 # syslog says things like
1377 # 'Failed to set receive buffer: requested 4194304, got 425984'
1378 # google suggets giving it even more than that
1379 tu /etc/sysctl.conf<<'EOF'
1380 net.core.rmem_max = 67108864
1381 net.core.wmem_max = 16777216
1385 # some reason it doesn\'t seem to start automatically anyways
1386 pi-nostart transmission-daemon
1387 # be extra sure its not started
1388 ser disable transmission-daemon
1389 ser stop transmission-daemon
1391 # the folder was moved here after an install around 02/2017.
1392 # it contains runtime data,
1393 # plus a simple symlink to the config file which it\'s
1394 # not worth separating out.
1395 # between comps, the uid can change
1397 f=$tdir/transmission-daemon
1398 for d in $tdir/partial-torrents $tdir/torrents $f; do
1399 if [[ ! -d $d ]]; then
1402 sudo chown -R debian-transmission:user2 $d
1404 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1405 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1406 sudo chown -R debian-transmission:debian-transmission $f
1407 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1409 # config file documented here, and it\'s the same config
1410 # for daemon vs client, so it\'s documented in the gui.
1411 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1413 # I originaly setup rpc-whitelist, but after using
1414 # routing to a network namespace, it doesn\'t see the
1415 # real source address, so it\'s disabled.
1417 # Changed the cache-size to 256 mb, reduces disk use.
1418 # It is a read & write cache.
1420 # just fyi: default rpc port is 9091
1421 if ! systemctl is-active transmission-daemon-nn &>/dev/null && \
1422 ! systemctl is-active transmission-daemon; then
1424 command sudo ruby <<EOF >$tmp
1426 p = '/etc/transmission-daemon/settings.json'
1428 'rpc-whitelist-enabled' => false,
1429 'rpc-authentication-required' => false,
1430 'incomplete-dir' => '$tdir/partial-torrents',
1431 'incomplete-dir-enabled' => true,
1432 'download-dir' => '$tdir/torrents',
1433 "speed-limit-up" => 800,
1434 "speed-limit-up-enabled" => true,
1435 "peer-port" => 61486,
1436 "cache-size-mb" => 256,
1437 "ratio-limit" => 5.0,
1438 "ratio-limit-enabled" => false,
1440 puts(JSON.pretty_generate(JSON.parse(File.read(p)).merge(s)))
1442 cat $tmp | sudo dd of=/etc/transmission-daemon/settings.json
1446 ####### end transmission
1450 # to persist upload/dl metadata. initially, moved all the stuff
1451 # in /var/lib/transmission-daemon to /d/tor
1452 s usermod --home /d/tor debian-transmission
1453 sgo transmission-daemon-nn
1459 ######### begin transmission client setup ######
1461 # to connect from a remote client, trans-remote-route in brc2
1464 if [[ -e /p/transmission-rpc-pass ]]; then
1465 # arch had a default config,
1466 # debian had nothing until you start it.
1467 # With a little trial an error, here is a minimal config
1468 # taken from the generated one, plus changes that the
1469 # settings ui does, without a bunch of ui crap settings.
1471 # only settings I set were
1476 # the password is randomly generated on first run, i copied it out
1477 # so it could be used by other hosts.
1480 p = '/etc/transmission-daemon/settings.json'
1481 s = JSON.parse(File.read(p))
1482 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1483 # default is 0022 (18 in decimal)
1485 File.write p, JSON.pretty_generate(s)
1488 rpc_pass=$(</p/transmission-rpc-pass)
1489 for f in /home/*; do
1491 uid=$(id -u $u 2>/dev/null) || continue
1492 if [[ ! $uid -ge 1000 ]]; then
1495 d=$f/.config/transmission-remote-gtk
1496 sudo -u $u mkdir -p $d
1497 # i tried setting hostname to transmission.b8.nz, so i could dynamically change where
1498 # this connects to, but it said some 421 denied error when I did that. Then it
1499 # froze X when i ran it under strace. Whatever.
1500 sudo -u $u dd of=$d/config.json <<EOF
1504 "profile-name" : "Default",
1505 "hostname" : "10.174.2.2",
1506 "rpc-url-path" : "/transmission/rpc",
1508 "password" : "$rpc_pass",
1509 "auto-connect" : true,
1513 "update-active-only" : false,
1514 "activeonly-fullsync-enabled" : false,
1515 "activeonly-fullsync-every" : 2,
1516 "update-interval" : 3,
1517 "min-update-interval" : 3,
1518 "session-update-interval" : 60,
1519 "exec-commands" : [],
1524 "add-options-dialog" : false
1529 ######### end transmission client setup ######
1535 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1536 # goto http://127.0.0.1:631
1537 # administration tab, add new printer button.
1538 # In debian, I could use hte recommended driver,
1539 # in arch, I had to pick out the 6L driver.
1542 # bridge networking as user fails. google lead here, but it doesn\'t work:
1543 # oh well, I give up.
1544 # http://wiki.qemu.org/Features-Done/HelperNetworking
1546 # f=/etc/qemu/bridge.conf
1550 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1553 # general known for debian/ubuntu, not for fedora
1555 m /a/bin/buildscripts/go
1556 # only needed for rg. cargo takes up 11 gigs, filled up the disk on je.
1557 m /a/bin/buildscripts/rust
1558 m /a/bin/buildscripts/misc
1560 #m /a/bin/buildscripts/pithosfly
1561 #m /a/bin/buildscripts/alacritty
1562 #m /a/bin/buildscripts/kitty
1564 pi-nostart virtinst virt-manager
1566 # i cant if this is whats causing it to start even though
1567 # its disabled. note: it leaves around dnsmasq instances even
1568 # if you stop it. what the hell systemd?
1570 # allow user to run vms, from debian handbook. libvirt-qemu
1571 # based on https://www.whonix.org/wiki/KVM#First-time_User.3F
1572 for x in iank user2; do s usermod -a -G libvirt,kvm,libvirt-qemu $x; done
1575 pi --no-install-recommends kdeconnect
1576 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1577 ### but gnome + xmonad not working in flidas, so i disabled it
1578 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1579 # cd /a/opt/indicator-kdeconnect
1582 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1585 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1586 # # it seems, according to
1587 # # /etc/xdg/autostart/kdeconnectd.desktop
1588 # # I'm not seeing the icon, but the clipboard replication is working
1591 ### begin model 01 arduino support ###
1592 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1593 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1594 # set arduino var in bashrc,
1595 # have system config file setup too.
1596 sudo adduser $USER dialout
1599 # download arduino ide, extract in /a/opt, ignore the install script, run ./arduino,
1600 # toolbar, preferences, add board manager url:
1601 # https://raw.githubusercontent.com/keyboardio/boardsmanager/master/package_keyboardio_index.json
1602 # toolbar, board manager, add keyboardio
1603 # toolbar, select model01 board
1604 # toolbar, examples, model01, compile
1608 # this is for the mail command too. update-alternatives is kind of misleading
1609 # since at least it's main commands pretend mail does not exist.
1610 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1611 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1613 ######### end misc packages #########
1616 # packages I once used before and liked, but don\'t want installed now for
1618 # python-sqlite is used for offlineimap
1619 # lxappearance python-sqlite dolphin paman dconf-editor
1625 # todo, finish configuring smart.
1628 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1629 # turn on smart. background on options:
1630 # first line, -a = test everyting on all devices.
1631 # -S on, turn on disk internal saving of vendor specific info,
1632 # from google, seems like this is usually already on and fairly standard.
1633 # -o on, turn on 4 hour period non-performance degrading testing.
1634 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1635 sched="-s (S/../.././02|L/../../6/03)"
1636 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1637 DEVICESCAN -a -o on -S on -n standby,q $sched \
1638 -m root@mail.iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1640 # in the default configuration of at least ubuntu 14.04, resolvconf is
1641 # configured to order any nameservers associated with tun* or tap*
1642 # before the normal internet interfaces, which means they are always
1643 # consulted first. This is often slower and undesirable, ie. local dns
1644 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1646 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1647 # however, this breaks dns lookup for hosts on the openvpn lan.
1648 # I can\'t figure out why hosts on the normal lan would not be
1649 # broken under the default ordering, except the host I was
1650 # testing with previously had an entry in /etc/hosts.
1652 ############# end unfinished
1654 ########### misc stuff
1657 xdg-settings set default-web-browser abrowser.desktop
1659 # xdg-settings get default-web-browser
1661 # pressing tab after sdf here:
1662 # scp sdfbash: set +o noglob: command not found
1663 # in t11, bash 5.1.16. this fixes it.
1664 sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
1666 rm -fv /home/iank/.mpv/watch_later
1667 rm -rf /home/iank/.mpv
1669 if [[ ! -e ~/.local/bin/pip ]]; then
1671 wget -O$tmp https://bootstrap.pypa.io/get-pip.py
1677 # soo, apt install beets fails due to wanting a pip package,
1678 # we find out why it wants this through
1679 # apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances beets | less
1680 # python-mediafile requires tox, which requires virtualenv, which requires pip.
1681 # but, python-mediafile doesn't really require tox, it is specified in
1682 # ./usr/lib/python3/dist-packages/mediafile-0.9.0.dist-info/METADATA
1683 # as being required only for testing, but the debian package
1684 # included it anyways, due to a mistake or bad tooling or something.
1685 # I don't plan to use tox, so, according to https://serverfault.com/a/251091,
1686 # we can create and install a dummy package by:
1688 # "equivs-control <name>, edit the file produced to provide the right
1689 # dependency and have a nice name, then run equivs-build <name> and
1690 # finally dpkg -i the resulting .deb file"
1691 # as of 2023-02, the tox dependency was removed in debian unstable, so
1692 # this hack will probably go away in t12.
1694 if pcheck beets; then
1695 tmpdir="$(mktemp -d)"
1697 # edited from output of equivs-control tox
1701 Standards-Version: 3.9.2
1703 Description: tox-dummy
1706 sudo dpkg -i tox_1.0_all.deb
1708 pi beets python3-discogs-client
1713 # get rid of annoying message
1714 s sed -ri "s/^([[:space:]]*ui.print_\('Playing)/#\1/" /usr/share/beets/beetsplug/play.py
1717 # notes about barrier
1718 # run barrier, do the gui config,
1719 # setup the 2 screens, using hostnames for the new screen.
1720 # save the server config
1721 # $HOME/.local/share/barrier/.barrier.conf
1724 # ssl errors, resolved via advice here: https://github.com/debauchee/barrier/issues/231
1725 # BARRIER_SSL_PATH=~/.local/share/barrier/SSL/
1726 # mkdir -p "${BARRIER_SSL_PATH}"
1727 # openssl req -x509 -nodes -days 365 -subj /CN=Barrier -newkey rsa:4096 -keyout ${BARRIER_SSL_PATH}/Barrier.pem -out ${BARRIER_SSL_PATH}/Barrier.pem
1728 # ran on both machines.
1729 # When pressing start in the gui, the cli options used are printed to the console,
1730 # they are useful. So on server, just run barriers, client run barrierc SERVER_IP
1732 ### begin timetrap setup
1733 if mountpoint /p &>/dev/null; then
1734 mkdir -p ~/.timetrap/
1735 ln -sf /a/opt/timetrap_formatters ~/.timetrap/formatters
1736 if ! type -p t &>/dev/null; then
1737 pi ruby-dev libsqlite3-dev
1738 gem install --user timetrap
1741 ### end timetrap setup
1743 # leftover cleanup for t9
1747 # needed for debootstrap scripts for fai since fai requires debian
1750 pi-nostart network-manager
1751 # i hate networkmanager. noo, of course disabling it doesnt work
1752 # unless you add a hack. found this by doing
1753 # systemd-analyze dot > x.dot
1757 soff NetworkManager-wait-online.service
1758 # make networkmanager use resolvconf instead of its own dnsmasq which
1759 # conflicts with the normal dnsmasq package.
1760 f=/etc/NetworkManager/NetworkManager.conf
1762 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1763 sudo sed -ri '/ *\[main\]/a dns=default' $f
1764 if [[ $m != $(md5sum $f) ]]; then
1765 srestart NetworkManager
1767 # networkmanager has this nasty behavior on flidas: if the machine
1768 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1769 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1771 # This can be manually fixed by stoping dnsmasq,
1772 # then based on whats in /run/dnsmasq/, i see we can run
1773 # s resolvconf -d NetworkManager
1774 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1775 ser disable NetworkManager
1779 # I have no use for avahi,
1780 # had to run this twice when doing manually, i dunno why
1781 soff avahi-daemon ||:
1785 # make my /etc/fonts/conf.d/ get used.
1786 # I have a new sans-serif font there because the default one
1787 # displays l and I as the same char, grrrrr.
1790 pi desktop-file-utils
1791 m /a/bin/distro-setup/mymimes
1793 if type -p dbus-launch >/dev/null; then
1794 # stop autopoping windows when i plug in an android phone.
1795 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1796 # with still 0 exit code.
1797 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1798 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1801 # on grub upgrade, we get prompts unless we do this
1803 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1804 devs+=("$(devbyid $dev),")
1806 devs[-1]=${devs[-1]%,} # jonied by commas
1807 sudo debconf-set-selections <<EOF
1808 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1812 sysd-prom-fail-install dynamicipupdate
1813 sysd-prom-fail-install systemstatus
1814 sysd-prom-fail-install btrfsmaintstop
1815 sgo btrfsmaint.timer
1821 if grep -xFq $HOSTNAME /a/bin/ds/machine_specific/btrbk.hosts; then
1825 # note: to see when a timer was last run,
1829 ### begin prometheus ###
1833 # Font awesome is needed for the alertmanager ui.
1834 pi prometheus-alertmanager prometheus fonts-font-awesome
1835 /c/roles/prom/files/simple/usr/local/bin/fsf-install-prometheus
1836 # make it available for other machines
1837 rsync -a /usr/local/bin/amtool /a/opt/bin
1838 web-conf -p 9091 -f 9090 - apache2 b8.nz <<'EOF'
1841 AuthName "basic_auth"
1843 # htpasswd -c prometheus-htpasswd USERNAME
1844 AuthUserFile "/etc/prometheus-htpasswd"
1849 web-conf -p 9094 -f 9093 - apache2 b8.nz <<'EOF'
1852 AuthName "basic_auth"
1854 # htpasswd -c prometheus-htpasswd USERNAME
1855 AuthUserFile "/etc/prometheus-htpasswd"
1860 # by default, the alertmanager web ui is not enabled other than a page
1861 # that suggests to use the amtool cli. that tool is good, but you cant
1862 # silence things nearly as easily as with the gui.
1863 if [[ ! -e /usr/share/prometheus/alertmanager/ui/index.html ]]; then
1864 # default script didnt work, required some changes to get elm 19.1,
1865 # which is a dependency of the latest alertmanager. I modified
1866 # and copied it into /b/ds. In future, might need some other
1868 #sudo /usr/share/prometheus/alertmanager/generate-ui.sh
1869 sudo /b/ds/generate-ui.sh
1870 ser restart prometheus-alertmanager
1873 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter -l 127.0.0.1
1875 for ser in prometheus-node-exporter prometheus-alertmanager prometheus; do
1876 sysd-prom-fail-install $ser
1881 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter
1885 # cleanup old files. 2023-02
1886 x=(/var/lib/prometheus/node-exporter/*.premerge)
1887 if [[ -e ${x[0]} ]]; then
1888 s rm /var/lib/prometheus/node-exporter/*
1893 # todo, for limiting node exporter http,
1894 # either use iptables or, in
1895 # /etc/default/prometheus-node-exporter
1896 # listen on the wireguard interface
1899 if [[ -e /etc/wireguard/wghole.conf ]]; then
1900 wgip=$(command sudo sed -rn 's,^ *Address *= *([^/]+).*,\1,p' /etc/wireguard/wghole.conf)
1901 # old filename. remove once all hosts are updated.
1902 s rm -fv /etc/apache2/sites-enabled/${HOSTNAME}wg.b8.nz.conf
1903 s bash -x web-conf -i -a $wgip -p 9101 -f 9100 - apache2 ${HOSTNAME}wg.b8.nz <<'EOF'
1906 AuthName "basic_auth"
1908 # htpasswd -c prometheus-export-htpasswd USERNAME
1909 AuthUserFile "/etc/prometheus-export-htpasswd"
1913 # For work, i think we will just use the firewall for hosts in the main data center, and
1914 # vpn for hosts outside it.
1916 # TODO: figure out how to detect the ping failure and try again.
1918 # Binding to the wg interface, it might go down, so always restart, and wait for it on boot.
1919 s mkdir /etc/systemd/system/apache2.service.d
1920 sd /etc/systemd/system/apache2.service.d/restart.conf <<EOF
1922 After=wg-quick@wghole.service
1923 StartLimitIntervalSec=0
1934 ### end prometheus ###
1936 ### begin bitcoin ###
1940 sudo install -m 0755 -o root -g root -t /usr/bin /a/opt/bitcoin-27.0/bin/*
1941 # Note: i leave it to system-status to start and stop bitcoin.
1942 # note: the bitcoin user & group are setup in fai
1943 sudo usermod -a -G bitcoin iank
1944 # todo: make bitcoin have a stable uid/gid
1945 sudo mkdir -p /var/lib/bitcoind
1946 sudo chown bitcoin:bitcoin /var/lib/bitcoind
1947 # 710 comes from the upstream bitcoin unit file
1948 sudo chmod 710 /var/lib/bitcoind
1949 # note, there exists
1950 # /a/bin/ds/disabled/bitcoin
1956 ### begin live streaming ###
1958 # comparing nginx rtmp to icecast
1959 # `mpv --cache=no` had about 2.5 sec latency vs 4 seconds.
1960 # Then I discovered this command which had about .5 sec latency:
1961 #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
1962 ## a lot of those args arent needed, here is what I ended up with:
1963 # #ffplay -f live_flv -fflags nobuffer -flags low_delay -i rtmp://localhost/live
1965 # A problem with rtmp is that it doesn't support vp8/vp9, requiring the partly patent encumbered h264.
1966 # Looking at alternative protocols: dash & hls are both high latency, I tested dash with the nginx-rtmp
1967 # module and got about 5 seconds of latency, web results imply that is normal.
1969 # Webrtc is what jitsi & bbb use, but an annoying thing is that
1970 # generally requires a web browser with javascript, or some special
1971 # client, and afaik, it has a smaller limit on number of clients.
1973 # Another option is to try rtp/rtsp, there are some servers here:
1974 # https://en.wikipedia.org/wiki/Real-Time_Streaming_Protocol
1977 ## reference for setting up rtmp
1978 # pi nginx libnginx-mod-rtmp
1979 # cat >/etc/nginx/modules-enabled/rtmp.conf <<'EOF'
1980 ## based on https://opensource.com/article/19/1/basic-live-video-streaming-server#comments
1981 ## and https://github.com/arut/nginx-rtmp-module/wiki/Directives
1984 # allow publish 127.0.0.1;
1988 # application live {
1996 ### end live streaming ###
2000 # from https://raw.githubusercontent.com/cli/cli/trunk/docs/install_linux.md
2001 # One time setup afterwards:
2004 # When it gets to the page where it asks to authorize github, the button
2005 # is grayed out. You can just open browser dev tools, inspect the
2006 # button, remove disabled="", then click it and it works.
2008 # Auth token gets saved into /p/c/subdir_files/.local/share/keyrings/
2010 # initial config goes to /home/iank/.config/gh
2011 curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
2012 && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
2013 && 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 \
2014 && sudo apt update \
2015 && sudo apt install gh -y
2020 # remove trisquel banner. it is cool but takes up too much space.
2021 sudo rm -f /etc/update-motd.d/01-banner
2025 sd /etc/cups/client.conf <<'EOF'
2026 ServerName printserver1.office.fsf.org
2033 In mate settings settings, change scrolling to two-finger,
2034 because the default edge scroll doesn\'t work. Originally found this in debian.
2037 # Remove dep that came in with desktop to fix associations.
2038 m pu transmission-gtk
2042 lnf -T /d/vidshare /home/iank/Videos
2046 # # Based on guix manual instructions, also added code to profile.
2047 # # disabled since i'm not using it now.
2049 # if ! type -p guix >/dev/null; then
2051 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
2052 # # added some stuff to envonment.sh for profile based on
2053 # # manual instructions
2054 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
2055 # # echo is to get past prompt
2056 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
2057 # guix install glibc-utf8-locales
2058 # guix package --install guile
2064 m /a/bin/buildscripts/tor-browser
2065 # one root command needed to install
2066 s ln -sf /a/opt/tor-browser/Browser/start-tor-browser /usr/local/bin
2071 web-conf -p 4500 -f 4533 -e ian@iankelling.org apache2 b8.nz
2077 pi-nostart nfs-kernel-server
2079 # todo, this is old, probably needs removing
2080 if [[ $HOSTNAME == tp ]]; then
2081 sd /etc/wireguard/wg0.conf <<EOF
2083 PrivateKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.key)
2084 Address = 10.3.0.2/24, fdfd::2/64
2087 PresharedKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.psk)
2088 PublicKey = 9RnAsJB+ISrA/9lmDKBoT08oBiKwzA64exBBj+rO+ng=
2089 Endpoint = b8.nz:26000
2090 AllowedIPs = 10.3.0.1/24, fdfd::1/64
2091 PersistentKeepalive = 20
2093 sudo systemctl enable wg-quick@wg0
2094 sudo systemctl start wg-quick@wg0
2098 if [[ $HOSTNAME == kw ]]; then
2099 # hosts 1-199. 200+ are dynamic, avoid those
2100 tu /etc/exports <<'EOF'
2101 /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)
2102 /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)
2110 # if I was going to create a persistent vm, i might do it like this:
2111 # variant=something # from: virt-install --os-variant list
2112 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
2113 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
2114 # -n some_name --import --os-variant $variant --cpu host-model-only
2117 # for brother HL-2270DW, this worked:
2118 # https://askubuntu.com/questions/1067234/cant-use-wireless-brother-printer-2270dw-ubuntu-18-04
2119 # /a/opt/linux-brprinter-installer-2.2.2-1
2120 # answer n when it asks about uri.
2121 # Then go to cups, delete the existing printer, added on with dnssd url. browsed to
2122 # ppd at /usr/share/ppd/HL2270DW.ppd, which is duplicated at /usr/share/cups/model/HL2270DW.ppd
2123 # ppd file got installed from bash -x ./usr/local/Brother/Printer/HL2270DW/cupswrapper/cupswrap,
2124 # which I downloaded from their driver. but dont do that again, i copied it to /a/opt/HL2270DW.ppd,
2127 # 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.
2128 # Then it was already configured, but if i needed to, go to its web ui, default pass is "access".
2130 ######### begin stuff belonging at the end ##########