fix race condition
[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 exec &> >(sudo tee -a /var/log/distro-end)
22 echo "$0: $(date): starting now)"
23 # see example of usage to understand.
24 end_msg() {
25 local y
26 IFS= read -r -d '' y ||:
27 end_msg_var+="$y"
28 }
29 end() {
30 e "$end_msg_var"
31 echo 0 >~/.local/distro-end
32 if $pending_reboot; then
33 echo "$0: pending reboot and then finished. doing it now."
34 s reboot now
35 else
36 echo "$0: $(date): ending now)"
37 fi
38 exit 0
39 }
40 pre="${0##*/}:"
41 s() {
42 printf "s %s\n" "$*"
43 SUDOD="$PWD" sudo -i "$@";
44 }
45 sd() {
46 s dd of="$1" 2>/dev/null
47 }
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; }
51 distro=$(distro-name)
52 codename=$(debian-codename)
53 codename_compat=$(debian-codename-compat)
54 pending_reboot=false
55 sed="sed --follow-symlinks"
56 # template
57 case $distro in
58 esac
59
60 #### initial packages
61 pup
62 if isdeb; then
63 pi aptitude
64 fi
65
66 # avoid prompts
67 s debconf-set-selections <<EOF
68 popularity-contest popularity-contest/participate boolean true
69 EOF
70
71 ########### begin section including linode ################
72 pi ${p2[@]}
73
74
75 conflink
76
77 # no equivalent in other distros:
78 if isdeb && pcheck apt-file; then
79 # this condition is just a speed optimization
80 pi apt-file
81 s apt-file update
82 fi
83
84
85 # disable motd junk.
86 case $distro in
87 debian)
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
94 ;;
95 trisquel|ubuntu)
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
99 ;;
100 esac
101
102
103
104
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 ||:
116 m p update
117 fi
118 pi python-certbot-apache
119 else
120 err "distro unknown for certbot"
121 fi
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,
126 EOF
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,
129 EOF
130 ser daemon-reload
131 m sgo certbotmail.timer
132 ### end certbot install ###
133
134
135 # dogcam setup. not using atm
136 # case $HOSTNAME in
137 # lj|li)
138 # /a/bin/webcam/install-server
139 # ;;
140 # kw)
141 # /a/bin/webcam/install-client
142 # ;;
143 # esac
144
145
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
153 # <Location />
154 # AllowOverride None
155 # AuthType basic
156 # AuthName "Authentication Required"
157 # # setup one time, with root:www-data, 640
158 # AuthUserFile "/etc/prometheus-htpasswd"
159 # Require valid-user
160 # </Location>
161 # EOF
162 # fi
163
164
165 ######### begin flidas pinned packages ######
166 case $(debian-codename) in
167 # needed for debootstrap scripts for fai since fai requires debian
168 flidas)
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
171 Package: *
172 Pin: release a=xenial
173 Pin-Priority: -100
174
175 Package: *
176 Pin: release a=xenial-updates
177 Pin-Priority: -100
178
179 Package: *
180 Pin: release a=xenial-security
181 Pin-Priority: -100
182 EOF
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
187 EOF
188
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
192 Package: *
193 Pin: release a=bionic
194 Pin-Priority: -100
195
196 Package: *
197 Pin: release a=bionic-updates
198 Pin-Priority: -100
199
200 Package: *
201 Pin: release a=bionic-security
202 Pin-Priority: -100
203 EOF
204 fi
205
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
211 Pin-Priority: 1005
212
213 Package: btrfs-progs libzstd1
214 Pin: release a=bionic-updates
215 Pin-Priority: 1005
216
217 Package: btrfs-progs libzstd1
218 Pin: release a=bionic-security
219 Pin-Priority: 1005
220 EOF
221
222
223 t=$(mktemp)
224 cat >$t <<EOF
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
228 EOF
229 f=/etc/apt/sources.list.d/bionic.list
230 if ! diff -q $t $f; then
231 s cp $t $f
232 s chmod 644 $f
233 m p update
234 fi
235
236 # no special reason, but its better for btrfs-progs to
237 # be closer to our kernel version
238 pi btrfs-progs
239
240 if [[ ! -e /usr/share/debootstrap/scripts/xenial ]]; then
241 t=$(mktemp -d)
242 cd $t
243 m aptitude download debootstrap/xenial
244 m ex ./*
245 s cp ./usr/share/debootstrap/scripts/* /usr/share/debootstrap/scripts
246 fi
247
248 sd /etc/apt/preferences.d/flidas-etiona <<EOF
249 Package: *
250 Pin: release a=etiona
251 Pin-Priority: -100
252
253 Package: *
254 Pin: release a=etiona-updates
255 Pin-Priority: -100
256
257 Package: *
258 Pin: release a=etiona-security
259 Pin-Priority: -100
260
261 Package: *
262 Pin: release a=etiona-backports
263 Pin-Priority: -100
264 EOF
265
266 t=$(mktemp)
267 cat >$t <<EOF
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
272 EOF
273 f=/etc/apt/sources.list.d/etiona.list
274 if ! diff -q $t $f; then
275 s cp $t $f
276 n s chmod 644 $f
277 m p update
278 fi
279
280 sd /etc/apt/preferences.d/debian-goodies <<EOF
281 Package: debian-goodies
282 Pin: release n=etiona
283 Pin-Priority: 1005
284 EOF
285
286
287 sd /etc/apt/preferences.d/flidas-buster <<EOF
288 Package: *
289 Pin: release n=buster
290 Pin-Priority: -100
291
292 Package: *
293 Pin: release n=buster-updates
294 Pin-Priority: -100
295 EOF
296
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
300 s rm -fv $f
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";
304 # EOF
305
306 f=/etc/apt/sources.list.d/buster.list
307 s rm -fv $f
308 # t=$(mktemp)
309 # cat >$t <<EOF
310 # deb http://http.us.debian.org/debian buster main
311 # deb-src http://http.us.debian.org/debian buster main
312
313 # deb http://security.debian.org/ buster/updates main
314 # deb-src http://security.debian.org/ buster/updates main
315
316 # deb http://http.us.debian.org/debian buster-updates main
317 # deb-src http://http.us.debian.org/debian buster-updates main
318 # EOF
319 # if ! diff -q $t $f; then
320 # s cp $t $f
321 # s chmod 644 $f
322 # p update
323 # fi
324
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.
328 pi debian-goodies
329
330 sd /etc/apt/preferences.d/shellcheck <<EOF
331 Package: shellcheck
332 Pin: release a=etiona
333 Pin-Priority: 1005
334
335 Package: shellcheck
336 Pin: release a=etiona-updates
337 Pin-Priority: 1005
338
339 Package: shellcheck
340 Pin: release a=etiona-security
341 Pin-Priority: 1005
342 EOF
343
344 sd /etc/apt/preferences.d/bash <<EOF
345 Package: bash
346 Pin: release a=etiona
347 Pin-Priority: 1005
348
349 Package: bash
350 Pin: release a=etiona-updates
351 Pin-Priority: 1005
352
353 Package: bash
354 Pin: release a=etiona-security
355 Pin-Priority: 1005
356 EOF
357
358
359 ;;
360 *)
361 if isdeb; then
362 pi debian-goodies shellcheck
363 fi
364 ;;
365 esac
366 ######### end flidas pinned packages ######
367
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";
375 EOF
376
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=*";
387 };
388 EOF
389
390 # old names, too verbose
391 s rm -f /etc/cron.d/unattended-upgrade-reboot /usr/local/bin/zelous-unattended-reboot
392
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
398 EOF
399 ##### end automatic upgrades ####
400
401
402
403 ###### begin website setup
404 case $HOSTNAME in
405 li|l2)
406 f=/var/lib/bind/db.b8.nz
407 if [[ ! -e $f ]]; then
408 ser stop bind9
409 s rm -fv $f.jnl
410 s install -m 644 -o bind -g bind /p/c/machine_specific/linode/bind-initial/db.b8.nz $f
411 ser restart bind9
412 fi
413 ;;&
414 l2)
415 end
416 ;;
417 li)
418
419 case $HOSTNAME in
420 li) domain=iankelling.org ;;
421 esac
422 m /a/h/setup.sh $domain
423 m /a/h/build.rb
424
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
428
429 # do certificate to avoid warning about unsigned cert,
430 # which is overkill for my use, but hey, I'm cool, I know
431 # how to do this.
432 m web-conf apache2 mumble.iankelling.org
433 s rm -fv /etc/apache2/sites-enabled/mumble.iankelling.org
434 s <<'EOF'
435 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
436 /a/bin/distro-setup/certbot-renew-hook
437 EOF
438
439
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
446 # and man openvpn
447
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
452 EOF
453
454 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
455 vpn_service=openvpn-server@server
456 else
457 vpn_service=openvpn@server
458 fi
459
460 sudo dd of=/etc/systemd/system/vpnmail.service <<EOF
461 [Unit]
462 Description=Turns on iptables mail nat
463
464 [Service]
465 Type=oneshot
466 RemainAfterExit=yes
467 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
468 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
469
470 [Install]
471 WantedBy=$vpn_service.service
472 EOF
473 ser daemon-reload
474 m sgo vpnmail.service
475 # needed for li's local mail delivery.
476 tu /etc/hosts <<<"10.8.0.4 mail.iankelling.org"
477 m sgo $vpn_service
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
481 ser reload apache2
482
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
487 <Location />
488 Options +FollowSymLinks +Multiviews +Indexes
489 AllowOverride None
490 AuthType basic
491 AuthName "Authentication Required"
492 # setup one time, with root:www-data, 640
493 AuthUserFile "/etc/caldav-htpasswd"
494 Require valid-user
495 </Location>
496 EOF
497 # nginx version of above would be:
498 # auth_basic "Not currently available";
499 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
500
501
502
503 ###### begin znc setup #####
504 pi znc
505
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/
510 sudo -i <<'EOF'
511 export RENEWED_LINEAGE=/etc/letsencrypt/live/iankelling.org
512 /a/bin/distro-setup/certbot-renew-hook
513 EOF
514
515 # znc config generated by doing
516 # znc --makeconf
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
536 #
537 # i set Buffer = 500
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
541 # on killing the,
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 \
547 #
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'
552 [Unit]
553 Description=ZNC, an advanced IRC bouncer
554 After=network-online.target
555
556 [Service]
557 ExecStart=/usr/bin/znc -f --datadir=/var/lib/znc
558 User=znc
559
560 [Install]
561 WantedBy=multi-user.target
562 EOF
563 ser daemon-reload
564 m sgo znc
565 ###### stop znc setup #####
566
567 end
568 ;;
569 esac
570 ###### end website setup
571
572 ########### end section including li/lj ###############
573
574 #### desktop stuff
575 case $codename_compat in
576 xenial)
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
580 ;;
581 stretch)
582 pi task-mate-desktop
583 ;;
584 buster)
585 # mate doesnt have wayland support yet
586 pi task-gnome-desktop
587 ;;
588 esac
589
590
591
592
593 # TODO: some of the X programs can be removed from pall when using wayland
594
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)
600
601
602 m sgo fsf-vpn-dns-cleanup
603
604
605 # website is dead june 14 2019. back in october, but meh
606 s rm -fv /etc/apt/sources.list.d/iridium-browser.list
607 # case $distro in
608 # debian)
609 # pi chromium ;;
610 # trisquel|ubuntu)
611 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
612 # t=$(mktemp)
613 # cat >$t <<EOF
614 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
615 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
616 # EOF
617 # f=/etc/apt/sources.list.d/iridium-browser.list
618 # if ! diff -q $t $f; then
619 # s cp $t $f
620 # s chmod 644 $f
621 # p update
622 # fi
623 # pi iridium-browser
624 # ;;
625 # esac
626
627
628 ### begin home vpn server setup
629
630
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
635 # # server keys.
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
643 # mkdir -p $dir
644 # s bash -c "cp /etc/openvpn/client/home* $dir"
645 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
646 # done
647
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
654 EOF
655 s sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
656
657 if [[ $HOSTNAME == tp ]]; then
658 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
659 vpn_service=openvpn-server@server
660 else
661 vpn_service=openvpn@server
662 fi
663 m sgo $vpn_service
664 fi
665 ### end vpn server setup
666
667
668 ##### rss2email
669 # note, see bashrc for more documentation.
670 pi rss2email
671 sd /etc/systemd/system/rss2email.service <<'EOF'
672 [Unit]
673 Description=rss2email
674 After=multi-user.target
675
676 [Service]
677 User=iank
678 Type=oneshot
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
683 EOF
684 sd /etc/systemd/system/rss2email.timer <<'EOF'
685 [Unit]
686 Description=rss2email
687
688 [Timer]
689 # for initial run. required.
690 OnActiveSec=30
691 # for subsequent runs.
692 OnUnitInactiveSec=300
693
694 [Install]
695 WantedBy=timers.target
696 EOF
697 s systemctl daemon-reload
698
699
700 ######### begin pump.io periodic backup #############
701 if [[ $HOSTNAME == frodo ]]; then
702 sd /etc/systemd/system/pumpbackup.service <<'EOF'
703 [Unit]
704 Description=pump li backup
705 After=multi-user.target
706
707 [Service]
708 User=iank
709 Type=oneshot
710 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
711 EOF
712 sd /etc/systemd/system/pumpbackup.timer <<'EOF'
713 [Unit]
714 Description=pump li backup hourly
715
716 [Timer]
717 OnCalendar=hourly
718
719 [Install]
720 WantedBy=timers.target
721 EOF
722 ser daemon-reload
723 m sgo pumpbackup.timer
724 fi
725 ######### end pump.io periodic backup #############
726
727
728 ######### begin irc periodic backup #############
729 if [[ $HOSTNAME == frodo ]]; then
730 sd /etc/systemd/system/ircbackup.service <<'EOF'
731 [Unit]
732 Description=irc li backup
733 After=multi-user.target
734
735 [Service]
736 User=iank
737 Type=oneshot
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
739 EOF
740 sd /etc/systemd/system/ircbackup.timer <<'EOF'
741 [Unit]
742 Description=irc li backup hourly
743
744 [Timer]
745 OnCalendar=hourly
746
747 [Install]
748 WantedBy=timers.target
749 EOF
750 s systemctl daemon-reload
751 sgo ircbackup.timer
752 fi
753
754
755 ######### end irc periodic backup #############
756
757
758 case $distro in
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
764 ser disable openvpn
765 ;;
766 *) pi openvpn;;
767 esac
768
769 m /a/bin/distro-setup/radicale-setup
770
771
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
790 p update
791 fi
792 fi
793 pi syncthing
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
797
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,
807 # based on
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.
811 #
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
817 #
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.
826 #
827 # On phone, set settings to run syncthing all the time, and
828 # show no notification.
829 #
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.
832 #
833 # if needed to install on a remote comp:
834 # ssh -L 8384:localhost:8384 -N frodo
835 # open http://localhost:8384/
836 #
837 # Note, the other thing i did was port forward port 22000,
838 # per https://docs.syncthing.net/users/firewall.html
839
840 fi
841 ############# end syncthing setup ###########
842
843
844
845 ####### begin misc packages ###########
846
847 case $codename in
848 flidas)
849
850 ;;
851 esac
852
853
854 # sakura config is owned by ian
855 m reset-sakura
856 m reset-konsole
857 m sudo -u user2 -i reset-konsole
858 # user2 xscreensaver we don't want to reset
859 m reset-xscreensaver
860
861
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
865 # cabal update
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
869
870 m primary-setup
871
872 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
873 m cp /p/.linphonerc-initial ~/.linphonerc
874 fi
875
876
877 ### begin spd install
878 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
879 t=$(mktemp)
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
881 s dpkg -i $t
882 m rm $t
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)
888 if [[ $x ]]; then
889 s mkdir -p /usr/local/spdhackfix
890 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
891 fi
892 ### end spd install
893
894
895 # nagstamon setting which were set through the ui
896 # in filters tab:
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
907
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
920 # fullscreen = True
921 # but i'm just going to rely on the webpage plus sms for now.
922
923
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
928
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
941 EOF
942
943 mkschroot() {
944 distro=$1
945 shift
946 case $distro in
947 ubuntu)
948 repo=http://archive.ubuntu.com/ubuntu/
949 ;;
950 debian)
951 repo=http://deb.debian.org/debian/
952 ;;
953 esac
954 n=$1
955 shift
956 if schroot -l | grep -xFq chroot:$n; then
957 echo "$0: $n schroot already installed, skipping"
958 return 0
959 fi
960 apps=($@)
961 d=/nocow/schroot/$n
962 sd /etc/schroot/chroot.d/$n.conf <<EOF
963 [$n]
964 description=$n
965 type=directory
966 directory=$d
967 profile=desktop
968 preserve-environment=true
969 users=$USER,user2
970 EOF
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[@]}
975 else
976 s mkdir -p $d
977
978 s debootstrap $n $d $repo
979 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
980 fi
981 s cp -P {,$d}/etc/localtime
982 }
983 sd /etc/systemd/system/schrootupdate.service <<'EOF'
984 [Unit]
985 Description=schrootupdate
986 After=multi-user.target
987
988 [Service]
989 Type=oneshot
990 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
991 EOF
992 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
993 [Unit]
994 Description=schrootupdate
995
996 [Timer]
997 OnCalendar=*-*-* 04:20:00
998
999 [Install]
1000 WantedBy=timers.target
1001 EOF
1002 ser daemon-reload
1003 m sgo schrootupdate.timer
1004
1005
1006
1007 # for my roommate
1008 case $distro in
1009 trisquel)
1010 m mkschroot debian stretch firefox-esr pulseaudio chromium
1011 ;;
1012 debian)
1013 pi chromium
1014 ;;
1015 esac
1016
1017 s mkdir -p /nocow/user
1018 s chown $USER:$USER /nocow/user
1019 pi anki
1020
1021
1022 ####### begin transmission
1023
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
1029 s adduser --quiet \
1030 --gid 450 \
1031 --uid 450 \
1032 --system \
1033 --no-create-home \
1034 --disabled-password \
1035 --home /var/lib/transmission-daemon \
1036 debian-transmission
1037 fi
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
1043
1044 # note i had to do this, which is persistent:
1045 # cd /i/k
1046 # s chgrp debian-transmission torrents partial-torrents
1047
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
1054 EOF
1055 s sysctl -p
1056
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
1062
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
1072 fi
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
1076 fi
1077 done
1078 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1079 #
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
1083 #
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.
1087 #
1088 # Changed the cache-size to 256 mb, reduces disk use.
1089 # It is a read & write cache.
1090 #
1091 s ruby <<'EOF'
1092 require 'json'
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,
1106 })) + "\n")
1107 EOF
1108 ####### end transmission
1109
1110
1111
1112 # trisquel 8 = openvpn, debian stretch = openvpn-client
1113 vpn_ser=openvpn-client
1114 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1115 vpn_ser=openvpn
1116 fi
1117
1118 sd /etc/systemd/system/transmission-daemon-nn.service <<EOF
1119 [Unit]
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
1125
1126 [Service]
1127 #User=debian-transmission
1128 # notify type doesn't work with sudo
1129 #Type=notify
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
1132 PrivateNetwork=true
1133 Nice=19
1134
1135 [Install]
1136 WantedBy=multi-user.target
1137 EOF
1138 ser daemon-reload
1139
1140 if [[ $HOSTNAME == frodo ]]; then
1141 m sgo transmission-daemon-nn
1142 fi
1143
1144
1145 ######### begin transmission client setup ######
1146
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.
1153 #
1154 # only settings I set were
1155 # hostname
1156 # auto-connect
1157 # password
1158
1159 # the password is randomly generated on first run, i copied it out
1160 # so it could be used by other hosts.
1161 s ruby <<'EOF'
1162 require 'json'
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)
1167 s["umask"] = 2
1168 File.write p, JSON.pretty_generate(s)
1169 EOF
1170
1171 rpc_pass=$(</p/transmission-rpc-pass)
1172 for f in /home/*; do
1173 u=${f##*/}
1174 uid=$(id -u $u 2>/dev/null) || continue
1175 if [[ ! $uid -ge 1000 ]]; then
1176 continue
1177 fi
1178 d=$f/.config/transmission-remote-gtk
1179 s -u $u mkdir -p $d
1180 s -u $u dd of=$d/config.json <<EOF
1181 {
1182 "profiles" : [
1183 {
1184 "profile-name" : "Default",
1185 "hostname" : "transmission.b8.nz",
1186 "rpc-url-path" : "/transmission/rpc",
1187 "username" : "",
1188 "password" : "$rpc_pass",
1189 "auto-connect" : true,
1190 "ssl" : false,
1191 "timeout" : 40,
1192 "retries" : 3,
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,
1199 "exec-commands" : [
1200 ],
1201 "destinations" : [
1202 ]
1203 }
1204 ],
1205 "profile-id" : 0,
1206 "add-options-dialog" : false
1207 }
1208 EOF
1209 done
1210 fi
1211 ######### end transmission client setup ######
1212
1213
1214 ### printer setup
1215 pi cups hplip
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.
1221
1222
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
1228 # s mkdir /etc/qemu
1229 # f=/etc/qemu/bridge.conf
1230 # sd $f <<'EOF'
1231 # allow br0
1232 # EOF
1233 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1234 # s chmod 640 $f
1235
1236 # general known for debian/ubuntu, not for fedora
1237
1238 m /a/bin/buildscripts/go
1239 m /a/bin/buildscripts/rust
1240 m /a/bin/buildscripts/misc
1241
1242 pi-nostart virtinst virt-manager
1243
1244
1245
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
1251 # mkdir -p build
1252 # cd build
1253 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1254 # make
1255 # sudo make install
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
1260
1261
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
1268
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
1273
1274 ######### end misc packages #########
1275
1276
1277 # packages I once used before and liked, but don\'t want installed now for
1278 # various reasons:
1279 # python-sqlite is used for offlineimap
1280 # lxappearance python-sqlite dolphin paman dconf-editor
1281
1282
1283
1284 ######## unfinished
1285
1286 # todo, finish configuring smart.
1287
1288 pi smartmontools
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
1300
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
1306 # can do:
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.
1312
1313 ############# end unfinished
1314
1315 ########### misc stuff
1316
1317 # make networkmanager use resolvconf instead of its own dnsmasq which
1318 # conflicts with the normal dnsmasq package.
1319 f=/etc/NetworkManager/NetworkManager.conf
1320 m=$(md5sum $f)
1321 s sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1322 if [[ $m != $(md5sum $f) ]]; then
1323 srestart NetworkManager
1324 fi
1325
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.
1329 s fc-cache
1330
1331 m /a/bin/distro-setup/mymimes
1332
1333
1334 m sgo dynamicipupdate
1335
1336
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
1342
1343
1344 # on grub upgrade, we get prompts unless we do this
1345 devs=()
1346 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1347 devs+=("$(devbyid $dev),")
1348 done
1349 devs[-1]=${devs[-1]%,} # jonied by commas
1350 s debconf-set-selections <<EOF
1351 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1352 EOF
1353
1354 # btrfs maintenance
1355 sgo btrfsmaint.timer
1356 sgo btrfsmaintstop.timer
1357
1358 # aren't autoupdating this, but I do check on it somewhat regularly.
1359 m cd /a/opt/btrbk
1360 s make install
1361
1362 m sgo btrbk.timer
1363 # note: to see when it was last run,
1364 # ser list-timers
1365
1366
1367 end_msg <<'EOF'
1368 In mate settings settings, change scrolling to two-finger,
1369 because the default edge scroll doesn\'t work. Originally found this in debian.
1370 EOF
1371
1372 # Remove dep that came in with desktop to fix associations.
1373 m pu transmission-gtk
1374
1375 s gpasswd -a iank adm #needed for reading logs
1376
1377 m /a/bin/buildscripts/pithosfly
1378
1379
1380 # # Based on guix manual instructions, also added code to profile.
1381 # # disabled since i'm not using it now.
1382 # pi nscd
1383 # if ! type -p guix >/dev/null; then
1384 # cd $(mktemp -d)
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
1393 # fi
1394
1395
1396
1397 pi tor
1398 m /a/bin/buildscripts/tor-browser
1399
1400 # nfs server
1401 pi-nostart nfs-kernel-server
1402
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
1406 # nameservers.
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
1413
1414
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)
1423 EOF
1424 s exportfs -rav
1425 fi
1426
1427
1428
1429
1430
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
1436
1437
1438
1439 ######### begin stuff belonging at the end ##########
1440
1441 end