2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
5 # shellcheck source=/a/bin/ds/.bashrc
6 export LC_USEBASHRC
=t
; if [[ -s ~
/.bashrc
]]; then . ~
/.bashrc
; fi
9 source /a
/bin
/bash-bear-trap
/bash-bear
10 src
="$(readlink -f -- "${BASH_SOURCE[0]}")"; src
=${src%/*} # directory of this file
12 if [[ $EUID == 0 ]]; then
13 echo "$0: error: run as regular user" >&2
18 echo 1 >~
/.local
/distro-end
21 # shellcheck source=./pkgs
24 echo "$0: $(date) starting now)"
25 # see example of usage to understand.
28 IFS
= read -r -d '' y ||
:
33 echo 0 >~
/.local
/distro-end
34 if $pending_reboot; then
35 echo "$0: pending reboot and then finished. doing it now."
36 echo "exiting with status 0"
39 echo "$0: $(date): ending now)"
40 echo "exiting with status 0"
46 printf "$pre sudo %s\n" "$*"
47 SUDOD
="$PWD" command sudo
"$@";
49 m
() { printf "$pre %s\n" "$*"; "$@"; }
50 e
() { printf "$pre %s\n" "$*"; }
52 codename
=$
(debian-codename
)
53 codename_compat
=$
(debian-codename-compat
)
55 sed="sed --follow-symlinks"
57 # when we schroot, it will fail if we are in a directory that doesnt exist in the chroot
67 # get sudo pass cached right away
68 if ! sudo
-nv 2>/dev
/null
; then
74 # old repo. remove when all machines updated
75 sudo
rm -fv /etc
/apt
/sources.list.d
/wireguard-ubuntu-wireguard-bionic.list
77 sudo
rm -fv /etc
/apt
/preferences.d
/minetest
86 sudo debconf-set-selections
<<EOF
87 popularity-contest popularity-contest/participate boolean true
90 ########### begin section including vps ################
97 # no equivalent in other distros:
98 if isdeb
&& pcheck apt-file
; then
99 # this condition is just a speed optimization
108 # allows me to pipe with ssh -t, and gets rid of spam
109 # http://forums.debian.net/viewtopic.php?f=5&t=85822
110 # i'd rather disable the service than comment the init file
111 # this says disabling the service, it will still get restarted
112 # but this script doesn't do anything on restart, so it should be fine
113 sudo truncate
-s0 /var
/run
/motd.dynamic
116 # this isn't a complete solution. It still shows me when updates are available,
117 # but it's no big deal.
118 sudo
rm -fv /etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
127 ######### begin universal pinned packages ######
128 case $
(debian-codename
) in
129 etiona|flidas|nabia|aramo
)
130 sudo
rm -fv /etc
/apt
/preferences.d
/etiona-buster
131 sd
/etc
/apt
/preferences.d
/trisquel-debian
<<EOF
132 Explanation: Debian* includes Debian + Debian Backports
134 Pin: release o=Debian*
137 Explanation: ubuntu's version is outdated
138 Package: debian-archive-keyring
139 Pin: release o=Debian*
146 #p install --no-install-recommends minetest/buster libleveldb1d/buster libncursesw6/buster libtinfo6/buster
148 # shellcheck disable=SC2043 # in case we want more than 1 in the loop later.
149 for n
in bookworm
; do
150 f
=/etc
/apt
/sources.list.d
/$n.list
157 deb http://deb.debian.org/debian bookworm main
158 deb-src http://deb.debian.org/debian bookworm main
160 deb http://deb.debian.org/debian-security/ bookworm-security main
161 deb-src http://deb.debian.org/debian-security/ bookworm-security main
163 deb http://deb.debian.org/debian bookworm-updates main
164 deb-src http://deb.debian.org/debian bookworm-updates main
166 deb http://http.debian.net/debian bookworm-backports main
167 deb-src http://http.debian.net/debian bookworm-backports main
172 if ! diff -q $t $f; then
181 p download debian-archive-keyring
182 s dpkg
-i debian-archive-keyring
188 if [[ ! -e /usr
/share
/debootstrap
/scripts
/bookworm
]]; then
191 m aptitude download debootstrap
/bookworm
193 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
198 sd
/etc
/apt
/preferences.d
/focal
<<'EOF'
200 Pin: release n=focal,o=Ubuntu
204 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
205 Package: spamassassin sa-compile spamc
206 Pin: release n=focal,o=Ubuntu
209 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
210 Package: spamassassin sa-compile spamc
211 Pin: release n=focal,o=Ubuntu
214 sd
/etc
/apt
/preferences.d
/psd
<<'EOF'
215 Package: profile-sync-daemon
216 Pin: release n=focal,o=Ubuntu
220 f
=/etc
/apt
/sources.list.d
/focal.list
223 deb http://us.archive.ubuntu.com/ubuntu/ focal main universe
224 deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main universe
225 deb http://us.archive.ubuntu.com/ubuntu/ focal-security main universe
227 if ! diff -q $t $f; then
228 sudo
dd if=$t of
=$f status
=none
234 sd
/etc
/apt
/preferences.d
/nabia-etiona
<<'EOF'
236 Pin: release n=nabia*,o=Trisquel
240 f
=/etc
/apt
/sources.list.d
/nabia.list
243 deb http://mirror.fsf.org/trisquel/ nabia main
244 deb-src http://mirror.fsf.org/trisquel/ nabia main
246 deb http://mirror.fsf.org/trisquel/ nabia-updates main
247 deb-src http://mirror.fsf.org/trisquel/ nabia-updates main
249 deb http://archive.trisquel.info/trisquel/ nabia-security main
250 deb-src http://archive.trisquel.info/trisquel/ nabia-security main
252 # Uncomment this lines to enable the backports optional repository
253 deb http://mirror.fsf.org/trisquel/ nabia-backports main
254 deb-src http://mirror.fsf.org/trisquel/ nabia-backports main
256 if ! diff -q $t $f; then
257 sudo
dd if=$t of
=$f status
=none
261 # duplicated in fai. Pin for bionic + ubuntu so that ppas dont get
263 sd
/etc
/apt
/preferences.d
/etiona-bionic
<<'EOF'
265 Pin: release n=bionic,o=Ubuntu
268 Pin: release n=bionic,o=Ubuntu
272 sd
/etc
/apt
/preferences.d
/etiona-sa
<<'EOF'
274 Pin: release n=bionic,o=Ubuntu
280 sd
/etc
/apt
/preferences.d
/aramo-nabia
<<'EOF'
282 Pin: release n=aramo*,o=Trisquel
285 f
=/etc
/apt
/sources.list.d
/aramo.list
288 deb http://mirror.fsf.org/trisquel/ aramo main
289 deb-src http://mirror.fsf.org/trisquel/ aramo main
291 deb http://mirror.fsf.org/trisquel/ aramo-updates main
292 deb-src http://mirror.fsf.org/trisquel/ aramo-updates main
294 deb http://archive.trisquel.info/trisquel/ aramo-security main
295 deb-src http://archive.trisquel.info/trisquel/ aramo-security main
297 # Uncomment this lines to enable the backports optional repository
298 deb http://mirror.fsf.org/trisquel/ aramo-backports main
299 deb-src http://mirror.fsf.org/trisquel/ aramo-backports main
301 if ! diff -q $t $f; then
302 sudo
dd if=$t of
=$f status
=none
309 pi debian-goodies shellcheck
314 case $codename_compat in
316 s systemctl
enable --now ssh-agent-iank
320 case $codename_compat in
322 sd
/etc
/apt
/preferences.d
/nabia-btrfs-progs
<<'EOF'
324 Pin: release a=buster-backports
327 p
install btrfs-progs
332 # 2020-03-03 old file
333 s
rm -fv /etc
/apt
/preferences.d
/radicale
334 ######### end universal pinned packages ######
339 sd
/etc
/apt
/preferences.d
/obs
<<EOF
341 Pin: release n=bionic
344 sd
/etc
/apt
/preferences.d
/chromium
<<EOF
346 Pin: release n=bionic
351 # note, to get the latest, it would be n=bullseye*
352 # but that has conflicting package versions, so this does the old one.
353 # I only use it for special rare purposes. Just keep in mind it is an
354 # outdated insecure version.
355 sd
/etc
/apt
/preferences.d
/chromium-bullseye
<<EOF
356 Package: chromium chromium-* libicu67 libjpeg62-turbo libjsoncpp24 libre2-9 libwebpmux3
357 Pin: release o=Debian*,n=bullseye
362 # obs dependency not in trisquel
363 sd
/etc
/apt
/preferences.d
/obs
<<EOF
365 Pin: release n=jammy,o=Ubuntu
373 ##### begin automatic upgrades (after checkrestart has been installed) ####
374 # if apt-config-auto-update is installed,
375 # it also has similar config, in a file 10something,
376 # but i think this overrides it since its higher number.
377 # This file was part of the automatic-updates package,
378 # and it has a config option to not get new package lists,
379 # which seems pretty stupid to me, you cant actually upgrade
380 # anything if you dont have the new package list.
381 sd
/etc
/apt
/apt.conf.d
/20auto-upgrades
<<'EOF'
382 # note: man apt.conf says
383 # /usr/share/doc/apt/examples/configure-index.gz is a configuration file showing
384 # example values for all possible options.
385 # but that is a incorrect.
386 # Periodic and other options are only documented in
387 # /usr/lib/apt/apt.systemd.daily
388 # That filename can be found through poking around in apt daily cronjob.
389 APT::Periodic::Update-Package-Lists "1";
390 APT::Periodic::Download-Upgradeable-Packages "1";
391 # 0 means disabled. I used to set this to 7, however, trisquel doesn't
392 # have an archive of old package versions, so I want to
393 # keep around old versions so I can easily downgrade.
394 APT::Periodic::AutocleanInterval "0";
395 # daily expire old files /var/cache/apt if it gets above this MB
396 APT::Periodic::MaxSize "50000";
397 APT::Periodic::Unattended-Upgrade "1";
400 # fyi: default file has comments about available options,
401 # you may want to read that, do pkx unattended-upgrades
402 # default is just security updates. this list found from reading
403 # match_whitelist_string() in $(which unattended-upgrades)
404 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
405 Unattended-Upgrade::Mail "root";
406 Unattended-Upgrade::MailOnlyOnError "true";
407 Unattended-Upgrade::Remove-Unused-Dependencies "true";
408 Unattended-Upgrade::Origins-Pattern {
409 "o=*,l=*,a=*,c=*,site=*,n=*";
414 sudo
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
/etc
/cron.d
/myupgrade
416 # myupgrade cron exists in /etc/cron.d/ian
418 ##### end automatic upgrades ####
421 # commented in case i want to use this sometime later
422 # sd /etc/apt/preferences.d/buster-backports <<EOF
424 # Pin: release a=buster-backports
429 ###### begin website setup
433 f
=/var
/lib
/bind
/db.b8.nz
434 if [[ ! -e $f ]]; then
438 sudo
/c
/roles
/prom_export
/files
/simple
/usr
/local
/bin
/fsf-install-node-exporter
-l 127.0.0.1
441 web-conf
-p 9101 -f 9100 - apache2
${HOSTNAME}ex.b8.nz
<<'EOF'
444 AuthName "basic_auth"
446 # htpasswd -c prometheus-export-htpasswd USERNAME
447 AuthUserFile "/etc/prometheus-export-htpasswd"
456 # i just dont feel like setting up a special purpose ssh key to do this automatically.
458 # run this once for bk on local machine:
459 # only used for old openvpn setup
460 /a/exe/vpn-mk-client-cert -c bk.b8.nz -b expertpath -n mail li.iankelling.org
470 if [[ ! -L ~
/eggdrop
/eggdrop
]]; then
472 git clone https
://github.com
/eggheads
/eggdrop eggdrop-src
480 # dunno if this is really needed. it was part of the documented eggdrop systemd install script
481 sudo loginctl enable-linger
482 systemctl
--user enable fsysbot
483 systemctl
--user start fsysbot
485 m
/a
/h
/setup.sh iankelling.org
487 # start mumble only when im going to use it, since i dont use it much
488 pi-nostart mumble-server
489 sudo
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
491 # do certificate to avoid warning about unsigned cert,
492 # which is overkill for my use, but hey, I'm cool, I know
494 m web-conf apache2 mumble.iankelling.org
495 sudo
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
497 # general vpn for as needed use
498 vpn-server-setup
-d -r -4 10.5.5 -p 443 -n hole
500 # todo: consider if this should exist for the
502 teeu
/etc
/openvpn
/server
/hole.conf
<<'EOF'
508 files
=(/etc
/openvpn
/client-config-hole
/*)
509 if (( ${#files[@]} >= 1 )); then
513 for host in ${!vpn_ips[@]}; do
514 sd
/etc
/openvpn
/client-config-hole
/$host <<EOF
515 ifconfig-push 10.5.5.${vpn_ips[$host]} 255.255.255.0
520 # for adding cert to system with /p
523 #mkc /p/c/machine_specific/$host/filesystem/etc/openvpn/client
524 #vpn-mk-client-cert -b $host -n hole -r iankelling.org
525 #s chown -R iank:iank .
527 # example of adding to remote system 107,
528 # vpn-mk-client-cert -n hole -c 10.2.0.107 -b hd8 iankelling.org
530 # for wireguard hole vpn, use function:
534 # if it is going to want to connect to transmission-daemon on ok
535 # wghole bo 28 10.174.2.2/32
537 # requested from linode via a support ticket.
538 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
539 # ipv6 stuff pieced together
540 # via slightly wrong information from
541 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
542 # https://community.openvpn.net/openvpn/wiki/IPv6
545 # This uses a public /64, but afaik, that is not needed for my
546 # current use case, since I'm doing ipv6 nat, they could be private
547 # and nat to a public address. I'm doing ipv6 nat in order to have 2
548 # vpn clients that externally share the same ip when sending so they
549 # share ip reputation. Note, the eth0 and tunx needed to be
550 # different subnets. On the same, I saw some neighbor packet go
551 # unanswered, tcpdump showed packets getting lost. I tried splitting the
552 # /64, it didn't work but I didn't investigate closely.
555 # not starting as i intend to replace it
556 m vpn-server-setup
-s -i tunmail
-n mail -d -6 2600:3c00
:e002
:3800::/64 2600:3c00
:e002
:3800::1/64
557 sudo
tee /etc
/openvpn
/client-config-mail
/mailclient
<<'EOF'
558 ifconfig-push 10.8.0.4 255.255.255.0
559 ifconfig-ipv6-push 2600:3c00:e002:3800::4/64
561 sudo
tee /etc
/openvpn
/client-config-mail
/expertpath
<<'EOF'
562 ifconfig-push 10.8.0.5 255.255.255.0
563 ifconfig-ipv6-push 2600:3c00:e002:3800::5/64
567 sudo
dd of
=/etc
/systemd
/system
/vpn-mail-forward.service
<<'EOF'
569 Description=Turns on iptables mail nat
570 BindsTo=openvpn-server@mail.service
575 ExecStart=/a/bin/distro-setup/vpn-mail-forward tunmail start
576 ExecStop=/a/bin/distro-setup/vpn-mail-forward tunmail stop
579 RequiredBy=openvpn-server@mail.service
584 # needed for li's local mail delivery.
585 tu
/etc
/hosts
<<<"10.8.0.4 mx.iankelling.org"
587 # wgmail handles this.
588 #sgo vpn-mail-forward.service
590 #sgo openvpn-server@mail
593 # setup let's encrypt cert
594 m web-conf apache2 mail.iankelling.org
595 # TODO, i expanded the above cert manually to mx.iankelling.org, this should be captured
596 # in the automation here. We use mail.iankelling.org as our ehlo name when sending mail
597 # but our mx record is mx.iankelling.org. Initially I was just using mail.iankelling.org,
598 # but the problem is I want multiple ips to be able to identify as mail.iankelling.org,
599 # but a subset to be mx.iankelling.org. Afaik, there is no problem with having
600 # our mail cert be for mail.iankelling.org, and have people connect to mx.ian...,
601 # but it doesn't make logical sense to do this.
602 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
605 a2enmod -q proxy proxy_http
606 domain=cal.iankelling.org
607 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
608 # https://radicale.org/2.1.html
609 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
610 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
612 # this doesn't exactly fit with the documentation.
613 # We need location / to do an auth, it cant be done outside,
614 # in order to pass on X-Remote-User. And we need
615 # the other location in order to remove the /radicale/ for
616 # requests which have it. This could be done with a rewrite,
617 # but i just get something working and call it a day.
622 AuthName "Authentication Required"
623 # setup one time, with root:www-data, 640
624 AuthUserFile "/etc/caldav-htpasswd"
626 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
628 <Location "/radicale/">
629 Options +FollowSymLinks +Multiviews -Indexes
630 RequestHeader set X-Script-Name /radicale/
631 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
632 ProxyPass "http://10.8.0.4:5232/" retry=0
633 ProxyPassReverse "http://10.8.0.4:5232/"
636 # nginx version of above would be:
637 # auth_basic "Not currently available";
638 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
642 ###### begin znc setup #####
645 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
646 # to get into the web interface,
647 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
648 # https://iankelling.org:12533/
649 # login as ian, pass is in pass store, the part after :
651 # znc config generated by doing
653 # selected port is also used in erc config
654 # comma separated channel list worked.
655 # while figuring things out, running znc -D for debug in foreground.
656 # to exit and save config:
657 # /msg *status shutdown
658 # configed auth on freenode by following
659 # https://wiki.znc.in/Sasl:
663 # Set MyNickservName pa$$w0rd
664 # created the system service after, and had to do
665 # mv /home/iank/.znc/* /var/lib/znc
666 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
667 # and made a copy of the config files into /p/c
668 # /msg *status LoadMod --type=global log -sanitize
669 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
670 # /msg *status LoadMod --type=network perform
671 # /query *perform add PRIVMSG ChanServ :invite #fsf-office
672 # /msg *perform add JOIN #fsf-office
673 # /msg *status LoadMod NickServ
676 # also ran /znc LoadMod clearbufferonmsg
677 # it would be nice if erc supported erc query buffers by doing
678 # /msg *status clearbuffer <name of the query/receiver
680 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
681 # if that was the case i could remove the module clearbufferonmsg
682 # also would be nice if erc supported
683 # https://wiki.znc.in/self-message
684 # https://wiki.znc.in/Query_buffers \
686 # for geekshed, there was no sasl support as far as I can tell,
687 # so I set to msg nickserv to identify upon connect.
688 if ! getent passwd znc > /dev/null; then
689 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
691 sudo chmod 700 /var/lib/znc
692 sudo chown -R znc:znc /var/lib/znc
693 # Avoid restarting if possible, reconnecting to irc is annoying.
694 # The unit file was made active with conflink.
695 # Note, avoid using ser here because we wrap sudo to prints the command first.
696 if [[ $(systemctl is-active znc) != active ]]; then
699 ###### stop znc setup #####
708 # todo, save the config
709 /etc/cron.daily/stream-cert
710 web-conf -c /etc/cert-live.fsf.org -p 443 -f 8000 apache2 live.fsf.org
714 ###### end website setup
716 ########### end section including li/lj ###############
721 ### system76 things ###
723 bo) # sy| sy doesnt seem to really need this.
724 # note, i stored the initial popos packages at /a/bin/data/popos-pkgs
725 if [[ ! -e /etc/apt/sources.list.d/system76.list ]]; then
726 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
727 sd /etc/apt/sources.list.d/system76.list <<EOF
728 deb http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
729 deb-src http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
731 # ubuntu keyserver is prone to intermittent failures
732 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5D1F3A80254F6AFBA254FED5ACD442D1C8B7748B
734 # https://support.system76.com/articles/install-ubuntu/
735 # but i'm hoping this is not needed
736 # sd /etc/apt/preferences.d/system76 <<'EOF'
738 # Pin: release o=LP-PPA-system76-dev-stable
742 # TODO: I had to uninstall linux-image-generic-hwe-20.04 because of a conflict
743 # about linux-firmware. Should probably install it to begin with in fai if
745 pi system76-driver system76-firmware
746 # if you get a notice about a firmware update, the notifier on i3
747 # is too dumb to do anything when you click it. so to see
749 # /var/cache/system76-firmware-daemon
750 # extract the xz files there, one will contain a changelog.
751 # then to install an update:
752 # s system76-firmware-cli schedule
756 ### end system76 things ###
762 ## one time setup thing I did
764 # cargo build --release
765 # cp target/release/obs-cmd ../bin
767 ## in obs, tools -> websocket server settings -> generate/copy password
769 # note: obs-studio on gnu does not support webrtc, it seems mainly because
770 # libdatachannel is not packaged. If it was, it would just need to do
771 # apt source obs-studio, obs-studio-30.1.1/debian/rules set -DENABLE_WEBRTC=ON
773 # I did manage to build libdatachannel following its instructions, then make install,
774 # then obs failed due to nvidia. found those options to disable with
775 # rg 'option\(ENABLE' | gr nv, then build obs like so:
777 # 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 ..
781 # however, I didn't end up trying it out.
783 # note, in terminal source, i setup a transform so it would show the
784 # bottom 1080p section of the terminal instead of the top if the
785 # screen was bigger. click like 2 times in the preview so the red
786 # lines show up, right click, edit transform (or ctrl-e). bounding
787 # box type: scale to width of bounds. alignment in bounding box:
788 # bottom left. bounding box size 1920 x 1080.
790 # ppa:obsproject/obs-studio
791 if [[ ! -s /etc/apt/sources.list.d/obs.list ]]; then
792 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
793 sd /etc/apt/sources.list.d/obs.list <<EOF
794 deb http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
795 deb-src http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
797 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BC7345F522079769F5BBE987EFC71127F425E228
804 case $codename_compat in
806 # mate-indicator-applet and beyond are msc things I noticed diffing a
807 # standard install with mine.
808 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
814 # todo: figure out mate for buster
815 # pi task-gnome-desktop
818 # i had installing mate-indicator-applet, but im not sure why so i removed
819 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras anacron
822 # # apt-get update periodically fails with an appstream error.
823 # # this removes gnome-core, but its just a package for dependencies
824 # p -y remove appstream
827 # by default, it sleeps when not logged in to x/wayland and on ac power.
829 if id -u gdm &>/dev/null; then
830 sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
834 # lightdm startup fails without this. on etiona, we got unity-greeter installed automatically,
835 # it would probably work on nabia too, but google just lead me to this and it works fine.
836 pi lightdm-gtk-greeter
837 # ok, this is really weird
838 # normally this file has
839 sd /etc/X11/Xsession.d/99x11-common_start <<'EOF'
841 # this file normally just has: exec $STARTUP
842 # but then ~/.xsession-errors
843 # says $STARTUP is not found, which appears to be the real
844 # error, but normal bash doesnt operate that way.
845 # https://bugs.launchpad.net/ubuntu/+source/im-config/+bug/1879352
848 # also, gdm wayland was default, had to do
849 # dpkg-reconfigure gdm3
850 # and choose lightdm.
854 # not yet bothering with mate
855 pi lightdm-gtk-greeter lightdm
860 if [[ $codename_compat == flidas ]]; then
861 # doesnt exist in newer
870 # firefox would work here too, apt would select abrowser.
871 # and the update-alternatives thing i think is becuz firefox is
872 # generally available before abrowser and this helps fix things
873 # up when we have both.
875 s update-alternatives --set x-www-browser /usr/bin/abrowser
887 # newer distros just use adb for package name it seems
888 case $codename_compat in
890 pi android-tools-adbd
894 case $codename_compat in
896 pi libext2fs-dev libzstd-dev
897 cd /a/opt/btrfs-progs
902 case $codename_compat in
911 # not packaged in newer distros it seems
912 case $codename_compat in
913 bionic|buster|stretch)
919 # TODO: some of the X programs can be removed from pall when using wayland
921 # depends gcc is a way to install suggests. this is apparently the only
922 # way to install suggests even if the main package is already
923 # installed. reinstall doesn't work, uninstalling can cause removing
924 # dependent packages.
925 # shellcheck disable=SC2046 # word splitting is intended
926 pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $($src/distro-pkgs)
928 # schroot service will restart schroot sessions after reboot.
932 # fix systemd unit failure. i dont know of any actual impact
933 # other than systemd showing in degraded state. So, we dont bother
934 # fixing the current state, let it fix on the next reboot.
935 # https://gitlab.com/cjwatson/binfmt-support/-/commit/54f0e1af8a
936 tmp=$(systemctl cat binfmt-support.service | grep ^After=)
937 if [[ $tmp != *systemd-binfmt.service* ]]; then
938 s u /etc/systemd/system/binfmt-support.service.d/override.conf <<EOF
940 $tmp systemd-binfmt.service
945 # commented, not worth the hassle i think.
951 sudo rm -fv /etc/systemd/resolved.conf.d/iank.conf
953 # website is dead june 14 2019. back in october, but meh
954 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
959 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
962 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
963 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
965 # f=/etc/apt/sources.list.d/iridium-browser.list
966 # if ! diff -q $t $f; then
977 if mountpoint /p &>/dev/null; then
978 # note, see bashrc for more documentation.
980 sd /etc/systemd/system/rss2email.service <<'EOF'
982 Description=rss2email
983 After=multi-user.target
988 # about 24 hours of failures
989 # it copies over its files without respecting symlinks, so
990 # we pass options to use different location.
991 ExecStart=/usr/local/bin/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
993 sd /etc/systemd/system/rss2email.timer <<'EOF'
995 Description=rss2email
998 # for initial run. required.
1000 # for subsequent runs.
1001 OnUnitInactiveSec=300
1004 WantedBy=timers.target
1006 sudo systemctl daemon-reload
1010 ######### begin irc periodic backup #############
1011 if [[ $HOSTNAME == frodo ]]; then
1012 sd /etc/systemd/system/ircbackup.service <<'EOF'
1014 Description=irc li backup
1015 After=multi-user.target
1020 ExecStart=/usr/local/bin/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
1022 sd /etc/systemd/system/ircbackup.timer <<'EOF'
1024 Description=irc li backup hourly
1030 WantedBy=timers.target
1032 sudo systemctl daemon-reload
1037 ######### end irc periodic backup #############
1041 # pi-nostart does not disable
1045 if [[ -e /p/c/gen-fsf-vpn ]]; then
1049 if [[ -e /p/c/machine_specific/$HOSTNAME/filesystem/etc/openvpn/client/hole.crt ]]; then
1050 sgo openvpn-client@hole
1053 ############# begin syncthing setup ###########
1056 f=/usr/share/keyrings/syncthing-archive-keyring.gpg
1057 if [[ ! -e $f ]]; then
1058 s curl -s -o $f https://syncthing.net/release-key.gpg
1060 s="deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable"
1061 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
1062 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
1068 m lnf -T /w/syncthing /home/iank/.config/syncthing
1069 ser daemon-reload # syncthing likely not properly packaged
1070 sgo syncthing@iank # runs as iank
1074 # 1003 just happens to be what was on my system
1075 if ! getent passwd ziva; then
1076 s groupadd -g 1003 ziva
1077 # syncthing state / config / db are all in ~/.config/syncthing
1078 s useradd -g 1003 -u 1003 -d /d/ziva-home -c ziva -s /bin/bash ziva
1084 # user for short term use dropping of privileges
1086 if ! getent group zu &>/dev/null; then
1087 s groupadd -g 1023 zu
1089 if ! getent passwd zu &>/dev/null; then
1090 s useradd -g 1023 -u 1023 -c zu -s /bin/bash zu
1094 # these things persist in ~/.config/syncthing, which I save in
1095 # /w/syncthing (not in /p, because syncthing should continue to
1096 # run on home server even when using laptop as primary device)
1097 # open http://localhost:8384/
1098 # change listen address from default to tcp://:22001,
1099 # this is because we do port forward so it doesn\'t have to use
1100 # some external server, but the syncthing is broken for port forward,
1101 # you get a message, something "like connected to myself, this should not happen"
1102 # when connecting to other local devices, so I bump the port up by 1,
1104 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
1105 # Without this, it was being stuck syncing at 0%.
1106 # Set gui username and password.
1108 # install syncthing via f-droid,
1109 # folder setting, turn off send only.
1110 # on phone, add device, click bar code icon
1111 # on dekstop, top right, actions, device id
1112 # after adding, notification will appear on desktop to confirm
1114 # syncing folder. from phone to desktop: select desktop in the
1115 # folder on phone\'s sync options, notification will appear in
1116 # desktop\'s web ui within a minute. For the reverse, the
1117 # notification will appear in android\'s notifications, you have to
1118 # swipe down and tap it to add the folder. It won\'t appear in the
1119 # syncthing ui, which would be intuitive, but don\'t wait for it
1120 # there. The notification may not work, instead open the web gui
1121 # from in the app, there should be a notification within there.
1123 # On phone, set settings to run syncthing all the time, and
1124 # show no notification.
1126 # Folder versioning would make sense if I didn\'t already use btrfs
1127 # for backups. I would choose staggered, or trash can for more space.
1129 # if needed to install on a remote comp:
1130 # ssh -L 8384:localhost:8384 -N frodo
1131 # open http://localhost:8384/
1133 # Note, the other thing i did was port forward port 22000,
1134 # per https://docs.syncthing.net/users/firewall.html
1136 ############# end syncthing setup ###########
1140 ####### begin misc packages ###########
1142 # old location, 2023.
1143 sudo rm -fv /etc/systemd/system/profanity.service
1146 ln -sfT /d/p/profanity ~/.local/share/profanity
1147 ln -sfT /d/p/profanity-config ~/.config/profanity
1148 source /a/bin/bash_unpublished/source-state
1149 if [[ $HOSTNAME == "$HOST2" || ! -e /p/profanity-here ]]; then
1150 systemctl --user --now enable profanity
1155 ln -sfT /p/profanity ~/.local/share/profanity
1156 ln -sfT /p/profanity-config ~/.config/profanity
1167 sudo update-alternatives --set pinentry /usr/bin/pinentry-gtk-2
1170 # sakura config is owned by ian
1173 m sudo -u user2 -i reset-konsole
1174 # user2 xscreensaver we don't want to reset
1175 m reset-xscreensaver
1178 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
1179 # this is also in primary-setup
1180 # pi libxss-dev # dependency based on build failure
1182 # cabal install --upgrade-dependencies --force-reinstalls arbtt
1183 # also, i assume syncing this between machines somehow messed up the data.
1185 ## not using arbtt for now
1186 # if mountpoint /p &>/dev/null; then
1190 # # same as seru enable arbtt, but works over ssh when systemctl --user causes error:
1191 # # Failed to connect to bus: No such file or directory
1192 # lnf -T /a/bin/ds/subdir_files/.config/systemd/user/arbtt.service /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1194 # seru start arbtt ||:
1198 rm -fv /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1203 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
1204 m cp /p/.linphonerc-initial ~/.linphonerc
1207 # linphone in t10 wont do dns with systemd-resolved or something
1208 s teeu /etc/hosts <<'EOF'
1209 74.94.156.215 watson.fsf.org
1214 ### begin spd install
1215 if mountpoint /p &>/dev/null; then
1216 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
1218 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
1221 # this guesses at the appropriate directory, adjust if needed
1222 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
1223 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
1224 # newer distro had gpg2 as default, older one, flidas, need to make it that way
1225 gpgpath=$(which gpg2) ||:
1226 if [[ $gpgpath ]]; then
1227 sudo mkdir -p /usr/local/spdhackfix
1228 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
1234 # nagstamon setting which were set through the ui
1235 # monitor url https://klaxon.fsf.org/cgi-bin
1236 # monitor url cgi https://klaxon.fsf.org/cgi-bin
1238 # all unknown services
1239 # all warning services
1240 # acknowledged hosts & services
1241 # hosts & services down for maintenence
1242 # services on down hosts
1243 # services on hosts in maintenece
1244 # services on unreachable osts
1245 # hosts in soft state
1246 # services in soft state
1247 # in display tab: fullscreen
1249 # these translate to these settings I think
1250 # filter_acknowledged_hosts_services = True
1251 # filter_all_unknown_services = True
1252 # filter_all_warning_services = True
1253 # filter_hosts_in_soft_state = True
1254 # filter_hosts_services_maintenance = True
1255 # filter_services_in_soft_state = True
1256 # filter_services_on_down_hosts = True
1257 # filter_services_on_hosts_in_maintenance = True
1258 # filter_services_on_unreachable_hosts = True
1259 # notify_if_up = False
1260 # statusbar_floating = False
1262 # but i'm just going to rely on the webpage plus sms for now.
1265 # it asks if it should make users in it's group capture packets without root,
1266 # which is arguably more secure than running wireshark as root. default is no,
1267 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
1268 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
1270 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
1271 # listed in the default config as suggested.
1272 # /run/usr/1000 i noticed was missing for pulseaudio
1273 # /run/user/0 just seemed like a not bad idea, given the above
1274 tu /etc/schroot/desktop/fstab <<'EOF'
1275 /p /p none rw,bind 0 0
1276 /a /a none rw,bind 0 0
1277 /run /run none rw,bind 0 0
1278 /run/lock /run/lock none rw,bind 0 0
1279 /dev/shm /dev/shm none rw,bind 0 0
1280 /run/shm /run/shm none rw,bind 0 0
1281 /run/user/1000 /run/user/1000 none rw,bind 0 0
1282 /run/user/1001 /run/user/1001 none rw,bind 0 0
1283 /run/user/0 /run/user/0 none rw,bind 0 0
1286 # todo: consider if this should use the new sysd-prom-fail
1287 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1289 Description=schrootupdate
1290 After=multi-user.target
1294 ExecStart=/usr/local/bin/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1296 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1298 Description=schrootupdate
1301 OnCalendar=*-*-* 04:20:00 America/New_York
1304 WantedBy=timers.target
1307 sgo schrootupdate.timer
1314 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/bookworm.list/BOOKWORM_FREE \
1315 debian bookworm firefox-esr pulseaudio chromium
1322 sudo mkdir -p /nocow/user
1323 sudo chown $USER:$USER /nocow/user
1327 ####### begin transmission
1337 tdir=/nocow/user/tor
1343 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1344 # 450 seems likely to be unused. we need to specify one or else
1345 # it won't be stable across installs.
1346 if ! getent passwd debian-transmission > /dev/null; then
1347 sudo groupadd -g 450 debian-transmission
1348 sudo adduser --quiet \
1353 --disabled-password \
1354 --home /var/lib/transmission-daemon \
1357 # We want group writable stuff from transmission.
1358 # However, after setting this, I learn that transmission sets it's
1359 # own umask based on it's settings file. Well, no harm leaving this
1360 # so it's set right from the beginning.
1361 sudo chfn debian-transmission -o umask=0002
1363 # note i had to do this, which is persistent:
1365 # s chgrp debian-transmission torrents partial-torrents
1367 # syslog says things like
1368 # 'Failed to set receive buffer: requested 4194304, got 425984'
1369 # google suggets giving it even more than that
1370 tu /etc/sysctl.conf<<'EOF'
1371 net.core.rmem_max = 67108864
1372 net.core.wmem_max = 16777216
1376 # some reason it doesn\'t seem to start automatically anyways
1377 pi-nostart transmission-daemon
1378 # be extra sure its not started
1379 ser disable transmission-daemon
1380 ser stop transmission-daemon
1382 # the folder was moved here after an install around 02/2017.
1383 # it contains runtime data,
1384 # plus a simple symlink to the config file which it\'s
1385 # not worth separating out.
1386 # between comps, the uid can change
1388 f=$tdir/transmission-daemon
1389 for d in $tdir/partial-torrents $tdir/torrents $f; do
1390 if [[ ! -d $d ]]; then
1393 sudo chown -R debian-transmission:user2 $d
1395 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1396 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1397 sudo chown -R debian-transmission:debian-transmission $f
1398 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1400 # config file documented here, and it\'s the same config
1401 # for daemon vs client, so it\'s documented in the gui.
1402 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1404 # I originaly setup rpc-whitelist, but after using
1405 # routing to a network namespace, it doesn\'t see the
1406 # real source address, so it\'s disabled.
1408 # Changed the cache-size to 256 mb, reduces disk use.
1409 # It is a read & write cache.
1411 # just fyi: default rpc port is 9091
1412 if ! systemctl is-active transmission-daemon-nn &>/dev/null && \
1413 ! systemctl is-active transmission-daemon; then
1415 command sudo ruby <<EOF >$tmp
1417 p = '/etc/transmission-daemon/settings.json'
1419 'rpc-whitelist-enabled' => false,
1420 'rpc-authentication-required' => false,
1421 'incomplete-dir' => '$tdir/partial-torrents',
1422 'incomplete-dir-enabled' => true,
1423 'download-dir' => '$tdir/torrents',
1424 "speed-limit-up" => 800,
1425 "speed-limit-up-enabled" => true,
1426 "peer-port" => 61486,
1427 "cache-size-mb" => 256,
1428 "ratio-limit" => 5.0,
1429 "ratio-limit-enabled" => false,
1431 puts(JSON.pretty_generate(JSON.parse(File.read(p)).merge(s)))
1433 cat $tmp | sudo dd of=/etc/transmission-daemon/settings.json
1437 ####### end transmission
1441 # to persist upload/dl metadata. initially, moved all the stuff
1442 # in /var/lib/transmission-daemon to /d/tor
1443 s usermod --home /d/tor debian-transmission
1444 sgo transmission-daemon-nn
1450 ######### begin transmission client setup ######
1452 # to connect from a remote client, trans-remote-route in brc2
1455 if [[ -e /p/transmission-rpc-pass ]]; then
1456 # arch had a default config,
1457 # debian had nothing until you start it.
1458 # With a little trial an error, here is a minimal config
1459 # taken from the generated one, plus changes that the
1460 # settings ui does, without a bunch of ui crap settings.
1462 # only settings I set were
1467 # the password is randomly generated on first run, i copied it out
1468 # so it could be used by other hosts.
1471 p = '/etc/transmission-daemon/settings.json'
1472 s = JSON.parse(File.read(p))
1473 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1474 # default is 0022 (18 in decimal)
1476 File.write p, JSON.pretty_generate(s)
1479 rpc_pass=$(</p/transmission-rpc-pass)
1480 for f in /home/*; do
1482 uid=$(id -u $u 2>/dev/null) || continue
1483 if [[ ! $uid -ge 1000 ]]; then
1486 d=$f/.config/transmission-remote-gtk
1487 sudo -u $u mkdir -p $d
1488 # i tried setting hostname to transmission.b8.nz, so i could dynamically change where
1489 # this connects to, but it said some 421 denied error when I did that. Then it
1490 # froze X when i ran it under strace. Whatever.
1491 sudo -u $u dd of=$d/config.json <<EOF
1495 "profile-name" : "Default",
1496 "hostname" : "10.174.2.2",
1497 "rpc-url-path" : "/transmission/rpc",
1499 "password" : "$rpc_pass",
1500 "auto-connect" : true,
1504 "update-active-only" : false,
1505 "activeonly-fullsync-enabled" : false,
1506 "activeonly-fullsync-every" : 2,
1507 "update-interval" : 3,
1508 "min-update-interval" : 3,
1509 "session-update-interval" : 60,
1510 "exec-commands" : [],
1515 "add-options-dialog" : false
1520 ######### end transmission client setup ######
1526 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1527 # goto http://127.0.0.1:631
1528 # administration tab, add new printer button.
1529 # In debian, I could use hte recommended driver,
1530 # in arch, I had to pick out the 6L driver.
1533 # bridge networking as user fails. google lead here, but it doesn\'t work:
1534 # oh well, I give up.
1535 # http://wiki.qemu.org/Features-Done/HelperNetworking
1537 # f=/etc/qemu/bridge.conf
1541 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1544 # general known for debian/ubuntu, not for fedora
1546 m /a/bin/buildscripts/go
1547 # only needed for rg. cargo takes up 11 gigs, filled up the disk on je.
1548 m /a/bin/buildscripts/rust
1549 m /a/bin/buildscripts/misc
1550 m /a/bin/buildscripts/pithosfly
1551 #m /a/bin/buildscripts/alacritty
1552 #m /a/bin/buildscripts/kitty
1554 pi-nostart virtinst virt-manager
1556 # i cant if this is whats causing it to start even though
1557 # its disabled. note: it leaves around dnsmasq instances even
1558 # if you stop it. what the hell systemd?
1560 # allow user to run vms, from debian handbook. libvirt-qemu
1561 # based on https://www.whonix.org/wiki/KVM#First-time_User.3F
1562 for x in iank user2; do s usermod -a -G libvirt,kvm,libvirt-qemu $x; done
1565 pi --no-install-recommends kdeconnect
1566 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1567 ### but gnome + xmonad not working in flidas, so i disabled it
1568 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1569 # cd /a/opt/indicator-kdeconnect
1572 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1575 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1576 # # it seems, according to
1577 # # /etc/xdg/autostart/kdeconnectd.desktop
1578 # # I'm not seeing the icon, but the clipboard replication is working
1581 ### begin model 01 arduino support ###
1582 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1583 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1584 # set arduino var in bashrc,
1585 # have system config file setup too.
1586 sudo adduser $USER dialout
1589 # download arduino ide, extract in /a/opt, ignore the install script, run ./arduino,
1590 # toolbar, preferences, add board manager url:
1591 # https://raw.githubusercontent.com/keyboardio/boardsmanager/master/package_keyboardio_index.json
1592 # toolbar, board manager, add keyboardio
1593 # toolbar, select model01 board
1594 # toolbar, examples, model01, compile
1598 # this is for the mail command too. update-alternatives is kind of misleading
1599 # since at least it's main commands pretend mail does not exist.
1600 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1601 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1603 ######### end misc packages #########
1606 # packages I once used before and liked, but don\'t want installed now for
1608 # python-sqlite is used for offlineimap
1609 # lxappearance python-sqlite dolphin paman dconf-editor
1615 # todo, finish configuring smart.
1618 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1619 # turn on smart. background on options:
1620 # first line, -a = test everyting on all devices.
1621 # -S on, turn on disk internal saving of vendor specific info,
1622 # from google, seems like this is usually already on and fairly standard.
1623 # -o on, turn on 4 hour period non-performance degrading testing.
1624 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1625 sched="-s (S/../.././02|L/../../6/03)"
1626 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1627 DEVICESCAN -a -o on -S on -n standby,q $sched \
1628 -m root@mail.iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1630 # in the default configuration of at least ubuntu 14.04, resolvconf is
1631 # configured to order any nameservers associated with tun* or tap*
1632 # before the normal internet interfaces, which means they are always
1633 # consulted first. This is often slower and undesirable, ie. local dns
1634 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1636 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1637 # however, this breaks dns lookup for hosts on the openvpn lan.
1638 # I can\'t figure out why hosts on the normal lan would not be
1639 # broken under the default ordering, except the host I was
1640 # testing with previously had an entry in /etc/hosts.
1642 ############# end unfinished
1644 ########### misc stuff
1647 xdg-settings set default-web-browser abrowser.desktop
1649 # xdg-settings get default-web-browser
1651 # pressing tab after sdf here:
1652 # scp sdfbash: set +o noglob: command not found
1653 # in t11, bash 5.1.16. this fixes it.
1654 sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
1656 rm -fv /home/iank/.mpv/watch_later
1657 rm -rf /home/iank/.mpv
1659 if [[ ! -e ~/.local/bin/pip ]]; then
1661 wget -O$tmp https://bootstrap.pypa.io/get-pip.py
1667 # soo, apt install beets fails due to wanting a pip package,
1668 # we find out why it wants this through
1669 # apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances beets | less
1670 # python-mediafile requires tox, which requires virtualenv, which requires pip.
1671 # but, python-mediafile doesn't really require tox, it is specified in
1672 # ./usr/lib/python3/dist-packages/mediafile-0.9.0.dist-info/METADATA
1673 # as being required only for testing, but the debian package
1674 # included it anyways, due to a mistake or bad tooling or something.
1675 # I don't plan to use tox, so, according to https://serverfault.com/a/251091,
1676 # we can create and install a dummy package by:
1678 # "equivs-control <name>, edit the file produced to provide the right
1679 # dependency and have a nice name, then run equivs-build <name> and
1680 # finally dpkg -i the resulting .deb file"
1681 # as of 2023-02, the tox dependency was removed in debian unstable, so
1682 # this hack will probably go away in t12.
1684 if pcheck beets; then
1685 tmpdir="$(mktemp -d)"
1687 # edited from output of equivs-control tox
1691 Standards-Version: 3.9.2
1693 Description: tox-dummy
1696 sudo dpkg -i tox_1.0_all.deb
1698 pi beets python3-discogs-client
1703 # get rid of annoying message
1704 s sed -ri "s/^([[:space:]]*ui.print_\('Playing)/#\1/" /usr/share/beets/beetsplug/play.py
1707 # notes about barrier
1708 # run barrier, do the gui config,
1709 # setup the 2 screens, using hostnames for the new screen.
1710 # save the server config
1711 # $HOME/.local/share/barrier/.barrier.conf
1714 # ssl errors, resolved via advice here: https://github.com/debauchee/barrier/issues/231
1715 # BARRIER_SSL_PATH=~/.local/share/barrier/SSL/
1716 # mkdir -p "${BARRIER_SSL_PATH}"
1717 # openssl req -x509 -nodes -days 365 -subj /CN=Barrier -newkey rsa:4096 -keyout ${BARRIER_SSL_PATH}/Barrier.pem -out ${BARRIER_SSL_PATH}/Barrier.pem
1718 # ran on both machines.
1719 # When pressing start in the gui, the cli options used are printed to the console,
1720 # they are useful. So on server, just run barriers, client run barrierc SERVER_IP
1722 ### begin timetrap setup
1723 if mountpoint /p &>/dev/null; then
1724 mkdir -p ~/.timetrap/
1725 ln -sf /a/opt/timetrap_formatters ~/.timetrap/formatters
1726 if ! type -p t &>/dev/null; then
1727 pi ruby-dev libsqlite3-dev
1728 gem install --user timetrap
1731 ### end timetrap setup
1733 # leftover cleanup for t9
1737 # needed for debootstrap scripts for fai since fai requires debian
1740 pi-nostart network-manager
1741 # i hate networkmanager. noo, of course disabling it doesnt work
1742 # unless you add a hack. found this by doing
1743 # systemd-analyze dot > x.dot
1747 soff NetworkManager-wait-online.service
1748 # make networkmanager use resolvconf instead of its own dnsmasq which
1749 # conflicts with the normal dnsmasq package.
1750 f=/etc/NetworkManager/NetworkManager.conf
1752 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1753 sudo sed -ri '/ *\[main\]/a dns=default' $f
1754 if [[ $m != $(md5sum $f) ]]; then
1755 srestart NetworkManager
1757 # networkmanager has this nasty behavior on flidas: if the machine
1758 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1759 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1761 # This can be manually fixed by stoping dnsmasq,
1762 # then based on whats in /run/dnsmasq/, i see we can run
1763 # s resolvconf -d NetworkManager
1764 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1765 ser disable NetworkManager
1769 # I have no use for avahi,
1770 # had to run this twice when doing manually, i dunno why
1771 soff avahi-daemon ||:
1775 # make my /etc/fonts/conf.d/ get used.
1776 # I have a new sans-serif font there because the default one
1777 # displays l and I as the same char, grrrrr.
1780 pi desktop-file-utils
1781 m /a/bin/distro-setup/mymimes
1783 if type -p dbus-launch >/dev/null; then
1784 # stop autopoping windows when i plug in an android phone.
1785 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1786 # with still 0 exit code.
1787 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1788 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1791 # on grub upgrade, we get prompts unless we do this
1793 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1794 devs+=("$(devbyid $dev),")
1796 devs[-1]=${devs[-1]%,} # jonied by commas
1797 sudo debconf-set-selections <<EOF
1798 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1802 sysd-prom-fail-install dynamicipupdate
1803 sysd-prom-fail-install systemstatus
1804 sysd-prom-fail-install btrfsmaintstop
1805 sgo btrfsmaint.timer
1811 if grep -xFq $HOSTNAME /a/bin/ds/machine_specific/btrbk.hosts; then
1815 # note: to see when a timer was last run,
1819 ### begin prometheus ###
1823 # Font awesome is needed for the alertmanager ui.
1824 pi prometheus-alertmanager prometheus fonts-font-awesome
1825 /c/roles/prom/files/simple/usr/local/bin/fsf-install-prometheus
1826 # make it available for other machines
1827 rsync -a /usr/local/bin/amtool /a/opt/bin
1828 web-conf -p 9091 -f 9090 - apache2 i.b8.nz <<'EOF'
1831 AuthName "basic_auth"
1833 # htpasswd -c prometheus-htpasswd USERNAME
1834 AuthUserFile "/etc/prometheus-htpasswd"
1839 web-conf -p 9094 -f 9093 - apache2 i.b8.nz <<'EOF'
1842 AuthName "basic_auth"
1844 # htpasswd -c prometheus-htpasswd USERNAME
1845 AuthUserFile "/etc/prometheus-htpasswd"
1850 # by default, the alertmanager web ui is not enabled other than a page
1851 # that suggests to use the amtool cli. that tool is good, but you cant
1852 # silence things nearly as easily as with the gui.
1853 if [[ ! -e /usr/share/prometheus/alertmanager/ui/index.html ]]; then
1854 # default script didnt work, required some changes to get elm 19.1,
1855 # which is a dependency of the latest alertmanager. I modified
1856 # and copied it into /b/ds. In future, might need some other
1858 #sudo /usr/share/prometheus/alertmanager/generate-ui.sh
1859 sudo /b/ds/generate-ui.sh
1860 ser restart prometheus-alertmanager
1863 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter -l 127.0.0.1
1865 for ser in prometheus-node-exporter prometheus-alertmanager prometheus; do
1866 sysd-prom-fail-install $ser
1871 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter
1875 # cleanup old files. 2023-02
1876 x=(/var/lib/prometheus/node-exporter/*.premerge)
1877 if [[ -e ${x[0]} ]]; then
1878 s rm /var/lib/prometheus/node-exporter/*
1883 # todo, for limiting node exporter http,
1884 # either use iptables or, in
1885 # /etc/default/prometheus-node-exporter
1886 # listen on the wireguard interface
1889 wgip=$(command sudo sed -rn 's,^ *Address *= *([^/]+).*,\1,p' /etc/wireguard/wghole.conf)
1890 # old filename. remove once all hosts are updated.
1891 s rm -fv /etc/apache2/sites-enabled/${HOSTNAME}wg.b8.nz.conf
1892 web-conf -i -a $wgip -p 9101 -f 9100 - apache2 ${HOSTNAME}wg.b8.nz <<'EOF'
1895 AuthName "basic_auth"
1897 # htpasswd -c prometheus-export-htpasswd USERNAME
1898 AuthUserFile "/etc/prometheus-export-htpasswd"
1902 # For work, i think we will just use the firewall for hosts in the main data center, and
1903 # vpn for hosts outside it.
1905 # TODO: figure out how to detect the ping failure and try again.
1907 # Binding to the wg interface, it might go down, so always restart, and wait for it on boot.
1908 s mkdir /etc/systemd/system/apache2.service.d
1909 sd /etc/systemd/system/apache2.service.d/restart.conf <<EOF
1911 After=wg-quick@wghole.service
1912 StartLimitIntervalSec=0
1922 ### end prometheus ###
1924 ### begin nagios ###
1926 pi nagios-nrpe-server
1930 # the backport is for this bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800345
1931 pi nagios4 nagios-nrpe-plugin monitoring-plugins-basic/bullseye-backports
1932 s rm -fv /etc/apache2/conf-enabled/nagios4-cgi.conf
1934 # to add a password for admin:
1935 # htdigest /etc/nagios4/htdigest.users Nagios4 iank
1936 # now using the same pass as prometheus
1938 # nagstamon auth settings, set to digest instead of basic.
1940 web-conf -p 3005 - apache2 i.b8.nz <<'EOF'
1941 # adapted from /etc/apache2/conf-enabled/nagios4-cgi.conf
1943 ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4
1944 ScriptAlias /nagios4/cgi-bin /usr/lib/cgi-bin/nagios4
1946 # Where the stylesheets (config files) reside
1947 Alias /nagios4/stylesheets /etc/nagios4/stylesheets
1949 # Where the HTML pages live
1950 Alias /nagios4 /usr/share/nagios4/htdocs
1952 <DirectoryMatch (/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)>
1953 Options FollowSymLinks
1954 DirectoryIndex index.php index.html
1955 AllowOverride AuthConfig
1957 # The default Debian nagios4 install sets use_authentication=0 in
1958 # /etc/nagios4/cgi.cfg, which turns off nagos's internal authentication.
1959 # This is insecure. As a compromise this default apache2 configuration
1960 # only allows private IP addresses access.
1962 # The <Files>...</Files> below shows how you can secure the nagios4
1963 # web site so anybody can view it, but only authenticated users can issue
1964 # commands (such as silence notifications). To do that replace the
1965 # "Require all granted" with "Require valid-user", and use htdigest
1966 # program from the apache2-utils package to add users to
1967 # /etc/nagios4/htdigest.users.
1969 # A step up is to insist all users validate themselves by moving
1970 # the stanza's in the <Files>..<Files> into the <DirectoryMatch>.
1971 # Then by setting use_authentication=1 in /etc/nagios4/cgi.cfg you
1972 # can configure which people get to see a particular service from
1973 # within the nagios configuration.
1975 AuthDigestDomain "Nagios4"
1976 AuthDigestProvider file
1977 AuthUserFile "/etc/nagios4-htdigest.users"
1978 AuthGroupFile "/etc/group"
1984 <Directory /usr/share/nagios4/htdocs>
1991 # when you alter a service through the web, it changes vars in /var/lib/nagios4/status.dat. for example:
1992 # notifications_enabled=1
1993 # note, the same variable exists in the correspdonding "define service {"
1995 # in the default config, we have these definitions
1997 # 11 define command {
1998 # 2 define contact {
1999 # 1 define contactgroup {
2001 # 4 define hostgroup {
2002 # 23 define service {
2003 # 5 define timeperiod {
2008 # klaxon:/etc/nagios3 # grep -rho '^ *define [^{ ]*' | sort | uniq -c
2011 # 6 define contactgroup
2013 # 1 define hostextinfo
2014 # 16 define hostgroup
2015 # 3040 define service
2016 # 2 define servicedependency
2017 # 6 define timeperiod
2024 ### begin bitcoin ###
2028 sudo install -m 0755 -o root -g root -t /usr/bin /a/opt/bitcoin-26.0/bin/*
2029 # Note: i leave it to system-status to start and stop bitcoin.
2030 # note: the bitcoin user & group are setup in fai
2031 sudo usermod -a -G bitcoin iank
2032 # todo: make bitcoin have a stable uid/gid
2033 sudo mkdir -p /var/lib/bitcoind
2034 sudo chown bitcoin:bitcoin /var/lib/bitcoind
2035 # 710 comes from the upstream bitcoin unit file
2036 sudo chmod 710 /var/lib/bitcoind
2037 # note, there exists
2038 # /a/bin/ds/disabled/bitcoin
2044 ### begin live streaming ###
2046 # comparing nginx rtmp to icecast
2047 # `mpv --cache=no` had about 2.5 sec latency vs 4 seconds.
2048 # Then I discovered this command which had about .5 sec latency:
2049 #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
2050 ## a lot of those args arent needed, here is what I ended up with:
2051 # #ffplay -f live_flv -fflags nobuffer -flags low_delay -i rtmp://localhost/live
2053 # A problem with rtmp is that it doesn't support vp8/vp9, requiring the partly patent encumbered h264.
2054 # Looking at alternative protocols: dash & hls are both high latency, I tested dash with the nginx-rtmp
2055 # module and got about 5 seconds of latency, web results imply that is normal.
2057 # Webrtc is what jitsi & bbb use, but an annoying thing is that
2058 # generally requires a web browser with javascript, or some special
2059 # client, and afaik, it has a smaller limit on number of clients.
2061 # Another option is to try rtp/rtsp, there are some servers here:
2062 # https://en.wikipedia.org/wiki/Real-Time_Streaming_Protocol
2065 ## reference for setting up rtmp
2066 # pi nginx libnginx-mod-rtmp
2067 # cat >/etc/nginx/modules-enabled/rtmp.conf <<'EOF'
2068 ## based on https://opensource.com/article/19/1/basic-live-video-streaming-server#comments
2069 ## and https://github.com/arut/nginx-rtmp-module/wiki/Directives
2072 # allow publish 127.0.0.1;
2076 # application live {
2084 ### end live streaming ###
2088 # from https://raw.githubusercontent.com/cli/cli/trunk/docs/install_linux.md
2089 # One time setup afterwards:
2092 # When it gets to the page where it asks to authorize github, the button
2093 # is grayed out. You can just open browser dev tools, inspect the
2094 # button, remove disabled="", then click it and it works.
2096 # Auth token gets saved into /p/c/subdir_files/.local/share/keyrings/
2098 # initial config goes to /home/iank/.config/gh
2099 curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
2100 && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
2101 && 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 \
2102 && sudo apt update \
2103 && sudo apt install gh -y
2107 # remove trisquel banner. it is cool but takes up too much space.
2108 sudo rm -f /etc/update-motd.d/01-banner
2112 sd /etc/cups/client.conf <<'EOF'
2113 ServerName printserver1.office.fsf.org
2120 In mate settings settings, change scrolling to two-finger,
2121 because the default edge scroll doesn\'t work. Originally found this in debian.
2124 # Remove dep that came in with desktop to fix associations.
2125 m pu transmission-gtk
2129 lnf -T /d/vidshare /home/iank/Videos
2133 # # Based on guix manual instructions, also added code to profile.
2134 # # disabled since i'm not using it now.
2136 # if ! type -p guix >/dev/null; then
2138 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
2139 # # added some stuff to envonment.sh for profile based on
2140 # # manual instructions
2141 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
2142 # # echo is to get past prompt
2143 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
2144 # guix install glibc-utf8-locales
2145 # guix package --install guile
2151 m /a/bin/buildscripts/tor-browser
2152 # one root command needed to install
2153 s ln -sf /a/opt/tor-browser/Browser/start-tor-browser /usr/local/bin
2158 web-conf -p 4500 -f 4533 -e ian@iankelling.org apache2 b8.nz
2164 pi-nostart nfs-kernel-server
2166 # todo, this is old, probably needs removing
2167 if [[ $HOSTNAME == tp ]]; then
2168 sd /etc/wireguard/wg0.conf <<EOF
2170 PrivateKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.key)
2171 Address = 10.3.0.2/24, fdfd::2/64
2174 PresharedKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.psk)
2175 PublicKey = 9RnAsJB+ISrA/9lmDKBoT08oBiKwzA64exBBj+rO+ng=
2176 Endpoint = b8.nz:26000
2177 AllowedIPs = 10.3.0.1/24, fdfd::1/64
2178 PersistentKeepalive = 20
2180 sudo systemctl enable wg-quick@wg0
2181 sudo systemctl start wg-quick@wg0
2185 if [[ $HOSTNAME == kw ]]; then
2186 # hosts 1-199. 200+ are dynamic, avoid those
2187 tu /etc/exports <<'EOF'
2188 /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)
2189 /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)
2197 # if I was going to create a persistent vm, i might do it like this:
2198 # variant=something # from: virt-install --os-variant list
2199 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
2200 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
2201 # -n some_name --import --os-variant $variant --cpu host-model-only
2204 # for brother HL-2270DW, this worked:
2205 # https://askubuntu.com/questions/1067234/cant-use-wireless-brother-printer-2270dw-ubuntu-18-04
2206 # /a/opt/linux-brprinter-installer-2.2.2-1
2207 # answer n when it asks about uri.
2208 # Then go to cups, delete the existing printer, added on with dnssd url. browsed to
2209 # ppd at /usr/share/ppd/HL2270DW.ppd, which is duplicated at /usr/share/cups/model/HL2270DW.ppd
2210 # ppd file got installed from bash -x ./usr/local/Brother/Printer/HL2270DW/cupswrapper/cupswrap,
2211 # which I downloaded from their driver. but dont do that again, i copied it to /a/opt/HL2270DW.ppd,
2214 # 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.
2215 # Then it was already configured, but if i needed to, go to its web ui, default pass is "access".
2217 ######### begin stuff belonging at the end ##########