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