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