2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
6 source /a
/bin
/errhandle
/err
7 src
="$(readlink -f -- "${BASH_SOURCE[0]}")"; src
=${src%/*} # directory of this file
9 if [[ $EUID == 0 ]]; then
10 echo "$0: error: run as regular user" >&2
15 echo 1 >~
/.local
/distro-end
18 # shellcheck source=./pkgs
21 exec &> >(sudo
tee -a /var
/log
/distro-end
)
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."
36 echo "$0: $(date): ending now)"
43 SUDOD
="$PWD" sudo
-i "$@";
46 s
dd of
="$1" 2>/dev
/null
48 m
() { printf "$pre %s\n" "$*"; "$@"; }
49 e
() { printf "$pre %s\n" "$*"; }
50 err
() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $0: $*" >&2; }
52 codename
=$
(debian-codename
)
53 codename_compat
=$
(debian-codename-compat
)
55 sed="sed --follow-symlinks"
67 s debconf-set-selections
<<EOF
68 popularity-contest popularity-contest/participate boolean true
71 ########### begin section including linode ################
77 # no equivalent in other distros:
78 if isdeb
&& pcheck apt-file
; then
79 # this condition is just a speed optimization
88 # allows me to pipe with ssh -t, and gets rid of spam
89 # http://forums.debian.net/viewtopic.php?f=5&t=85822
90 # i'd rather disable the service than comment the init file
91 # this says disabling the service, it will still get restarted
92 # but this script doesn't do anything on restart, so it should be fine
93 s truncate
-s0 /var
/run
/motd.dynamic
96 # this isn't a complete solution. It still shows me when updates are available,
97 # but it's no big deal.
98 s
rm -fv /etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
105 ### begin certbot install ###
106 if [[ $distro == debian
]]; then
107 # note, need python-certbot-nginx for nginx, but it depends on nginx,
108 # and I'm not installing nginx by default right now.
109 pi certbot python-certbot-apache
110 elif [[ $codename_compat == xenial
]]; then
111 # not packaged in xenial or flidas
112 pi software-properties-common
113 l
="deb http://ppa.launchpad.net/certbot/certbot/ubuntu xenial main"
114 if ! grep -xFq "$l" /etc
/apt
/sources.list
{,.d
/*.list
}; then
115 s add-apt-repository
-y ppa
:certbot
/certbot ||
:
118 pi python-certbot-apache
120 err
"distro unknown for certbot"
122 # make a version of the certbot timer that emails me.
123 x
=/systemd
/system
/certbot
124 $sed -r -f - /lib
$x.timer
<<'EOF' |sd /etc${x}mail.timer
125 s,^Description.*,\0 mail version,
127 $sed -r -f - /lib
$x.service
<<'EOF' |sd /etc${x}mail.service
128 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
131 m sgo certbotmail.timer
132 ### end certbot install ###
135 # dogcam setup. not using atm
138 # /a/bin/webcam/install-server
141 # /a/bin/webcam/install-client
146 ## not actually using prometheus just yet
147 # # office is not exposed to internet yet
148 # if [[ $HOSTNAME != kw ]]; then
149 # ## prometheus node exporter setup
150 # web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF'
151 # #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
152 # # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
156 # AuthName "Authentication Required"
157 # # setup one time, with root:www-data, 640
158 # AuthUserFile "/etc/prometheus-htpasswd"
165 ######### begin flidas pinned packages ######
166 case $
(debian-codename
) in
167 # needed for debootstrap scripts for fai since fai requires debian
169 curl http
://archive.ubuntu.com
/ubuntu
/project
/ubuntu-archive-keyring.gpg | s apt-key add
-
170 sd
/etc
/apt
/preferences.d
/flidas-xenial
<<EOF
172 Pin: release a=xenial
176 Pin: release a=xenial-updates
180 Pin: release a=xenial-security
183 sd
/etc
/apt
/sources.list.d
/xenial.list
2>/dev
/null
<<EOF
184 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
185 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
186 deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
189 if ! apt-key list |
grep /C0B21F32
&>/dev
/null
; then
190 s apt-key adv
--keyserver keyserver.ubuntu.com
--recv-keys 3B4FE6ACC0B21F32
191 sd
/etc
/apt
/preferences.d
/flidas-bionic
<<EOF
193 Pin: release a=bionic
197 Pin: release a=bionic-updates
201 Pin: release a=bionic-security
206 # better to run btrfs-progs which matches our kernel version
207 # (note, renamed from btrfs-tools)
208 sd
/etc
/apt
/preferences.d
/btrfs-progs
<<EOF
209 Package: btrfs-progs libzstd1
210 Pin: release a=bionic
213 Package: btrfs-progs libzstd1
214 Pin: release a=bionic-updates
217 Package: btrfs-progs libzstd1
218 Pin: release a=bionic-security
225 deb http://us.archive.ubuntu.com/ubuntu/ bionic main
226 deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main
227 deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main
229 f
=/etc
/apt
/sources.list.d
/bionic.list
230 if ! diff -q $t $f; then
236 # no special reason, but its better for btrfs-progs to
237 # be closer to our kernel version
240 if [[ ! -e /usr
/share
/debootstrap
/scripts
/xenial
]]; then
243 m aptitude download debootstrap
/xenial
245 s
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
248 sd
/etc
/apt
/preferences.d
/flidas-etiona
<<EOF
250 Pin: release a=etiona
254 Pin: release a=etiona-updates
258 Pin: release a=etiona-security
262 Pin: release a=etiona-backports
268 deb http://mirror.fsf.org/trisquel/ etiona main
269 deb http://mirror.fsf.org/trisquel/ etiona-updates main
270 deb http://archive.trisquel.info/trisquel/ etiona-security main
271 deb http://mirror.fsf.org/trisquel/ etiona-backports main
273 f
=/etc
/apt
/sources.list.d
/etiona.list
274 if ! diff -q $t $f; then
280 sd
/etc
/apt
/preferences.d
/debian-goodies
<<EOF
281 Package: debian-goodies
282 Pin: release n=etiona
287 sd
/etc
/apt
/preferences.d
/flidas-buster
<<EOF
289 Pin: release n=buster
293 Pin: release n=buster-updates
297 # dont use buster because it causes dist-upgrade to think its downgrading
298 # packages while really just reinstalling the same version.
299 f
=/etc
/apt
/apt.conf.d
/01iank
301 # # stupid buster uses some key algorithm not supported by flidas gpg that apt uses.
302 # sd /etc/apt/apt.conf.d/01iank <<'EOF'
303 # Acquire::AllowInsecureRepositories "true";
306 f
=/etc
/apt
/sources.list.d
/buster.list
310 # deb http://http.us.debian.org/debian buster main
311 # deb-src http://http.us.debian.org/debian buster main
313 # deb http://security.debian.org/ buster/updates main
314 # deb-src http://security.debian.org/ buster/updates main
316 # deb http://http.us.debian.org/debian buster-updates main
317 # deb-src http://http.us.debian.org/debian buster-updates main
319 # if ! diff -q $t $f; then
325 # newer version needed for false positive in checkrestart.
326 # I did buster at first, but other problem above with having
327 # buster repos. not sure if the false positive exists in etiona.
330 sd
/etc
/apt
/preferences.d
/shellcheck
<<EOF
332 Pin: release a=etiona
336 Pin: release a=etiona-updates
340 Pin: release a=etiona-security
344 sd
/etc
/apt
/preferences.d
/bash
<<EOF
346 Pin: release a=etiona
350 Pin: release a=etiona-updates
354 Pin: release a=etiona-security
362 pi debian-goodies shellcheck
366 ######### end flidas pinned packages ######
368 ##### begin automatic upgrades (after checkrestart has been installed) ####
369 sd
/etc
/apt
/apt.conf.d
/10periodic
<<'EOF'
370 # this file was mostly just comments.
371 APT::Periodic::Update-Package-Lists "1";
372 APT::Periodic::Download-Upgradeable-Packages "1";
373 APT::Periodic::AutocleanInterval "7";
374 APT::Periodic::Unattended-Upgrade "1";
377 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
378 # fyi: default file has comments about available options,
379 # you may want to read that, do pkx unattended-upgrades
380 Unattended-Upgrade::Mail "root";
381 Unattended-Upgrade::MailOnlyOnError "true";
382 Unattended-Upgrade::Remove-Unused-Dependencies "true";
383 Unattended-Upgrade::Origins-Pattern {
384 # default is just security updates. this list found from reading
385 # match_whitelist_string() in `which unattended-upgrades`
386 "o=*,l=*,a=*,c=*,site=*,n=*";
390 # old names, too verbose
391 s
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
393 sd
/etc
/cron.d
/myupgrade
<<'EOF'
394 # Setup reboots when running outdated stuff, unattended upgrades happen
395 # at 6 am + rand(60 min).
396 20 7 * * * root /usr/local/bin/myupgrade | /usr/local/bin/log-once -1 myupgrade
397 0 * * * * root /usr/local/bin/mycheckrestart | /usr/local/bin/log-once -1 mycheckrestart
399 ##### end automatic upgrades ####
403 ###### begin website setup
406 f
=/var
/lib
/bind
/db.b8.nz
407 if [[ ! -e $f ]]; then
410 s
install -m 644 -o bind -g bind /p
/c
/machine_specific
/linode
/bind-initial
/db.b8.nz
$f
420 li
) domain
=iankelling.org
;;
422 m
/a
/h
/setup.sh
$domain
425 # start mumble only when im going to use it, since i dont use it much
426 pi-nostart mumble-server
427 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
429 # do certificate to avoid warning about unsigned cert,
430 # which is overkill for my use, but hey, I'm cool, I know
432 m web-conf apache2 mumble.iankelling.org
433 s
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
435 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
436 /a/bin/distro-setup/certbot-renew-hook
440 # requested from linode via a support ticket.
441 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
442 # ipv6 stuff pieced together
443 # via slightly wrong information from
444 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
445 # https://community.openvpn.net/openvpn/wiki/IPv6
448 m vpn-server-setup
-rd 2600:3c00
:e000
:280::1/64 2600:3c00
::f03c
:91ff
:feb4
:0bf3
449 s
tee /etc
/openvpn
/client-config
/mail <<'EOF'
450 ifconfig-push 10.8.0.4 255.255.255.0
451 ifconfig-ipv6-push 2600:3c00:e000:280::2/64
454 if [[ -e /lib
/systemd
/system
/openvpn-server@.service
]]; then
455 vpn_service
=openvpn-server@server
457 vpn_service
=openvpn@server
460 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
462 Description=Turns on iptables mail nat
467 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
468 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
471 WantedBy=$vpn_service.service
474 m sgo vpnmail.service
475 # needed for li's local mail delivery.
476 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
478 # setup let's encrypt cert
479 m web-conf apache2 mail.iankelling.org
480 s rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
483 domain=cal.iankelling.org
484 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
485 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
486 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
488 Options +FollowSymLinks +Multiviews +Indexes
491 AuthName "Authentication Required"
492 # setup one time, with root:www-data, 640
493 AuthUserFile "/etc/caldav-htpasswd"
497 # nginx version of above would be:
498 # auth_basic "Not currently available";
499 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
503 ###### begin znc setup #####
506 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
507 # to get into the web interface,
508 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
509 # https://iankelling.org:12533/
511 export RENEWED_LINEAGE=/etc/letsencrypt/live/iankelling.org
512 /a/bin/distro-setup/certbot-renew-hook
515 # znc config generated by doing
517 # selected port is also used in erc config
518 # comma separated channel list worked.
519 # while figuring things out, running znc -D for debug in foreground.
520 # to exit and save config:
521 # /msg *status shutdown
522 # configed auth on freenode by following
523 # https://wiki.znc.in/Sasl:
524 # /msg *sasl RequireAuth yes
525 # /msg *sasl Mechanism PLAIN
526 # /msg *sasl Set ident_name password
527 # created the system service after, and had to do
528 # mv /home/iank/.znc/* /var/lib/znc
529 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
530 # and made a copy of the config files into /p/c
531 # /msg *status LoadMod --type=global log -sanitize
532 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
533 # /msg *status LoadMod --type=network perform
534 # /msg *perform add PRIVMSG ChanServ :invite #fsf-office
535 # /msg *perform add JOIN #fsf-office
538 # also ran /znc LoadMod clearbufferonmsg
539 # it would be nice if erc supported erc query buffers by doing
540 # /msg *status clearbuffer <name of the query/receiver
542 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
543 # if that was the case i could remove the module clearbufferonmsg
544 # also would be nice if erc supported
545 # https://wiki.znc.in/self-message
546 # https://wiki.znc.in/Query_buffers \
548 s useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc || [[ $? == 9 ]] # 9 if it exists already
549 s chmod 700 /var/lib/znc
550 s chown -R znc:znc /var/lib/znc
551 sd /etc/systemd/system/znc.service 2>/dev/null <<'EOF'
553 Description=ZNC, an advanced IRC bouncer
554 After=network-online.target
557 ExecStart=/usr/bin/znc -f --datadir=/var/lib/znc
561 WantedBy=multi-user.target
565 ###### stop znc setup #####
570 ###### end website setup
572 ########### end section including li/lj ###############
575 case $codename_compat in
577 # mate-indicator-applet and beyond are msc things I noticed diffing a
578 # standard install with mine.
579 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
585 # mate doesnt have wayland support yet
586 pi task-gnome-desktop
593 # TODO: some of the X programs can be removed from pall when using wayland
595 # depends gcc is a way to install suggests. this is apparently the only
596 # way to install suggests even if the main package is already
597 # installed. reinstall doesn't work, uninstalling can cause removing
598 # dependent packages.
599 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)
602 m sgo fsf-vpn-dns-cleanup
605 # website is dead june 14 2019. back in october, but meh
606 s rm -fv /etc/apt/sources.list.d/iridium-browser.list
611 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
614 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
615 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
617 # f=/etc/apt/sources.list.d/iridium-browser.list
618 # if ! diff -q $t $f; then
628 ### begin home vpn server setup
631 # # this section done initially to make persistent keys.
632 # # Also note, I temporarily set /etc/hosts so my host was
633 # # b8.nz when running this, since the vpn client config
634 # # generator assumes we need to go to that server to get
636 # vpn-server-setup -rds
637 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
638 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
639 # # kw = kgpe work machine.
640 # for host in x2 x3 kw; do
641 # vpn-mk-client-cert -b $host -n home b8.nz 1196
642 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
644 # s bash -c "cp /etc/openvpn/client/home* $dir"
645 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
648 # key already exists, so this won't generate one, just the configs.
649 m vpn-server-setup -rds
650 s tee -a /etc/openvpn/server/server.conf <<'EOF'
651 push "dhcp-option DNS 10.0.0.1"
652 push "route 10.0.0.0 255.255.0.0"
653 client-connect /a/bin/distro-setup/vpn-client-connect
655 s sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
657 if [[ $HOSTNAME == tp ]]; then
658 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
659 vpn_service=openvpn-server@server
661 vpn_service=openvpn@server
665 ### end vpn server setup
669 # note, see bashrc for more documentation.
671 sd /etc/systemd/system/rss2email.service <<'EOF'
673 Description=rss2email
674 After=multi-user.target
679 # about 24 hours of failures
680 # it copies over its files without respecting symlinks, so
681 # we pass options to use different location.
682 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
684 sd /etc/systemd/system/rss2email.timer <<'EOF'
686 Description=rss2email
689 # for initial run. required.
691 # for subsequent runs.
692 OnUnitInactiveSec=300
695 WantedBy=timers.target
697 s systemctl daemon-reload
700 ######### begin pump.io periodic backup #############
701 if [[ $HOSTNAME == frodo ]]; then
702 sd /etc/systemd/system/pumpbackup.service <<'EOF'
704 Description=pump li backup
705 After=multi-user.target
710 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
712 sd /etc/systemd/system/pumpbackup.timer <<'EOF'
714 Description=pump li backup hourly
720 WantedBy=timers.target
723 m sgo pumpbackup.timer
725 ######### end pump.io periodic backup #############
728 ######### begin irc periodic backup #############
729 if [[ $HOSTNAME == frodo ]]; then
730 sd /etc/systemd/system/ircbackup.service <<'EOF'
732 Description=irc li backup
733 After=multi-user.target
738 ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
740 sd /etc/systemd/system/ircbackup.timer <<'EOF'
742 Description=irc li backup hourly
748 WantedBy=timers.target
750 s systemctl daemon-reload
755 ######### end irc periodic backup #############
759 debian|trisquel|ubuntu)
760 # suggests resolvconf package. installing it here is redundant, but make sure anyways.
761 # todo: check other distros to make sure it\'s installed
762 pi-nostart openvpn resolvconf
763 # pi-nostart does not disable
769 m /a/bin/distro-setup/radicale-setup
772 ############# begin syncthing setup ###########
773 if [[ $HOSTNAME == frodo ]]; then
774 # It\'s simpler to just worry about running it in one place for now.
775 # I assume it would work to clone it\'s config to another non-phone
776 # and just run it in one place instead of the normal having a
777 # separate config. I lean toward using the same config, since btrfs
778 # syncs between comps.
779 # testing has relatively up to date packages
780 if ! isdebian-testing; then
781 # based on error when doing apt-get update:
782 # E: The method driver /usr/lib/apt/methods/https could not be found.
783 pi apt-transport-https
784 # google led me here:
785 # https://apt.syncthing.net/
786 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
787 s="deb http://apt.syncthing.net/ syncthing release"
788 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
789 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
794 m lnf -T /w/syncthing /home/iank/.config/syncthing
795 ser daemon-reload # syncthing likely not properly packaged
796 m sgo syncthing@iank # runs as iank
798 # these things persist in ~/.config/syncthing, which I save in
799 # /w/syncthing (not in /p, because syncthing should continue to
800 # run on home server even when using laptop as primary device)
801 # open http://localhost:8384/
802 # change listen address from default to tcp://:22001,
803 # this is because we do port forward so it doesn\'t have to use
804 # some external server, but the syncthing is broken for port forward,
805 # you get a message, something "like connected to myself, this should not happen"
806 # when connecting to other local devices, so I bump the port up by 1,
808 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
809 # Without this, it was being stuck syncing at 0%.
810 # Set gui username and password.
812 # install syncthing via f-droid,
813 # folder setting, turn off send only.
814 # on phone, add device, click bar code icon
815 # on dekstop, top right, actions, device id
816 # after adding, notification will appear on desktop to confirm
818 # syncing folder. from phone to desktop: select desktop in the
819 # folder on phone\'s sync options, notification will appear in
820 # desktop\'s web ui within a minute. For the reverse, the
821 # notification will appear in android\'s notifications, you have to
822 # swipe down and tap it to add the folder. It won\'t appear in the
823 # syncthing ui, which would be intuitive, but don\'t wait for it
824 # there. The notification may not work, instead open the web gui
825 # from in the app, there should be a notification within there.
827 # On phone, set settings to run syncthing all the time, and
828 # show no notification.
830 # Folder versioning would make sense if I didn\'t already use btrfs
831 # for backups. I would choose staggered, or trash can for more space.
833 # if needed to install on a remote comp:
834 # ssh -L 8384:localhost:8384 -N frodo
835 # open http://localhost:8384/
837 # Note, the other thing i did was port forward port 22000,
838 # per https://docs.syncthing.net/users/firewall.html
841 ############# end syncthing setup ###########
845 ####### begin misc packages ###########
854 # sakura config is owned by ian
857 m sudo -u user2 -i reset-konsole
858 # user2 xscreensaver we don't want to reset
862 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
863 # this is also in primary-setup
864 # pi libxss-dev # dependency based on build failure
866 # cabal install --upgrade-dependencies --force-reinstalls arbtt
867 # also, i assume syncing this between machines somehow messed thin
868 #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log
872 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
873 m cp /p/.linphonerc-initial ~/.linphonerc
877 ### begin spd install
878 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
880 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
883 # this guesses at the appropriate directory, adjust if needed
884 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
885 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
886 # newer distro had gpg2 as default, older one, flidas, need to make it that way
887 gpgpath=$(which gpg2)
889 s mkdir -p /usr/local/spdhackfix
890 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
895 # nagstamon setting which were set through the ui
897 # all unknown sources
898 # all warning services
899 # acknowledged hosts & services
900 # hosts & services down for maintenence
901 # services on down hosts
902 # services on hosts in maintenece
903 # services on unreachable osts
904 # hosts in soft state
905 # services in soft state
906 # in display tab: fullscreen
908 # these translate to these settings I think
909 # filter_acknowledged_hosts_services = True
910 # filter_all_unknown_services = True
911 # filter_all_warning_services = True
912 # filter_hosts_in_soft_state = True
913 # filter_hosts_services_maintenance = True
914 # filter_services_in_soft_state = True
915 # filter_services_on_down_hosts = True
916 # filter_services_on_hosts_in_maintenance = True
917 # filter_services_on_unreachable_hosts = True
918 # notify_if_up = False
919 # statusbar_floating = False
921 # but i'm just going to rely on the webpage plus sms for now.
924 # it asks if it should make users in it's group capture packets without root,
925 # which is arguably more secure than running wireshark as root. default is no,
926 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
927 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
929 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
930 # listed in the default config as suggested.
931 # /run/usr/1000 i noticed was missing for pulseaudio
932 # /run/user/0 just seemed like a not bad idea, given the above
933 tu /etc/schroot/desktop/fstab <<'EOF'
934 /run /run none rw,bind 0 0
935 /run/lock /run/lock none rw,bind 0 0
936 /dev/shm /dev/shm none rw,bind 0 0
937 /run/shm /run/shm none rw,bind 0 0
938 /run/user/1000 /run/user/1000 none rw,bind 0 0
939 /run/user/1001 /run/user/1001 none rw,bind 0 0
940 /run/user/0 /run/user/0 none rw,bind 0 0
948 repo=http://archive.ubuntu.com/ubuntu/
951 repo=http://deb.debian.org/debian/
956 if schroot -l | grep -xFq chroot:$n; then
957 echo "$0: $n schroot already installed, skipping"
962 sd /etc/schroot/chroot.d/$n.conf <<EOF
968 preserve-environment=true
971 if [[ -e $d/bin ]]; then
972 s chroot $d apt-get update
973 s chroot $d apt-get -y dist-upgrade --purge --auto-remove
974 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
978 s debootstrap $n $d $repo
979 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
981 s cp -P {,$d}/etc/localtime
983 sd /etc/systemd/system/schrootupdate.service <<'EOF'
985 Description=schrootupdate
986 After=multi-user.target
990 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
992 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
994 Description=schrootupdate
997 OnCalendar=*-*-* 04:20:00
1000 WantedBy=timers.target
1003 m sgo schrootupdate.timer
1010 m mkschroot debian stretch firefox-esr pulseaudio chromium
1017 s mkdir -p /nocow/user
1018 s chown $USER:$USER /nocow/user
1022 ####### begin transmission
1024 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1025 # 450 seems likely to be unused. we need to specify one or else
1026 # it won't be stable across installs.
1027 if ! getent passwd debian-transmission > /dev/null; then
1028 s groupadd -g 450 debian-transmission
1034 --disabled-password \
1035 --home /var/lib/transmission-daemon \
1038 # We want group writable stuff from transmission.
1039 # However, after setting this, I learn that transmission sets it's
1040 # own umask based on it's settings file. Well, no harm leaving this
1041 # so it's set right from the beginning.
1042 s chfn debian-transmission -o umask=0002
1044 # note i had to do this, which is persistent:
1046 # s chgrp debian-transmission torrents partial-torrents
1048 # syslog says things like
1049 # 'Failed to set receive buffer: requested 4194304, got 425984'
1050 # google suggets giving it even more than that
1051 tu /etc/sysctl.conf<<'EOF'
1052 net.core.rmem_max = 67108864
1053 net.core.wmem_max = 16777216
1057 # some reason it doesn\'t seem to start automatically anyways
1058 pi-nostart transmission-daemon
1059 # be extra sure its not started
1060 ser disable transmission-daemon
1061 ser stop transmission-daemon
1063 # the folder was moved here after an install around 02/2017.
1064 # it contains runtime data,
1065 # plus a simple symlink to the config file which it\'s
1066 # not worth separating out.
1067 # between comps, the uid can change
1068 f=/i/transmission-daemon
1069 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1070 if [[ -e $f ]]; then
1071 s chown -R debian-transmission:debian-transmission $f
1073 for f in /i/k/partial-torrents /i/k/torrents; do
1074 if [[ -e $f ]]; then
1075 s chown -R debian-transmission:user2 $f
1078 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1080 # config file documented here, and it\'s the same config
1081 # for daemon vs client, so it\'s documented in the gui.
1082 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1084 # I originaly setup rpc-whitelist, but after using
1085 # routing to a network namespace, it doesn\'t see the
1086 # real source address, so it\'s disabled.
1088 # Changed the cache-size to 256 mb, reduces disk use.
1089 # It is a read & write cache.
1093 p = '/etc/transmission-daemon/settings.json'
1094 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1095 'rpc-whitelist-enabled' => false,
1096 'rpc-authentication-required' => false,
1097 'incomplete-dir' => '/i/k/partial-torrents',
1098 'incomplete-dir-enabled' => true,
1099 'download-dir' => '/i/k/torrents',
1100 "speed-limit-up" => 800,
1101 "speed-limit-up-enabled" => true,
1102 "peer-port" => 61486,
1103 "cache-size-mb" => 256,
1104 "ratio-limit" => 5.0,
1105 "ratio-limit-enabled" => true,
1108 ####### end transmission
1112 # trisquel 8 = openvpn, debian stretch = openvpn-client
1113 vpn_ser=openvpn-client
1114 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1118 sd /etc/systemd/system/transmission-daemon-nn.service <<EOF
1120 Description=Transmission BitTorrent Daemon netns
1121 After=network.target
1122 Requires=${vpn_ser}-nn@client.service
1123 After=${vpn_ser}-nn@client.service
1124 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1127 #User=debian-transmission
1128 # notify type doesn't work with sudo
1130 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1131 ExecReload=/bin/kill -s HUP \$MAINPID
1136 WantedBy=multi-user.target
1140 if [[ $HOSTNAME == frodo ]]; then
1141 m sgo transmission-daemon-nn
1145 ######### begin transmission client setup ######
1147 if [[ -e /p/transmission-rpc-pass ]]; then
1148 # arch had a default config,
1149 # debian had nothing until you start it.
1150 # With a little trial an error, here is a minimal config
1151 # taken from the generated one, plus changes that the
1152 # settings ui does, without a bunch of ui crap settings.
1154 # only settings I set were
1159 # the password is randomly generated on first run, i copied it out
1160 # so it could be used by other hosts.
1163 p = '/etc/transmission-daemon/settings.json'
1164 s = JSON.parse(File.read(p))
1165 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1166 # default is 0022 (18 in decimal)
1168 File.write p, JSON.pretty_generate(s)
1171 rpc_pass=$(</p/transmission-rpc-pass)
1172 for f in /home/*; do
1174 uid=$(id -u $u 2>/dev/null) || continue
1175 if [[ ! $uid -ge 1000 ]]; then
1178 d=$f/.config/transmission-remote-gtk
1180 s -u $u dd of=$d/config.json <<EOF
1184 "profile-name" : "Default",
1185 "hostname" : "transmission.b8.nz",
1186 "rpc-url-path" : "/transmission/rpc",
1188 "password" : "$rpc_pass",
1189 "auto-connect" : true,
1193 "update-active-only" : false,
1194 "activeonly-fullsync-enabled" : false,
1195 "activeonly-fullsync-every" : 2,
1196 "update-interval" : 3,
1197 "min-update-interval" : 3,
1198 "session-update-interval" : 60,
1206 "add-options-dialog" : false
1211 ######### end transmission client setup ######
1216 s gpasswd -a $USER lpadmin # based on ubuntu wiki
1217 # goto http://127.0.0.1:631
1218 # administration tab, add new printer button.
1219 # In debian, I could use hte recommended driver,
1220 # in arch, I had to pick out the 6L driver.
1223 # allow user to run vms, from debian handbook
1224 for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
1225 # bridge networking as user fails. google lead here, but it doesn\'t work:
1226 # oh well, I give up.
1227 # http://wiki.qemu.org/Features-Done/HelperNetworking
1229 # f=/etc/qemu/bridge.conf
1233 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1236 # general known for debian/ubuntu, not for fedora
1238 m /a/bin/buildscripts/go
1239 m /a/bin/buildscripts/rust
1240 m /a/bin/buildscripts/misc
1242 pi-nostart virtinst virt-manager
1246 pi --no-install-recommends kdeconnect
1247 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1248 ### but gnome + xmonad not working in flidas, so i disabled it
1249 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1250 # cd /a/opt/indicator-kdeconnect
1253 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1256 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1257 # # it seems, according to
1258 # # /etc/xdg/autostart/kdeconnectd.desktop
1259 # # I'm not seeing the icon, but the clipboard replication is working
1262 ### model 01 arduino support ###
1263 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1264 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1265 # set arduino var in bashrc,
1266 # have system config file setup too.
1267 s adduser $USER dialout
1269 # this is for the mail command too. update-alternatives is kind of misleading
1270 # since at least it's main commands pretend mail does not exist.
1271 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1272 s update-alternatives --set mailx /usr/bin/mail.mailutils
1274 ######### end misc packages #########
1277 # packages I once used before and liked, but don\'t want installed now for
1279 # python-sqlite is used for offlineimap
1280 # lxappearance python-sqlite dolphin paman dconf-editor
1286 # todo, finish configuring smart.
1289 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1290 # turn on smart. background on options:
1291 # first line, -a = test everyting on all devices.
1292 # -S on, turn on disk internal saving of vendor specific info,
1293 # from google, seems like this is usually already on and fairly standard.
1294 # -o on, turn on 4 hour period non-performance degrading testing.
1295 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1296 sched="-s (S/../.././02|L/../../6/03)"
1297 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1298 DEVICESCAN -a -o on -S on -n standby,q $sched \
1299 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1301 # in the default configuration of at least ubuntu 14.04, resolvconf is
1302 # configured to order any nameservers associated with tun* or tap*
1303 # before the normal internet interfaces, which means they are always
1304 # consulted first. This is often slower and undesirable, ie. local dns
1305 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1307 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1308 # however, this breaks dns lookup for hosts on the openvpn lan.
1309 # I can\'t figure out why hosts on the normal lan would not be
1310 # broken under the default ordering, except the host I was
1311 # testing with previously had an entry in /etc/hosts.
1313 ############# end unfinished
1315 ########### misc stuff
1317 # make networkmanager use resolvconf instead of its own dnsmasq which
1318 # conflicts with the normal dnsmasq package.
1319 f=/etc/NetworkManager/NetworkManager.conf
1321 s sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1322 if [[ $m != $(md5sum $f) ]]; then
1323 srestart NetworkManager
1326 # make my /etc/fonts/conf.d/ get used.
1327 # I have a new sans-serif font there because the default one
1328 # displays l and I as the same char, grrrrr.
1331 m /a/bin/distro-setup/mymimes
1334 m sgo dynamicipupdate
1337 # stop autopoping windows when i plug in an android phone.
1338 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1339 # with still 0 exit code.
1340 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1341 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1344 # on grub upgrade, we get prompts unless we do this
1346 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1347 devs+=("$(devbyid $dev),")
1349 devs[-1]=${devs[-1]%,} # jonied by commas
1350 s debconf-set-selections <<EOF
1351 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1355 sgo btrfsmaint.timer
1356 sgo btrfsmaintstop.timer
1358 # aren't autoupdating this, but I do check on it somewhat regularly.
1363 # note: to see when it was last run,
1368 In mate settings settings, change scrolling to two-finger,
1369 because the default edge scroll doesn\'t work. Originally found this in debian.
1372 # Remove dep that came in with desktop to fix associations.
1373 m pu transmission-gtk
1375 s gpasswd -a iank adm #needed for reading logs
1377 m /a/bin/buildscripts/pithosfly
1380 # # Based on guix manual instructions, also added code to profile.
1381 # # disabled since i'm not using it now.
1383 # if ! type -p guix >/dev/null; then
1385 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1386 # # added some stuff to envonment.sh for profile based on
1387 # # manual instructions
1388 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1389 # # echo is to get past prompt
1390 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1391 # guix install glibc-utf8-locales
1392 # guix package --install guile
1398 m /a/bin/buildscripts/tor-browser
1401 pi-nostart nfs-kernel-server
1403 # networkmanager has this nasty behavior on flidas: if the machine
1404 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1405 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1407 # This can be manually fixed by stoping dnsmasq,
1408 # then based on whats in /run/dnsmasq/, i see we can run
1409 # s resolvconf -d NetworkManager
1410 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1411 ser stop NetworkManager
1412 ser disable NetworkManager
1415 if [[ $HOSTNAME == frodo ]]; then
1416 # nohide = export filesystems mounted deeper than the export point
1417 # fsid=0 makes this export the "root" export
1418 # not documented in the man page, but this means
1419 # 1. it can be mounted with a shorthand of server:/
1420 # 2. exports that are subdirectories of this one will automatically be mounted
1421 tu /etc/exports <<'EOF'
1422 /k 10.0.0.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1431 # if I was going to create a persistent vm, i might do it like this:
1432 # variant=something # from: virt-install --os-variant list
1433 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1434 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1435 # -n some_name --import --os-variant $variant --cpu host-model-only
1439 ######### begin stuff belonging at the end ##########