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
180 p download debian-archive-keyring
181 s dpkg
-i debian-archive-keyring
186 if [[ ! -e /usr
/share
/debootstrap
/scripts
/bookworm
]]; then
189 m aptitude download debootstrap
/bookworm
191 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
196 sd
/etc
/apt
/preferences.d
/focal
<<'EOF'
198 Pin: release n=focal,o=Ubuntu
202 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
203 Package: spamassassin sa-compile spamc
204 Pin: release n=focal,o=Ubuntu
207 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
208 Package: spamassassin sa-compile spamc
209 Pin: release n=focal,o=Ubuntu
212 sd
/etc
/apt
/preferences.d
/psd
<<'EOF'
213 Package: profile-sync-daemon
214 Pin: release n=focal,o=Ubuntu
218 f
=/etc
/apt
/sources.list.d
/focal.list
221 deb http://us.archive.ubuntu.com/ubuntu/ focal main universe
222 deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main universe
223 deb http://us.archive.ubuntu.com/ubuntu/ focal-security main universe
225 if ! diff -q $t $f; then
226 sudo
dd if=$t of
=$f status
=none
232 sd
/etc
/apt
/preferences.d
/nabia-etiona
<<'EOF'
234 Pin: release n=nabia*,o=Trisquel
238 f
=/etc
/apt
/sources.list.d
/nabia.list
241 deb http://mirror.fsf.org/trisquel/ nabia main
242 deb-src http://mirror.fsf.org/trisquel/ nabia main
244 deb http://mirror.fsf.org/trisquel/ nabia-updates main
245 deb-src http://mirror.fsf.org/trisquel/ nabia-updates main
247 deb http://archive.trisquel.info/trisquel/ nabia-security main
248 deb-src http://archive.trisquel.info/trisquel/ nabia-security main
250 # Uncomment this lines to enable the backports optional repository
251 deb http://mirror.fsf.org/trisquel/ nabia-backports main
252 deb-src http://mirror.fsf.org/trisquel/ nabia-backports main
254 if ! diff -q $t $f; then
255 sudo
dd if=$t of
=$f status
=none
259 # duplicated in fai. Pin for bionic + ubuntu so that ppas dont get
261 sd
/etc
/apt
/preferences.d
/etiona-bionic
<<'EOF'
263 Pin: release n=bionic,o=Ubuntu
266 Pin: release n=bionic,o=Ubuntu
270 sd
/etc
/apt
/preferences.d
/etiona-sa
<<'EOF'
272 Pin: release n=bionic,o=Ubuntu
278 sd
/etc
/apt
/preferences.d
/aramo-nabia
<<'EOF'
280 Pin: release n=aramo*,o=Trisquel
283 f
=/etc
/apt
/sources.list.d
/aramo.list
286 deb http://mirror.fsf.org/trisquel/ aramo main
287 deb-src http://mirror.fsf.org/trisquel/ aramo main
289 deb http://mirror.fsf.org/trisquel/ aramo-updates main
290 deb-src http://mirror.fsf.org/trisquel/ aramo-updates main
292 deb http://archive.trisquel.info/trisquel/ aramo-security main
293 deb-src http://archive.trisquel.info/trisquel/ aramo-security main
295 # Uncomment this lines to enable the backports optional repository
296 deb http://mirror.fsf.org/trisquel/ aramo-backports main
297 deb-src http://mirror.fsf.org/trisquel/ aramo-backports main
299 if ! diff -q $t $f; then
300 sudo
dd if=$t of
=$f status
=none
307 pi debian-goodies shellcheck
312 case $codename_compat in
314 s systemctl
enable --now ssh-agent-iank
318 case $codename_compat in
320 sd
/etc
/apt
/preferences.d
/nabia-btrfs-progs
<<'EOF'
322 Pin: release a=buster-backports
325 p
install btrfs-progs
330 # 2020-03-03 old file
331 s
rm -fv /etc
/apt
/preferences.d
/radicale
332 ######### end universal pinned packages ######
337 sd
/etc
/apt
/preferences.d
/obs
<<EOF
339 Pin: release n=bionic
342 sd
/etc
/apt
/preferences.d
/chromium
<<EOF
344 Pin: release n=bionic
349 # note, to get the latest, it would be n=bullseye*
350 # but that has conflicting package versions, so this does the old one.
351 # I only use it for special rare purposes. Just keep in mind it is an
352 # outdated insecure version.
353 sd
/etc
/apt
/preferences.d
/chromium-bullseye
<<EOF
354 Package: chromium chromium-* libicu67 libjpeg62-turbo libjsoncpp24 libre2-9 libwebpmux3
355 Pin: release o=Debian*,n=bullseye
360 # obs dependency not in trisquel
361 sd
/etc
/apt
/preferences.d
/obs
<<EOF
363 Pin: release n=jammy,o=Ubuntu
371 ##### begin automatic upgrades (after checkrestart has been installed) ####
372 # if apt-config-auto-update is installed,
373 # it also has similar config, in a file 10something,
374 # but i think this overrides it since its higher number.
375 # This file was part of the automatic-updates package,
376 # and it has a config option to not get new package lists,
377 # which seems pretty stupid to me, you cant actually upgrade
378 # anything if you dont have the new package list.
379 sd
/etc
/apt
/apt.conf.d
/20auto-upgrades
<<'EOF'
380 # note: man apt.conf says
381 # /usr/share/doc/apt/examples/configure-index.gz is a configuration file showing
382 # example values for all possible options.
383 # but that is a incorrect.
384 # Periodic and other options are only documented in
385 # /usr/lib/apt/apt.systemd.daily
386 # That filename can be found through poking around in apt daily cronjob.
387 APT::Periodic::Update-Package-Lists "1";
388 APT::Periodic::Download-Upgradeable-Packages "1";
389 # 0 means disabled. I used to set this to 7, however, trisquel doesn't
390 # have an archive of old package versions, so I want to
391 # keep around old versions so I can easily downgrade.
392 APT::Periodic::AutocleanInterval "0";
393 # daily expire old files /var/cache/apt if it gets above this MB
394 APT::Periodic::MaxSize "50000";
395 APT::Periodic::Unattended-Upgrade "1";
398 # fyi: default file has comments about available options,
399 # you may want to read that, do pkx unattended-upgrades
400 # default is just security updates. this list found from reading
401 # match_whitelist_string() in $(which unattended-upgrades)
402 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
403 Unattended-Upgrade::Mail "root";
404 Unattended-Upgrade::MailOnlyOnError "true";
405 Unattended-Upgrade::Remove-Unused-Dependencies "true";
406 Unattended-Upgrade::Origins-Pattern {
407 "o=*,l=*,a=*,c=*,site=*,n=*";
412 sudo
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
/etc
/cron.d
/myupgrade
414 # myupgrade cron exists in /etc/cron.d/ian
416 ##### end automatic upgrades ####
419 # commented in case i want to use this sometime later
420 # sd /etc/apt/preferences.d/buster-backports <<EOF
422 # Pin: release a=buster-backports
427 ###### begin website setup
431 f
=/var
/lib
/bind
/db.b8.nz
432 if [[ ! -e $f ]]; then
436 sudo
/c
/roles
/prom_export
/files
/simple
/usr
/local
/bin
/fsf-install-node-exporter
-l 127.0.0.1
439 web-conf
-p 9101 -f 9100 - apache2
${HOSTNAME}ex.b8.nz
<<'EOF'
442 AuthName "basic_auth"
444 # htpasswd -c prometheus-export-htpasswd USERNAME
445 AuthUserFile "/etc/prometheus-export-htpasswd"
454 # i just dont feel like setting up a special purpose ssh key to do this automatically.
456 # run this once for bk on local machine:
457 # only used for old openvpn setup
458 /a/exe/vpn-mk-client-cert -c bk.b8.nz -b expertpath -n mail li.iankelling.org
468 if [[ ! -L ~
/eggdrop
/eggdrop
]]; then
470 git clone https
://github.com
/eggheads
/eggdrop eggdrop-src
478 # dunno if this is really needed. it was part of the documented eggdrop systemd install script
479 sudo loginctl enable-linger
480 systemctl
--user enable fsysbot
481 systemctl
--user start fsysbot
483 m
/a
/h
/setup.sh iankelling.org
485 # start mumble only when im going to use it, since i dont use it much
486 pi-nostart mumble-server
487 sudo
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
489 # do certificate to avoid warning about unsigned cert,
490 # which is overkill for my use, but hey, I'm cool, I know
492 m web-conf apache2 mumble.iankelling.org
493 sudo
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
495 # general vpn for as needed use
496 vpn-server-setup
-d -r -4 10.5.5 -p 443 -n hole
498 # todo: consider if this should exist for the
500 teeu
/etc
/openvpn
/server
/hole.conf
<<'EOF'
506 files
=(/etc
/openvpn
/client-config-hole
/*)
507 if (( ${#files[@]} >= 1 )); then
511 for host in ${!vpn_ips[@]}; do
512 sd
/etc
/openvpn
/client-config-hole
/$host <<EOF
513 ifconfig-push 10.5.5.${vpn_ips[$host]} 255.255.255.0
518 # for adding cert to system with /p
521 #mkc /p/c/machine_specific/$host/filesystem/etc/openvpn/client
522 #vpn-mk-client-cert -b $host -n hole -r iankelling.org
523 #s chown -R iank:iank .
525 # example of adding to remote system 107,
526 # vpn-mk-client-cert -n hole -c 10.2.0.107 -b hd8 iankelling.org
528 # for wireguard hole vpn, use function:
532 # if it is going to want to connect to transmission-daemon on ok
533 # wghole bo 28 10.174.2.2/32
535 # requested from linode via a support ticket.
536 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
537 # ipv6 stuff pieced together
538 # via slightly wrong information from
539 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
540 # https://community.openvpn.net/openvpn/wiki/IPv6
543 # This uses a public /64, but afaik, that is not needed for my
544 # current use case, since I'm doing ipv6 nat, they could be private
545 # and nat to a public address. I'm doing ipv6 nat in order to have 2
546 # vpn clients that externally share the same ip when sending so they
547 # share ip reputation. Note, the eth0 and tunx needed to be
548 # different subnets. On the same, I saw some neighbor packet go
549 # unanswered, tcpdump showed packets getting lost. I tried splitting the
550 # /64, it didn't work but I didn't investigate closely.
553 # not starting as i intend to replace it
554 m vpn-server-setup
-s -i tunmail
-n mail -d -6 2600:3c00
:e002
:3800::/64 2600:3c00
:e002
:3800::1/64
555 sudo
tee /etc
/openvpn
/client-config-mail
/mailclient
<<'EOF'
556 ifconfig-push 10.8.0.4 255.255.255.0
557 ifconfig-ipv6-push 2600:3c00:e002:3800::4/64
559 sudo
tee /etc
/openvpn
/client-config-mail
/expertpath
<<'EOF'
560 ifconfig-push 10.8.0.5 255.255.255.0
561 ifconfig-ipv6-push 2600:3c00:e002:3800::5/64
565 sudo
dd of
=/etc
/systemd
/system
/vpn-mail-forward.service
<<'EOF'
567 Description=Turns on iptables mail nat
568 BindsTo=openvpn-server@mail.service
573 ExecStart=/a/bin/distro-setup/vpn-mail-forward tunmail start
574 ExecStop=/a/bin/distro-setup/vpn-mail-forward tunmail stop
577 RequiredBy=openvpn-server@mail.service
582 # needed for li's local mail delivery.
583 tu
/etc
/hosts
<<<"10.8.0.4 mx.iankelling.org"
585 # wgmail handles this.
586 #sgo vpn-mail-forward.service
588 #sgo openvpn-server@mail
591 # setup let's encrypt cert
592 m web-conf apache2 mail.iankelling.org
593 # TODO, i expanded the above cert manually to mx.iankelling.org, this should be captured
594 # in the automation here. We use mail.iankelling.org as our ehlo name when sending mail
595 # but our mx record is mx.iankelling.org. Initially I was just using mail.iankelling.org,
596 # but the problem is I want multiple ips to be able to identify as mail.iankelling.org,
597 # but a subset to be mx.iankelling.org. Afaik, there is no problem with having
598 # our mail cert be for mail.iankelling.org, and have people connect to mx.ian...,
599 # but it doesn't make logical sense to do this.
600 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
603 a2enmod -q proxy proxy_http
604 domain=cal.iankelling.org
605 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
606 # https://radicale.org/2.1.html
607 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
608 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
610 # this doesn't exactly fit with the documentation.
611 # We need location / to do an auth, it cant be done outside,
612 # in order to pass on X-Remote-User. And we need
613 # the other location in order to remove the /radicale/ for
614 # requests which have it. This could be done with a rewrite,
615 # but i just get something working and call it a day.
620 AuthName "Authentication Required"
621 # setup one time, with root:www-data, 640
622 AuthUserFile "/etc/caldav-htpasswd"
624 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
626 <Location "/radicale/">
627 Options +FollowSymLinks +Multiviews -Indexes
628 RequestHeader set X-Script-Name /radicale/
629 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
630 ProxyPass "http://10.8.0.4:5232/" retry=0
631 ProxyPassReverse "http://10.8.0.4:5232/"
634 # nginx version of above would be:
635 # auth_basic "Not currently available";
636 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
640 ###### begin znc setup #####
643 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
644 # to get into the web interface,
645 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
646 # https://iankelling.org:12533/
647 # login as ian, pass is in pass store, the part after :
649 # znc config generated by doing
651 # selected port is also used in erc config
652 # comma separated channel list worked.
653 # while figuring things out, running znc -D for debug in foreground.
654 # to exit and save config:
655 # /msg *status shutdown
656 # configed auth on freenode by following
657 # https://wiki.znc.in/Sasl:
661 # Set MyNickservName pa$$w0rd
662 # created the system service after, and had to do
663 # mv /home/iank/.znc/* /var/lib/znc
664 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
665 # and made a copy of the config files into /p/c
666 # /msg *status LoadMod --type=global log -sanitize
667 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
668 # /msg *status LoadMod --type=network perform
669 # /query *perform add PRIVMSG ChanServ :invite #fsf-office
670 # /msg *perform add JOIN #fsf-office
671 # /msg *status LoadMod NickServ
674 # also ran /znc LoadMod clearbufferonmsg
675 # it would be nice if erc supported erc query buffers by doing
676 # /msg *status clearbuffer <name of the query/receiver
678 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
679 # if that was the case i could remove the module clearbufferonmsg
680 # also would be nice if erc supported
681 # https://wiki.znc.in/self-message
682 # https://wiki.znc.in/Query_buffers \
684 # for geekshed, there was no sasl support as far as I can tell,
685 # so I set to msg nickserv to identify upon connect.
686 if ! getent passwd znc > /dev/null; then
687 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
689 sudo chmod 700 /var/lib/znc
690 sudo chown -R znc:znc /var/lib/znc
691 # Avoid restarting if possible, reconnecting to irc is annoying.
692 # The unit file was made active with conflink.
693 # Note, avoid using ser here because we wrap sudo to prints the command first.
694 if [[ $(systemctl is-active znc) != active ]]; then
697 ###### stop znc setup #####
706 # todo, save the config
707 /etc/cron.daily/stream-cert
708 web-conf -c /etc/cert-live.fsf.org -p 443 -f 8000 apache2 live.fsf.org
712 ###### end website setup
714 ########### end section including li/lj ###############
719 ### system76 things ###
721 bo) # sy| sy doesnt seem to really need this.
722 # note, i stored the initial popos packages at /a/bin/data/popos-pkgs
723 if [[ ! -e /etc/apt/sources.list.d/system76.list ]]; then
724 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
725 sd /etc/apt/sources.list.d/system76.list <<EOF
726 deb http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
727 deb-src http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
729 # ubuntu keyserver is prone to intermittent failures
730 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5D1F3A80254F6AFBA254FED5ACD442D1C8B7748B
732 # https://support.system76.com/articles/install-ubuntu/
733 # but i'm hoping this is not needed
734 # sd /etc/apt/preferences.d/system76 <<'EOF'
736 # Pin: release o=LP-PPA-system76-dev-stable
740 # TODO: I had to uninstall linux-image-generic-hwe-20.04 because of a conflict
741 # about linux-firmware. Should probably install it to begin with in fai if
743 pi system76-driver system76-firmware
744 # if you get a notice about a firmware update, the notifier on i3
745 # is too dumb to do anything when you click it. so to see
747 # /var/cache/system76-firmware-daemon
748 # extract the xz files there, one will contain a changelog.
749 # then to install an update:
750 # s system76-firmware-cli schedule
754 ### end system76 things ###
759 # ppa:obsproject/obs-studio
760 if [[ ! -s /etc/apt/sources.list.d/obs.list ]]; then
761 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
762 sd /etc/apt/sources.list.d/obs.list <<EOF
763 deb http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
764 deb-src http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
766 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BC7345F522079769F5BBE987EFC71127F425E228
772 case $codename_compat in
774 # mate-indicator-applet and beyond are msc things I noticed diffing a
775 # standard install with mine.
776 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
782 # todo: figure out mate for buster
783 # pi task-gnome-desktop
786 # i had installing mate-indicator-applet, but im not sure why so i removed
787 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras anacron
790 # # apt-get update periodically fails with an appstream error.
791 # # this removes gnome-core, but its just a package for dependencies
792 # p -y remove appstream
795 # by default, it sleeps when not logged in to x/wayland and on ac power.
797 if id -u gdm &>/dev/null; then
798 sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
802 # lightdm startup fails without this. on etiona, we got unity-greeter installed automatically,
803 # it would probably work on nabia too, but google just lead me to this and it works fine.
804 pi lightdm-gtk-greeter
805 # ok, this is really weird
806 # normally this file has
807 sd /etc/X11/Xsession.d/99x11-common_start <<'EOF'
809 # this file normally just has: exec $STARTUP
810 # but then ~/.xsession-errors
811 # says $STARTUP is not found, which appears to be the real
812 # error, but normal bash doesnt operate that way.
813 # https://bugs.launchpad.net/ubuntu/+source/im-config/+bug/1879352
816 # also, gdm wayland was default, had to do
817 # dpkg-reconfigure gdm3
818 # and choose lightdm.
822 # not yet bothering with mate
823 pi lightdm-gtk-greeter lightdm
828 if [[ $codename_compat == flidas ]]; then
829 # doesnt exist in newer
838 # firefox would work here too, apt would select abrowser.
839 # and the update-alternatives thing i think is becuz firefox is
840 # generally available before abrowser and this helps fix things
841 # up when we have both.
843 s update-alternatives --set x-www-browser /usr/bin/abrowser
855 # newer distros just use adb for package name it seems
856 case $codename_compat in
858 pi android-tools-adbd
862 case $codename_compat in
864 pi libext2fs-dev libzstd-dev
865 cd /a/opt/btrfs-progs
870 case $codename_compat in
879 # not packaged in newer distros it seems
880 case $codename_compat in
881 bionic|buster|stretch)
887 # TODO: some of the X programs can be removed from pall when using wayland
889 # depends gcc is a way to install suggests. this is apparently the only
890 # way to install suggests even if the main package is already
891 # installed. reinstall doesn't work, uninstalling can cause removing
892 # dependent packages.
893 # shellcheck disable=SC2046 # word splitting is intended
894 pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $($src/distro-pkgs)
896 # schroot service will restart schroot sessions after reboot.
900 # fix systemd unit failure. i dont know of any actual impact
901 # other than systemd showing in degraded state. So, we dont bother
902 # fixing the current state, let it fix on the next reboot.
903 # https://gitlab.com/cjwatson/binfmt-support/-/commit/54f0e1af8a
904 tmp=$(systemctl cat binfmt-support.service | grep ^After=)
905 if [[ $tmp != *systemd-binfmt.service* ]]; then
906 s u /etc/systemd/system/binfmt-support.service.d/override.conf <<EOF
908 $tmp systemd-binfmt.service
913 # commented, not worth the hassle i think.
919 sudo rm -fv /etc/systemd/resolved.conf.d/iank.conf
921 # website is dead june 14 2019. back in october, but meh
922 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
927 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
930 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
931 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
933 # f=/etc/apt/sources.list.d/iridium-browser.list
934 # if ! diff -q $t $f; then
945 if mountpoint /p &>/dev/null; then
946 # note, see bashrc for more documentation.
948 sd /etc/systemd/system/rss2email.service <<'EOF'
950 Description=rss2email
951 After=multi-user.target
956 # about 24 hours of failures
957 # it copies over its files without respecting symlinks, so
958 # we pass options to use different location.
959 ExecStart=/usr/local/bin/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
961 sd /etc/systemd/system/rss2email.timer <<'EOF'
963 Description=rss2email
966 # for initial run. required.
968 # for subsequent runs.
969 OnUnitInactiveSec=300
972 WantedBy=timers.target
974 sudo systemctl daemon-reload
978 ######### begin irc periodic backup #############
979 if [[ $HOSTNAME == frodo ]]; then
980 sd /etc/systemd/system/ircbackup.service <<'EOF'
982 Description=irc li backup
983 After=multi-user.target
988 ExecStart=/usr/local/bin/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
990 sd /etc/systemd/system/ircbackup.timer <<'EOF'
992 Description=irc li backup hourly
998 WantedBy=timers.target
1000 sudo systemctl daemon-reload
1005 ######### end irc periodic backup #############
1009 # pi-nostart does not disable
1013 if [[ -e /p/c/gen-fsf-vpn ]]; then
1017 if [[ -e /p/c/machine_specific/$HOSTNAME/filesystem/etc/openvpn/client/hole.crt ]]; then
1018 sgo openvpn-client@hole
1021 ############# begin syncthing setup ###########
1024 f=/usr/share/keyrings/syncthing-archive-keyring.gpg
1025 if [[ ! -e $f ]]; then
1026 s curl -s -o $f https://syncthing.net/release-key.gpg
1028 s="deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable"
1029 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
1030 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
1036 m lnf -T /w/syncthing /home/iank/.config/syncthing
1037 ser daemon-reload # syncthing likely not properly packaged
1038 sgo syncthing@iank # runs as iank
1042 # 1003 just happens to be what was on my system
1043 if ! getent passwd ziva; then
1044 s groupadd -g 1003 ziva
1045 # syncthing state / config / db are all in ~/.config/syncthing
1046 s useradd -g 1003 -u 1003 -d /d/ziva-home -c ziva -s /bin/bash ziva
1052 # user for short term use dropping of privileges
1054 if ! getent group zu &>/dev/null; then
1055 s groupadd -g 1023 zu
1057 if ! getent passwd zu &>/dev/null; then
1058 s useradd -g 1023 -u 1023 -c zu -s /bin/bash zu
1062 # these things persist in ~/.config/syncthing, which I save in
1063 # /w/syncthing (not in /p, because syncthing should continue to
1064 # run on home server even when using laptop as primary device)
1065 # open http://localhost:8384/
1066 # change listen address from default to tcp://:22001,
1067 # this is because we do port forward so it doesn\'t have to use
1068 # some external server, but the syncthing is broken for port forward,
1069 # you get a message, something "like connected to myself, this should not happen"
1070 # when connecting to other local devices, so I bump the port up by 1,
1072 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
1073 # Without this, it was being stuck syncing at 0%.
1074 # Set gui username and password.
1076 # install syncthing via f-droid,
1077 # folder setting, turn off send only.
1078 # on phone, add device, click bar code icon
1079 # on dekstop, top right, actions, device id
1080 # after adding, notification will appear on desktop to confirm
1082 # syncing folder. from phone to desktop: select desktop in the
1083 # folder on phone\'s sync options, notification will appear in
1084 # desktop\'s web ui within a minute. For the reverse, the
1085 # notification will appear in android\'s notifications, you have to
1086 # swipe down and tap it to add the folder. It won\'t appear in the
1087 # syncthing ui, which would be intuitive, but don\'t wait for it
1088 # there. The notification may not work, instead open the web gui
1089 # from in the app, there should be a notification within there.
1091 # On phone, set settings to run syncthing all the time, and
1092 # show no notification.
1094 # Folder versioning would make sense if I didn\'t already use btrfs
1095 # for backups. I would choose staggered, or trash can for more space.
1097 # if needed to install on a remote comp:
1098 # ssh -L 8384:localhost:8384 -N frodo
1099 # open http://localhost:8384/
1101 # Note, the other thing i did was port forward port 22000,
1102 # per https://docs.syncthing.net/users/firewall.html
1104 ############# end syncthing setup ###########
1108 ####### begin misc packages ###########
1110 # old location, 2023.
1111 sudo rm -fv /etc/systemd/system/profanity.service
1114 ln -sfT /d/p/profanity ~/.local/share/profanity
1115 ln -sfT /d/p/profanity-config ~/.config/profanity
1116 source /a/bin/bash_unpublished/source-state
1117 if [[ $HOSTNAME == "$HOST2" || ! -e /p/profanity-here ]]; then
1118 systemctl --user --now enable profanity
1123 ln -sfT /p/profanity ~/.local/share/profanity
1124 ln -sfT /p/profanity-config ~/.config/profanity
1135 sudo update-alternatives --set pinentry /usr/bin/pinentry-gtk-2
1138 # sakura config is owned by ian
1141 m sudo -u user2 -i reset-konsole
1142 # user2 xscreensaver we don't want to reset
1143 m reset-xscreensaver
1146 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
1147 # this is also in primary-setup
1148 # pi libxss-dev # dependency based on build failure
1150 # cabal install --upgrade-dependencies --force-reinstalls arbtt
1151 # also, i assume syncing this between machines somehow messed up the data.
1153 ## not using arbtt for now
1154 # if mountpoint /p &>/dev/null; then
1158 # # same as seru enable arbtt, but works over ssh when systemctl --user causes error:
1159 # # Failed to connect to bus: No such file or directory
1160 # lnf -T /a/bin/ds/subdir_files/.config/systemd/user/arbtt.service /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1162 # seru start arbtt ||:
1166 rm -fv /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1171 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
1172 m cp /p/.linphonerc-initial ~/.linphonerc
1175 # linphone in t10 wont do dns with systemd-resolved or something
1176 s teeu /etc/hosts <<'EOF'
1177 74.94.156.215 watson.fsf.org
1182 ### begin spd install
1183 if mountpoint /p &>/dev/null; then
1184 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
1186 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
1189 # this guesses at the appropriate directory, adjust if needed
1190 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
1191 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
1192 # newer distro had gpg2 as default, older one, flidas, need to make it that way
1193 gpgpath=$(which gpg2) ||:
1194 if [[ $gpgpath ]]; then
1195 sudo mkdir -p /usr/local/spdhackfix
1196 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
1202 # nagstamon setting which were set through the ui
1203 # monitor url https://klaxon.fsf.org/cgi-bin
1204 # monitor url cgi https://klaxon.fsf.org/cgi-bin
1206 # all unknown services
1207 # all warning services
1208 # acknowledged hosts & services
1209 # hosts & services down for maintenence
1210 # services on down hosts
1211 # services on hosts in maintenece
1212 # services on unreachable osts
1213 # hosts in soft state
1214 # services in soft state
1215 # in display tab: fullscreen
1217 # these translate to these settings I think
1218 # filter_acknowledged_hosts_services = True
1219 # filter_all_unknown_services = True
1220 # filter_all_warning_services = True
1221 # filter_hosts_in_soft_state = True
1222 # filter_hosts_services_maintenance = True
1223 # filter_services_in_soft_state = True
1224 # filter_services_on_down_hosts = True
1225 # filter_services_on_hosts_in_maintenance = True
1226 # filter_services_on_unreachable_hosts = True
1227 # notify_if_up = False
1228 # statusbar_floating = False
1230 # but i'm just going to rely on the webpage plus sms for now.
1233 # it asks if it should make users in it's group capture packets without root,
1234 # which is arguably more secure than running wireshark as root. default is no,
1235 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
1236 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
1238 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
1239 # listed in the default config as suggested.
1240 # /run/usr/1000 i noticed was missing for pulseaudio
1241 # /run/user/0 just seemed like a not bad idea, given the above
1242 tu /etc/schroot/desktop/fstab <<'EOF'
1243 /p /p none rw,bind 0 0
1244 /a /a none rw,bind 0 0
1245 /run /run none rw,bind 0 0
1246 /run/lock /run/lock none rw,bind 0 0
1247 /dev/shm /dev/shm none rw,bind 0 0
1248 /run/shm /run/shm none rw,bind 0 0
1249 /run/user/1000 /run/user/1000 none rw,bind 0 0
1250 /run/user/1001 /run/user/1001 none rw,bind 0 0
1251 /run/user/0 /run/user/0 none rw,bind 0 0
1254 # todo: consider if this should use the new sysd-prom-fail
1255 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1257 Description=schrootupdate
1258 After=multi-user.target
1262 ExecStart=/usr/local/bin/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1264 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1266 Description=schrootupdate
1269 OnCalendar=*-*-* 04:20:00 America/New_York
1272 WantedBy=timers.target
1275 sgo schrootupdate.timer
1282 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/bookworm.list/BOOKWORM_FREE \
1283 debian bookworm firefox-esr pulseaudio chromium
1290 sudo mkdir -p /nocow/user
1291 sudo chown $USER:$USER /nocow/user
1295 ####### begin transmission
1305 tdir=/nocow/user/tor
1311 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1312 # 450 seems likely to be unused. we need to specify one or else
1313 # it won't be stable across installs.
1314 if ! getent passwd debian-transmission > /dev/null; then
1315 sudo groupadd -g 450 debian-transmission
1316 sudo adduser --quiet \
1321 --disabled-password \
1322 --home /var/lib/transmission-daemon \
1325 # We want group writable stuff from transmission.
1326 # However, after setting this, I learn that transmission sets it's
1327 # own umask based on it's settings file. Well, no harm leaving this
1328 # so it's set right from the beginning.
1329 sudo chfn debian-transmission -o umask=0002
1331 # note i had to do this, which is persistent:
1333 # s chgrp debian-transmission torrents partial-torrents
1335 # syslog says things like
1336 # 'Failed to set receive buffer: requested 4194304, got 425984'
1337 # google suggets giving it even more than that
1338 tu /etc/sysctl.conf<<'EOF'
1339 net.core.rmem_max = 67108864
1340 net.core.wmem_max = 16777216
1344 # some reason it doesn\'t seem to start automatically anyways
1345 pi-nostart transmission-daemon
1346 # be extra sure its not started
1347 ser disable transmission-daemon
1348 ser stop transmission-daemon
1350 # the folder was moved here after an install around 02/2017.
1351 # it contains runtime data,
1352 # plus a simple symlink to the config file which it\'s
1353 # not worth separating out.
1354 # between comps, the uid can change
1356 f=$tdir/transmission-daemon
1357 for d in $tdir/partial-torrents $tdir/torrents $f; do
1358 if [[ ! -d $d ]]; then
1361 sudo chown -R debian-transmission:user2 $d
1363 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1364 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1365 sudo chown -R debian-transmission:debian-transmission $f
1366 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1368 # config file documented here, and it\'s the same config
1369 # for daemon vs client, so it\'s documented in the gui.
1370 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1372 # I originaly setup rpc-whitelist, but after using
1373 # routing to a network namespace, it doesn\'t see the
1374 # real source address, so it\'s disabled.
1376 # Changed the cache-size to 256 mb, reduces disk use.
1377 # It is a read & write cache.
1379 # just fyi: default rpc port is 9091
1380 if ! systemctl is-active transmission-daemon-nn &>/dev/null && \
1381 ! systemctl is-active transmission-daemon; then
1383 command sudo ruby <<EOF >$tmp
1385 p = '/etc/transmission-daemon/settings.json'
1387 'rpc-whitelist-enabled' => false,
1388 'rpc-authentication-required' => false,
1389 'incomplete-dir' => '$tdir/partial-torrents',
1390 'incomplete-dir-enabled' => true,
1391 'download-dir' => '$tdir/torrents',
1392 "speed-limit-up" => 800,
1393 "speed-limit-up-enabled" => true,
1394 "peer-port" => 61486,
1395 "cache-size-mb" => 256,
1396 "ratio-limit" => 5.0,
1397 "ratio-limit-enabled" => false,
1399 puts(JSON.pretty_generate(JSON.parse(File.read(p)).merge(s)))
1401 cat $tmp | sudo dd of=/etc/transmission-daemon/settings.json
1405 ####### end transmission
1409 # to persist upload/dl metadata. initially, moved all the stuff
1410 # in /var/lib/transmission-daemon to /d/tor
1411 s usermod --home /d/tor debian-transmission
1412 sgo transmission-daemon-nn
1418 ######### begin transmission client setup ######
1420 # to connect from a remote client, trans-remote-route in brc2
1423 if [[ -e /p/transmission-rpc-pass ]]; then
1424 # arch had a default config,
1425 # debian had nothing until you start it.
1426 # With a little trial an error, here is a minimal config
1427 # taken from the generated one, plus changes that the
1428 # settings ui does, without a bunch of ui crap settings.
1430 # only settings I set were
1435 # the password is randomly generated on first run, i copied it out
1436 # so it could be used by other hosts.
1439 p = '/etc/transmission-daemon/settings.json'
1440 s = JSON.parse(File.read(p))
1441 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1442 # default is 0022 (18 in decimal)
1444 File.write p, JSON.pretty_generate(s)
1447 rpc_pass=$(</p/transmission-rpc-pass)
1448 for f in /home/*; do
1450 uid=$(id -u $u 2>/dev/null) || continue
1451 if [[ ! $uid -ge 1000 ]]; then
1454 d=$f/.config/transmission-remote-gtk
1455 sudo -u $u mkdir -p $d
1456 # i tried setting hostname to transmission.b8.nz, so i could dynamically change where
1457 # this connects to, but it said some 421 denied error when I did that. Then it
1458 # froze X when i ran it under strace. Whatever.
1459 sudo -u $u dd of=$d/config.json <<EOF
1463 "profile-name" : "Default",
1464 "hostname" : "10.174.2.2",
1465 "rpc-url-path" : "/transmission/rpc",
1467 "password" : "$rpc_pass",
1468 "auto-connect" : true,
1472 "update-active-only" : false,
1473 "activeonly-fullsync-enabled" : false,
1474 "activeonly-fullsync-every" : 2,
1475 "update-interval" : 3,
1476 "min-update-interval" : 3,
1477 "session-update-interval" : 60,
1478 "exec-commands" : [],
1483 "add-options-dialog" : false
1488 ######### end transmission client setup ######
1494 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1495 # goto http://127.0.0.1:631
1496 # administration tab, add new printer button.
1497 # In debian, I could use hte recommended driver,
1498 # in arch, I had to pick out the 6L driver.
1501 # bridge networking as user fails. google lead here, but it doesn\'t work:
1502 # oh well, I give up.
1503 # http://wiki.qemu.org/Features-Done/HelperNetworking
1505 # f=/etc/qemu/bridge.conf
1509 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1512 # general known for debian/ubuntu, not for fedora
1514 m /a/bin/buildscripts/go
1515 # only needed for rg. cargo takes up 11 gigs, filled up the disk on je.
1516 m /a/bin/buildscripts/rust
1517 m /a/bin/buildscripts/misc
1518 m /a/bin/buildscripts/pithosfly
1519 #m /a/bin/buildscripts/alacritty
1520 #m /a/bin/buildscripts/kitty
1522 pi-nostart virtinst virt-manager
1524 # i cant if this is whats causing it to start even though
1525 # its disabled. note: it leaves around dnsmasq instances even
1526 # if you stop it. what the hell systemd?
1528 # allow user to run vms, from debian handbook. libvirt-qemu
1529 # based on https://www.whonix.org/wiki/KVM#First-time_User.3F
1530 for x in iank user2; do s usermod -a -G libvirt,kvm,libvirt-qemu $x; done
1533 pi --no-install-recommends kdeconnect
1534 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1535 ### but gnome + xmonad not working in flidas, so i disabled it
1536 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1537 # cd /a/opt/indicator-kdeconnect
1540 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1543 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1544 # # it seems, according to
1545 # # /etc/xdg/autostart/kdeconnectd.desktop
1546 # # I'm not seeing the icon, but the clipboard replication is working
1549 ### begin model 01 arduino support ###
1550 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1551 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1552 # set arduino var in bashrc,
1553 # have system config file setup too.
1554 sudo adduser $USER dialout
1557 # download arduino ide, extract in /a/opt, ignore the install script, run ./arduino,
1558 # toolbar, preferences, add board manager url:
1559 # https://raw.githubusercontent.com/keyboardio/boardsmanager/master/package_keyboardio_index.json
1560 # toolbar, board manager, add keyboardio
1561 # toolbar, select model01 board
1562 # toolbar, examples, model01, compile
1566 # this is for the mail command too. update-alternatives is kind of misleading
1567 # since at least it's main commands pretend mail does not exist.
1568 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1569 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1571 ######### end misc packages #########
1574 # packages I once used before and liked, but don\'t want installed now for
1576 # python-sqlite is used for offlineimap
1577 # lxappearance python-sqlite dolphin paman dconf-editor
1583 # todo, finish configuring smart.
1586 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1587 # turn on smart. background on options:
1588 # first line, -a = test everyting on all devices.
1589 # -S on, turn on disk internal saving of vendor specific info,
1590 # from google, seems like this is usually already on and fairly standard.
1591 # -o on, turn on 4 hour period non-performance degrading testing.
1592 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1593 sched="-s (S/../.././02|L/../../6/03)"
1594 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1595 DEVICESCAN -a -o on -S on -n standby,q $sched \
1596 -m root@mail.iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1598 # in the default configuration of at least ubuntu 14.04, resolvconf is
1599 # configured to order any nameservers associated with tun* or tap*
1600 # before the normal internet interfaces, which means they are always
1601 # consulted first. This is often slower and undesirable, ie. local dns
1602 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1604 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1605 # however, this breaks dns lookup for hosts on the openvpn lan.
1606 # I can\'t figure out why hosts on the normal lan would not be
1607 # broken under the default ordering, except the host I was
1608 # testing with previously had an entry in /etc/hosts.
1610 ############# end unfinished
1612 ########### misc stuff
1615 xdg-settings set default-web-browser abrowser.desktop
1617 # xdg-settings get default-web-browser
1619 # pressing tab after sdf here:
1620 # scp sdfbash: set +o noglob: command not found
1621 # in t11, bash 5.1.16. this fixes it.
1622 sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
1624 rm -fv /home/iank/.mpv/watch_later
1625 rm -rf /home/iank/.mpv
1627 if [[ ! -e ~/.local/bin/pip ]]; then
1629 wget -O$tmp https://bootstrap.pypa.io/get-pip.py
1635 # soo, apt install beets fails due to wanting a pip package,
1636 # we find out why it wants this through
1637 # apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances beets | less
1638 # python-mediafile requires tox, which requires virtualenv, which requires pip.
1639 # but, python-mediafile doesn't really require tox, it is specified in
1640 # ./usr/lib/python3/dist-packages/mediafile-0.9.0.dist-info/METADATA
1641 # as being required only for testing, but the debian package
1642 # included it anyways, due to a mistake or bad tooling or something.
1643 # I don't plan to use tox, so, according to https://serverfault.com/a/251091,
1644 # we can create and install a dummy package by:
1646 # "equivs-control <name>, edit the file produced to provide the right
1647 # dependency and have a nice name, then run equivs-build <name> and
1648 # finally dpkg -i the resulting .deb file"
1649 # as of 2023-02, the tox dependency was removed in debian unstable, so
1650 # this hack will probably go away in t12.
1652 if pcheck beets; then
1653 tmpdir="$(mktemp -d)"
1655 # edited from output of equivs-control tox
1659 Standards-Version: 3.9.2
1661 Description: tox-dummy
1664 sudo dpkg -i tox_1.0_all.deb
1666 pi beets python3-discogs-client
1671 # get rid of annoying message
1672 s sed -ri "s/^([[:space:]]*ui.print_\('Playing)/#\1/" /usr/share/beets/beetsplug/play.py
1675 # notes about barrier
1676 # run barrier, do the gui config,
1677 # setup the 2 screens, using hostnames for the new screen.
1678 # save the server config
1679 # $HOME/.local/share/barrier/.barrier.conf
1682 # ssl errors, resolved via advice here: https://github.com/debauchee/barrier/issues/231
1683 # BARRIER_SSL_PATH=~/.local/share/barrier/SSL/
1684 # mkdir -p "${BARRIER_SSL_PATH}"
1685 # openssl req -x509 -nodes -days 365 -subj /CN=Barrier -newkey rsa:4096 -keyout ${BARRIER_SSL_PATH}/Barrier.pem -out ${BARRIER_SSL_PATH}/Barrier.pem
1686 # ran on both machines.
1687 # When pressing start in the gui, the cli options used are printed to the console,
1688 # they are useful. So on server, just run barriers, client run barrierc SERVER_IP
1690 ### begin timetrap setup
1691 if mountpoint /p &>/dev/null; then
1692 mkdir -p ~/.timetrap/
1693 ln -sf /a/opt/timetrap_formatters ~/.timetrap/formatters
1694 if ! type -p t &>/dev/null; then
1695 pi ruby-dev libsqlite3-dev
1696 gem install --user timetrap
1699 ### end timetrap setup
1701 # leftover cleanup for t9
1705 # needed for debootstrap scripts for fai since fai requires debian
1708 pi-nostart network-manager
1709 # i hate networkmanager. noo, of course disabling it doesnt work
1710 # unless you add a hack. found this by doing
1711 # systemd-analyze dot > x.dot
1715 soff NetworkManager-wait-online.service
1716 # make networkmanager use resolvconf instead of its own dnsmasq which
1717 # conflicts with the normal dnsmasq package.
1718 f=/etc/NetworkManager/NetworkManager.conf
1720 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1721 sudo sed -ri '/ *\[main\]/a dns=default' $f
1722 if [[ $m != $(md5sum $f) ]]; then
1723 srestart NetworkManager
1725 # networkmanager has this nasty behavior on flidas: if the machine
1726 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1727 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1729 # This can be manually fixed by stoping dnsmasq,
1730 # then based on whats in /run/dnsmasq/, i see we can run
1731 # s resolvconf -d NetworkManager
1732 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1733 ser disable NetworkManager
1737 # I have no use for avahi,
1738 # had to run this twice when doing manually, i dunno why
1739 soff avahi-daemon ||:
1743 # make my /etc/fonts/conf.d/ get used.
1744 # I have a new sans-serif font there because the default one
1745 # displays l and I as the same char, grrrrr.
1748 pi desktop-file-utils
1749 m /a/bin/distro-setup/mymimes
1751 if type -p dbus-launch >/dev/null; then
1752 # stop autopoping windows when i plug in an android phone.
1753 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1754 # with still 0 exit code.
1755 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1756 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1759 # on grub upgrade, we get prompts unless we do this
1761 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1762 devs+=("$(devbyid $dev),")
1764 devs[-1]=${devs[-1]%,} # jonied by commas
1765 sudo debconf-set-selections <<EOF
1766 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1770 sysd-prom-fail-install dynamicipupdate
1771 sysd-prom-fail-install systemstatus
1772 sysd-prom-fail-install btrfsmaintstop
1773 sgo btrfsmaint.timer
1779 if grep -xFq $HOSTNAME /a/bin/ds/machine_specific/btrbk.hosts; then
1783 # note: to see when a timer was last run,
1787 ### begin prometheus ###
1791 # Font awesome is needed for the alertmanager ui.
1792 pi prometheus-alertmanager prometheus fonts-font-awesome
1793 /c/roles/prom/files/simple/usr/local/bin/fsf-install-prometheus
1794 # make it available for other machines
1795 rsync -a /usr/local/bin/amtool /a/opt/bin
1796 web-conf -p 9091 -f 9090 - apache2 i.b8.nz <<'EOF'
1799 AuthName "basic_auth"
1801 # htpasswd -c prometheus-htpasswd USERNAME
1802 AuthUserFile "/etc/prometheus-htpasswd"
1807 web-conf -p 9094 -f 9093 - apache2 i.b8.nz <<'EOF'
1810 AuthName "basic_auth"
1812 # htpasswd -c prometheus-htpasswd USERNAME
1813 AuthUserFile "/etc/prometheus-htpasswd"
1818 # by default, the alertmanager web ui is not enabled other than a page
1819 # that suggests to use the amtool cli. that tool is good, but you cant
1820 # silence things nearly as easily as with the gui.
1821 if [[ ! -e /usr/share/prometheus/alertmanager/ui/index.html ]]; then
1822 # default script didnt work, required some changes to get elm 19.1,
1823 # which is a dependency of the latest alertmanager. I modified
1824 # and copied it into /b/ds. In future, might need some other
1826 #sudo /usr/share/prometheus/alertmanager/generate-ui.sh
1827 sudo /b/ds/generate-ui.sh
1828 ser restart prometheus-alertmanager
1831 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter -l 127.0.0.1
1833 for ser in prometheus-node-exporter prometheus-alertmanager prometheus; do
1834 sysd-prom-fail-install $ser
1839 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter
1843 # cleanup old files. 2023-02
1844 x=(/var/lib/prometheus/node-exporter/*.premerge)
1845 if [[ -e ${x[0]} ]]; then
1846 s rm /var/lib/prometheus/node-exporter/*
1851 # todo, for limiting node exporter http,
1852 # either use iptables or, in
1853 # /etc/default/prometheus-node-exporter
1854 # listen on the wireguard interface
1857 wgip=$(command sudo sed -rn 's,^ *Address *= *([^/]+).*,\1,p' /etc/wireguard/wghole.conf)
1858 # old filename. remove once all hosts are updated.
1859 s rm -fv /etc/apache2/sites-enabled/${HOSTNAME}wg.b8.nz.conf
1860 web-conf -i -a $wgip -p 9101 -f 9100 - apache2 ${HOSTNAME}wg.b8.nz <<'EOF'
1863 AuthName "basic_auth"
1865 # htpasswd -c prometheus-export-htpasswd USERNAME
1866 AuthUserFile "/etc/prometheus-export-htpasswd"
1870 # For work, i think we will just use the firewall for hosts in the main data center, and
1871 # vpn for hosts outside it.
1873 # TODO: figure out how to detect the ping failure and try again.
1875 # Binding to the wg interface, it might go down, so always restart, and wait for it on boot.
1876 s mkdir /etc/systemd/system/apache2.service.d
1877 sd /etc/systemd/system/apache2.service.d/restart.conf <<EOF
1879 After=wg-quick@wghole.service
1880 StartLimitIntervalSec=0
1890 ### end prometheus ###
1892 ### begin nagios ###
1894 pi nagios-nrpe-server
1898 # the backport is for this bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800345
1899 pi nagios4 nagios-nrpe-plugin monitoring-plugins-basic/bullseye-backports
1900 s rm -fv /etc/apache2/conf-enabled/nagios4-cgi.conf
1902 # to add a password for admin:
1903 # htdigest /etc/nagios4/htdigest.users Nagios4 iank
1904 # now using the same pass as prometheus
1906 # nagstamon auth settings, set to digest instead of basic.
1908 web-conf -p 3005 - apache2 i.b8.nz <<'EOF'
1909 # adapted from /etc/apache2/conf-enabled/nagios4-cgi.conf
1911 ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4
1912 ScriptAlias /nagios4/cgi-bin /usr/lib/cgi-bin/nagios4
1914 # Where the stylesheets (config files) reside
1915 Alias /nagios4/stylesheets /etc/nagios4/stylesheets
1917 # Where the HTML pages live
1918 Alias /nagios4 /usr/share/nagios4/htdocs
1920 <DirectoryMatch (/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)>
1921 Options FollowSymLinks
1922 DirectoryIndex index.php index.html
1923 AllowOverride AuthConfig
1925 # The default Debian nagios4 install sets use_authentication=0 in
1926 # /etc/nagios4/cgi.cfg, which turns off nagos's internal authentication.
1927 # This is insecure. As a compromise this default apache2 configuration
1928 # only allows private IP addresses access.
1930 # The <Files>...</Files> below shows how you can secure the nagios4
1931 # web site so anybody can view it, but only authenticated users can issue
1932 # commands (such as silence notifications). To do that replace the
1933 # "Require all granted" with "Require valid-user", and use htdigest
1934 # program from the apache2-utils package to add users to
1935 # /etc/nagios4/htdigest.users.
1937 # A step up is to insist all users validate themselves by moving
1938 # the stanza's in the <Files>..<Files> into the <DirectoryMatch>.
1939 # Then by setting use_authentication=1 in /etc/nagios4/cgi.cfg you
1940 # can configure which people get to see a particular service from
1941 # within the nagios configuration.
1943 AuthDigestDomain "Nagios4"
1944 AuthDigestProvider file
1945 AuthUserFile "/etc/nagios4-htdigest.users"
1946 AuthGroupFile "/etc/group"
1952 <Directory /usr/share/nagios4/htdocs>
1959 # when you alter a service through the web, it changes vars in /var/lib/nagios4/status.dat. for example:
1960 # notifications_enabled=1
1961 # note, the same variable exists in the correspdonding "define service {"
1963 # in the default config, we have these definitions
1965 # 11 define command {
1966 # 2 define contact {
1967 # 1 define contactgroup {
1969 # 4 define hostgroup {
1970 # 23 define service {
1971 # 5 define timeperiod {
1976 # klaxon:/etc/nagios3 # grep -rho '^ *define [^{ ]*' | sort | uniq -c
1979 # 6 define contactgroup
1981 # 1 define hostextinfo
1982 # 16 define hostgroup
1983 # 3040 define service
1984 # 2 define servicedependency
1985 # 6 define timeperiod
1992 ### begin bitcoin ###
1996 sudo install -m 0755 -o root -g root -t /usr/bin /a/opt/bitcoin-26.0/bin/*
1997 # Note: i leave it to system-status to start and stop bitcoin.
1998 # note: the bitcoin user & group are setup in fai
1999 sudo usermod -a -G bitcoin iank
2000 # todo: make bitcoin have a stable uid/gid
2001 sudo mkdir -p /var/lib/bitcoind
2002 sudo chown bitcoin:bitcoin /var/lib/bitcoind
2003 # 710 comes from the upstream bitcoin unit file
2004 sudo chmod 710 /var/lib/bitcoind
2005 # note, there exists
2006 # /a/bin/ds/disabled/bitcoin
2014 # from https://raw.githubusercontent.com/cli/cli/trunk/docs/install_linux.md
2015 # One time setup afterwards:
2018 # When it gets to the page where it asks to authorize github, the button
2019 # is grayed out. You can just open browser dev tools, inspect the
2020 # button, remove disabled="", then click it and it works.
2022 # Auth token gets saved into /p/c/subdir_files/.local/share/keyrings/
2024 # initial config goes to /home/iank/.config/gh
2025 curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
2026 && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
2027 && 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 \
2028 && sudo apt update \
2029 && sudo apt install gh -y
2033 # remove trisquel banner. it is cool but takes up too much space.
2034 sudo rm -f /etc/update-motd.d/01-banner
2038 sd /etc/cups/client.conf <<'EOF'
2039 ServerName printserver1.office.fsf.org
2046 In mate settings settings, change scrolling to two-finger,
2047 because the default edge scroll doesn\'t work. Originally found this in debian.
2050 # Remove dep that came in with desktop to fix associations.
2051 m pu transmission-gtk
2055 lnf -T /d/vidshare /home/iank/Videos
2059 # # Based on guix manual instructions, also added code to profile.
2060 # # disabled since i'm not using it now.
2062 # if ! type -p guix >/dev/null; then
2064 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
2065 # # added some stuff to envonment.sh for profile based on
2066 # # manual instructions
2067 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
2068 # # echo is to get past prompt
2069 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
2070 # guix install glibc-utf8-locales
2071 # guix package --install guile
2077 m /a/bin/buildscripts/tor-browser
2078 # one root command needed to install
2079 s ln -sf /a/opt/tor-browser/Browser/start-tor-browser /usr/local/bin
2083 pi-nostart nfs-kernel-server
2085 # todo, this is old, probably needs removing
2086 if [[ $HOSTNAME == tp ]]; then
2087 sd /etc/wireguard/wg0.conf <<EOF
2089 PrivateKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.key)
2090 Address = 10.3.0.2/24, fdfd::2/64
2093 PresharedKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.psk)
2094 PublicKey = 9RnAsJB+ISrA/9lmDKBoT08oBiKwzA64exBBj+rO+ng=
2095 Endpoint = b8.nz:26000
2096 AllowedIPs = 10.3.0.1/24, fdfd::1/64
2097 PersistentKeepalive = 20
2099 sudo systemctl enable wg-quick@wg0
2100 sudo systemctl start wg-quick@wg0
2104 if [[ $HOSTNAME == kw ]]; then
2105 # hosts 1-199. 200+ are dynamic, avoid those
2106 tu /etc/exports <<'EOF'
2107 /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)
2108 /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)
2116 # if I was going to create a persistent vm, i might do it like this:
2117 # variant=something # from: virt-install --os-variant list
2118 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
2119 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
2120 # -n some_name --import --os-variant $variant --cpu host-model-only
2123 # for brother HL-2270DW, this worked:
2124 # https://askubuntu.com/questions/1067234/cant-use-wireless-brother-printer-2270dw-ubuntu-18-04
2125 # /a/opt/linux-brprinter-installer-2.2.2-1
2126 # answer n when it asks about uri.
2127 # Then go to cups, delete the existing printer, added on with dnssd url. browsed to
2128 # ppd at /usr/share/ppd/HL2270DW.ppd, which is duplicated at /usr/share/cups/model/HL2270DW.ppd
2129 # ppd file got installed from bash -x ./usr/local/Brother/Printer/HL2270DW/cupswrapper/cupswrap,
2130 # which I downloaded from their driver. but dont do that again, i copied it to /a/opt/HL2270DW.ppd,
2133 # 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.
2134 # Then it was already configured, but if i needed to, go to its web ui, default pass is "access".
2136 ######### begin stuff belonging at the end ##########