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