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