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