2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4 export BRC
=t
; if [[ -s ~
/.bashrc
]];then . ~
/.bashrc
;fi
7 source /a
/bin
/errhandle
/err
8 src
="$(readlink -f -- "${BASH_SOURCE[0]}")"; src
=${src%/*} # directory of this file
10 if [[ $EUID == 0 ]]; then
11 echo "$0: error: run as regular user" >&2
16 echo 1 >~
/.local
/distro-end
19 # shellcheck source=./pkgs
22 echo "$0: $(date) starting now)"
23 # see example of usage to understand.
26 IFS
= read -r -d '' y ||
:
31 echo 0 >~
/.local
/distro-end
32 if $pending_reboot; then
33 echo "$0: pending reboot and then finished. doing it now."
34 echo "exiting with status 0"
37 echo "$0: $(date): ending now)"
38 echo "exiting with status 0"
44 printf "$pre %s\n" "$*"
45 SUDOD
="$PWD" command sudo
"$@";
48 sudo
dd of
="$1" 2>/dev
/null
50 m
() { printf "$pre %s\n" "$*"; "$@"; }
51 e
() { printf "$pre %s\n" "$*"; }
52 err
() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $0: $*" >&2; }
54 codename
=$
(debian-codename
)
55 codename_compat
=$
(debian-codename-compat
)
57 sed="sed --follow-symlinks"
69 sudo debconf-set-selections
<<EOF
70 popularity-contest popularity-contest/participate boolean true
73 ########### begin section including linode ################
79 # no equivalent in other distros:
80 if isdeb
&& pcheck apt-file
; then
81 # this condition is just a speed optimization
90 # allows me to pipe with ssh -t, and gets rid of spam
91 # http://forums.debian.net/viewtopic.php?f=5&t=85822
92 # i'd rather disable the service than comment the init file
93 # this says disabling the service, it will still get restarted
94 # but this script doesn't do anything on restart, so it should be fine
95 sudo truncate
-s0 /var
/run
/motd.dynamic
98 # this isn't a complete solution. It still shows me when updates are available,
99 # but it's no big deal.
100 sudo
rm -fv /etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
107 ### begin certbot install ###
108 if [[ $distro == debian ||
$codename_compat == bionic
]]; then
109 # note, need python-certbot-nginx for nginx, but it depends on nginx,
110 # and I'm not installing nginx by default right now.
111 pi certbot python3-certbot-apache
112 elif [[ $codename_compat == xenial
]]; then
113 # not packaged in xenial or flidas
114 pi software-properties-common
115 l
="deb http://ppa.launchpad.net/certbot/certbot/ubuntu xenial main"
116 if ! grep -xFq "$l" /etc
/apt
/sources.list
{,.d
/*.list
}; then
117 sudo add-apt-repository
-y ppa
:certbot
/certbot ||
:
120 pi python-certbot-apache
122 err
"distro unknown for certbot"
124 # make a version of the certbot timer that emails me.
125 x
=/systemd
/system
/certbot
126 $sed -r -f - /lib
$x.timer
<<'EOF' |sd /etc${x}mail.timer
127 s,^Description.*,\0 mail version,
129 $sed -r -f - /lib
$x.service
<<'EOF' |sd /etc${x}mail.service
130 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
133 sgo certbotmail.timer
134 ### end certbot install ###
137 # dogcam setup. not using atm
140 # /a/bin/webcam/install-server
143 # /a/bin/webcam/install-client
148 ## not actually using prometheus just yet
149 # # office is not exposed to internet yet
150 # if [[ $HOSTNAME != kw ]]; then
151 # ## prometheus node exporter setup
152 # web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF'
153 # #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
154 # # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
158 # AuthName "Authentication Required"
159 # # setup one time, with root:www-data, 640
160 # AuthUserFile "/etc/prometheus-htpasswd"
167 ######### begin flidas pinned packages ######
168 case $
(debian-codename
) in
169 # needed for debootstrap scripts for fai since fai requires debian
171 curl http
://archive.ubuntu.com
/ubuntu
/project
/ubuntu-archive-keyring.gpg | s apt-key add
-
172 sd
/etc
/apt
/preferences.d
/flidas-xenial
<<EOF
174 Pin: release a=xenial
178 Pin: release a=xenial-updates
182 Pin: release a=xenial-security
186 Pin: release n=xenial
189 sd
/etc
/apt
/sources.list.d
/xenial.list
2>/dev
/null
<<EOF
190 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
191 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
192 deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
195 if ! apt-key list |
grep /C0B21F32
&>/dev
/null
; then
196 sudo apt-key adv
--keyserver keyserver.ubuntu.com
--recv-keys 3B4FE6ACC0B21F32
197 sd
/etc
/apt
/preferences.d
/flidas-bionic
<<EOF
199 Pin: release a=bionic
203 Pin: release a=bionic-updates
207 Pin: release a=bionic-security
212 # better to run btrfs-progs which matches our kernel version
213 # (note, renamed from btrfs-tools)
214 sd
/etc
/apt
/preferences.d
/btrfs-progs
<<EOF
215 Package: btrfs-progs libzstd1
216 Pin: release a=bionic
219 Package: btrfs-progs libzstd1
220 Pin: release a=bionic-updates
223 Package: btrfs-progs libzstd1
224 Pin: release a=bionic-security
231 deb http://us.archive.ubuntu.com/ubuntu/ bionic main
232 deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main
233 deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main
235 f
=/etc
/apt
/sources.list.d
/bionic.list
236 if ! diff -q $t $f; then
242 # no special reason, but its better for btrfs-progs to
243 # be closer to our kernel version
246 if [[ ! -e /usr
/share
/debootstrap
/scripts
/xenial
]]; then
249 m aptitude download debootstrap
/xenial
251 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
254 sd
/etc
/apt
/preferences.d
/flidas-etiona
<<EOF
256 Pin: release a=etiona
260 Pin: release a=etiona-updates
264 Pin: release a=etiona-security
268 Pin: release a=etiona-backports
274 deb http://mirror.fsf.org/trisquel/ etiona main
275 deb http://mirror.fsf.org/trisquel/ etiona-updates main
276 deb http://archive.trisquel.info/trisquel/ etiona-security main
277 deb http://mirror.fsf.org/trisquel/ etiona-backports main
279 f
=/etc
/apt
/sources.list.d
/etiona.list
280 if ! diff -q $t $f; then
286 sd
/etc
/apt
/preferences.d
/debian-goodies
<<EOF
287 Package: debian-goodies
288 Pin: release n=etiona
293 sd
/etc
/apt
/preferences.d
/flidas-buster
<<EOF
295 Pin: release n=buster
299 Pin: release n=buster-updates
303 # dont use buster because it causes dist-upgrade to think its downgrading
304 # packages while really just reinstalling the same version.
305 f
=/etc
/apt
/apt.conf.d
/01iank
307 # # stupid buster uses some key algorithm not supported by flidas gpg that apt uses.
308 # sd /etc/apt/apt.conf.d/01iank <<'EOF'
309 # Acquire::AllowInsecureRepositories "true";
312 f
=/etc
/apt
/sources.list.d
/buster.list
316 # deb http://http.us.debian.org/debian buster main
317 # deb-src http://http.us.debian.org/debian buster main
319 # deb http://security.debian.org/ buster/updates main
320 # deb-src http://security.debian.org/ buster/updates main
322 # deb http://http.us.debian.org/debian buster-updates main
323 # deb-src http://http.us.debian.org/debian buster-updates main
325 # if ! diff -q $t $f; then
331 # newer version needed for false positive in checkrestart.
332 # I did buster at first, but other problem above with having
333 # buster repos. not sure if the false positive exists in etiona.
336 sd
/etc
/apt
/preferences.d
/shellcheck
<<EOF
338 Pin: release a=etiona
342 Pin: release a=etiona-updates
346 Pin: release a=etiona-security
350 sd
/etc
/apt
/preferences.d
/bash
<<EOF
352 Pin: release a=etiona
356 Pin: release a=etiona-updates
360 Pin: release a=etiona-security
367 sd
/etc
/apt
/preferences.d
/etiona-bionic
<<'EOF'
369 Pin: release n=bionic
372 Package: firefox gnome-screenshot gnome-icon-theme libnautilus-extension1a gnome-settings-daemon nautilus yelp gnome-settings-daemon-schemas nautilus-data ubuntu-wallpapers gnome-control-center gnome-control-center-data gnome-control-center-faces libsnapd-glib1 ubuntu-wallpapers-bionic gir1.2-snapd-1 ubuntu-drivers-common ubuntu-docs libyelp0
373 Pin: release n=bionic
379 pi debian-goodies shellcheck
383 ######### end flidas pinned packages ######
385 ##### begin automatic upgrades (after checkrestart has been installed) ####
386 sd
/etc
/apt
/apt.conf.d
/10periodic
<<'EOF'
387 # this file was mostly just comments.
388 APT::Periodic::Update-Package-Lists "1";
389 APT::Periodic::Download-Upgradeable-Packages "1";
390 APT::Periodic::AutocleanInterval "7";
391 APT::Periodic::Unattended-Upgrade "1";
394 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
395 # fyi: default file has comments about available options,
396 # you may want to read that, do pkx unattended-upgrades
397 Unattended-Upgrade::Mail "root";
398 Unattended-Upgrade::MailOnlyOnError "true";
399 Unattended-Upgrade::Remove-Unused-Dependencies "true";
400 Unattended-Upgrade::Origins-Pattern {
401 # default is just security updates. this list found from reading
402 # match_whitelist_string() in $(which unattended-upgrades)
403 "o=*,l=*,a=*,c=*,site=*,n=*";
407 # old names, too verbose
408 sudo
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
410 sd
/etc
/cron.d
/myupgrade
<<'EOF'
411 # Setup reboots when running outdated stuff, unattended upgrades happen
412 # at 6 am + rand(60 min).
416 # default is /usr/bin:/bin
417 PATH=/usr/bin:/bin:/usr/local/bin
418 20 7 * * * iank myupgrade |& log-once -1 myupgrade
419 0 * * * * root mycheckrestart |& log-once -1 mycheckrestart
421 ##### end automatic upgrades ####
425 ###### begin website setup
429 f
=/var
/lib
/bind
/db.b8.nz
430 if [[ ! -e $f ]]; then
433 sudo
install -m 644 -o bind -g bind /p
/c
/machine_specific
/linode
/bind-initial
/db.b8.nz
$f
438 # setup let's encrypt cert
439 m web-conf apache2 l2.b8.nz
440 sudo
rm -fv /etc
/apache
2/sites-enabled
/l2.b8.nz
{,-redir}.conf
442 s lnf
-T /etc
/letsencrypt
/live
/l2.b8.nz
/fullchain.pem
/etc
/exim
4/exim.crt
443 if [[ ! -L /etc
/exim
4/exim.key
]]; then
444 s lnf
-T /etc
/letsencrypt
/live
/l2.b8.nz
/privkey.pem
/etc
/exim
4/exim.key
453 m
/a
/h
/setup.sh iankelling.org
456 m
/a
/h
/setup.sh
-s b8.nz
459 # allow symlinks on non-main hosts so i can host files in arbitrary paths
460 m
/a
/h
/setup.sh
-s -p 80
465 # start mumble only when im going to use it, since i dont use it much
466 pi-nostart mumble-server
467 sudo
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
469 # do certificate to avoid warning about unsigned cert,
470 # which is overkill for my use, but hey, I'm cool, I know
472 m web-conf apache2 mumble.iankelling.org
473 sudo
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
475 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
476 /a/bin/distro-setup/certbot-renew-hook
480 # requested from linode via a support ticket.
481 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
482 # ipv6 stuff pieced together
483 # via slightly wrong information from
484 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
485 # https://community.openvpn.net/openvpn/wiki/IPv6
488 m vpn-server-setup
-rd 2600:3c00
:e000
:280::1/64 2600:3c00
::f03c
:91ff
:feb4
:0bf3
489 sudo
tee /etc
/openvpn
/client-config
/mail <<'EOF'
490 ifconfig-push 10.8.0.4 255.255.255.0
491 ifconfig-ipv6-push 2600:3c00:e000:280::2/64
494 if [[ -e /lib
/systemd
/system
/openvpn-server@.service
]]; then
495 vpn_service
=openvpn-server@server
497 vpn_service
=openvpn@server
500 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
502 Description=Turns on iptables mail nat
507 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
508 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
511 WantedBy=$vpn_service.service
515 # needed for li's local mail delivery.
516 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
518 # setup let's encrypt cert
519 m web-conf apache2 mail.iankelling.org
520 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
523 domain=cal.iankelling.org
524 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
525 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
526 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
528 Options +FollowSymLinks +Multiviews +Indexes
531 AuthName "Authentication Required"
532 # setup one time, with root:www-data, 640
533 AuthUserFile "/etc/caldav-htpasswd"
537 # nginx version of above would be:
538 # auth_basic "Not currently available";
539 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
543 ###### begin znc setup #####
546 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
547 # to get into the web interface,
548 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
549 # https://iankelling.org:12533/
551 export RENEWED_LINEAGE=/etc/letsencrypt/live/iankelling.org
552 /a/bin/distro-setup/certbot-renew-hook
555 # znc config generated by doing
557 # selected port is also used in erc config
558 # comma separated channel list worked.
559 # while figuring things out, running znc -D for debug in foreground.
560 # to exit and save config:
561 # /msg *status shutdown
562 # configed auth on freenode by following
563 # https://wiki.znc.in/Sasl:
564 # /msg *sasl RequireAuth yes
565 # /msg *sasl Mechanism PLAIN
566 # /msg *sasl Set ident_name password
567 # created the system service after, and had to do
568 # mv /home/iank/.znc/* /var/lib/znc
569 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
570 # and made a copy of the config files into /p/c
571 # /msg *status LoadMod --type=global log -sanitize
572 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
573 # /msg *status LoadMod --type=network perform
574 # /msg *perform add PRIVMSG ChanServ :invite #fsf-office
575 # /msg *perform add JOIN #fsf-office
578 # also ran /znc LoadMod clearbufferonmsg
579 # it would be nice if erc supported erc query buffers by doing
580 # /msg *status clearbuffer <name of the query/receiver
582 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
583 # if that was the case i could remove the module clearbufferonmsg
584 # also would be nice if erc supported
585 # https://wiki.znc.in/self-message
586 # https://wiki.znc.in/Query_buffers \
588 if ! getent passwd znc > /dev/null; then
589 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
591 sudo chmod 700 /var/lib/znc
592 sudo chown -R znc:znc /var/lib/znc
593 # Avoid restarting if possible, reconnecting to irc is annoying.
594 # The unit file was made active with conflink.
595 # Note, avoid using ser here because we wrap sudo to prints the command first.
596 if [[ $(systemctl is-active znc) != active ]]; then
599 ###### stop znc setup #####
604 ###### end website setup
606 ########### end section including li/lj ###############
609 case $codename_compat in
611 # mate-indicator-applet and beyond are msc things I noticed diffing a
612 # standard install with mine.
613 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
619 # mate doesnt have wayland support yet
620 pi task-gnome-desktop
624 # by default, it sleeps when not logged in to x/wayland and on ac power.
626 sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
627 systemctl --user stop gvfs-daemon
628 systemctl --user disable gvfs-daemon
633 if [[ $codename_compat == flidas ]]; then
634 # doesnt exist in newer
638 # abrowser is not in etiona yet, abrowser version is 68,
639 # abrowser won't run on a firefox profile that was on firefox
640 # version 70. firefox in ubuntu is at version 70.
641 # have to rm compabibility.ini to even try downgrade.
643 sudo update-alternatives --set x-www-browser /usr/bin/firefox
645 # TODO: some of the X programs can be removed from pall when using wayland
647 # depends gcc is a way to install suggests. this is apparently the only
648 # way to install suggests even if the main package is already
649 # installed. reinstall doesn't work, uninstalling can cause removing
650 # dependent packages.
651 pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $(apt-cache depends gcc|grep -i suggests:| awk '{print $2}') $($src/distro-pkgs)
654 # website is dead june 14 2019. back in october, but meh
655 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
660 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
663 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
664 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
666 # f=/etc/apt/sources.list.d/iridium-browser.list
667 # if ! diff -q $t $f; then
677 ### begin home vpn server setup
680 # # this section done initially to make persistent keys.
681 # # Also note, I temporarily set /etc/hosts so my host was
682 # # b8.nz when running this, since the vpn client config
683 # # generator assumes we need to go to that server to get
685 # vpn-server-setup -rds
686 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
687 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
688 # # kw = kgpe work machine.
689 # for host in x2 x3 kw; do
690 # vpn-mk-client-cert -b $host -n home b8.nz 1196
691 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
693 # s bash -c "cp /etc/openvpn/client/home* $dir"
694 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
697 # key already exists, so this won't generate one, just the configs.
698 m vpn-server-setup -rds
699 sudo tee -a /etc/openvpn/server/server.conf <<'EOF'
700 push "dhcp-option DNS 10.0.0.1"
701 push "route 10.0.0.0 255.255.0.0"
702 client-connect /a/bin/distro-setup/vpn-client-connect
704 sudo sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
706 if [[ $HOSTNAME == tp ]]; then
707 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
708 vpn_service=openvpn-server@server
710 vpn_service=openvpn@server
714 ### end vpn server setup
718 # note, see bashrc for more documentation.
720 sd /etc/systemd/system/rss2email.service <<'EOF'
722 Description=rss2email
723 After=multi-user.target
728 # about 24 hours of failures
729 # it copies over its files without respecting symlinks, so
730 # we pass options to use different location.
731 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
733 sd /etc/systemd/system/rss2email.timer <<'EOF'
735 Description=rss2email
738 # for initial run. required.
740 # for subsequent runs.
741 OnUnitInactiveSec=300
744 WantedBy=timers.target
746 sudo systemctl daemon-reload
749 ######### begin pump.io periodic backup #############
750 if [[ $HOSTNAME == frodo ]]; then
751 sd /etc/systemd/system/pumpbackup.service <<'EOF'
753 Description=pump li backup
754 After=multi-user.target
759 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
761 sd /etc/systemd/system/pumpbackup.timer <<'EOF'
763 Description=pump li backup hourly
769 WantedBy=timers.target
774 ######### end pump.io periodic backup #############
777 ######### begin irc periodic backup #############
778 if [[ $HOSTNAME == frodo ]]; then
779 sd /etc/systemd/system/ircbackup.service <<'EOF'
781 Description=irc li backup
782 After=multi-user.target
787 ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
789 sd /etc/systemd/system/ircbackup.timer <<'EOF'
791 Description=irc li backup hourly
797 WantedBy=timers.target
799 sudo systemctl daemon-reload
804 ######### end irc periodic backup #############
808 # pi-nostart does not disable
813 m /a/bin/distro-setup/radicale-setup
816 ############# begin syncthing setup ###########
817 if [[ $HOSTNAME == frodo ]]; then
818 # It\'s simpler to just worry about running it in one place for now.
819 # I assume it would work to clone it\'s config to another non-phone
820 # and just run it in one place instead of the normal having a
821 # separate config. I lean toward using the same config, since btrfs
822 # syncs between comps.
823 # testing has relatively up to date packages
824 if ! isdebian-testing; then
825 # based on error when doing apt-get update:
826 # E: The method driver /usr/lib/apt/methods/https could not be found.
827 pi apt-transport-https
828 # google led me here:
829 # https://apt.syncthing.net/
830 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
831 s="deb http://apt.syncthing.net/ syncthing release"
832 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
833 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
838 m lnf -T /w/syncthing /home/iank/.config/syncthing
839 ser daemon-reload # syncthing likely not properly packaged
840 sgo syncthing@iank # runs as iank
842 # these things persist in ~/.config/syncthing, which I save in
843 # /w/syncthing (not in /p, because syncthing should continue to
844 # run on home server even when using laptop as primary device)
845 # open http://localhost:8384/
846 # change listen address from default to tcp://:22001,
847 # this is because we do port forward so it doesn\'t have to use
848 # some external server, but the syncthing is broken for port forward,
849 # you get a message, something "like connected to myself, this should not happen"
850 # when connecting to other local devices, so I bump the port up by 1,
852 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
853 # Without this, it was being stuck syncing at 0%.
854 # Set gui username and password.
856 # install syncthing via f-droid,
857 # folder setting, turn off send only.
858 # on phone, add device, click bar code icon
859 # on dekstop, top right, actions, device id
860 # after adding, notification will appear on desktop to confirm
862 # syncing folder. from phone to desktop: select desktop in the
863 # folder on phone\'s sync options, notification will appear in
864 # desktop\'s web ui within a minute. For the reverse, the
865 # notification will appear in android\'s notifications, you have to
866 # swipe down and tap it to add the folder. It won\'t appear in the
867 # syncthing ui, which would be intuitive, but don\'t wait for it
868 # there. The notification may not work, instead open the web gui
869 # from in the app, there should be a notification within there.
871 # On phone, set settings to run syncthing all the time, and
872 # show no notification.
874 # Folder versioning would make sense if I didn\'t already use btrfs
875 # for backups. I would choose staggered, or trash can for more space.
877 # if needed to install on a remote comp:
878 # ssh -L 8384:localhost:8384 -N frodo
879 # open http://localhost:8384/
881 # Note, the other thing i did was port forward port 22000,
882 # per https://docs.syncthing.net/users/firewall.html
885 ############# end syncthing setup ###########
889 ####### begin misc packages ###########
898 # sakura config is owned by ian
901 m sudo -u user2 -i reset-konsole
902 # user2 xscreensaver we don't want to reset
906 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
907 # this is also in primary-setup
908 # pi libxss-dev # dependency based on build failure
910 # cabal install --upgrade-dependencies --force-reinstalls arbtt
911 # also, i assume syncing this between machines somehow messed thin
912 #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log
916 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
917 m cp /p/.linphonerc-initial ~/.linphonerc
921 ### begin spd install
922 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
924 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
927 # this guesses at the appropriate directory, adjust if needed
928 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
929 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
930 # newer distro had gpg2 as default, older one, flidas, need to make it that way
931 gpgpath=$(which gpg2)
933 sudo mkdir -p /usr/local/spdhackfix
934 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
939 # nagstamon setting which were set through the ui
941 # all unknown sources
942 # all warning services
943 # acknowledged hosts & services
944 # hosts & services down for maintenence
945 # services on down hosts
946 # services on hosts in maintenece
947 # services on unreachable osts
948 # hosts in soft state
949 # services in soft state
950 # in display tab: fullscreen
952 # these translate to these settings I think
953 # filter_acknowledged_hosts_services = True
954 # filter_all_unknown_services = True
955 # filter_all_warning_services = True
956 # filter_hosts_in_soft_state = True
957 # filter_hosts_services_maintenance = True
958 # filter_services_in_soft_state = True
959 # filter_services_on_down_hosts = True
960 # filter_services_on_hosts_in_maintenance = True
961 # filter_services_on_unreachable_hosts = True
962 # notify_if_up = False
963 # statusbar_floating = False
965 # but i'm just going to rely on the webpage plus sms for now.
968 # it asks if it should make users in it's group capture packets without root,
969 # which is arguably more secure than running wireshark as root. default is no,
970 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
971 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
973 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
974 # listed in the default config as suggested.
975 # /run/usr/1000 i noticed was missing for pulseaudio
976 # /run/user/0 just seemed like a not bad idea, given the above
977 tu /etc/schroot/desktop/fstab <<'EOF'
978 /run /run none rw,bind 0 0
979 /run/lock /run/lock none rw,bind 0 0
980 /dev/shm /dev/shm none rw,bind 0 0
981 /run/shm /run/shm none rw,bind 0 0
982 /run/user/1000 /run/user/1000 none rw,bind 0 0
983 /run/user/1001 /run/user/1001 none rw,bind 0 0
984 /run/user/0 /run/user/0 none rw,bind 0 0
992 repo=http://archive.ubuntu.com/ubuntu/
995 repo=http://deb.debian.org/debian/
1000 if schroot -l | grep -xFq chroot:$n; then
1001 echo "$0: $n schroot already installed, skipping"
1006 sd /etc/schroot/chroot.d/$n.conf <<EOF
1012 preserve-environment=true
1015 if [[ -e $d/bin ]]; then
1016 sudo chroot $d apt-get update
1017 sudo chroot $d apt-get -y dist-upgrade --purge --auto-remove
1018 cd; sudo schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1022 sudo debootstrap $n $d $repo
1023 cd; sudo schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1025 sudo cp -P {,$d}/etc/localtime
1027 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1029 Description=schrootupdate
1030 After=multi-user.target
1034 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1036 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1038 Description=schrootupdate
1041 OnCalendar=*-*-* 04:20:00
1044 WantedBy=timers.target
1047 sgo schrootupdate.timer
1054 # cant do buster due to old gpg
1055 m mkschroot debian stretch firefox-esr pulseaudio chromium
1062 sudo mkdir -p /nocow/user
1063 sudo chown $USER:$USER /nocow/user
1067 ####### begin transmission
1078 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1079 # 450 seems likely to be unused. we need to specify one or else
1080 # it won't be stable across installs.
1081 if ! getent passwd debian-transmission > /dev/null; then
1082 sudo groupadd -g 450 debian-transmission
1083 sudo adduser --quiet \
1088 --disabled-password \
1089 --home /var/lib/transmission-daemon \
1092 # We want group writable stuff from transmission.
1093 # However, after setting this, I learn that transmission sets it's
1094 # own umask based on it's settings file. Well, no harm leaving this
1095 # so it's set right from the beginning.
1096 sudo chfn debian-transmission -o umask=0002
1098 # note i had to do this, which is persistent:
1100 # s chgrp debian-transmission torrents partial-torrents
1102 # syslog says things like
1103 # 'Failed to set receive buffer: requested 4194304, got 425984'
1104 # google suggets giving it even more than that
1105 tu /etc/sysctl.conf<<'EOF'
1106 net.core.rmem_max = 67108864
1107 net.core.wmem_max = 16777216
1111 # some reason it doesn\'t seem to start automatically anyways
1112 pi-nostart transmission-daemon
1113 # be extra sure its not started
1114 ser disable transmission-daemon
1115 ser stop transmission-daemon
1117 # the folder was moved here after an install around 02/2017.
1118 # it contains runtime data,
1119 # plus a simple symlink to the config file which it\'s
1120 # not worth separating out.
1121 # between comps, the uid can change
1122 f=$tdir/transmission-daemon
1124 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1125 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1126 sudo chown -R debian-transmission:debian-transmission $f
1127 for f in $tdir/partial-torrents $tdir/torrents; do
1128 if [[ -e $f ]]; then
1129 sudo chown -R debian-transmission:user2 $f
1132 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1134 # config file documented here, and it\'s the same config
1135 # for daemon vs client, so it\'s documented in the gui.
1136 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1138 # I originaly setup rpc-whitelist, but after using
1139 # routing to a network namespace, it doesn\'t see the
1140 # real source address, so it\'s disabled.
1142 # Changed the cache-size to 256 mb, reduces disk use.
1143 # It is a read & write cache.
1146 p = '/etc/transmission-daemon/settings.json'
1147 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1148 'rpc-whitelist-enabled' => false,
1149 'rpc-authentication-required' => false,
1150 'incomplete-dir' => '$tdir/partial-torrents',
1151 'incomplete-dir-enabled' => true,
1152 'download-dir' => '$tdir/torrents',
1153 "speed-limit-up" => 800,
1154 "speed-limit-up-enabled" => true,
1155 "peer-port" => 61486,
1156 "cache-size-mb" => 256,
1157 "ratio-limit" => 5.0,
1158 "ratio-limit-enabled" => true,
1161 ####### end transmission
1165 # trisquel 8 = openvpn, debian stretch = openvpn-client
1166 vpn_ser=openvpn-client
1167 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1171 sd /etc/systemd/system/transmission-daemon-nn.service <<EOF
1173 Description=Transmission BitTorrent Daemon netns
1174 After=network.target
1175 Requires=${vpn_ser}-nn@client.service
1176 After=${vpn_ser}-nn@client.service
1177 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1180 #User=debian-transmission
1181 # notify type doesn't work with sudo
1183 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1184 ExecReload=/bin/kill -s HUP \$MAINPID
1189 WantedBy=multi-user.target
1193 if [[ $HOSTNAME == frodo ]]; then
1194 sgo transmission-daemon-nn
1198 ######### begin transmission client setup ######
1200 if [[ -e /p/transmission-rpc-pass ]]; then
1201 # arch had a default config,
1202 # debian had nothing until you start it.
1203 # With a little trial an error, here is a minimal config
1204 # taken from the generated one, plus changes that the
1205 # settings ui does, without a bunch of ui crap settings.
1207 # only settings I set were
1212 # the password is randomly generated on first run, i copied it out
1213 # so it could be used by other hosts.
1216 p = '/etc/transmission-daemon/settings.json'
1217 s = JSON.parse(File.read(p))
1218 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1219 # default is 0022 (18 in decimal)
1221 File.write p, JSON.pretty_generate(s)
1224 rpc_pass=$(</p/transmission-rpc-pass)
1225 for f in /home/*; do
1227 uid=$(id -u $u 2>/dev/null) || continue
1228 if [[ ! $uid -ge 1000 ]]; then
1231 d=$f/.config/transmission-remote-gtk
1232 sudo -u $u mkdir -p $d
1233 sudo -u $u dd of=$d/config.json <<EOF
1237 "profile-name" : "Default",
1238 "hostname" : "transmission.b8.nz",
1240 "rpc-url-path" : "/transmission/rpc",
1242 "password" : "$rpc_pass",
1243 "auto-connect" : true,
1247 "update-active-only" : false,
1248 "activeonly-fullsync-enabled" : false,
1249 "activeonly-fullsync-every" : 2,
1250 "update-interval" : 3,
1251 "min-update-interval" : 3,
1252 "session-update-interval" : 60,
1253 "exec-commands" : [],
1257 "profile-name" : "local",
1258 "hostname" : "10.173.0.2",
1261 "password" : "$rpc_pass",
1262 "auto-connect" : true,
1266 "update-active-only" : false,
1267 "activeonly-fullsync-enabled" : false,
1268 "activeonly-fullsync-every" : 2,
1269 "update-interval" : 3,
1270 "min-update-interval" : 3,
1271 "session-update-interval" : 60,
1272 "exec-commands" : [],
1277 "add-options-dialog" : false
1282 ######### end transmission client setup ######
1287 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1288 # goto http://127.0.0.1:631
1289 # administration tab, add new printer button.
1290 # In debian, I could use hte recommended driver,
1291 # in arch, I had to pick out the 6L driver.
1294 # bridge networking as user fails. google lead here, but it doesn\'t work:
1295 # oh well, I give up.
1296 # http://wiki.qemu.org/Features-Done/HelperNetworking
1298 # f=/etc/qemu/bridge.conf
1302 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1305 # general known for debian/ubuntu, not for fedora
1307 m /a/bin/buildscripts/go
1308 m /a/bin/buildscripts/rust
1309 m /a/bin/buildscripts/misc
1311 pi-nostart virtinst virt-manager
1312 # allow user to run vms, from debian handbook
1313 for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
1316 pi --no-install-recommends kdeconnect
1317 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1318 ### but gnome + xmonad not working in flidas, so i disabled it
1319 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1320 # cd /a/opt/indicator-kdeconnect
1323 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1326 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1327 # # it seems, according to
1328 # # /etc/xdg/autostart/kdeconnectd.desktop
1329 # # I'm not seeing the icon, but the clipboard replication is working
1332 ### model 01 arduino support ###
1333 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1334 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1335 # set arduino var in bashrc,
1336 # have system config file setup too.
1337 sudo adduser $USER dialout
1339 # this is for the mail command too. update-alternatives is kind of misleading
1340 # since at least it's main commands pretend mail does not exist.
1341 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1342 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1344 ######### end misc packages #########
1347 # packages I once used before and liked, but don\'t want installed now for
1349 # python-sqlite is used for offlineimap
1350 # lxappearance python-sqlite dolphin paman dconf-editor
1356 # todo, finish configuring smart.
1359 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1360 # turn on smart. background on options:
1361 # first line, -a = test everyting on all devices.
1362 # -S on, turn on disk internal saving of vendor specific info,
1363 # from google, seems like this is usually already on and fairly standard.
1364 # -o on, turn on 4 hour period non-performance degrading testing.
1365 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1366 sched="-s (S/../.././02|L/../../6/03)"
1367 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1368 DEVICESCAN -a -o on -S on -n standby,q $sched \
1369 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1371 # in the default configuration of at least ubuntu 14.04, resolvconf is
1372 # configured to order any nameservers associated with tun* or tap*
1373 # before the normal internet interfaces, which means they are always
1374 # consulted first. This is often slower and undesirable, ie. local dns
1375 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1377 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1378 # however, this breaks dns lookup for hosts on the openvpn lan.
1379 # I can\'t figure out why hosts on the normal lan would not be
1380 # broken under the default ordering, except the host I was
1381 # testing with previously had an entry in /etc/hosts.
1383 ############# end unfinished
1385 ########### misc stuff
1387 case $(debian-codename) in
1388 # needed for debootstrap scripts for fai since fai requires debian
1391 pi-nostart network-manager
1392 # make networkmanager use resolvconf instead of its own dnsmasq which
1393 # conflicts with the normal dnsmasq package.
1394 f=/etc/NetworkManager/NetworkManager.conf
1396 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1397 sudo sed -ri '/ *\[main\]/a dns=default' $f
1398 if [[ $m != $(md5sum $f) ]]; then
1399 srestart NetworkManager
1401 # networkmanager has this nasty behavior on flidas: if the machine
1402 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1403 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1405 # This can be manually fixed by stoping dnsmasq,
1406 # then based on whats in /run/dnsmasq/, i see we can run
1407 # s resolvconf -d NetworkManager
1408 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1409 ser disable NetworkManager
1413 # make my /etc/fonts/conf.d/ get used.
1414 # I have a new sans-serif font there because the default one
1415 # displays l and I as the same char, grrrrr.
1418 pi desktop-file-utils
1419 m /a/bin/distro-setup/mymimes
1425 # stop autopoping windows when i plug in an android phone.
1426 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1427 # with still 0 exit code.
1428 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1429 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1432 # on grub upgrade, we get prompts unless we do this
1434 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1435 devs+=("$(devbyid $dev),")
1437 devs[-1]=${devs[-1]%,} # jonied by commas
1438 sudo debconf-set-selections <<EOF
1439 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1443 sgo btrfsmaint.timer
1444 sgo btrfsmaintstop.timer
1446 # aren't autoupdating this, but I do check on it somewhat regularly.
1451 # note: to see when it was last run,
1456 In mate settings settings, change scrolling to two-finger,
1457 because the default edge scroll doesn\'t work. Originally found this in debian.
1460 # Remove dep that came in with desktop to fix associations.
1461 m pu transmission-gtk
1464 m /a/bin/buildscripts/pithosfly
1467 # # Based on guix manual instructions, also added code to profile.
1468 # # disabled since i'm not using it now.
1470 # if ! type -p guix >/dev/null; then
1472 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1473 # # added some stuff to envonment.sh for profile based on
1474 # # manual instructions
1475 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1476 # # echo is to get past prompt
1477 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1478 # guix install glibc-utf8-locales
1479 # guix package --install guile
1485 m /a/bin/buildscripts/tor-browser
1488 pi-nostart nfs-kernel-server
1492 if [[ $HOSTNAME == frodo ]]; then
1493 # nohide = export filesystems mounted deeper than the export point
1494 # fsid=0 makes this export the "root" export
1495 # not documented in the man page, but this means
1496 # 1. it can be mounted with a shorthand of server:/
1497 # 2. exports that are subdirectories of this one will automatically be mounted
1498 tu /etc/exports <<'EOF'
1499 /k 10.0.0.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1508 # if I was going to create a persistent vm, i might do it like this:
1509 # variant=something # from: virt-install --os-variant list
1510 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1511 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1512 # -n some_name --import --os-variant $variant --cpu host-model-only
1516 ######### begin stuff belonging at the end ##########