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