minor bug fix
[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 # avoid restarting if possible, reconnecting to irc is annoying.
565 if [[ $(ser is-active znc) != active ]]; then
566 m sgo znc
567 fi
568 ###### stop znc setup #####
569
570 end
571 ;;
572 esac
573 ###### end website setup
574
575 ########### end section including li/lj ###############
576
577 #### desktop stuff
578 case $codename_compat in
579 xenial)
580 # mate-indicator-applet and beyond are msc things I noticed diffing a
581 # standard install with mine.
582 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
583 ;;
584 stretch)
585 pi task-mate-desktop
586 ;;
587 buster)
588 # mate doesnt have wayland support yet
589 pi task-gnome-desktop
590 ;;
591 esac
592
593
594
595
596 # TODO: some of the X programs can be removed from pall when using wayland
597
598 # depends gcc is a way to install suggests. this is apparently the only
599 # way to install suggests even if the main package is already
600 # installed. reinstall doesn't work, uninstalling can cause removing
601 # dependent packages.
602 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)
603
604
605 m sgo fsf-vpn-dns-cleanup
606
607
608 # website is dead june 14 2019. back in october, but meh
609 s rm -fv /etc/apt/sources.list.d/iridium-browser.list
610 # case $distro in
611 # debian)
612 # pi chromium ;;
613 # trisquel|ubuntu)
614 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
615 # t=$(mktemp)
616 # cat >$t <<EOF
617 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
618 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
619 # EOF
620 # f=/etc/apt/sources.list.d/iridium-browser.list
621 # if ! diff -q $t $f; then
622 # s cp $t $f
623 # s chmod 644 $f
624 # p update
625 # fi
626 # pi iridium-browser
627 # ;;
628 # esac
629
630
631 ### begin home vpn server setup
632
633
634 # # this section done initially to make persistent keys.
635 # # Also note, I temporarily set /etc/hosts so my host was
636 # # b8.nz when running this, since the vpn client config
637 # # generator assumes we need to go to that server to get
638 # # server keys.
639 # vpn-server-setup -rds
640 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
641 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
642 # # kw = kgpe work machine.
643 # for host in x2 x3 kw; do
644 # vpn-mk-client-cert -b $host -n home b8.nz 1196
645 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
646 # mkdir -p $dir
647 # s bash -c "cp /etc/openvpn/client/home* $dir"
648 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
649 # done
650
651 # key already exists, so this won't generate one, just the configs.
652 m vpn-server-setup -rds
653 s tee -a /etc/openvpn/server/server.conf <<'EOF'
654 push "dhcp-option DNS 10.0.0.1"
655 push "route 10.0.0.0 255.255.0.0"
656 client-connect /a/bin/distro-setup/vpn-client-connect
657 EOF
658 s sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
659
660 if [[ $HOSTNAME == tp ]]; then
661 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
662 vpn_service=openvpn-server@server
663 else
664 vpn_service=openvpn@server
665 fi
666 m sgo $vpn_service
667 fi
668 ### end vpn server setup
669
670
671 ##### rss2email
672 # note, see bashrc for more documentation.
673 pi rss2email
674 sd /etc/systemd/system/rss2email.service <<'EOF'
675 [Unit]
676 Description=rss2email
677 After=multi-user.target
678
679 [Service]
680 User=iank
681 Type=oneshot
682 # about 24 hours of failures
683 # it copies over its files without respecting symlinks, so
684 # we pass options to use different location.
685 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
686 EOF
687 sd /etc/systemd/system/rss2email.timer <<'EOF'
688 [Unit]
689 Description=rss2email
690
691 [Timer]
692 # for initial run. required.
693 OnActiveSec=30
694 # for subsequent runs.
695 OnUnitInactiveSec=300
696
697 [Install]
698 WantedBy=timers.target
699 EOF
700 s systemctl daemon-reload
701
702
703 ######### begin pump.io periodic backup #############
704 if [[ $HOSTNAME == frodo ]]; then
705 sd /etc/systemd/system/pumpbackup.service <<'EOF'
706 [Unit]
707 Description=pump li backup
708 After=multi-user.target
709
710 [Service]
711 User=iank
712 Type=oneshot
713 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
714 EOF
715 sd /etc/systemd/system/pumpbackup.timer <<'EOF'
716 [Unit]
717 Description=pump li backup hourly
718
719 [Timer]
720 OnCalendar=hourly
721
722 [Install]
723 WantedBy=timers.target
724 EOF
725 ser daemon-reload
726 m sgo pumpbackup.timer
727 fi
728 ######### end pump.io periodic backup #############
729
730
731 ######### begin irc periodic backup #############
732 if [[ $HOSTNAME == frodo ]]; then
733 sd /etc/systemd/system/ircbackup.service <<'EOF'
734 [Unit]
735 Description=irc li backup
736 After=multi-user.target
737
738 [Service]
739 User=iank
740 Type=oneshot
741 ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
742 EOF
743 sd /etc/systemd/system/ircbackup.timer <<'EOF'
744 [Unit]
745 Description=irc li backup hourly
746
747 [Timer]
748 OnCalendar=hourly
749
750 [Install]
751 WantedBy=timers.target
752 EOF
753 s systemctl daemon-reload
754 sgo ircbackup.timer
755 fi
756
757
758 ######### end irc periodic backup #############
759
760
761 case $distro in
762 debian|trisquel|ubuntu)
763 # suggests resolvconf package. installing it here is redundant, but make sure anyways.
764 # todo: check other distros to make sure it\'s installed
765 pi-nostart openvpn resolvconf
766 # pi-nostart does not disable
767 ser disable openvpn
768 ;;
769 *) pi openvpn;;
770 esac
771
772 m /a/bin/distro-setup/radicale-setup
773
774
775 ############# begin syncthing setup ###########
776 if [[ $HOSTNAME == frodo ]]; then
777 # It\'s simpler to just worry about running it in one place for now.
778 # I assume it would work to clone it\'s config to another non-phone
779 # and just run it in one place instead of the normal having a
780 # separate config. I lean toward using the same config, since btrfs
781 # syncs between comps.
782 # testing has relatively up to date packages
783 if ! isdebian-testing; then
784 # based on error when doing apt-get update:
785 # E: The method driver /usr/lib/apt/methods/https could not be found.
786 pi apt-transport-https
787 # google led me here:
788 # https://apt.syncthing.net/
789 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
790 s="deb http://apt.syncthing.net/ syncthing release"
791 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
792 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
793 p update
794 fi
795 fi
796 pi syncthing
797 m lnf -T /w/syncthing /home/iank/.config/syncthing
798 ser daemon-reload # syncthing likely not properly packaged
799 m sgo syncthing@iank # runs as iank
800
801 # these things persist in ~/.config/syncthing, which I save in
802 # /w/syncthing (not in /p, because syncthing should continue to
803 # run on home server even when using laptop as primary device)
804 # open http://localhost:8384/
805 # change listen address from default to tcp://:22001,
806 # this is because we do port forward so it doesn\'t have to use
807 # some external server, but the syncthing is broken for port forward,
808 # you get a message, something "like connected to myself, this should not happen"
809 # when connecting to other local devices, so I bump the port up by 1,
810 # based on
811 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
812 # Without this, it was being stuck syncing at 0%.
813 # Set gui username and password.
814 #
815 # install syncthing via f-droid,
816 # folder setting, turn off send only.
817 # on phone, add device, click bar code icon
818 # on dekstop, top right, actions, device id
819 # after adding, notification will appear on desktop to confirm
820 #
821 # syncing folder. from phone to desktop: select desktop in the
822 # folder on phone\'s sync options, notification will appear in
823 # desktop\'s web ui within a minute. For the reverse, the
824 # notification will appear in android\'s notifications, you have to
825 # swipe down and tap it to add the folder. It won\'t appear in the
826 # syncthing ui, which would be intuitive, but don\'t wait for it
827 # there. The notification may not work, instead open the web gui
828 # from in the app, there should be a notification within there.
829 #
830 # On phone, set settings to run syncthing all the time, and
831 # show no notification.
832 #
833 # Folder versioning would make sense if I didn\'t already use btrfs
834 # for backups. I would choose staggered, or trash can for more space.
835 #
836 # if needed to install on a remote comp:
837 # ssh -L 8384:localhost:8384 -N frodo
838 # open http://localhost:8384/
839 #
840 # Note, the other thing i did was port forward port 22000,
841 # per https://docs.syncthing.net/users/firewall.html
842
843 fi
844 ############# end syncthing setup ###########
845
846
847
848 ####### begin misc packages ###########
849
850 case $codename in
851 flidas)
852
853 ;;
854 esac
855
856
857 # sakura config is owned by ian
858 m reset-sakura
859 m reset-konsole
860 m sudo -u user2 -i reset-konsole
861 # user2 xscreensaver we don't want to reset
862 m reset-xscreensaver
863
864
865 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
866 # this is also in primary-setup
867 # pi libxss-dev # dependency based on build failure
868 # cabal update
869 # cabal install --upgrade-dependencies --force-reinstalls arbtt
870 # also, i assume syncing this between machines somehow messed thin
871 #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log
872
873 m primary-setup
874
875 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
876 m cp /p/.linphonerc-initial ~/.linphonerc
877 fi
878
879
880 ### begin spd install
881 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
882 t=$(mktemp)
883 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
884 s dpkg -i $t
885 m rm $t
886 # this guesses at the appropriate directory, adjust if needed
887 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
888 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
889 # newer distro had gpg2 as default, older one, flidas, need to make it that way
890 gpgpath=$(which gpg2)
891 if [[ $x ]]; then
892 s mkdir -p /usr/local/spdhackfix
893 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
894 fi
895 ### end spd install
896
897
898 # nagstamon setting which were set through the ui
899 # in filters tab:
900 # all unknown sources
901 # all warning services
902 # acknowledged hosts & services
903 # hosts & services down for maintenence
904 # services on down hosts
905 # services on hosts in maintenece
906 # services on unreachable osts
907 # hosts in soft state
908 # services in soft state
909 # in display tab: fullscreen
910
911 # these translate to these settings I think
912 # filter_acknowledged_hosts_services = True
913 # filter_all_unknown_services = True
914 # filter_all_warning_services = True
915 # filter_hosts_in_soft_state = True
916 # filter_hosts_services_maintenance = True
917 # filter_services_in_soft_state = True
918 # filter_services_on_down_hosts = True
919 # filter_services_on_hosts_in_maintenance = True
920 # filter_services_on_unreachable_hosts = True
921 # notify_if_up = False
922 # statusbar_floating = False
923 # fullscreen = True
924 # but i'm just going to rely on the webpage plus sms for now.
925
926
927 # it asks if it should make users in it's group capture packets without root,
928 # which is arguably more secure than running wireshark as root. default is no,
929 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
930 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
931
932 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
933 # listed in the default config as suggested.
934 # /run/usr/1000 i noticed was missing for pulseaudio
935 # /run/user/0 just seemed like a not bad idea, given the above
936 tu /etc/schroot/desktop/fstab <<'EOF'
937 /run /run none rw,bind 0 0
938 /run/lock /run/lock none rw,bind 0 0
939 /dev/shm /dev/shm none rw,bind 0 0
940 /run/shm /run/shm none rw,bind 0 0
941 /run/user/1000 /run/user/1000 none rw,bind 0 0
942 /run/user/1001 /run/user/1001 none rw,bind 0 0
943 /run/user/0 /run/user/0 none rw,bind 0 0
944 EOF
945
946 mkschroot() {
947 distro=$1
948 shift
949 case $distro in
950 ubuntu)
951 repo=http://archive.ubuntu.com/ubuntu/
952 ;;
953 debian)
954 repo=http://deb.debian.org/debian/
955 ;;
956 esac
957 n=$1
958 shift
959 if schroot -l | grep -xFq chroot:$n; then
960 echo "$0: $n schroot already installed, skipping"
961 return 0
962 fi
963 apps=($@)
964 d=/nocow/schroot/$n
965 sd /etc/schroot/chroot.d/$n.conf <<EOF
966 [$n]
967 description=$n
968 type=directory
969 directory=$d
970 profile=desktop
971 preserve-environment=true
972 users=$USER,user2
973 EOF
974 if [[ -e $d/bin ]]; then
975 s chroot $d apt-get update
976 s chroot $d apt-get -y dist-upgrade --purge --auto-remove
977 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
978 else
979 s mkdir -p $d
980
981 s debootstrap $n $d $repo
982 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
983 fi
984 s cp -P {,$d}/etc/localtime
985 }
986 sd /etc/systemd/system/schrootupdate.service <<'EOF'
987 [Unit]
988 Description=schrootupdate
989 After=multi-user.target
990
991 [Service]
992 Type=oneshot
993 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
994 EOF
995 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
996 [Unit]
997 Description=schrootupdate
998
999 [Timer]
1000 OnCalendar=*-*-* 04:20:00
1001
1002 [Install]
1003 WantedBy=timers.target
1004 EOF
1005 ser daemon-reload
1006 m sgo schrootupdate.timer
1007
1008
1009
1010 # for my roommate
1011 case $distro in
1012 trisquel)
1013 m mkschroot debian stretch firefox-esr pulseaudio chromium
1014 ;;
1015 debian)
1016 pi chromium
1017 ;;
1018 esac
1019
1020 s mkdir -p /nocow/user
1021 s chown $USER:$USER /nocow/user
1022 pi anki
1023
1024
1025 ####### begin transmission
1026
1027 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1028 # 450 seems likely to be unused. we need to specify one or else
1029 # it won't be stable across installs.
1030 if ! getent passwd debian-transmission > /dev/null; then
1031 s groupadd -g 450 debian-transmission
1032 s adduser --quiet \
1033 --gid 450 \
1034 --uid 450 \
1035 --system \
1036 --no-create-home \
1037 --disabled-password \
1038 --home /var/lib/transmission-daemon \
1039 debian-transmission
1040 fi
1041 # We want group writable stuff from transmission.
1042 # However, after setting this, I learn that transmission sets it's
1043 # own umask based on it's settings file. Well, no harm leaving this
1044 # so it's set right from the beginning.
1045 s chfn debian-transmission -o umask=0002
1046
1047 # note i had to do this, which is persistent:
1048 # cd /i/k
1049 # s chgrp debian-transmission torrents partial-torrents
1050
1051 # syslog says things like
1052 # 'Failed to set receive buffer: requested 4194304, got 425984'
1053 # google suggets giving it even more than that
1054 tu /etc/sysctl.conf<<'EOF'
1055 net.core.rmem_max = 67108864
1056 net.core.wmem_max = 16777216
1057 EOF
1058 s sysctl -p
1059
1060 # some reason it doesn\'t seem to start automatically anyways
1061 pi-nostart transmission-daemon
1062 # be extra sure its not started
1063 ser disable transmission-daemon
1064 ser stop transmission-daemon
1065
1066 # the folder was moved here after an install around 02/2017.
1067 # it contains runtime data,
1068 # plus a simple symlink to the config file which it\'s
1069 # not worth separating out.
1070 # between comps, the uid can change
1071 f=/i/transmission-daemon
1072 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1073 if [[ -e $f ]]; then
1074 s chown -R debian-transmission:debian-transmission $f
1075 fi
1076 for f in /i/k/partial-torrents /i/k/torrents; do
1077 if [[ -e $f ]]; then
1078 s chown -R debian-transmission:user2 $f
1079 fi
1080 done
1081 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1082 #
1083 # config file documented here, and it\'s the same config
1084 # for daemon vs client, so it\'s documented in the gui.
1085 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1086 #
1087 # I originaly setup rpc-whitelist, but after using
1088 # routing to a network namespace, it doesn\'t see the
1089 # real source address, so it\'s disabled.
1090 #
1091 # Changed the cache-size to 256 mb, reduces disk use.
1092 # It is a read & write cache.
1093 #
1094 s ruby <<'EOF'
1095 require 'json'
1096 p = '/etc/transmission-daemon/settings.json'
1097 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1098 'rpc-whitelist-enabled' => false,
1099 'rpc-authentication-required' => false,
1100 'incomplete-dir' => '/i/k/partial-torrents',
1101 'incomplete-dir-enabled' => true,
1102 'download-dir' => '/i/k/torrents',
1103 "speed-limit-up" => 800,
1104 "speed-limit-up-enabled" => true,
1105 "peer-port" => 61486,
1106 "cache-size-mb" => 256,
1107 "ratio-limit" => 5.0,
1108 "ratio-limit-enabled" => true,
1109 })) + "\n")
1110 EOF
1111 ####### end transmission
1112
1113
1114
1115 # trisquel 8 = openvpn, debian stretch = openvpn-client
1116 vpn_ser=openvpn-client
1117 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1118 vpn_ser=openvpn
1119 fi
1120
1121 sd /etc/systemd/system/transmission-daemon-nn.service <<EOF
1122 [Unit]
1123 Description=Transmission BitTorrent Daemon netns
1124 After=network.target
1125 Requires=${vpn_ser}-nn@client.service
1126 After=${vpn_ser}-nn@client.service
1127 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1128
1129 [Service]
1130 #User=debian-transmission
1131 # notify type doesn't work with sudo
1132 #Type=notify
1133 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1134 ExecReload=/bin/kill -s HUP \$MAINPID
1135 PrivateNetwork=true
1136 Nice=19
1137
1138 [Install]
1139 WantedBy=multi-user.target
1140 EOF
1141 ser daemon-reload
1142
1143 if [[ $HOSTNAME == frodo ]]; then
1144 m sgo transmission-daemon-nn
1145 fi
1146
1147
1148 ######### begin transmission client setup ######
1149
1150 if [[ -e /p/transmission-rpc-pass ]]; then
1151 # arch had a default config,
1152 # debian had nothing until you start it.
1153 # With a little trial an error, here is a minimal config
1154 # taken from the generated one, plus changes that the
1155 # settings ui does, without a bunch of ui crap settings.
1156 #
1157 # only settings I set were
1158 # hostname
1159 # auto-connect
1160 # password
1161
1162 # the password is randomly generated on first run, i copied it out
1163 # so it could be used by other hosts.
1164 s ruby <<'EOF'
1165 require 'json'
1166 p = '/etc/transmission-daemon/settings.json'
1167 s = JSON.parse(File.read(p))
1168 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1169 # default is 0022 (18 in decimal)
1170 s["umask"] = 2
1171 File.write p, JSON.pretty_generate(s)
1172 EOF
1173
1174 rpc_pass=$(</p/transmission-rpc-pass)
1175 for f in /home/*; do
1176 u=${f##*/}
1177 uid=$(id -u $u 2>/dev/null) || continue
1178 if [[ ! $uid -ge 1000 ]]; then
1179 continue
1180 fi
1181 d=$f/.config/transmission-remote-gtk
1182 s -u $u mkdir -p $d
1183 s -u $u dd of=$d/config.json <<EOF
1184 {
1185 "profiles" : [
1186 {
1187 "profile-name" : "Default",
1188 "hostname" : "transmission.b8.nz",
1189 "rpc-url-path" : "/transmission/rpc",
1190 "username" : "",
1191 "password" : "$rpc_pass",
1192 "auto-connect" : true,
1193 "ssl" : false,
1194 "timeout" : 40,
1195 "retries" : 3,
1196 "update-active-only" : false,
1197 "activeonly-fullsync-enabled" : false,
1198 "activeonly-fullsync-every" : 2,
1199 "update-interval" : 3,
1200 "min-update-interval" : 3,
1201 "session-update-interval" : 60,
1202 "exec-commands" : [
1203 ],
1204 "destinations" : [
1205 ]
1206 }
1207 ],
1208 "profile-id" : 0,
1209 "add-options-dialog" : false
1210 }
1211 EOF
1212 done
1213 fi
1214 ######### end transmission client setup ######
1215
1216
1217 ### printer setup
1218 pi cups hplip
1219 s gpasswd -a $USER lpadmin # based on ubuntu wiki
1220 # goto http://127.0.0.1:631
1221 # administration tab, add new printer button.
1222 # In debian, I could use hte recommended driver,
1223 # in arch, I had to pick out the 6L driver.
1224
1225
1226 # allow user to run vms, from debian handbook
1227 for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
1228 # bridge networking as user fails. google lead here, but it doesn\'t work:
1229 # oh well, I give up.
1230 # http://wiki.qemu.org/Features-Done/HelperNetworking
1231 # s mkdir /etc/qemu
1232 # f=/etc/qemu/bridge.conf
1233 # sd $f <<'EOF'
1234 # allow br0
1235 # EOF
1236 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1237 # s chmod 640 $f
1238
1239 # general known for debian/ubuntu, not for fedora
1240
1241 m /a/bin/buildscripts/go
1242 m /a/bin/buildscripts/rust
1243 m /a/bin/buildscripts/misc
1244
1245 pi-nostart virtinst virt-manager
1246
1247
1248
1249 pi --no-install-recommends kdeconnect
1250 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1251 ### but gnome + xmonad not working in flidas, so i disabled it
1252 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1253 # cd /a/opt/indicator-kdeconnect
1254 # mkdir -p build
1255 # cd build
1256 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1257 # make
1258 # sudo make install
1259 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1260 # # it seems, according to
1261 # # /etc/xdg/autostart/kdeconnectd.desktop
1262 # # I'm not seeing the icon, but the clipboard replication is working
1263
1264
1265 ### model 01 arduino support ###
1266 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1267 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1268 # set arduino var in bashrc,
1269 # have system config file setup too.
1270 s adduser $USER dialout
1271
1272 # this is for the mail command too. update-alternatives is kind of misleading
1273 # since at least it's main commands pretend mail does not exist.
1274 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1275 s update-alternatives --set mailx /usr/bin/mail.mailutils
1276
1277 ######### end misc packages #########
1278
1279
1280 # packages I once used before and liked, but don\'t want installed now for
1281 # various reasons:
1282 # python-sqlite is used for offlineimap
1283 # lxappearance python-sqlite dolphin paman dconf-editor
1284
1285
1286
1287 ######## unfinished
1288
1289 # todo, finish configuring smart.
1290
1291 pi smartmontools
1292 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1293 # turn on smart. background on options:
1294 # first line, -a = test everyting on all devices.
1295 # -S on, turn on disk internal saving of vendor specific info,
1296 # from google, seems like this is usually already on and fairly standard.
1297 # -o on, turn on 4 hour period non-performance degrading testing.
1298 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1299 sched="-s (S/../.././02|L/../../6/03)"
1300 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1301 DEVICESCAN -a -o on -S on -n standby,q $sched \
1302 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1303
1304 # in the default configuration of at least ubuntu 14.04, resolvconf is
1305 # configured to order any nameservers associated with tun* or tap*
1306 # before the normal internet interfaces, which means they are always
1307 # consulted first. This is often slower and undesirable, ie. local dns
1308 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1309 # can do:
1310 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1311 # however, this breaks dns lookup for hosts on the openvpn lan.
1312 # I can\'t figure out why hosts on the normal lan would not be
1313 # broken under the default ordering, except the host I was
1314 # testing with previously had an entry in /etc/hosts.
1315
1316 ############# end unfinished
1317
1318 ########### misc stuff
1319
1320 # make networkmanager use resolvconf instead of its own dnsmasq which
1321 # conflicts with the normal dnsmasq package.
1322 f=/etc/NetworkManager/NetworkManager.conf
1323 m=$(md5sum $f)
1324 s sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1325 if [[ $m != $(md5sum $f) ]]; then
1326 srestart NetworkManager
1327 fi
1328
1329 # make my /etc/fonts/conf.d/ get used.
1330 # I have a new sans-serif font there because the default one
1331 # displays l and I as the same char, grrrrr.
1332 s fc-cache
1333
1334 m /a/bin/distro-setup/mymimes
1335
1336
1337 m sgo dynamicipupdate
1338
1339
1340 # stop autopoping windows when i plug in an android phone.
1341 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1342 # with still 0 exit code.
1343 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1344 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1345
1346
1347 # on grub upgrade, we get prompts unless we do this
1348 devs=()
1349 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1350 devs+=("$(devbyid $dev),")
1351 done
1352 devs[-1]=${devs[-1]%,} # jonied by commas
1353 s debconf-set-selections <<EOF
1354 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1355 EOF
1356
1357 # btrfs maintenance
1358 sgo btrfsmaint.timer
1359 sgo btrfsmaintstop.timer
1360
1361 # aren't autoupdating this, but I do check on it somewhat regularly.
1362 m cd /a/opt/btrbk
1363 s make install
1364
1365 m sgo btrbk.timer
1366 # note: to see when it was last run,
1367 # ser list-timers
1368
1369
1370 end_msg <<'EOF'
1371 In mate settings settings, change scrolling to two-finger,
1372 because the default edge scroll doesn\'t work. Originally found this in debian.
1373 EOF
1374
1375 # Remove dep that came in with desktop to fix associations.
1376 m pu transmission-gtk
1377
1378 s gpasswd -a iank adm #needed for reading logs
1379
1380 m /a/bin/buildscripts/pithosfly
1381
1382
1383 # # Based on guix manual instructions, also added code to profile.
1384 # # disabled since i'm not using it now.
1385 # pi nscd
1386 # if ! type -p guix >/dev/null; then
1387 # cd $(mktemp -d)
1388 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1389 # # added some stuff to envonment.sh for profile based on
1390 # # manual instructions
1391 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1392 # # echo is to get past prompt
1393 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1394 # guix install glibc-utf8-locales
1395 # guix package --install guile
1396 # fi
1397
1398
1399
1400 pi tor
1401 m /a/bin/buildscripts/tor-browser
1402
1403 # nfs server
1404 pi-nostart nfs-kernel-server
1405
1406 # networkmanager has this nasty behavior on flidas: if the machine
1407 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1408 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1409 # nameservers.
1410 # This can be manually fixed by stoping dnsmasq,
1411 # then based on whats in /run/dnsmasq/, i see we can run
1412 # s resolvconf -d NetworkManager
1413 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1414 ser stop NetworkManager
1415 ser disable NetworkManager
1416
1417
1418 if [[ $HOSTNAME == frodo ]]; then
1419 # nohide = export filesystems mounted deeper than the export point
1420 # fsid=0 makes this export the "root" export
1421 # not documented in the man page, but this means
1422 # 1. it can be mounted with a shorthand of server:/
1423 # 2. exports that are subdirectories of this one will automatically be mounted
1424 tu /etc/exports <<'EOF'
1425 /k 10.0.0.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1426 EOF
1427 s exportfs -rav
1428 fi
1429
1430
1431
1432
1433
1434 # if I was going to create a persistent vm, i might do it like this:
1435 # variant=something # from: virt-install --os-variant list
1436 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1437 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1438 # -n some_name --import --os-variant $variant --cpu host-model-only
1439
1440
1441
1442 ######### begin stuff belonging at the end ##########
1443
1444 end