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