3 # Program to setup Ian's computers
4 # Copyright (C) 2024 Ian Kelling
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # SPDX-License-Identifier: GPL-3.0-or-later
21 # shellcheck source=/a/bin/ds/.bashrc
22 export LC_USEBASHRC
=t
; if [[ -s ~
/.bashrc
]]; then . ~
/.bashrc
; fi
25 source /a
/bin
/bash-bear-trap
/bash-bear
26 src
="$(readlink -f -- "${BASH_SOURCE[0]}")"; src
=${src%/*} # directory of this file
28 if [[ $EUID == 0 ]]; then
29 echo "$0: error: run as regular user" >&2
34 echo 1 >~
/.local
/distro-end
37 # shellcheck source=./pkgs
40 echo "$0: $(date) starting now)"
41 # see example of usage to understand.
44 IFS
= read -r -d '' y ||
:
49 echo 0 >~
/.local
/distro-end
50 if $pending_reboot; then
51 echo "$0: pending reboot and then finished. doing it now."
52 echo "exiting with status 0"
55 echo "$0: $(date): ending now)"
56 echo "exiting with status 0"
62 printf "$pre sudo %s\n" "$*"
63 SUDOD
="$PWD" command sudo
"$@";
65 m
() { printf "$pre %s\n" "$*"; "$@"; }
66 e
() { printf "$pre %s\n" "$*"; }
68 codename
=$
(debian-codename
)
69 codename_compat
=$
(debian-codename-compat
)
71 sed="sed --follow-symlinks"
73 # when we schroot, it will fail if we are in a directory that doesnt exist in the chroot
83 # get sudo pass cached right away
84 if ! sudo
-nv 2>/dev
/null
; then
90 # old repo. remove when all machines updated
91 sudo
rm -fv /etc
/apt
/sources.list.d
/wireguard-ubuntu-wireguard-bionic.list
93 sudo
rm -fv /etc
/apt
/preferences.d
/minetest
102 sudo debconf-set-selections
<<EOF
103 popularity-contest popularity-contest/participate boolean true
106 ########### begin section including vps ################
113 # no equivalent in other distros:
114 if isdeb
&& pcheck apt-file
; then
115 # this condition is just a speed optimization
124 # allows me to pipe with ssh -t, and gets rid of spam
125 # http://forums.debian.net/viewtopic.php?f=5&t=85822
126 # i'd rather disable the service than comment the init file
127 # this says disabling the service, it will still get restarted
128 # but this script doesn't do anything on restart, so it should be fine
129 sudo truncate
-s0 /var
/run
/motd.dynamic
132 # this isn't a complete solution. It still shows me when updates are available,
133 # but it's no big deal.
134 sudo
rm -fv /etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
143 ######### begin universal pinned packages ######
144 case $
(debian-codename
) in
145 etiona|flidas|nabia|aramo
)
146 sudo
rm -fv /etc
/apt
/preferences.d
/etiona-buster
147 sd
/etc
/apt
/preferences.d
/trisquel-debian
<<EOF
148 Explanation: Debian* includes Debian + Debian Backports
150 Pin: release o=Debian*
153 Explanation: ubuntu's version is outdated
154 Package: debian-archive-keyring
155 Pin: release o=Debian*
162 #p install --no-install-recommends minetest/buster libleveldb1d/buster libncursesw6/buster libtinfo6/buster
164 # shellcheck disable=SC2043 # in case we want more than 1 in the loop later.
165 for n
in bookworm
; do
166 f
=/etc
/apt
/sources.list.d
/$n.list
173 deb http://deb.debian.org/debian bookworm main
174 deb-src http://deb.debian.org/debian bookworm main
176 deb http://deb.debian.org/debian-security/ bookworm-security main
177 deb-src http://deb.debian.org/debian-security/ bookworm-security main
179 deb http://deb.debian.org/debian bookworm-updates main
180 deb-src http://deb.debian.org/debian bookworm-updates main
182 deb http://http.debian.net/debian bookworm-backports main
183 deb-src http://http.debian.net/debian bookworm-backports main
188 if ! diff -q $t $f; then
197 p download debian-archive-keyring
198 s dpkg
-i debian-archive-keyring
204 if [[ ! -e /usr
/share
/debootstrap
/scripts
/bookworm
]]; then
207 m aptitude download debootstrap
/bookworm
209 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
214 sd
/etc
/apt
/preferences.d
/focal
<<'EOF'
216 Pin: release n=focal,o=Ubuntu
220 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
221 Package: spamassassin sa-compile spamc
222 Pin: release n=focal,o=Ubuntu
225 sd
/etc
/apt
/preferences.d
/spamassassin
<<'EOF'
226 Package: spamassassin sa-compile spamc
227 Pin: release n=focal,o=Ubuntu
230 sd
/etc
/apt
/preferences.d
/psd
<<'EOF'
231 Package: profile-sync-daemon
232 Pin: release n=focal,o=Ubuntu
236 f
=/etc
/apt
/sources.list.d
/focal.list
239 deb http://us.archive.ubuntu.com/ubuntu/ focal main universe
240 deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main universe
241 deb http://us.archive.ubuntu.com/ubuntu/ focal-security main universe
243 if ! diff -q $t $f; then
244 sudo
dd if=$t of
=$f status
=none
250 sd
/etc
/apt
/preferences.d
/nabia-etiona
<<'EOF'
252 Pin: release n=nabia*,o=Trisquel
256 f
=/etc
/apt
/sources.list.d
/nabia.list
259 deb http://mirror.fsf.org/trisquel/ nabia main
260 deb-src http://mirror.fsf.org/trisquel/ nabia main
262 deb http://mirror.fsf.org/trisquel/ nabia-updates main
263 deb-src http://mirror.fsf.org/trisquel/ nabia-updates main
265 deb http://archive.trisquel.info/trisquel/ nabia-security main
266 deb-src http://archive.trisquel.info/trisquel/ nabia-security main
268 # Uncomment this lines to enable the backports optional repository
269 deb http://mirror.fsf.org/trisquel/ nabia-backports main
270 deb-src http://mirror.fsf.org/trisquel/ nabia-backports main
272 if ! diff -q $t $f; then
273 sudo
dd if=$t of
=$f status
=none
277 # duplicated in fai. Pin for bionic + ubuntu so that ppas dont get
279 sd
/etc
/apt
/preferences.d
/etiona-bionic
<<'EOF'
281 Pin: release n=bionic,o=Ubuntu
284 Pin: release n=bionic,o=Ubuntu
288 sd
/etc
/apt
/preferences.d
/etiona-sa
<<'EOF'
290 Pin: release n=bionic,o=Ubuntu
296 sd
/etc
/apt
/preferences.d
/aramo-nabia
<<'EOF'
298 Pin: release n=aramo*,o=Trisquel
301 f
=/etc
/apt
/sources.list.d
/aramo.list
304 deb http://mirror.fsf.org/trisquel/ aramo main
305 deb-src http://mirror.fsf.org/trisquel/ aramo main
307 deb http://mirror.fsf.org/trisquel/ aramo-updates main
308 deb-src http://mirror.fsf.org/trisquel/ aramo-updates main
310 deb http://archive.trisquel.info/trisquel/ aramo-security main
311 deb-src http://archive.trisquel.info/trisquel/ aramo-security main
313 # Uncomment this lines to enable the backports optional repository
314 deb http://mirror.fsf.org/trisquel/ aramo-backports main
315 deb-src http://mirror.fsf.org/trisquel/ aramo-backports main
317 if ! diff -q $t $f; then
318 sudo
dd if=$t of
=$f status
=none
325 pi debian-goodies shellcheck
330 case $codename_compat in
332 s systemctl
enable --now ssh-agent-iank
336 case $codename_compat in
338 sd
/etc
/apt
/preferences.d
/nabia-btrfs-progs
<<'EOF'
340 Pin: release a=buster-backports
343 p
install btrfs-progs
348 # 2020-03-03 old file
349 s
rm -fv /etc
/apt
/preferences.d
/radicale
350 ######### end universal pinned packages ######
355 sd
/etc
/apt
/preferences.d
/obs
<<EOF
357 Pin: release n=bionic
360 sd
/etc
/apt
/preferences.d
/chromium
<<EOF
362 Pin: release n=bionic
367 # note, to get the latest, it would be n=bullseye*
368 # but that has conflicting package versions, so this does the old one.
369 # I only use it for special rare purposes. Just keep in mind it is an
370 # outdated insecure version.
371 sd
/etc
/apt
/preferences.d
/chromium-bullseye
<<EOF
372 Package: chromium chromium-* libicu67 libjpeg62-turbo libjsoncpp24 libre2-9 libwebpmux3
373 Pin: release o=Debian*,n=bullseye
378 # obs dependency not in trisquel
379 sd
/etc
/apt
/preferences.d
/obs
<<EOF
381 Pin: release n=jammy,o=Ubuntu
389 ##### begin automatic upgrades (after checkrestart has been installed) ####
390 # if apt-config-auto-update is installed,
391 # it also has similar config, in a file 10something,
392 # but i think this overrides it since its higher number.
393 # This file was part of the automatic-updates package,
394 # and it has a config option to not get new package lists,
395 # which seems pretty stupid to me, you cant actually upgrade
396 # anything if you dont have the new package list.
397 sd
/etc
/apt
/apt.conf.d
/20auto-upgrades
<<'EOF'
398 # note: man apt.conf says
399 # /usr/share/doc/apt/examples/configure-index.gz is a configuration file showing
400 # example values for all possible options.
401 # but that is a incorrect.
402 # Periodic and other options are only documented in
403 # /usr/lib/apt/apt.systemd.daily
404 # That filename can be found through poking around in apt daily cronjob.
405 APT::Periodic::Update-Package-Lists "1";
406 APT::Periodic::Download-Upgradeable-Packages "1";
407 # 0 means disabled. I used to set this to 7, however, trisquel doesn't
408 # have an archive of old package versions, so I want to
409 # keep around old versions so I can easily downgrade.
410 APT::Periodic::AutocleanInterval "0";
411 # daily expire old files /var/cache/apt if it gets above this MB
412 APT::Periodic::MaxSize "50000";
413 APT::Periodic::Unattended-Upgrade "1";
416 # fyi: default file has comments about available options,
417 # you may want to read that, do pkx unattended-upgrades
418 # default is just security updates. this list found from reading
419 # match_whitelist_string() in $(which unattended-upgrades)
420 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
421 Unattended-Upgrade::Mail "root";
422 Unattended-Upgrade::MailOnlyOnError "true";
423 Unattended-Upgrade::Remove-Unused-Dependencies "true";
424 Unattended-Upgrade::Origins-Pattern {
425 "o=*,l=*,a=*,c=*,site=*,n=*";
430 sudo
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
/etc
/cron.d
/myupgrade
432 # myupgrade cron exists in /etc/cron.d/ian
434 ##### end automatic upgrades ####
437 # commented in case i want to use this sometime later
438 # sd /etc/apt/preferences.d/buster-backports <<EOF
440 # Pin: release a=buster-backports
445 ###### begin website setup
449 f
=/var
/lib
/bind
/db.b8.nz
450 if [[ ! -e $f ]]; then
454 sudo
/c
/roles
/prom_export
/files
/simple
/usr
/local
/bin
/fsf-install-node-exporter
-l 127.0.0.1
457 web-conf
-p 9101 -f 9100 - apache2
${HOSTNAME}ex.b8.nz
<<'EOF'
460 AuthName "basic_auth"
462 # htpasswd -c prometheus-export-htpasswd USERNAME
463 AuthUserFile "/etc/prometheus-export-htpasswd"
472 # i just dont feel like setting up a special purpose ssh key to do this automatically.
474 # run this once for bk on local machine:
475 # only used for old openvpn setup
476 /a/exe/vpn-mk-client-cert -c bk.b8.nz -b expertpath -n mail li.iankelling.org
486 if [[ ! -L ~
/eggdrop
/eggdrop
]]; then
488 git clone https
://github.com
/eggheads
/eggdrop eggdrop-src
496 # dunno if this is really needed. it was part of the documented eggdrop systemd install script
497 sudo loginctl enable-linger
498 systemctl
--user enable fsysbot
499 systemctl
--user start fsysbot
501 m
/a
/h
/setup.sh iankelling.org
503 # start mumble only when im going to use it, since i dont use it much
504 pi-nostart mumble-server
505 sudo
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
507 # do certificate to avoid warning about unsigned cert,
508 # which is overkill for my use, but hey, I'm cool, I know
510 m web-conf apache2 mumble.iankelling.org
511 sudo
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
513 # general vpn for as needed use
514 vpn-server-setup
-d -r -4 10.5.5 -p 443 -n hole
516 # todo: consider if this should exist for the
518 teeu
/etc
/openvpn
/server
/hole.conf
<<'EOF'
524 files
=(/etc
/openvpn
/client-config-hole
/*)
525 if (( ${#files[@]} >= 1 )); then
529 for host in ${!vpn_ips[@]}; do
530 sd
/etc
/openvpn
/client-config-hole
/$host <<EOF
531 ifconfig-push 10.5.5.${vpn_ips[$host]} 255.255.255.0
536 # for adding cert to system with /p
539 #mkc /p/c/machine_specific/$host/filesystem/etc/openvpn/client
540 #vpn-mk-client-cert -b $host -n hole -r iankelling.org
541 #s chown -R iank:iank .
543 # example of adding to remote system 107,
544 # vpn-mk-client-cert -n hole -c 10.2.0.107 -b hd8 iankelling.org
546 # for wireguard hole vpn, use function:
550 # if it is going to want to connect to transmission-daemon on ok
551 # wghole bo 28 10.174.2.2/32
553 # requested from linode via a support ticket.
554 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
555 # ipv6 stuff pieced together
556 # via slightly wrong information from
557 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
558 # https://community.openvpn.net/openvpn/wiki/IPv6
561 # This uses a public /64, but afaik, that is not needed for my
562 # current use case, since I'm doing ipv6 nat, they could be private
563 # and nat to a public address. I'm doing ipv6 nat in order to have 2
564 # vpn clients that externally share the same ip when sending so they
565 # share ip reputation. Note, the eth0 and tunx needed to be
566 # different subnets. On the same, I saw some neighbor packet go
567 # unanswered, tcpdump showed packets getting lost. I tried splitting the
568 # /64, it didn't work but I didn't investigate closely.
571 # not starting as i intend to replace it
572 m vpn-server-setup
-s -i tunmail
-n mail -d -6 2600:3c00
:e002
:3800::/64 2600:3c00
:e002
:3800::1/64
573 sudo
tee /etc
/openvpn
/client-config-mail
/mailclient
<<'EOF'
574 ifconfig-push 10.8.0.4 255.255.255.0
575 ifconfig-ipv6-push 2600:3c00:e002:3800::4/64
577 sudo
tee /etc
/openvpn
/client-config-mail
/expertpath
<<'EOF'
578 ifconfig-push 10.8.0.5 255.255.255.0
579 ifconfig-ipv6-push 2600:3c00:e002:3800::5/64
583 sudo
dd of
=/etc
/systemd
/system
/vpn-mail-forward.service
<<'EOF'
585 Description=Turns on iptables mail nat
586 BindsTo=openvpn-server@mail.service
591 ExecStart=/a/bin/distro-setup/vpn-mail-forward tunmail start
592 ExecStop=/a/bin/distro-setup/vpn-mail-forward tunmail stop
595 RequiredBy=openvpn-server@mail.service
600 # needed for li's local mail delivery.
601 tu
/etc
/hosts
<<<"10.8.0.4 mx.iankelling.org"
603 # wgmail handles this.
604 #sgo vpn-mail-forward.service
606 #sgo openvpn-server@mail
609 # setup let's encrypt cert
610 m web-conf apache2 mail.iankelling.org
611 # TODO, i expanded the above cert manually to mx.iankelling.org, this should be captured
612 # in the automation here. We use mail.iankelling.org as our ehlo name when sending mail
613 # but our mx record is mx.iankelling.org. Initially I was just using mail.iankelling.org,
614 # but the problem is I want multiple ips to be able to identify as mail.iankelling.org,
615 # but a subset to be mx.iankelling.org. Afaik, there is no problem with having
616 # our mail cert be for mail.iankelling.org, and have people connect to mx.ian...,
617 # but it doesn't make logical sense to do this.
618 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
621 a2enmod -q proxy proxy_http
622 domain=cal.iankelling.org
623 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
624 # https://radicale.org/2.1.html
625 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
626 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
628 # this doesn't exactly fit with the documentation.
629 # We need location / to do an auth, it cant be done outside,
630 # in order to pass on X-Remote-User. And we need
631 # the other location in order to remove the /radicale/ for
632 # requests which have it. This could be done with a rewrite,
633 # but i just get something working and call it a day.
638 AuthName "Authentication Required"
639 # setup one time, with root:www-data, 640
640 AuthUserFile "/etc/caldav-htpasswd"
642 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
644 <Location "/radicale/">
645 Options +FollowSymLinks +Multiviews -Indexes
646 RequestHeader set X-Script-Name /radicale/
647 RequestHeader set X-Remote-User expr=%{REMOTE_USER}
648 ProxyPass "http://10.8.0.4:5232/" retry=0
649 ProxyPassReverse "http://10.8.0.4:5232/"
652 # nginx version of above would be:
653 # auth_basic "Not currently available";
654 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
658 ###### begin znc setup #####
661 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
662 # to get into the web interface,
663 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
664 # https://iankelling.org:12533/
665 # login as ian, pass is in pass store, the part after :
667 # znc config generated by doing
669 # selected port is also used in erc config
670 # comma separated channel list worked.
671 # while figuring things out, running znc -D for debug in foreground.
672 # to exit and save config:
673 # /msg *status shutdown
674 # configed auth on freenode by following
675 # https://wiki.znc.in/Sasl:
679 # Set MyNickservName pa$$w0rd
680 # created the system service after, and had to do
681 # mv /home/iank/.znc/* /var/lib/znc
682 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
683 # and made a copy of the config files into /p/c
684 # /msg *status LoadMod --type=global log -sanitize
685 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
686 # /msg *status LoadMod --type=network perform
687 # /query *perform add PRIVMSG ChanServ :invite #fsf-office
688 # /msg *perform add JOIN #fsf-office
689 # /msg *status LoadMod NickServ
692 # also ran /znc LoadMod clearbufferonmsg
693 # it would be nice if erc supported erc query buffers by doing
694 # /msg *status clearbuffer <name of the query/receiver
696 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
697 # if that was the case i could remove the module clearbufferonmsg
698 # also would be nice if erc supported
699 # https://wiki.znc.in/self-message
700 # https://wiki.znc.in/Query_buffers \
702 # for geekshed, there was no sasl support as far as I can tell,
703 # so I set to msg nickserv to identify upon connect.
704 if ! getent passwd znc > /dev/null; then
705 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
707 sudo chmod 700 /var/lib/znc
708 sudo chown -R znc:znc /var/lib/znc
709 # Avoid restarting if possible, reconnecting to irc is annoying.
710 # The unit file was made active with conflink.
711 # Note, avoid using ser here because we wrap sudo to prints the command first.
712 if [[ $(systemctl is-active znc) != active ]]; then
715 ###### stop znc setup #####
724 # todo, save the config
725 /etc/cron.daily/stream-cert
726 web-conf -c /etc/cert-live.fsf.org -p 443 -f 8000 apache2 live.fsf.org
730 ###### end website setup
732 ########### end section including li/lj ###############
737 ### system76 things ###
739 bo) # sy| sy doesnt seem to really need this.
740 # note, i stored the initial popos packages at /a/bin/data/popos-pkgs
741 if [[ ! -e /etc/apt/sources.list.d/system76.list ]]; then
742 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
743 sd /etc/apt/sources.list.d/system76.list <<EOF
744 deb http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
745 deb-src http://ppa.launchpad.net/system76-dev/stable/ubuntu $codename_compat main
747 # ubuntu keyserver is prone to intermittent failures
748 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5D1F3A80254F6AFBA254FED5ACD442D1C8B7748B
750 # https://support.system76.com/articles/install-ubuntu/
751 # but i'm hoping this is not needed
752 # sd /etc/apt/preferences.d/system76 <<'EOF'
754 # Pin: release o=LP-PPA-system76-dev-stable
758 # TODO: I had to uninstall linux-image-generic-hwe-20.04 because of a conflict
759 # about linux-firmware. Should probably install it to begin with in fai if
761 pi system76-driver system76-firmware
762 # if you get a notice about a firmware update, the notifier on i3
763 # is too dumb to do anything when you click it. so to see
765 # /var/cache/system76-firmware-daemon
766 # extract the xz files there, one will contain a changelog.
767 # then to install an update:
768 # s system76-firmware-cli schedule
772 ### end system76 things ###
778 ## one time setup thing I did
780 # cargo build --release
781 # cp target/release/obs-cmd ../bin
783 ## in obs, tools -> websocket server settings -> generate/copy password
785 # note: obs-studio on gnu does not support webrtc, it seems mainly because
786 # libdatachannel is not packaged. If it was, it would just need to do
787 # apt source obs-studio, obs-studio-30.1.1/debian/rules set -DENABLE_WEBRTC=ON
789 # I did manage to build libdatachannel following its instructions, then make install,
790 # then obs failed due to nvidia. found those options to disable with
791 # rg 'option\(ENABLE' | gr nv, then build obs like so:
793 # 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 ..
797 # however, I didn't end up trying it out.
799 # note, in terminal source, i setup a transform so it would show the
800 # bottom 1080p section of the terminal instead of the top if the
801 # screen was bigger. click like 2 times in the preview so the red
802 # lines show up, right click, edit transform (or ctrl-e). bounding
803 # box type: scale to width of bounds. alignment in bounding box:
804 # bottom left. bounding box size 1920 x 1080.
806 # ppa:obsproject/obs-studio
807 if [[ ! -s /etc/apt/sources.list.d/obs.list ]]; then
808 # https://blog.zackad.dev/en/2017/08/17/add-ppa-simple-way.html
809 sd /etc/apt/sources.list.d/obs.list <<EOF
810 deb http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
811 deb-src http://ppa.launchpad.net/obsproject/obs-studio/ubuntu $codename_compat main
813 trysleep 4 15 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BC7345F522079769F5BBE987EFC71127F425E228
820 case $codename_compat in
822 # mate-indicator-applet and beyond are msc things I noticed diffing a
823 # standard install with mine.
824 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
830 # todo: figure out mate for buster
831 # pi task-gnome-desktop
834 # i had installing mate-indicator-applet, but im not sure why so i removed
835 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras anacron
838 # # apt-get update periodically fails with an appstream error.
839 # # this removes gnome-core, but its just a package for dependencies
840 # p -y remove appstream
843 # by default, it sleeps when not logged in to x/wayland and on ac power.
845 if id -u gdm &>/dev/null; then
846 sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
850 # lightdm startup fails without this. on etiona, we got unity-greeter installed automatically,
851 # it would probably work on nabia too, but google just lead me to this and it works fine.
852 pi lightdm-gtk-greeter
853 # ok, this is really weird
854 # normally this file has
855 sd /etc/X11/Xsession.d/99x11-common_start <<'EOF'
857 # this file normally just has: exec $STARTUP
858 # but then ~/.xsession-errors
859 # says $STARTUP is not found, which appears to be the real
860 # error, but normal bash doesnt operate that way.
861 # https://bugs.launchpad.net/ubuntu/+source/im-config/+bug/1879352
864 # also, gdm wayland was default, had to do
865 # dpkg-reconfigure gdm3
866 # and choose lightdm.
870 # not yet bothering with mate
871 pi lightdm-gtk-greeter lightdm
876 if [[ $codename_compat == flidas ]]; then
877 # doesnt exist in newer
886 # firefox would work here too, apt would select abrowser.
887 # and the update-alternatives thing i think is becuz firefox is
888 # generally available before abrowser and this helps fix things
889 # up when we have both.
891 s update-alternatives --set x-www-browser /usr/bin/abrowser
903 # newer distros just use adb for package name it seems
904 case $codename_compat in
906 pi android-tools-adbd
910 case $codename_compat in
912 pi libext2fs-dev libzstd-dev
913 cd /a/opt/btrfs-progs
918 case $codename_compat in
927 # not packaged in newer distros it seems
928 case $codename_compat in
929 bionic|buster|stretch)
935 # TODO: some of the X programs can be removed from pall when using wayland
937 # depends gcc is a way to install suggests. this is apparently the only
938 # way to install suggests even if the main package is already
939 # installed. reinstall doesn't work, uninstalling can cause removing
940 # dependent packages.
941 # shellcheck disable=SC2046 # word splitting is intended
942 pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $($src/distro-pkgs)
944 # schroot service will restart schroot sessions after reboot.
948 # fix systemd unit failure. i dont know of any actual impact
949 # other than systemd showing in degraded state. So, we dont bother
950 # fixing the current state, let it fix on the next reboot.
951 # https://gitlab.com/cjwatson/binfmt-support/-/commit/54f0e1af8a
952 tmp=$(systemctl cat binfmt-support.service | grep ^After=)
953 if [[ $tmp != *systemd-binfmt.service* ]]; then
954 s u /etc/systemd/system/binfmt-support.service.d/override.conf <<EOF
956 $tmp systemd-binfmt.service
961 # commented, not worth the hassle i think.
967 sudo rm -fv /etc/systemd/resolved.conf.d/iank.conf
969 # website is dead june 14 2019. back in october, but meh
970 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
975 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
978 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
979 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
981 # f=/etc/apt/sources.list.d/iridium-browser.list
982 # if ! diff -q $t $f; then
993 if mountpoint /p &>/dev/null; then
994 # note, see bashrc for more documentation.
996 sd /etc/systemd/system/rss2email.service <<'EOF'
998 Description=rss2email
999 After=multi-user.target
1004 # about 24 hours of failures
1005 # it copies over its files without respecting symlinks, so
1006 # we pass options to use different location.
1007 ExecStart=/usr/local/bin/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
1009 sd /etc/systemd/system/rss2email.timer <<'EOF'
1011 Description=rss2email
1014 # for initial run. required.
1016 # for subsequent runs.
1017 OnUnitInactiveSec=300
1020 WantedBy=timers.target
1022 sudo systemctl daemon-reload
1026 ######### begin irc periodic backup #############
1027 if [[ $HOSTNAME == frodo ]]; then
1028 sd /etc/systemd/system/ircbackup.service <<'EOF'
1030 Description=irc li backup
1031 After=multi-user.target
1036 ExecStart=/usr/local/bin/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
1038 sd /etc/systemd/system/ircbackup.timer <<'EOF'
1040 Description=irc li backup hourly
1046 WantedBy=timers.target
1048 sudo systemctl daemon-reload
1053 ######### end irc periodic backup #############
1057 # pi-nostart does not disable
1061 if [[ -e /p/c/gen-fsf-vpn ]]; then
1065 if [[ -e /p/c/machine_specific/$HOSTNAME/filesystem/etc/openvpn/client/hole.crt ]]; then
1066 sgo openvpn-client@hole
1069 ############# begin syncthing setup ###########
1072 f=/usr/share/keyrings/syncthing-archive-keyring.gpg
1073 if [[ ! -e $f ]]; then
1074 s curl -s -o $f https://syncthing.net/release-key.gpg
1076 s="deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable"
1077 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
1078 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
1084 m lnf -T /w/syncthing /home/iank/.config/syncthing
1085 ser daemon-reload # syncthing likely not properly packaged
1086 sgo syncthing@iank # runs as iank
1090 # 1003 just happens to be what was on my system
1091 if ! getent passwd ziva; then
1092 s groupadd -g 1003 ziva
1093 # syncthing state / config / db are all in ~/.config/syncthing
1094 s useradd -g 1003 -u 1003 -d /d/ziva-home -c ziva -s /bin/bash ziva
1100 # user for short term use dropping of privileges
1102 if ! getent group zu &>/dev/null; then
1103 s groupadd -g 1023 zu
1105 if ! getent passwd zu &>/dev/null; then
1106 s useradd -g 1023 -u 1023 -c zu -s /bin/bash zu
1110 # these things persist in ~/.config/syncthing, which I save in
1111 # /w/syncthing (not in /p, because syncthing should continue to
1112 # run on home server even when using laptop as primary device)
1113 # open http://localhost:8384/
1114 # change listen address from default to tcp://:22001,
1115 # this is because we do port forward so it doesn\'t have to use
1116 # some external server, but the syncthing is broken for port forward,
1117 # you get a message, something "like connected to myself, this should not happen"
1118 # when connecting to other local devices, so I bump the port up by 1,
1120 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
1121 # Without this, it was being stuck syncing at 0%.
1122 # Set gui username and password.
1124 # install syncthing via f-droid,
1125 # folder setting, turn off send only.
1126 # on phone, add device, click bar code icon
1127 # on dekstop, top right, actions, device id
1128 # after adding, notification will appear on desktop to confirm
1130 # syncing folder. from phone to desktop: select desktop in the
1131 # folder on phone\'s sync options, notification will appear in
1132 # desktop\'s web ui within a minute. For the reverse, the
1133 # notification will appear in android\'s notifications, you have to
1134 # swipe down and tap it to add the folder. It won\'t appear in the
1135 # syncthing ui, which would be intuitive, but don\'t wait for it
1136 # there. The notification may not work, instead open the web gui
1137 # from in the app, there should be a notification within there.
1139 # On phone, set settings to run syncthing all the time, and
1140 # show no notification.
1142 # Folder versioning would make sense if I didn\'t already use btrfs
1143 # for backups. I would choose staggered, or trash can for more space.
1145 # if needed to install on a remote comp:
1146 # ssh -L 8384:localhost:8384 -N frodo
1147 # open http://localhost:8384/
1149 # Note, the other thing i did was port forward port 22000,
1150 # per https://docs.syncthing.net/users/firewall.html
1152 ############# end syncthing setup ###########
1156 ####### begin misc packages ###########
1158 # old location, 2023.
1159 sudo rm -fv /etc/systemd/system/profanity.service
1162 ln -sfT /d/p/profanity ~/.local/share/profanity
1163 ln -sfT /d/p/profanity-config ~/.config/profanity
1164 source /a/bin/bash_unpublished/source-state
1165 if [[ $HOSTNAME == "$HOST2" || ! -e /p/profanity-here ]]; then
1166 systemctl --user --now enable profanity
1171 ln -sfT /p/profanity ~/.local/share/profanity
1172 ln -sfT /p/profanity-config ~/.config/profanity
1183 sudo update-alternatives --set pinentry /usr/bin/pinentry-gtk-2
1186 # sakura config is owned by ian
1189 m sudo -u user2 -i reset-konsole
1190 # user2 xscreensaver we don't want to reset
1191 m reset-xscreensaver
1194 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
1195 # this is also in primary-setup
1196 # pi libxss-dev # dependency based on build failure
1198 # cabal install --upgrade-dependencies --force-reinstalls arbtt
1199 # also, i assume syncing this between machines somehow messed up the data.
1201 ## not using arbtt for now
1202 # if mountpoint /p &>/dev/null; then
1206 # # same as seru enable arbtt, but works over ssh when systemctl --user causes error:
1207 # # Failed to connect to bus: No such file or directory
1208 # lnf -T /a/bin/ds/subdir_files/.config/systemd/user/arbtt.service /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1210 # seru start arbtt ||:
1214 rm -fv /home/iank/.config/systemd/user/default.target.wants/arbtt.service
1219 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
1220 m cp /p/.linphonerc-initial ~/.linphonerc
1223 # linphone in t10 wont do dns with systemd-resolved or something
1224 s teeu /etc/hosts <<'EOF'
1225 74.94.156.215 watson.fsf.org
1230 ### begin spd install
1231 if mountpoint /p &>/dev/null; then
1232 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
1234 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
1237 # this guesses at the appropriate directory, adjust if needed
1238 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
1239 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
1240 # newer distro had gpg2 as default, older one, flidas, need to make it that way
1241 gpgpath=$(which gpg2) ||:
1242 if [[ $gpgpath ]]; then
1243 sudo mkdir -p /usr/local/spdhackfix
1244 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
1250 # nagstamon setting which were set through the ui
1251 # monitor url https://klaxon.fsf.org/cgi-bin
1252 # monitor url cgi https://klaxon.fsf.org/cgi-bin
1254 # all unknown services
1255 # all warning services
1256 # acknowledged hosts & services
1257 # hosts & services down for maintenence
1258 # services on down hosts
1259 # services on hosts in maintenece
1260 # services on unreachable osts
1261 # hosts in soft state
1262 # services in soft state
1263 # in display tab: fullscreen
1265 # these translate to these settings I think
1266 # filter_acknowledged_hosts_services = True
1267 # filter_all_unknown_services = True
1268 # filter_all_warning_services = True
1269 # filter_hosts_in_soft_state = True
1270 # filter_hosts_services_maintenance = True
1271 # filter_services_in_soft_state = True
1272 # filter_services_on_down_hosts = True
1273 # filter_services_on_hosts_in_maintenance = True
1274 # filter_services_on_unreachable_hosts = True
1275 # notify_if_up = False
1276 # statusbar_floating = False
1278 # but i'm just going to rely on the webpage plus sms for now.
1281 # it asks if it should make users in it's group capture packets without root,
1282 # which is arguably more secure than running wireshark as root. default is no,
1283 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
1284 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
1286 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
1287 # listed in the default config as suggested.
1288 # /run/usr/1000 i noticed was missing for pulseaudio
1289 # /run/user/0 just seemed like a not bad idea, given the above
1290 tu /etc/schroot/desktop/fstab <<'EOF'
1291 /p /p none rw,bind 0 0
1292 /a /a none rw,bind 0 0
1293 /run /run none rw,bind 0 0
1294 /run/lock /run/lock none rw,bind 0 0
1295 /dev/shm /dev/shm none rw,bind 0 0
1296 /run/shm /run/shm none rw,bind 0 0
1297 /run/user/1000 /run/user/1000 none rw,bind 0 0
1298 /run/user/1001 /run/user/1001 none rw,bind 0 0
1299 /run/user/0 /run/user/0 none rw,bind 0 0
1302 # todo: consider if this should use the new sysd-prom-fail
1303 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1305 Description=schrootupdate
1306 After=multi-user.target
1310 ExecStart=/usr/local/bin/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1312 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1314 Description=schrootupdate
1317 OnCalendar=*-*-* 04:20:00 America/New_York
1320 WantedBy=timers.target
1323 sgo schrootupdate.timer
1330 m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/bookworm.list/BOOKWORM_FREE \
1331 debian bookworm firefox-esr pulseaudio chromium
1338 sudo mkdir -p /nocow/user
1339 sudo chown $USER:$USER /nocow/user
1343 ####### begin transmission
1353 tdir=/nocow/user/tor
1359 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1360 # 450 seems likely to be unused. we need to specify one or else
1361 # it won't be stable across installs.
1362 if ! getent passwd debian-transmission > /dev/null; then
1363 sudo groupadd -g 450 debian-transmission
1364 sudo adduser --quiet \
1369 --disabled-password \
1370 --home /var/lib/transmission-daemon \
1373 # We want group writable stuff from transmission.
1374 # However, after setting this, I learn that transmission sets it's
1375 # own umask based on it's settings file. Well, no harm leaving this
1376 # so it's set right from the beginning.
1377 sudo chfn debian-transmission -o umask=0002
1379 # note i had to do this, which is persistent:
1381 # s chgrp debian-transmission torrents partial-torrents
1383 # syslog says things like
1384 # 'Failed to set receive buffer: requested 4194304, got 425984'
1385 # google suggets giving it even more than that
1386 tu /etc/sysctl.conf<<'EOF'
1387 net.core.rmem_max = 67108864
1388 net.core.wmem_max = 16777216
1392 # some reason it doesn\'t seem to start automatically anyways
1393 pi-nostart transmission-daemon
1394 # be extra sure its not started
1395 ser disable transmission-daemon
1396 ser stop transmission-daemon
1398 # the folder was moved here after an install around 02/2017.
1399 # it contains runtime data,
1400 # plus a simple symlink to the config file which it\'s
1401 # not worth separating out.
1402 # between comps, the uid can change
1404 f=$tdir/transmission-daemon
1405 for d in $tdir/partial-torrents $tdir/torrents $f; do
1406 if [[ ! -d $d ]]; then
1409 sudo chown -R debian-transmission:user2 $d
1411 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1412 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1413 sudo chown -R debian-transmission:debian-transmission $f
1414 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1416 # config file documented here, and it\'s the same config
1417 # for daemon vs client, so it\'s documented in the gui.
1418 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1420 # I originaly setup rpc-whitelist, but after using
1421 # routing to a network namespace, it doesn\'t see the
1422 # real source address, so it\'s disabled.
1424 # Changed the cache-size to 256 mb, reduces disk use.
1425 # It is a read & write cache.
1427 # just fyi: default rpc port is 9091
1428 if ! systemctl is-active transmission-daemon-nn &>/dev/null && \
1429 ! systemctl is-active transmission-daemon; then
1431 command sudo ruby <<EOF >$tmp
1433 p = '/etc/transmission-daemon/settings.json'
1435 'rpc-whitelist-enabled' => false,
1436 'rpc-authentication-required' => false,
1437 'incomplete-dir' => '$tdir/partial-torrents',
1438 'incomplete-dir-enabled' => true,
1439 'download-dir' => '$tdir/torrents',
1440 "speed-limit-up" => 800,
1441 "speed-limit-up-enabled" => true,
1442 "peer-port" => 61486,
1443 "cache-size-mb" => 256,
1444 "ratio-limit" => 5.0,
1445 "ratio-limit-enabled" => false,
1447 puts(JSON.pretty_generate(JSON.parse(File.read(p)).merge(s)))
1449 cat $tmp | sudo dd of=/etc/transmission-daemon/settings.json
1453 ####### end transmission
1457 # to persist upload/dl metadata. initially, moved all the stuff
1458 # in /var/lib/transmission-daemon to /d/tor
1459 s usermod --home /d/tor debian-transmission
1460 sgo transmission-daemon-nn
1466 ######### begin transmission client setup ######
1468 # to connect from a remote client, trans-remote-route in brc2
1471 if [[ -e /p/transmission-rpc-pass ]]; then
1472 # arch had a default config,
1473 # debian had nothing until you start it.
1474 # With a little trial an error, here is a minimal config
1475 # taken from the generated one, plus changes that the
1476 # settings ui does, without a bunch of ui crap settings.
1478 # only settings I set were
1483 # the password is randomly generated on first run, i copied it out
1484 # so it could be used by other hosts.
1487 p = '/etc/transmission-daemon/settings.json'
1488 s = JSON.parse(File.read(p))
1489 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1490 # default is 0022 (18 in decimal)
1492 File.write p, JSON.pretty_generate(s)
1495 rpc_pass=$(</p/transmission-rpc-pass)
1496 for f in /home/*; do
1498 uid=$(id -u $u 2>/dev/null) || continue
1499 if [[ ! $uid -ge 1000 ]]; then
1502 d=$f/.config/transmission-remote-gtk
1503 sudo -u $u mkdir -p $d
1504 # i tried setting hostname to transmission.b8.nz, so i could dynamically change where
1505 # this connects to, but it said some 421 denied error when I did that. Then it
1506 # froze X when i ran it under strace. Whatever.
1507 sudo -u $u dd of=$d/config.json <<EOF
1511 "profile-name" : "Default",
1512 "hostname" : "10.174.2.2",
1513 "rpc-url-path" : "/transmission/rpc",
1515 "password" : "$rpc_pass",
1516 "auto-connect" : true,
1520 "update-active-only" : false,
1521 "activeonly-fullsync-enabled" : false,
1522 "activeonly-fullsync-every" : 2,
1523 "update-interval" : 3,
1524 "min-update-interval" : 3,
1525 "session-update-interval" : 60,
1526 "exec-commands" : [],
1531 "add-options-dialog" : false
1536 ######### end transmission client setup ######
1542 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1543 # goto http://127.0.0.1:631
1544 # administration tab, add new printer button.
1545 # In debian, I could use hte recommended driver,
1546 # in arch, I had to pick out the 6L driver.
1549 # bridge networking as user fails. google lead here, but it doesn\'t work:
1550 # oh well, I give up.
1551 # http://wiki.qemu.org/Features-Done/HelperNetworking
1553 # f=/etc/qemu/bridge.conf
1557 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1560 # general known for debian/ubuntu, not for fedora
1562 m /a/bin/buildscripts/go
1563 # only needed for rg. cargo takes up 11 gigs, filled up the disk on je.
1564 m /a/bin/buildscripts/rust
1565 m /a/bin/buildscripts/misc
1566 m /a/bin/buildscripts/pithosfly
1567 #m /a/bin/buildscripts/alacritty
1568 #m /a/bin/buildscripts/kitty
1570 pi-nostart virtinst virt-manager
1572 # i cant if this is whats causing it to start even though
1573 # its disabled. note: it leaves around dnsmasq instances even
1574 # if you stop it. what the hell systemd?
1576 # allow user to run vms, from debian handbook. libvirt-qemu
1577 # based on https://www.whonix.org/wiki/KVM#First-time_User.3F
1578 for x in iank user2; do s usermod -a -G libvirt,kvm,libvirt-qemu $x; done
1581 pi --no-install-recommends kdeconnect
1582 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1583 ### but gnome + xmonad not working in flidas, so i disabled it
1584 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1585 # cd /a/opt/indicator-kdeconnect
1588 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1591 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1592 # # it seems, according to
1593 # # /etc/xdg/autostart/kdeconnectd.desktop
1594 # # I'm not seeing the icon, but the clipboard replication is working
1597 ### begin model 01 arduino support ###
1598 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1599 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1600 # set arduino var in bashrc,
1601 # have system config file setup too.
1602 sudo adduser $USER dialout
1605 # download arduino ide, extract in /a/opt, ignore the install script, run ./arduino,
1606 # toolbar, preferences, add board manager url:
1607 # https://raw.githubusercontent.com/keyboardio/boardsmanager/master/package_keyboardio_index.json
1608 # toolbar, board manager, add keyboardio
1609 # toolbar, select model01 board
1610 # toolbar, examples, model01, compile
1614 # this is for the mail command too. update-alternatives is kind of misleading
1615 # since at least it's main commands pretend mail does not exist.
1616 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1617 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1619 ######### end misc packages #########
1622 # packages I once used before and liked, but don\'t want installed now for
1624 # python-sqlite is used for offlineimap
1625 # lxappearance python-sqlite dolphin paman dconf-editor
1631 # todo, finish configuring smart.
1634 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1635 # turn on smart. background on options:
1636 # first line, -a = test everyting on all devices.
1637 # -S on, turn on disk internal saving of vendor specific info,
1638 # from google, seems like this is usually already on and fairly standard.
1639 # -o on, turn on 4 hour period non-performance degrading testing.
1640 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1641 sched="-s (S/../.././02|L/../../6/03)"
1642 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1643 DEVICESCAN -a -o on -S on -n standby,q $sched \
1644 -m root@mail.iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1646 # in the default configuration of at least ubuntu 14.04, resolvconf is
1647 # configured to order any nameservers associated with tun* or tap*
1648 # before the normal internet interfaces, which means they are always
1649 # consulted first. This is often slower and undesirable, ie. local dns
1650 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1652 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1653 # however, this breaks dns lookup for hosts on the openvpn lan.
1654 # I can\'t figure out why hosts on the normal lan would not be
1655 # broken under the default ordering, except the host I was
1656 # testing with previously had an entry in /etc/hosts.
1658 ############# end unfinished
1660 ########### misc stuff
1663 xdg-settings set default-web-browser abrowser.desktop
1665 # xdg-settings get default-web-browser
1667 # pressing tab after sdf here:
1668 # scp sdfbash: set +o noglob: command not found
1669 # in t11, bash 5.1.16. this fixes it.
1670 sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
1672 rm -fv /home/iank/.mpv/watch_later
1673 rm -rf /home/iank/.mpv
1675 if [[ ! -e ~/.local/bin/pip ]]; then
1677 wget -O$tmp https://bootstrap.pypa.io/get-pip.py
1683 # soo, apt install beets fails due to wanting a pip package,
1684 # we find out why it wants this through
1685 # apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances beets | less
1686 # python-mediafile requires tox, which requires virtualenv, which requires pip.
1687 # but, python-mediafile doesn't really require tox, it is specified in
1688 # ./usr/lib/python3/dist-packages/mediafile-0.9.0.dist-info/METADATA
1689 # as being required only for testing, but the debian package
1690 # included it anyways, due to a mistake or bad tooling or something.
1691 # I don't plan to use tox, so, according to https://serverfault.com/a/251091,
1692 # we can create and install a dummy package by:
1694 # "equivs-control <name>, edit the file produced to provide the right
1695 # dependency and have a nice name, then run equivs-build <name> and
1696 # finally dpkg -i the resulting .deb file"
1697 # as of 2023-02, the tox dependency was removed in debian unstable, so
1698 # this hack will probably go away in t12.
1700 if pcheck beets; then
1701 tmpdir="$(mktemp -d)"
1703 # edited from output of equivs-control tox
1707 Standards-Version: 3.9.2
1709 Description: tox-dummy
1712 sudo dpkg -i tox_1.0_all.deb
1714 pi beets python3-discogs-client
1719 # get rid of annoying message
1720 s sed -ri "s/^([[:space:]]*ui.print_\('Playing)/#\1/" /usr/share/beets/beetsplug/play.py
1723 # notes about barrier
1724 # run barrier, do the gui config,
1725 # setup the 2 screens, using hostnames for the new screen.
1726 # save the server config
1727 # $HOME/.local/share/barrier/.barrier.conf
1730 # ssl errors, resolved via advice here: https://github.com/debauchee/barrier/issues/231
1731 # BARRIER_SSL_PATH=~/.local/share/barrier/SSL/
1732 # mkdir -p "${BARRIER_SSL_PATH}"
1733 # openssl req -x509 -nodes -days 365 -subj /CN=Barrier -newkey rsa:4096 -keyout ${BARRIER_SSL_PATH}/Barrier.pem -out ${BARRIER_SSL_PATH}/Barrier.pem
1734 # ran on both machines.
1735 # When pressing start in the gui, the cli options used are printed to the console,
1736 # they are useful. So on server, just run barriers, client run barrierc SERVER_IP
1738 ### begin timetrap setup
1739 if mountpoint /p &>/dev/null; then
1740 mkdir -p ~/.timetrap/
1741 ln -sf /a/opt/timetrap_formatters ~/.timetrap/formatters
1742 if ! type -p t &>/dev/null; then
1743 pi ruby-dev libsqlite3-dev
1744 gem install --user timetrap
1747 ### end timetrap setup
1749 # leftover cleanup for t9
1753 # needed for debootstrap scripts for fai since fai requires debian
1756 pi-nostart network-manager
1757 # i hate networkmanager. noo, of course disabling it doesnt work
1758 # unless you add a hack. found this by doing
1759 # systemd-analyze dot > x.dot
1763 soff NetworkManager-wait-online.service
1764 # make networkmanager use resolvconf instead of its own dnsmasq which
1765 # conflicts with the normal dnsmasq package.
1766 f=/etc/NetworkManager/NetworkManager.conf
1768 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1769 sudo sed -ri '/ *\[main\]/a dns=default' $f
1770 if [[ $m != $(md5sum $f) ]]; then
1771 srestart NetworkManager
1773 # networkmanager has this nasty behavior on flidas: if the machine
1774 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1775 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1777 # This can be manually fixed by stoping dnsmasq,
1778 # then based on whats in /run/dnsmasq/, i see we can run
1779 # s resolvconf -d NetworkManager
1780 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1781 ser disable NetworkManager
1785 # I have no use for avahi,
1786 # had to run this twice when doing manually, i dunno why
1787 soff avahi-daemon ||:
1791 # make my /etc/fonts/conf.d/ get used.
1792 # I have a new sans-serif font there because the default one
1793 # displays l and I as the same char, grrrrr.
1796 pi desktop-file-utils
1797 m /a/bin/distro-setup/mymimes
1799 if type -p dbus-launch >/dev/null; then
1800 # stop autopoping windows when i plug in an android phone.
1801 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1802 # with still 0 exit code.
1803 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1804 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1807 # on grub upgrade, we get prompts unless we do this
1809 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1810 devs+=("$(devbyid $dev),")
1812 devs[-1]=${devs[-1]%,} # jonied by commas
1813 sudo debconf-set-selections <<EOF
1814 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1818 sysd-prom-fail-install dynamicipupdate
1819 sysd-prom-fail-install systemstatus
1820 sysd-prom-fail-install btrfsmaintstop
1821 sgo btrfsmaint.timer
1827 if grep -xFq $HOSTNAME /a/bin/ds/machine_specific/btrbk.hosts; then
1831 # note: to see when a timer was last run,
1835 ### begin prometheus ###
1839 # Font awesome is needed for the alertmanager ui.
1840 pi prometheus-alertmanager prometheus fonts-font-awesome
1841 /c/roles/prom/files/simple/usr/local/bin/fsf-install-prometheus
1842 # make it available for other machines
1843 rsync -a /usr/local/bin/amtool /a/opt/bin
1844 web-conf -p 9091 -f 9090 - apache2 i.b8.nz <<'EOF'
1847 AuthName "basic_auth"
1849 # htpasswd -c prometheus-htpasswd USERNAME
1850 AuthUserFile "/etc/prometheus-htpasswd"
1855 web-conf -p 9094 -f 9093 - apache2 i.b8.nz <<'EOF'
1858 AuthName "basic_auth"
1860 # htpasswd -c prometheus-htpasswd USERNAME
1861 AuthUserFile "/etc/prometheus-htpasswd"
1866 # by default, the alertmanager web ui is not enabled other than a page
1867 # that suggests to use the amtool cli. that tool is good, but you cant
1868 # silence things nearly as easily as with the gui.
1869 if [[ ! -e /usr/share/prometheus/alertmanager/ui/index.html ]]; then
1870 # default script didnt work, required some changes to get elm 19.1,
1871 # which is a dependency of the latest alertmanager. I modified
1872 # and copied it into /b/ds. In future, might need some other
1874 #sudo /usr/share/prometheus/alertmanager/generate-ui.sh
1875 sudo /b/ds/generate-ui.sh
1876 ser restart prometheus-alertmanager
1879 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter -l 127.0.0.1
1881 for ser in prometheus-node-exporter prometheus-alertmanager prometheus; do
1882 sysd-prom-fail-install $ser
1887 s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter
1891 # cleanup old files. 2023-02
1892 x=(/var/lib/prometheus/node-exporter/*.premerge)
1893 if [[ -e ${x[0]} ]]; then
1894 s rm /var/lib/prometheus/node-exporter/*
1899 # todo, for limiting node exporter http,
1900 # either use iptables or, in
1901 # /etc/default/prometheus-node-exporter
1902 # listen on the wireguard interface
1905 wgip=$(command sudo sed -rn 's,^ *Address *= *([^/]+).*,\1,p' /etc/wireguard/wghole.conf)
1906 # old filename. remove once all hosts are updated.
1907 s rm -fv /etc/apache2/sites-enabled/${HOSTNAME}wg.b8.nz.conf
1908 web-conf -i -a $wgip -p 9101 -f 9100 - apache2 ${HOSTNAME}wg.b8.nz <<'EOF'
1911 AuthName "basic_auth"
1913 # htpasswd -c prometheus-export-htpasswd USERNAME
1914 AuthUserFile "/etc/prometheus-export-htpasswd"
1918 # For work, i think we will just use the firewall for hosts in the main data center, and
1919 # vpn for hosts outside it.
1921 # TODO: figure out how to detect the ping failure and try again.
1923 # Binding to the wg interface, it might go down, so always restart, and wait for it on boot.
1924 s mkdir /etc/systemd/system/apache2.service.d
1925 sd /etc/systemd/system/apache2.service.d/restart.conf <<EOF
1927 After=wg-quick@wghole.service
1928 StartLimitIntervalSec=0
1938 ### end prometheus ###
1940 ### begin nagios ###
1942 pi nagios-nrpe-server
1946 # the backport is for this bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800345
1947 pi nagios4 nagios-nrpe-plugin monitoring-plugins-basic/bullseye-backports
1948 s rm -fv /etc/apache2/conf-enabled/nagios4-cgi.conf
1950 # to add a password for admin:
1951 # htdigest /etc/nagios4/htdigest.users Nagios4 iank
1952 # now using the same pass as prometheus
1954 # nagstamon auth settings, set to digest instead of basic.
1956 web-conf -p 3005 - apache2 i.b8.nz <<'EOF'
1957 # adapted from /etc/apache2/conf-enabled/nagios4-cgi.conf
1959 ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4
1960 ScriptAlias /nagios4/cgi-bin /usr/lib/cgi-bin/nagios4
1962 # Where the stylesheets (config files) reside
1963 Alias /nagios4/stylesheets /etc/nagios4/stylesheets
1965 # Where the HTML pages live
1966 Alias /nagios4 /usr/share/nagios4/htdocs
1968 <DirectoryMatch (/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)>
1969 Options FollowSymLinks
1970 DirectoryIndex index.php index.html
1971 AllowOverride AuthConfig
1973 # The default Debian nagios4 install sets use_authentication=0 in
1974 # /etc/nagios4/cgi.cfg, which turns off nagos's internal authentication.
1975 # This is insecure. As a compromise this default apache2 configuration
1976 # only allows private IP addresses access.
1978 # The <Files>...</Files> below shows how you can secure the nagios4
1979 # web site so anybody can view it, but only authenticated users can issue
1980 # commands (such as silence notifications). To do that replace the
1981 # "Require all granted" with "Require valid-user", and use htdigest
1982 # program from the apache2-utils package to add users to
1983 # /etc/nagios4/htdigest.users.
1985 # A step up is to insist all users validate themselves by moving
1986 # the stanza's in the <Files>..<Files> into the <DirectoryMatch>.
1987 # Then by setting use_authentication=1 in /etc/nagios4/cgi.cfg you
1988 # can configure which people get to see a particular service from
1989 # within the nagios configuration.
1991 AuthDigestDomain "Nagios4"
1992 AuthDigestProvider file
1993 AuthUserFile "/etc/nagios4-htdigest.users"
1994 AuthGroupFile "/etc/group"
2000 <Directory /usr/share/nagios4/htdocs>
2007 # when you alter a service through the web, it changes vars in /var/lib/nagios4/status.dat. for example:
2008 # notifications_enabled=1
2009 # note, the same variable exists in the correspdonding "define service {"
2011 # in the default config, we have these definitions
2013 # 11 define command {
2014 # 2 define contact {
2015 # 1 define contactgroup {
2017 # 4 define hostgroup {
2018 # 23 define service {
2019 # 5 define timeperiod {
2024 # klaxon:/etc/nagios3 # grep -rho '^ *define [^{ ]*' | sort | uniq -c
2027 # 6 define contactgroup
2029 # 1 define hostextinfo
2030 # 16 define hostgroup
2031 # 3040 define service
2032 # 2 define servicedependency
2033 # 6 define timeperiod
2040 ### begin bitcoin ###
2044 sudo install -m 0755 -o root -g root -t /usr/bin /a/opt/bitcoin-26.0/bin/*
2045 # Note: i leave it to system-status to start and stop bitcoin.
2046 # note: the bitcoin user & group are setup in fai
2047 sudo usermod -a -G bitcoin iank
2048 # todo: make bitcoin have a stable uid/gid
2049 sudo mkdir -p /var/lib/bitcoind
2050 sudo chown bitcoin:bitcoin /var/lib/bitcoind
2051 # 710 comes from the upstream bitcoin unit file
2052 sudo chmod 710 /var/lib/bitcoind
2053 # note, there exists
2054 # /a/bin/ds/disabled/bitcoin
2060 ### begin live streaming ###
2062 # comparing nginx rtmp to icecast
2063 # `mpv --cache=no` had about 2.5 sec latency vs 4 seconds.
2064 # Then I discovered this command which had about .5 sec latency:
2065 #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
2066 ## a lot of those args arent needed, here is what I ended up with:
2067 # #ffplay -f live_flv -fflags nobuffer -flags low_delay -i rtmp://localhost/live
2069 # A problem with rtmp is that it doesn't support vp8/vp9, requiring the partly patent encumbered h264.
2070 # Looking at alternative protocols: dash & hls are both high latency, I tested dash with the nginx-rtmp
2071 # module and got about 5 seconds of latency, web results imply that is normal.
2073 # Webrtc is what jitsi & bbb use, but an annoying thing is that
2074 # generally requires a web browser with javascript, or some special
2075 # client, and afaik, it has a smaller limit on number of clients.
2077 # Another option is to try rtp/rtsp, there are some servers here:
2078 # https://en.wikipedia.org/wiki/Real-Time_Streaming_Protocol
2081 ## reference for setting up rtmp
2082 # pi nginx libnginx-mod-rtmp
2083 # cat >/etc/nginx/modules-enabled/rtmp.conf <<'EOF'
2084 ## based on https://opensource.com/article/19/1/basic-live-video-streaming-server#comments
2085 ## and https://github.com/arut/nginx-rtmp-module/wiki/Directives
2088 # allow publish 127.0.0.1;
2092 # application live {
2100 ### end live streaming ###
2104 # from https://raw.githubusercontent.com/cli/cli/trunk/docs/install_linux.md
2105 # One time setup afterwards:
2108 # When it gets to the page where it asks to authorize github, the button
2109 # is grayed out. You can just open browser dev tools, inspect the
2110 # button, remove disabled="", then click it and it works.
2112 # Auth token gets saved into /p/c/subdir_files/.local/share/keyrings/
2114 # initial config goes to /home/iank/.config/gh
2115 curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
2116 && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
2117 && 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 \
2118 && sudo apt update \
2119 && sudo apt install gh -y
2123 # remove trisquel banner. it is cool but takes up too much space.
2124 sudo rm -f /etc/update-motd.d/01-banner
2128 sd /etc/cups/client.conf <<'EOF'
2129 ServerName printserver1.office.fsf.org
2136 In mate settings settings, change scrolling to two-finger,
2137 because the default edge scroll doesn\'t work. Originally found this in debian.
2140 # Remove dep that came in with desktop to fix associations.
2141 m pu transmission-gtk
2145 lnf -T /d/vidshare /home/iank/Videos
2149 # # Based on guix manual instructions, also added code to profile.
2150 # # disabled since i'm not using it now.
2152 # if ! type -p guix >/dev/null; then
2154 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
2155 # # added some stuff to envonment.sh for profile based on
2156 # # manual instructions
2157 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
2158 # # echo is to get past prompt
2159 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
2160 # guix install glibc-utf8-locales
2161 # guix package --install guile
2167 m /a/bin/buildscripts/tor-browser
2168 # one root command needed to install
2169 s ln -sf /a/opt/tor-browser/Browser/start-tor-browser /usr/local/bin
2174 web-conf -p 4500 -f 4533 -e ian@iankelling.org apache2 b8.nz
2180 pi-nostart nfs-kernel-server
2182 # todo, this is old, probably needs removing
2183 if [[ $HOSTNAME == tp ]]; then
2184 sd /etc/wireguard/wg0.conf <<EOF
2186 PrivateKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.key)
2187 Address = 10.3.0.2/24, fdfd::2/64
2190 PresharedKey = $(cat /p/c/machine_specific/tp/filesystem/root/wg.psk)
2191 PublicKey = 9RnAsJB+ISrA/9lmDKBoT08oBiKwzA64exBBj+rO+ng=
2192 Endpoint = b8.nz:26000
2193 AllowedIPs = 10.3.0.1/24, fdfd::1/64
2194 PersistentKeepalive = 20
2196 sudo systemctl enable wg-quick@wg0
2197 sudo systemctl start wg-quick@wg0
2201 if [[ $HOSTNAME == kw ]]; then
2202 # hosts 1-199. 200+ are dynamic, avoid those
2203 tu /etc/exports <<'EOF'
2204 /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)
2205 /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)
2213 # if I was going to create a persistent vm, i might do it like this:
2214 # variant=something # from: virt-install --os-variant list
2215 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
2216 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
2217 # -n some_name --import --os-variant $variant --cpu host-model-only
2220 # for brother HL-2270DW, this worked:
2221 # https://askubuntu.com/questions/1067234/cant-use-wireless-brother-printer-2270dw-ubuntu-18-04
2222 # /a/opt/linux-brprinter-installer-2.2.2-1
2223 # answer n when it asks about uri.
2224 # Then go to cups, delete the existing printer, added on with dnssd url. browsed to
2225 # ppd at /usr/share/ppd/HL2270DW.ppd, which is duplicated at /usr/share/cups/model/HL2270DW.ppd
2226 # ppd file got installed from bash -x ./usr/local/Brother/Printer/HL2270DW/cupswrapper/cupswrap,
2227 # which I downloaded from their driver. but dont do that again, i copied it to /a/opt/HL2270DW.ppd,
2230 # 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.
2231 # Then it was already configured, but if i needed to, go to its web ui, default pass is "access".
2233 ######### begin stuff belonging at the end ##########