various updates
[distro-setup] / distro-end
1 #!/bin/bash -l
2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4
5 ### setup
6 source /a/bin/errhandle/err
7 src="$(readlink -f -- "${BASH_SOURCE[0]}")"; src=${src%/*} # directory of this file
8
9 if [[ $EUID == 0 ]]; then
10 echo "$0: error: run as regular user" >&2
11 exit 1
12 fi
13
14 _errcatch_cleanup() {
15 echo 1 >~/.local/distro-end
16 }
17
18 # shellcheck source=./pkgs
19 source $src/pkgs
20
21 set -x
22 exec &> >(sudo tee -a /var/log/distro-end)
23 echo "$0: $(date): starting now)"
24 # see example of usage to understand.
25 end_msg() {
26 local y
27 IFS= read -r -d '' y ||:
28 end_msg_var+="$y"
29 }
30 end() {
31 e "$end_msg_var"
32 echo 0 >~/.local/distro-end
33 if $pending_reboot; then
34 echo "$0: pending reboot and then finished. doing it now."
35 s reboot now
36 else
37 echo "$0: $(date): ending now)"
38 fi
39 exit 0
40 }
41 die() {
42 printf "$0: %s\n" "$*" >&2; exit 1
43 }
44 spa() { # simple package add
45 simple_packages+=($@)
46 }
47 distro=$(distro-name)
48 codename=$(debian-codename)
49 codename_compat=$(debian-codename-compat)
50 pending_reboot=false
51 sed="sed --follow-symlinks"
52 # template
53 case $distro in
54 esac
55
56 #### initial packages
57 pup
58 if isdeb; then
59 pi aptitude
60 fi
61
62 # avoid prompts
63 s debconf-set-selections <<EOF
64 popularity-contest popularity-contest/participate boolean true
65 EOF
66
67 ########### begin section including linode ################
68 pi ${p2[@]}
69
70
71 conflink
72
73
74 # no equivalent in other distros:
75 if isdeb && pcheck apt-file; then
76 # this condition is just a speed optimization
77 pi apt-file
78 s apt-file update
79 fi
80
81
82 # disable motd junk.
83 case $distro in
84 debian)
85 # allows me to pipe with ssh -t, and gets rid of spam
86 # http://forums.debian.net/viewtopic.php?f=5&t=85822
87 # i'd rather disable the service than comment the init file
88 # this says disabling the service, it will still get restarted
89 # but this script doesn't do anything on restart, so it should be fine
90 s dd of=/var/run/motd.dynamic if=/dev/null
91 ;;
92 trisquel|ubuntu)
93 # this isn't a complete solution. It still shows me when updates are available,
94 # but it's no big deal.
95 s rm -f /etc/update-motd.d/10-help-text /etc/update-motd.d/00-header
96 ;;
97 esac
98
99
100
101
102 ### begin certbot install ###
103 if [[ $distro == debian ]]; then
104 # note, need python-certbot-nginx for nginx, but it depends on nginx,
105 # and I'm not installing nginx by default right now.
106 pi certbot python-certbot-apache
107 elif [[ $codename_compat == xenial ]]; then
108 # not packaged in xenial or flidas
109 pi software-properties-common
110 l="deb http://ppa.launchpad.net/certbot/certbot/ubuntu xenial main"
111 if ! grep -xFq "$l" /etc/apt/sources.list{,.d/*.list}; then
112 s add-apt-repository -y ppa:certbot/certbot ||:
113 p update
114 fi
115 pi python-certbot-apache
116 else
117 die "distro unknown for certbot"
118 fi
119 # make a version of the certbot timer that emails me.
120 x=/systemd/system/certbot
121 $sed -r -f - /lib$x.timer <<'EOF' |s dd of=/etc${x}mail.timer
122 s,^Description.*,\0 mail version,
123 EOF
124 $sed -r -f - /lib$x.service <<'EOF' |s dd of=/etc${x}mail.service
125 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
126 EOF
127 ser daemon-reload
128 sgo certbotmail.timer
129 ### end certbot install ###
130
131
132 # dogcam setup. not using atm
133 # case $HOSTNAME in
134 # lj|li)
135 # /a/bin/webcam/install-server
136 # ;;
137 # kw)
138 # /a/bin/webcam/install-client
139 # ;;
140 # esac
141
142
143 ## not actually using prometheus just yet
144 # # office is not exposed to internet yet
145 # if [[ $HOSTNAME != kw ]]; then
146 # ## prometheus node exporter setup
147 # web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF'
148 # #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
149 # # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
150 # <Location />
151 # AllowOverride None
152 # AuthType basic
153 # AuthName "Authentication Required"
154 # # setup one time, with root:www-data, 640
155 # AuthUserFile "/etc/prometheus-htpasswd"
156 # Require valid-user
157 # </Location>
158 # EOF
159 # fi
160
161
162 ######### begin flidas pinned packages ######
163 case $(debian-codename) in
164 # needed for debootstrap scripts for fai since fai requires debian
165 flidas)
166 curl http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg | s apt-key add -
167 s dd of=/etc/apt/preferences.d/flidas-xenial <<EOF
168 Package: *
169 Pin: release a=xenial
170 Pin-Priority: -100
171
172 Package: *
173 Pin: release a=xenial-updates
174 Pin-Priority: -100
175
176 Package: *
177 Pin: release a=xenial-security
178 Pin-Priority: -100
179 EOF
180 s dd of=/etc/apt/sources.list.d/xenial.list 2>/dev/null <<EOF
181 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
182 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
183 deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
184 EOF
185
186 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
187 s dd of=/etc/apt/preferences.d/flidas-bionic <<EOF
188 Package: *
189 Pin: release a=bionic
190 Pin-Priority: -100
191
192 Package: *
193 Pin: release a=bionic-updates
194 Pin-Priority: -100
195
196 Package: *
197 Pin: release a=bionic-security
198 Pin-Priority: -100
199 EOF
200
201 # better to run btrfs-progs which matches our kernel version
202 # (note, renamed from btrfs-tools)
203 s dd of=/etc/apt/preferences.d/btrfs-progs <<EOF
204 Package: btrfs-progs libzstd1
205 Pin: release a=bionic
206 Pin-Priority: 1005
207
208 Package: btrfs-progs libzstd1
209 Pin: release a=bionic-updates
210 Pin-Priority: 1005
211
212 Package: btrfs-progs libzstd1
213 Pin: release a=bionic-security
214 Pin-Priority: 1005
215 EOF
216
217
218 t=$(mktemp)
219 cat >$t <<EOF
220 deb http://us.archive.ubuntu.com/ubuntu/ bionic main
221 deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main
222 deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main
223 EOF
224 f=/etc/apt/sources.list.d/bionic.list
225 if ! diff -q $t $f; then
226 s cp $t $f
227 s chmod 644 $f
228 p update
229 fi
230
231 # no special reason, but its better for btrfs-progs to
232 # be closer to our kernel version
233 pi btrfs-progs
234
235 t=$(mktemp -d)
236 cd $t
237 aptitude download debootstrap/xenial
238 ex ./*
239 s cp ./usr/share/debootstrap/scripts/* /usr/share/debootstrap/scripts
240
241 s dd of=/etc/apt/preferences.d/flidas-etiona <<EOF
242 Package: *
243 Pin: release a=etiona
244 Pin-Priority: -100
245
246 Package: *
247 Pin: release a=etiona-updates
248 Pin-Priority: -100
249
250 Package: *
251 Pin: release a=etiona-security
252 Pin-Priority: -100
253
254 Package: *
255 Pin: release a=etiona-backports
256 Pin-Priority: -100
257 EOF
258
259 t=$(mktemp)
260 cat >$t <<EOF
261 deb http://mirror.fsf.org/trisquel/ etiona main
262 deb http://mirror.fsf.org/trisquel/ etiona-updates main
263 deb http://archive.trisquel.info/trisquel/ etiona-security main
264 deb http://mirror.fsf.org/trisquel/ etiona-backports main
265 EOF
266 f=/etc/apt/sources.list.d/etiona.list
267 if ! diff -q $t $f; then
268 s cp $t $f
269 s chmod 644 $f
270 p update
271 fi
272
273 s dd of=/etc/apt/preferences.d/debian-goodies <<EOF
274 Package: debian-goodies
275 Pin: release n=etiona
276 Pin-Priority: 1005
277 EOF
278
279
280 s dd of=/etc/apt/preferences.d/flidas-buster <<EOF
281 Package: *
282 Pin: release n=buster
283 Pin-Priority: -100
284
285 Package: *
286 Pin: release n=buster-updates
287 Pin-Priority: -100
288 EOF
289
290 # dont use buster because it causes dist-upgrade to think its downgrading
291 # packages while really just reinstalling the same version.
292 f=/etc/apt/apt.conf.d/01iank
293 s rm -f $f
294 # # stupid buster uses some key algorithm not supported by flidas gpg that apt uses.
295 # s dd of=/etc/apt/apt.conf.d/01iank <<'EOF'
296 # Acquire::AllowInsecureRepositories "true";
297 # EOF
298
299 f=/etc/apt/sources.list.d/buster.list
300 s rm -f $f
301 # t=$(mktemp)
302 # cat >$t <<EOF
303 # deb http://http.us.debian.org/debian buster main
304 # deb-src http://http.us.debian.org/debian buster main
305
306 # deb http://security.debian.org/ buster/updates main
307 # deb-src http://security.debian.org/ buster/updates main
308
309 # deb http://http.us.debian.org/debian buster-updates main
310 # deb-src http://http.us.debian.org/debian buster-updates main
311 # EOF
312 # if ! diff -q $t $f; then
313 # s cp $t $f
314 # s chmod 644 $f
315 # p update
316 # fi
317
318 # newer version needed for false positive in checkrestart.
319 # I did buster at first, but other problem above with having
320 # buster repos. not sure if the false positive exists in etiona.
321 p install -y --allow-unauthenticated debian-goodies
322
323 s dd of=/etc/apt/preferences.d/shellcheck <<EOF
324 Package: shellcheck
325 Pin: release a=etiona
326 Pin-Priority: 1005
327
328 Package: shellcheck
329 Pin: release a=etiona-updates
330 Pin-Priority: 1005
331
332 Package: shellcheck
333 Pin: release a=etiona-security
334 Pin-Priority: 1005
335 EOF
336
337 s dd of=/etc/apt/preferences.d/bash <<EOF
338 Package: bash
339 Pin: release a=etiona
340 Pin-Priority: 1005
341
342 Package: bash
343 Pin: release a=etiona-updates
344 Pin-Priority: 1005
345
346 Package: bash
347 Pin: release a=etiona-security
348 Pin-Priority: 1005
349 EOF
350
351
352 ;;
353 *)
354 if isdeb; then
355 pi debian-goodies shellcheck
356 fi
357 ;;
358 esac
359 ######### end flidas pinned packages ######
360
361 ##### begin automatic upgrades (after checkrestart has been installed) ####
362 s dd of=/etc/apt/apt.conf.d/10periodic <<'EOF'
363 # this file was mostly just comments.
364 APT::Periodic::Update-Package-Lists "1";
365 APT::Periodic::Download-Upgradeable-Packages "1";
366 APT::Periodic::AutocleanInterval "7";
367 APT::Periodic::Unattended-Upgrade "1";
368 EOF
369
370 s dd of=/etc/apt/apt.conf.d/50unattended-upgrades <<EOF
371 # fyi: default file has comments about available options,
372 # you may want to read that, do pkx unattended-upgrades
373 Unattended-Upgrade::Mail "root";
374 Unattended-Upgrade::MailOnlyOnError "true";
375 Unattended-Upgrade::Remove-Unused-Dependencies "true";
376 Unattended-Upgrade::Origins-Pattern {
377 # default is just security updates. this list found from reading
378 # match_whitelist_string() in `which unattended-upgrades`
379 "o=*,l=*,a=*,c=*,site=*,n=*";
380 };
381 EOF
382
383 # old names, too verbose
384 s rm -f /etc/cron.d/unattended-upgrade-reboot /usr/local/bin/zelous-unattended-reboot
385
386 s dd of=/etc/cron.d/myupgrade <<'EOF'
387 # Setup reboots when running outdated stuff, unattended upgrades happen
388 # at 6 am + rand(60 min).
389 20 7 * * * root /usr/local/bin/myupgrade | /usr/local/bin/log-once -1 myupgrade
390 0 * * * * root /usr/local/bin/mycheckrestart | /usr/local/bin/log-once -1 mycheckrestart
391 EOF
392 ##### end automatic upgrades ####
393
394
395
396 ###### begin website setup
397 case $HOSTNAME in
398 li|l2)
399 f=/var/lib/bind/db.b8.nz
400 if [[ ! -e $f ]]; then
401 ser stop bind9
402 s rm -f $f.jnl
403 s install -m 644 -o bind -g bind /p/c/machine_specific/linode/bind-initial/db.b8.nz $f
404 ser restart bind9
405 fi
406 ;;&
407 l2)
408 end
409 ;;
410 li)
411
412 case $HOSTNAME in
413 li) domain=iankelling.org ;;
414 esac
415 /a/h/setup.sh $domain
416 /a/h/build.rb
417
418 # start mumble only when im going to use it, since i dont use it much
419 pi-nostart mumble-server
420 s $sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc/mumble-server.ini
421
422 # do certificate to avoid warning about unsigned cert,
423 # which is overkill for my use, but hey, I'm cool, I know
424 # how to do this.
425 web-conf apache2 mumble.iankelling.org
426 s rm -f /etc/apache2/sites-enabled/mumble.iankelling.org
427 sudo -i <<'EOF'
428 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
429 /a/bin/distro-setup/certbot-renew-hook
430 EOF
431
432
433 # requested from linode via a support ticket.
434 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
435 # ipv6 stuff pieced together
436 # via slightly wrong information from
437 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
438 # https://community.openvpn.net/openvpn/wiki/IPv6
439 # and man openvpn
440
441 vpn-server-setup -rd 2600:3c00:e000:280::1/64 2600:3c00::f03c:91ff:feb4:0bf3
442 s tee /etc/openvpn/client-config/mail <<'EOF'
443 ifconfig-push 10.8.0.4 255.255.255.0
444 ifconfig-ipv6-push 2600:3c00:e000:280::2/64
445 EOF
446
447 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
448 vpn_service=openvpn-server@server
449 else
450 vpn_service=openvpn@server
451 fi
452
453 sudo dd of=/etc/systemd/system/vpnmail.service <<EOF
454 [Unit]
455 Description=Turns on iptables mail nat
456
457 [Service]
458 Type=oneshot
459 RemainAfterExit=yes
460 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
461 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
462
463 [Install]
464 WantedBy=$vpn_service.service
465 EOF
466 ser daemon-reload
467 sgo vpnmail.service
468 # needed for li's local mail delivery.
469 tu /etc/hosts <<<"10.8.0.4 mail.iankelling.org"
470 sgo $vpn_service
471 # setup let's encrypt cert
472 web-conf apache2 mail.iankelling.org
473 s rm /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
474 ser reload apache2
475
476 domain=cal.iankelling.org
477 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
478 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
479 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
480 <Location />
481 Options +FollowSymLinks +Multiviews +Indexes
482 AllowOverride None
483 AuthType basic
484 AuthName "Authentication Required"
485 # setup one time, with root:www-data, 640
486 AuthUserFile "/etc/caldav-htpasswd"
487 Require valid-user
488 </Location>
489 EOF
490 # nginx version of above would be:
491 # auth_basic "Not currently available";
492 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
493
494
495
496 ###### begin znc setup #####
497 pi znc
498
499 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
500 # to get into the web interface,
501 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
502 # https://iankelling.org:12533/
503 sudo -i <<'EOF'
504 export RENEWED_LINEAGE=/etc/letsencrypt/live/iankelling.org
505 /a/bin/distro-setup/certbot-renew-hook
506 EOF
507
508 # znc config generated by doing
509 # znc --makeconf
510 # selected port is also used in erc config
511 # comma separated channel list worked.
512 # while figuring things out, running znc -D for debug in foreground.
513 # to exit and save config:
514 # /msg *status shutdown
515 # configed auth on freenode by following
516 # https://wiki.znc.in/Sasl:
517 # /msg *sasl RequireAuth yes
518 # /msg *sasl Mechanism PLAIN
519 # /msg *sasl Set ident_name password
520 # created the system service after, and had to do
521 # mv /home/iank/.znc/* /var/lib/znc
522 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
523 # and made a copy of the config files into /p/c
524 # /msg *status LoadMod --type=global log -sanitize
525 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
526 # /msg *status LoadMod --type=network perform
527 # /msg *perform add PRIVMSG ChanServ :invite #fsf-office
528 # /msg *perform add JOIN #fsf-office
529 #
530 # i set Buffer = 500
531 # also ran /znc LoadMod clearbufferonmsg
532 # it would be nice if erc supported erc query buffers by doing
533 # /msg *status clearbuffer <name of the query/receiver
534 # on killing the,
535 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
536 # if that was the case i could remove the module clearbufferonmsg
537 # also would be nice if erc supported
538 # https://wiki.znc.in/self-message
539 # https://wiki.znc.in/Query_buffers \
540 #
541 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
542 s chmod 700 /var/lib/znc
543 s chown -R znc:znc /var/lib/znc
544 s dd of=/etc/systemd/system/znc.service 2>/dev/null <<'EOF'
545 [Unit]
546 Description=ZNC, an advanced IRC bouncer
547 After=network-online.target
548
549 [Service]
550 ExecStart=/usr/bin/znc -f --datadir=/var/lib/znc
551 User=znc
552
553 [Install]
554 WantedBy=multi-user.target
555 EOF
556 ser daemon-reload
557 sgo znc
558 ###### stop znc setup #####
559
560 end
561 ;;
562 esac
563 ###### end website setup
564
565 ########### end section including li/lj ###############
566
567 #### desktop stuff
568 case $codename_compat in
569 xenial)
570 # mate-indicator-applet and beyond are msc things I noticed diffing a
571 # standard install with mine.
572 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
573 ;;
574 stretch)
575 pi task-mate-desktop
576 ;;
577 buster)
578 # mate doesnt have wayland support yet
579 pi task-gnome-desktop
580 ;;
581 esac
582
583
584
585
586 # TODO: some of the X programs can be removed from pall when using wayland
587
588 # depends gcc is a way to install suggests. this is apparently the only
589 # way to install suggests even if the main package is already
590 # installed. reinstall doesn't work, uninstalling can cause removing
591 # dependent packages.
592 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)
593
594
595 sgo fsf-vpn-dns-cleanup
596
597
598 # website is dead june 14 2019. back in october, but meh
599 s rm -f /etc/apt/sources.list.d/iridium-browser.list
600 # case $distro in
601 # debian)
602 # pi chromium ;;
603 # trisquel|ubuntu)
604 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
605 # t=$(mktemp)
606 # cat >$t <<EOF
607 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
608 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
609 # EOF
610 # f=/etc/apt/sources.list.d/iridium-browser.list
611 # if ! diff -q $t $f; then
612 # s cp $t $f
613 # s chmod 644 $f
614 # p update
615 # fi
616 # pi iridium-browser
617 # ;;
618 # esac
619
620
621 ### begin home vpn server setup
622
623
624 # # this section done initially to make persistent keys.
625 # # Also note, I temporarily set /etc/hosts so my host was
626 # # b8.nz when running this, since the vpn client config
627 # # generator assumes we need to go to that server to get
628 # # server keys.
629 # vpn-server-setup -rds
630 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
631 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
632 # # kw = kgpe work machine.
633 # for host in x2 x3 kw; do
634 # vpn-mk-client-cert -b $host -n home b8.nz 1196
635 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
636 # mkdir -p $dir
637 # s bash -c "cp /etc/openvpn/client/home* $dir"
638 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
639 # done
640
641 # key already exists, so this won't generate one, just the configs.
642 vpn-server-setup -rds
643 s tee -a /etc/openvpn/server/server.conf <<'EOF'
644 push "dhcp-option DNS 10.0.0.1"
645 push "route 10.0.0.0 255.255.0.0"
646 client-connect /a/bin/distro-setup/vpn-client-connect
647 EOF
648 s sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
649
650 if [[ $HOSTNAME == tp ]]; then
651 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
652 vpn_service=openvpn-server@server
653 else
654 vpn_service=openvpn@server
655 fi
656 sgo $vpn_service
657 fi
658 ### end vpn server setup
659
660
661 ##### rss2email
662 # note, see bashrc for more documentation.
663 pi rss2email
664 s dd of=/etc/systemd/system/rss2email.service <<'EOF'
665 [Unit]
666 Description=rss2email
667 After=multi-user.target
668
669 [Service]
670 User=iank
671 Type=oneshot
672 # about 24 hours of failures
673 # it copies over its files without respecting symlinks, so
674 # we pass options to use different location.
675 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
676 EOF
677 s dd of=/etc/systemd/system/rss2email.timer <<'EOF'
678 [Unit]
679 Description=rss2email
680
681 [Timer]
682 # for initial run. required.
683 OnActiveSec=30
684 # for subsequent runs.
685 OnUnitInactiveSec=300
686
687 [Install]
688 WantedBy=timers.target
689 EOF
690 s systemctl daemon-reload
691
692
693 ######### begin pump.io periodic backup #############
694 if [[ $HOSTNAME == frodo ]]; then
695 s dd of=/etc/systemd/system/pumpbackup.service <<'EOF'
696 [Unit]
697 Description=pump li backup
698 After=multi-user.target
699
700 [Service]
701 User=iank
702 Type=oneshot
703 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
704 EOF
705 s dd of=/etc/systemd/system/pumpbackup.timer <<'EOF'
706 [Unit]
707 Description=pump li backup hourly
708
709 [Timer]
710 OnCalendar=hourly
711
712 [Install]
713 WantedBy=timers.target
714 EOF
715 s systemctl daemon-reload
716 sgo pumpbackup.timer
717 fi
718 ######### end pump.io periodic backup #############
719
720
721 ######### begin irc periodic backup #############
722 if [[ $HOSTNAME == frodo ]]; then
723 s dd of=/etc/systemd/system/ircbackup.service <<'EOF'
724 [Unit]
725 Description=irc li backup
726 After=multi-user.target
727
728 [Service]
729 User=iank
730 Type=oneshot
731 ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
732 EOF
733 s dd of=/etc/systemd/system/ircbackup.timer <<'EOF'
734 [Unit]
735 Description=irc li backup hourly
736
737 [Timer]
738 OnCalendar=hourly
739
740 [Install]
741 WantedBy=timers.target
742 EOF
743 s systemctl daemon-reload
744 sgo ircbackup.timer
745 fi
746
747
748 ######### end irc periodic backup #############
749
750
751 # https://github.com/jlebon/textern
752 cd /a/opt/textern
753 make native-install USER=1
754
755 case $distro in
756 debian|trisquel|ubuntu)
757 # suggests resolvconf package. installing it here is redundant, but make sure anyways.
758 # todo: check other distros to make sure it\'s installed
759 pi-nostart openvpn resolvconf
760 # pi-nostart does not disable
761 ser disable openvpn
762 ;;
763 *) pi openvpn;;
764 esac
765
766 /a/bin/distro-setup/radicale-setup
767
768
769 ############# begin syncthing setup ###########
770 if [[ $HOSTNAME == frodo ]]; then
771 # It\'s simpler to just worry about running it in one place for now.
772 # I assume it would work to clone it\'s config to another non-phone
773 # and just run it in one place instead of the normal having a
774 # separate config. I lean toward using the same config, since btrfs
775 # syncs between comps.
776 # testing has relatively up to date packages
777 if ! isdebian-testing; then
778 # based on error when doing apt-get update:
779 # E: The method driver /usr/lib/apt/methods/https could not be found.
780 pi apt-transport-https
781 # google led me here:
782 # https://apt.syncthing.net/
783 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
784 s="deb http://apt.syncthing.net/ syncthing release"
785 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
786 echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
787 p update
788 fi
789 fi
790 pi syncthing
791 lnf -T /w/syncthing /home/iank/.config/syncthing
792 ser daemon-reload # syncthing likely not properly packaged
793 sgo syncthing@iank # runs as iank
794
795 # these things persist in ~/.config/syncthing, which I save in
796 # /w/syncthing (not in /p, because syncthing should continue to
797 # run on home server even when using laptop as primary device)
798 # open http://localhost:8384/
799 # change listen address from default to tcp://:22001,
800 # this is because we do port forward so it doesn\'t have to use
801 # some external server, but the syncthing is broken for port forward,
802 # you get a message, something "like connected to myself, this should not happen"
803 # when connecting to other local devices, so I bump the port up by 1,
804 # based on
805 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
806 # Without this, it was being stuck syncing at 0%.
807 # Set gui username and password.
808 #
809 # install syncthing via f-droid,
810 # folder setting, turn off send only.
811 # on phone, add device, click bar code icon
812 # on dekstop, top right, actions, device id
813 # after adding, notification will appear on desktop to confirm
814 #
815 # syncing folder. from phone to desktop: select desktop in the
816 # folder on phone\'s sync options, notification will appear in
817 # desktop\'s web ui within a minute. For the reverse, the
818 # notification will appear in android\'s notifications, you have to
819 # swipe down and tap it to add the folder. It won\'t appear in the
820 # syncthing ui, which would be intuitive, but don\'t wait for it
821 # there. The notification may not work, instead open the web gui
822 # from in the app, there should be a notification within there.
823 #
824 # On phone, set settings to run syncthing all the time, and
825 # show no notification.
826 #
827 # Folder versioning would make sense if I didn\'t already use btrfs
828 # for backups. I would choose staggered, or trash can for more space.
829 #
830 # if needed to install on a remote comp:
831 # ssh -L 8384:localhost:8384 -N frodo
832 # open http://localhost:8384/
833 #
834 # Note, the other thing i did was port forward port 22000,
835 # per https://docs.syncthing.net/users/firewall.html
836
837 fi
838 ############# end syncthing setup ###########
839
840
841
842 ####### begin misc packages ###########
843
844 case $codename in
845 flidas)
846
847 ;;
848 esac
849
850
851 # sakura config is owned by ian
852 reset-sakura
853 reset-konsole
854 sudo -u user2 -i reset-konsole
855 # user2 xscreensaver we don't want to reset
856 reset-xscreensaver
857
858
859 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
860 # this is also in primary-setup
861 # pi libxss-dev # dependency based on build failure
862 # cabal update
863 # cabal install --upgrade-dependencies --force-reinstalls arbtt
864 # also, i assume syncing this between machines somehow messed thin
865 #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log
866
867 primary-setup
868
869 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
870 cp /p/.linphonerc-initial ~/.linphonerc
871 fi
872
873
874 ### begin spd install
875 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
876 t=$(mktemp)
877 wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
878 s dpkg -i $t
879 rm $t
880 # this guesses at the appropriate directory, adjust if needed
881 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
882 sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
883 # newer distro had gpg2 as default, older one, flidas, need to make it that way
884 gpgpath=$(which gpg2)
885 if [[ $x ]]; then
886 s mkdir -p /usr/local/spdhackfix
887 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
888 fi
889 ### end spd install
890
891
892 # nagstamon setting which were set through the ui
893 # in filters tab:
894 # all unknown sources
895 # all warning services
896 # acknowledged hosts & services
897 # hosts & services down for maintenence
898 # services on down hosts
899 # services on hosts in maintenece
900 # services on unreachable osts
901 # hosts in soft state
902 # services in soft state
903 # in display tab: fullscreen
904
905 # these translate to these settings I think
906 # filter_acknowledged_hosts_services = True
907 # filter_all_unknown_services = True
908 # filter_all_warning_services = True
909 # filter_hosts_in_soft_state = True
910 # filter_hosts_services_maintenance = True
911 # filter_services_in_soft_state = True
912 # filter_services_on_down_hosts = True
913 # filter_services_on_hosts_in_maintenance = True
914 # filter_services_on_unreachable_hosts = True
915 # notify_if_up = False
916 # statusbar_floating = False
917 # fullscreen = True
918 # but i'm just going to rely on the webpage plus sms for now.
919
920
921 # it asks if it should make users in it's group capture packets without root,
922 # which is arguably more secure than running wireshark as root. default is no,
923 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
924 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
925
926 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
927 # listed in the default config as suggested.
928 # /run/usr/1000 i noticed was missing for pulseaudio
929 # /run/user/0 just seemed like a not bad idea, given the above
930 tu /etc/schroot/desktop/fstab <<'EOF'
931 /run /run none rw,bind 0 0
932 /run/lock /run/lock none rw,bind 0 0
933 /dev/shm /dev/shm none rw,bind 0 0
934 /run/shm /run/shm none rw,bind 0 0
935 /run/user/1000 /run/user/1000 none rw,bind 0 0
936 /run/user/1001 /run/user/1001 none rw,bind 0 0
937 /run/user/0 /run/user/0 none rw,bind 0 0
938 EOF
939
940 mkschroot() {
941 distro=$1
942 shift
943 case $distro in
944 ubuntu)
945 repo=http://archive.ubuntu.com/ubuntu/
946 ;;
947 debian)
948 repo=http://deb.debian.org/debian/
949 ;;
950 esac
951 n=$1
952 shift
953 if schroot -l | grep -xFq chroot:$n; then
954 echo "$0: $n schroot already installed, skipping"
955 return 0
956 fi
957 apps=($@)
958 d=/nocow/schroot/$n
959 s dd of=/etc/schroot/chroot.d/$n.conf <<EOF
960 [$n]
961 description=$n
962 type=directory
963 directory=$d
964 profile=desktop
965 preserve-environment=true
966 users=$USER,user2
967 EOF
968 if [[ -e $d/bin ]]; then
969 s chroot $d apt-get update
970 s chroot $d apt-get -y dist-upgrade --purge --auto-remove
971 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
972 else
973 s mkdir -p $d
974
975 s debootstrap $n $d $repo
976 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
977 fi
978 s cp -P {,$d}/etc/localtime
979 }
980 s dd of=/etc/systemd/system/schrootupdate.service <<'EOF'
981 [Unit]
982 Description=schrootupdate
983 After=multi-user.target
984
985 [Service]
986 Type=oneshot
987 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
988 EOF
989 s dd of=/etc/systemd/system/schrootupdate.timer <<'EOF'
990 [Unit]
991 Description=schrootupdate
992
993 [Timer]
994 OnCalendar=*-*-* 04:20:00
995
996 [Install]
997 WantedBy=timers.target
998 EOF
999 s systemctl daemon-reload
1000 sgo schrootupdate.timer
1001
1002
1003
1004 # for my roommate
1005 case $distro in
1006 trisquel)
1007 mkschroot debian stretch firefox-esr pulseaudio chromium
1008 ;;
1009 debian)
1010 pi chromium
1011 ;;
1012 esac
1013
1014 s mkdir -p /nocow/user
1015 s chown $USER:$USER /nocow/user
1016 pi anki
1017
1018
1019 ####### begin transmission
1020
1021 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1022 # 450 seems likely to be unused. we need to specify one or else
1023 # it won't be stable across installs.
1024 if ! getent passwd debian-transmission > /dev/null; then
1025 s groupadd -g 450 debian-transmission
1026 s adduser --quiet \
1027 --gid 450 \
1028 --uid 450 \
1029 --system \
1030 --no-create-home \
1031 --disabled-password \
1032 --home /var/lib/transmission-daemon \
1033 debian-transmission
1034 fi
1035 # We want group writable stuff from transmission.
1036 # However, after setting this, I learn that transmission sets it's
1037 # own umask based on it's settings file. Well, no harm leaving this
1038 # so it's set right from the beginning.
1039 s chfn debian-transmission -o umask=0002
1040
1041 # note i had to do this, which is persistent:
1042 # cd /i/k
1043 # s chgrp debian-transmission torrents partial-torrents
1044
1045 # syslog says things like
1046 # 'Failed to set receive buffer: requested 4194304, got 425984'
1047 # google suggets giving it even more than that
1048 tu /etc/sysctl.conf<<'EOF'
1049 net.core.rmem_max = 67108864
1050 net.core.wmem_max = 16777216
1051 EOF
1052 s sysctl -p
1053
1054 # some reason it doesn\'t seem to start automatically anyways
1055 pi-nostart transmission-daemon
1056 # be extra sure its not started
1057 ser disable transmission-daemon
1058 ser stop transmission-daemon
1059
1060 # the folder was moved here after an install around 02/2017.
1061 # it contains runtime data,
1062 # plus a simple symlink to the config file which it\'s
1063 # not worth separating out.
1064 # between comps, the uid can change
1065 f=/i/transmission-daemon
1066 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1067 if [[ -e $f ]]; then
1068 s chown -R debian-transmission:debian-transmission $f
1069 fi
1070 for f in /i/k/partial-torrents /i/k/torrents; do
1071 if [[ -e $f ]]; then
1072 s chown -R debian-transmission:user2 $f
1073 fi
1074 done
1075 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1076 #
1077 # config file documented here, and it\'s the same config
1078 # for daemon vs client, so it\'s documented in the gui.
1079 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1080 #
1081 # I originaly setup rpc-whitelist, but after using
1082 # routing to a network namespace, it doesn\'t see the
1083 # real source address, so it\'s disabled.
1084 #
1085 # Changed the cache-size to 256 mb, reduces disk use.
1086 # It is a read & write cache.
1087 #
1088 s ruby <<'EOF'
1089 require 'json'
1090 p = '/etc/transmission-daemon/settings.json'
1091 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1092 'rpc-whitelist-enabled' => false,
1093 'rpc-authentication-required' => false,
1094 'incomplete-dir' => '/i/k/partial-torrents',
1095 'incomplete-dir-enabled' => true,
1096 'download-dir' => '/i/k/torrents',
1097 "speed-limit-up" => 800,
1098 "speed-limit-up-enabled" => true,
1099 "peer-port" => 61486,
1100 "cache-size-mb" => 256,
1101 "ratio-limit" => 5.0,
1102 "ratio-limit-enabled" => true,
1103 })) + "\n")
1104 EOF
1105 ####### end transmission
1106
1107
1108
1109 # trisquel 8 = openvpn, debian stretch = openvpn-client
1110 vpn_ser=openvpn-client
1111 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1112 vpn_ser=openvpn
1113 fi
1114
1115 s dd of=/etc/systemd/system/transmission-daemon-nn.service <<EOF
1116 [Unit]
1117 Description=Transmission BitTorrent Daemon netns
1118 After=network.target
1119 Requires=${vpn_ser}-nn@client.service
1120 After=${vpn_ser}-nn@client.service
1121 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1122
1123 [Service]
1124 #User=debian-transmission
1125 # notify type doesn't work with sudo
1126 #Type=notify
1127 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1128 ExecReload=/bin/kill -s HUP \$MAINPID
1129 PrivateNetwork=true
1130 Nice=19
1131
1132 [Install]
1133 WantedBy=multi-user.target
1134 EOF
1135 ser daemon-reload
1136
1137 if [[ $HOSTNAME == frodo ]]; then
1138 sgo transmission-daemon-nn
1139 fi
1140
1141
1142 ######### begin transmission client setup ######
1143
1144 if [[ -e /p/transmission-rpc-pass ]]; then
1145 # arch had a default config,
1146 # debian had nothing until you start it.
1147 # With a little trial an error, here is a minimal config
1148 # taken from the generated one, plus changes that the
1149 # settings ui does, without a bunch of ui crap settings.
1150 #
1151 # only settings I set were
1152 # hostname
1153 # auto-connect
1154 # password
1155
1156 # the password is randomly generated on first run, i copied it out
1157 # so it could be used by other hosts.
1158 s ruby <<'EOF'
1159 require 'json'
1160 p = '/etc/transmission-daemon/settings.json'
1161 s = JSON.parse(File.read(p))
1162 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1163 # default is 0022 (18 in decimal)
1164 s["umask"] = 2
1165 File.write p, JSON.pretty_generate(s)
1166 EOF
1167
1168 rpc_pass=$(</p/transmission-rpc-pass)
1169 for f in /home/*; do
1170 u=${f##*/}
1171 if [[ ! $(id -u $u) -ge 1000 ]]; then
1172 continue
1173 fi
1174 d=$f/.config/transmission-remote-gtk
1175 s -u $u mkdir -p $d
1176 s -u $u dd of=$d/config.json <<EOF
1177 {
1178 "profiles" : [
1179 {
1180 "profile-name" : "Default",
1181 "hostname" : "transmission.b8.nz",
1182 "rpc-url-path" : "/transmission/rpc",
1183 "username" : "",
1184 "password" : "$rpc_pass",
1185 "auto-connect" : true,
1186 "ssl" : false,
1187 "timeout" : 40,
1188 "retries" : 3,
1189 "update-active-only" : false,
1190 "activeonly-fullsync-enabled" : false,
1191 "activeonly-fullsync-every" : 2,
1192 "update-interval" : 3,
1193 "min-update-interval" : 3,
1194 "session-update-interval" : 60,
1195 "exec-commands" : [
1196 ],
1197 "destinations" : [
1198 ]
1199 }
1200 ],
1201 "profile-id" : 0,
1202 "add-options-dialog" : false
1203 }
1204 EOF
1205 done
1206 fi
1207 ######### end transmission client setup ######
1208
1209
1210 ### printer setup
1211 pi cups hplip
1212 s gpasswd -a $USER lpadmin # based on ubuntu wiki
1213 # goto http://127.0.0.1:631
1214 # administration tab, add new printer button.
1215 # In debian, I could use hte recommended driver,
1216 # in arch, I had to pick out the 6L driver.
1217
1218
1219 # allow user to run vms, from debian handbook
1220 for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
1221 # bridge networking as user fails. google lead here, but it doesn\'t work:
1222 # oh well, I give up.
1223 # http://wiki.qemu.org/Features-Done/HelperNetworking
1224 # s mkdir /etc/qemu
1225 # f=/etc/qemu/bridge.conf
1226 # s dd of=$f <<'EOF'
1227 # allow br0
1228 # EOF
1229 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1230 # s chmod 640 $f
1231
1232 # general known for debian/ubuntu, not for fedora
1233
1234 /a/bin/buildscripts/go
1235
1236 pi-nostart virtinst virt-manager
1237
1238
1239
1240 pi --no-install-recommends kdeconnect
1241 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1242 ### but gnome + xmonad not working in flidas, so i disabled it
1243 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1244 # cd /a/opt/indicator-kdeconnect
1245 # mkdir -p build
1246 # cd build
1247 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1248 # make
1249 # sudo make install
1250 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1251 # # it seems, according to
1252 # # /etc/xdg/autostart/kdeconnectd.desktop
1253 # # I'm not seeing the icon, but the clipboard replication is working
1254
1255
1256 ### model 01 arduino support ###
1257 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1258 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1259 # set arduino var in bashrc,
1260 # have system config file setup too.
1261 sudo adduser $USER dialout
1262
1263 # this is for the mail command too. update-alternatives is kind of misleading
1264 # since at least it's main commands pretend mail does not exist.
1265 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1266 s update-alternatives --set mailx /usr/bin/mail.mailutils
1267
1268 ######### end misc packages #########
1269
1270
1271 # packages I once used before and liked, but don\'t want installed now for
1272 # various reasons:
1273 # python-sqlite is used for offlineimap
1274 # lxappearance python-sqlite dolphin paman dconf-editor
1275
1276
1277
1278 ######## unfinished
1279
1280 # todo, finish configuring smart.
1281
1282 pi smartmontools
1283 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1284 # turn on smart. background on options:
1285 # first line, -a = test everyting on all devices.
1286 # -S on, turn on disk internal saving of vendor specific info,
1287 # from google, seems like this is usually already on and fairly standard.
1288 # -o on, turn on 4 hour period non-performance degrading testing.
1289 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1290 sched="-s (S/../.././02|L/../../6/03)"
1291 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1292 DEVICESCAN -a -o on -S on -n standby,q $sched \
1293 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1294
1295 # in the default configuration of at least ubuntu 14.04, resolvconf is
1296 # configured to order any nameservers associated with tun* or tap*
1297 # before the normal internet interfaces, which means they are always
1298 # consulted first. This is often slower and undesirable, ie. local dns
1299 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1300 # can do:
1301 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1302 # however, this breaks dns lookup for hosts on the openvpn lan.
1303 # I can\'t figure out why hosts on the normal lan would not be
1304 # broken under the default ordering, except the host I was
1305 # testing with previously had an entry in /etc/hosts.
1306
1307 ############# end unfinished
1308
1309 ########### misc stuff
1310
1311 # make networkmanager use resolvconf instead of its own dnsmasq which
1312 # conflicts with the normal dnsmasq package.
1313 f=/etc/NetworkManager/NetworkManager.conf
1314 m=$(md5sum $f)
1315 s sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1316 if [[ $m != $(md5sum $f) ]]; then
1317 srestart NetworkManager
1318 fi
1319
1320 # make my /etc/fonts/conf.d/ get used.
1321 # I have a new sans-serif font there because the default one
1322 # displays l and I as the same char, grrrrr.
1323 s fc-cache
1324
1325 /a/bin/distro-setup/mymimes
1326
1327
1328 sgo dynamicipupdate
1329
1330
1331 # stop autopoping windows when i plug in an android phone.
1332 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1333 # with still 0 exit code.
1334 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1335 dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1336
1337
1338 # on grub upgrade, we get prompts unless we do this
1339 devs=()
1340 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1341 devs+=("$(devbyid $dev),")
1342 done
1343 devs[-1]=${devs[-1]%,} # jonied by commas
1344 s debconf-set-selections <<EOF
1345 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1346 EOF
1347
1348 # btrfs maintenance
1349 sgo btrfsmaint.timer
1350 sgo btrfsmaintstop.timer
1351
1352 # aren't autoupdating this, but I do check on it somewhat regularly.
1353 cd /a/opt/btrbk
1354 s make install
1355
1356 sgo btrbk.timer
1357 # note: to see when it was last run,
1358 # ser list-timers
1359
1360
1361 end_msg <<'EOF'
1362 In mate settings settings, change scrolling to two-finger,
1363 because the default edge scroll doesn\'t work. Originally found this in debian.
1364 EOF
1365
1366 case $distro in
1367 debian)
1368 # remove dep that came in with desktop
1369 pu transmission-gtk
1370 ;;
1371 esac
1372
1373
1374 s gpasswd -a iank adm ;; #needed for reading logs
1375
1376 /a/bin/buildscripts/pithosfly
1377
1378
1379 # # Based on guix manual instructions, also added code to profile.
1380 # # disabled since i'm not using it now.
1381 # pi nscd
1382 # if ! type -p guix >/dev/null; then
1383 # cd $(mktemp -d)
1384 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1385 # # added some stuff to envonment.sh for profile based on
1386 # # manual instructions
1387 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1388 # # echo is to get past prompt
1389 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1390 # guix install glibc-utf8-locales
1391 # guix package --install guile
1392 # fi
1393
1394
1395
1396 pi tor
1397 /a/bin/buildscripts/tor-browser
1398
1399 # nfs server
1400 pi-nostart nfs-server
1401
1402 # networkmanager has this nasty behavior on flidas: if the machine
1403 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1404 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1405 # nameservers.
1406 # This can be manually fixed by stoping dnsmasq,
1407 # then based on whats in /run/dnsmasq/, i see we can run
1408 # s resolvconf -d NetworkManager
1409 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1410 ser stop NetworkManager
1411 ser disable NetworkManager
1412
1413
1414 if [[ $HOSTNAME == frodo ]]; then
1415 # nohide = export filesystems mounted deeper than the export point
1416 # fsid=0 makes this export the "root" export
1417 # not documented in the man page, but this means
1418 # 1. it can be mounted with a shorthand of server:/
1419 # 2. exports that are subdirectories of this one will automatically be mounted
1420 tu /etc/exports <<'EOF'
1421 /k 10.0.0.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1422 EOF
1423 s exportfs -rav
1424 fi
1425
1426
1427
1428
1429
1430 # if I was going to create a persistent vm, i might do it like this:
1431 # variant=something # from: virt-install --os-variant list
1432 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1433 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1434 # -n some_name --import --os-variant $variant --cpu host-model-only
1435
1436
1437
1438 ######### begin stuff belonging at the end ##########
1439
1440 end