2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4 if [[ -s ~
/.bashrc
]];then . ~
/.bashrc
;fi
7 source /a
/bin
/errhandle
/err
8 src
="$(readlink -f -- "${BASH_SOURCE[0]}")"; src
=${src%/*} # directory of this file
10 if [[ $EUID == 0 ]]; then
11 echo "$0: error: run as regular user" >&2
16 echo 1 >~
/.local
/distro-end
19 # shellcheck source=./pkgs
22 echo "$0: $(date) starting now)"
23 # see example of usage to understand.
26 IFS
= read -r -d '' y ||
:
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"
37 echo "$0: $(date): ending now)"
38 echo "exiting with status 0"
44 printf "$pre %s\n" "$*"
45 SUDOD
="$PWD" command sudo
"$@";
48 sudo
dd of
="$1" 2>/dev
/null
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; }
54 codename
=$
(debian-codename
)
55 codename_compat
=$
(debian-codename-compat
)
57 sed="sed --follow-symlinks"
69 sudo debconf-set-selections
<<EOF
70 popularity-contest popularity-contest/participate boolean true
73 ########### begin section including linode ################
79 # no equivalent in other distros:
80 if isdeb
&& pcheck apt-file
; then
81 # this condition is just a speed optimization
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
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
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 ||
:
120 pi python-certbot-apache
122 err
"distro unknown for certbot"
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,
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,
133 sgo certbotmail.timer
134 ### end certbot install ###
137 # dogcam setup. not using atm
140 # /a/bin/webcam/install-server
143 # /a/bin/webcam/install-client
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
158 # AuthName "Authentication Required"
159 # # setup one time, with root:www-data, 640
160 # AuthUserFile "/etc/prometheus-htpasswd"
167 ######### begin flidas pinned packages ######
168 case $
(debian-codename
) in
169 # needed for debootstrap scripts for fai since fai requires debian
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
174 Pin: release a=xenial
178 Pin: release a=xenial-updates
182 Pin: release a=xenial-security
186 Pin: release n=xenial
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
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
199 Pin: release a=bionic
203 Pin: release a=bionic-updates
207 Pin: release a=bionic-security
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
219 Package: btrfs-progs libzstd1
220 Pin: release a=bionic-updates
223 Package: btrfs-progs libzstd1
224 Pin: release a=bionic-security
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
235 f
=/etc
/apt
/sources.list.d
/bionic.list
236 if ! diff -q $t $f; then
242 # no special reason, but its better for btrfs-progs to
243 # be closer to our kernel version
246 if [[ ! -e /usr
/share
/debootstrap
/scripts
/xenial
]]; then
249 m aptitude download debootstrap
/xenial
251 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
254 sd
/etc
/apt
/preferences.d
/flidas-etiona
<<EOF
256 Pin: release a=etiona
260 Pin: release a=etiona-updates
264 Pin: release a=etiona-security
268 Pin: release a=etiona-backports
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
279 f
=/etc
/apt
/sources.list.d
/etiona.list
280 if ! diff -q $t $f; then
286 sd
/etc
/apt
/preferences.d
/debian-goodies
<<EOF
287 Package: debian-goodies
288 Pin: release n=etiona
293 sd
/etc
/apt
/preferences.d
/flidas-buster
<<EOF
295 Pin: release n=buster
299 Pin: release n=buster-updates
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
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";
312 f
=/etc
/apt
/sources.list.d
/buster.list
316 # deb http://http.us.debian.org/debian buster main
317 # deb-src http://http.us.debian.org/debian buster main
319 # deb http://security.debian.org/ buster/updates main
320 # deb-src http://security.debian.org/ buster/updates main
322 # deb http://http.us.debian.org/debian buster-updates main
323 # deb-src http://http.us.debian.org/debian buster-updates main
325 # if ! diff -q $t $f; then
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.
336 sd
/etc
/apt
/preferences.d
/shellcheck
<<EOF
338 Pin: release a=etiona
342 Pin: release a=etiona-updates
346 Pin: release a=etiona-security
350 sd
/etc
/apt
/preferences.d
/bash
<<EOF
352 Pin: release a=etiona
356 Pin: release a=etiona-updates
360 Pin: release a=etiona-security
368 pi debian-goodies shellcheck
372 ######### end flidas pinned packages ######
374 ##### begin automatic upgrades (after checkrestart has been installed) ####
375 sd
/etc
/apt
/apt.conf.d
/10periodic
<<'EOF'
376 # this file was mostly just comments.
377 APT::Periodic::Update-Package-Lists "1";
378 APT::Periodic::Download-Upgradeable-Packages "1";
379 APT::Periodic::AutocleanInterval "7";
380 APT::Periodic::Unattended-Upgrade "1";
383 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
384 # fyi: default file has comments about available options,
385 # you may want to read that, do pkx unattended-upgrades
386 Unattended-Upgrade::Mail "root";
387 Unattended-Upgrade::MailOnlyOnError "true";
388 Unattended-Upgrade::Remove-Unused-Dependencies "true";
389 Unattended-Upgrade::Origins-Pattern {
390 # default is just security updates. this list found from reading
391 # match_whitelist_string() in $(which unattended-upgrades)
392 "o=*,l=*,a=*,c=*,site=*,n=*";
396 # old names, too verbose
397 sudo
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
399 sd
/etc
/cron.d
/myupgrade
<<'EOF'
400 # Setup reboots when running outdated stuff, unattended upgrades happen
401 # at 6 am + rand(60 min).
405 # default is /usr/bin:/bin
406 PATH=/usr/bin:/bin:/usr/local/bin
407 20 7 * * * iank myupgrade |& log-once -1 myupgrade
408 0 * * * * root mycheckrestart |& log-once -1 mycheckrestart
410 ##### end automatic upgrades ####
414 ###### begin website setup
418 f
=/var
/lib
/bind
/db.b8.nz
419 if [[ ! -e $f ]]; then
422 sudo
install -m 644 -o bind -g bind /p
/c
/machine_specific
/linode
/bind-initial
/db.b8.nz
$f
427 # setup let's encrypt cert
428 m web-conf apache2 l2.b8.nz
429 sudo
rm -fv /etc
/apache
2/sites-enabled
/l2.b8.nz
{,-redir}.conf
431 s lnf
-T /etc
/letsencrypt
/live
/l2.b8.nz
/fullchain.pem
/etc
/exim
4/exim.crt
432 if [[ ! -L /etc
/exim
4/exim.key
]]; then
433 s lnf
-T /etc
/letsencrypt
/live
/l2.b8.nz
/privkey.pem
/etc
/exim
4/exim.key
442 m
/a
/h
/setup.sh iankelling.org
445 m
/a
/h
/setup.sh
-s b8.nz
448 # allow symlinks on non-main hosts so i can host files in arbitrary paths
449 m
/a
/h
/setup.sh
-s -p 80
454 # start mumble only when im going to use it, since i dont use it much
455 pi-nostart mumble-server
456 sudo
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
458 # do certificate to avoid warning about unsigned cert,
459 # which is overkill for my use, but hey, I'm cool, I know
461 m web-conf apache2 mumble.iankelling.org
462 sudo
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
464 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
465 /a/bin/distro-setup/certbot-renew-hook
469 # requested from linode via a support ticket.
470 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
471 # ipv6 stuff pieced together
472 # via slightly wrong information from
473 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
474 # https://community.openvpn.net/openvpn/wiki/IPv6
477 m vpn-server-setup
-rd 2600:3c00
:e000
:280::1/64 2600:3c00
::f03c
:91ff
:feb4
:0bf3
478 sudo
tee /etc
/openvpn
/client-config
/mail <<'EOF'
479 ifconfig-push 10.8.0.4 255.255.255.0
480 ifconfig-ipv6-push 2600:3c00:e000:280::2/64
483 if [[ -e /lib
/systemd
/system
/openvpn-server@.service
]]; then
484 vpn_service
=openvpn-server@server
486 vpn_service
=openvpn@server
489 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
491 Description=Turns on iptables mail nat
496 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
497 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
500 WantedBy=$vpn_service.service
504 # needed for li's local mail delivery.
505 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
507 # setup let's encrypt cert
508 m web-conf apache2 mail.iankelling.org
509 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
512 domain=cal.iankelling.org
513 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
514 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
515 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
517 Options +FollowSymLinks +Multiviews +Indexes
520 AuthName "Authentication Required"
521 # setup one time, with root:www-data, 640
522 AuthUserFile "/etc/caldav-htpasswd"
526 # nginx version of above would be:
527 # auth_basic "Not currently available";
528 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
532 ###### begin znc setup #####
535 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
536 # to get into the web interface,
537 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
538 # https://iankelling.org:12533/
540 export RENEWED_LINEAGE=/etc/letsencrypt/live/iankelling.org
541 /a/bin/distro-setup/certbot-renew-hook
544 # znc config generated by doing
546 # selected port is also used in erc config
547 # comma separated channel list worked.
548 # while figuring things out, running znc -D for debug in foreground.
549 # to exit and save config:
550 # /msg *status shutdown
551 # configed auth on freenode by following
552 # https://wiki.znc.in/Sasl:
553 # /msg *sasl RequireAuth yes
554 # /msg *sasl Mechanism PLAIN
555 # /msg *sasl Set ident_name password
556 # created the system service after, and had to do
557 # mv /home/iank/.znc/* /var/lib/znc
558 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
559 # and made a copy of the config files into /p/c
560 # /msg *status LoadMod --type=global log -sanitize
561 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
562 # /msg *status LoadMod --type=network perform
563 # /msg *perform add PRIVMSG ChanServ :invite #fsf-office
564 # /msg *perform add JOIN #fsf-office
567 # also ran /znc LoadMod clearbufferonmsg
568 # it would be nice if erc supported erc query buffers by doing
569 # /msg *status clearbuffer <name of the query/receiver
571 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
572 # if that was the case i could remove the module clearbufferonmsg
573 # also would be nice if erc supported
574 # https://wiki.znc.in/self-message
575 # https://wiki.znc.in/Query_buffers \
577 if ! getent passwd znc > /dev/null; then
578 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
580 sudo chmod 700 /var/lib/znc
581 sudo chown -R znc:znc /var/lib/znc
582 # Avoid restarting if possible, reconnecting to irc is annoying.
583 # The unit file was made active with conflink.
584 # Note, avoid using ser here because we wrap sudo to prints the command first.
585 if [[ $(systemctl is-active znc) != active ]]; then
588 ###### stop znc setup #####
593 ###### end website setup
595 ########### end section including li/lj ###############
598 case $codename_compat in
600 # mate-indicator-applet and beyond are msc things I noticed diffing a
601 # standard install with mine.
602 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
608 # mate doesnt have wayland support yet
609 pi task-gnome-desktop
613 # by default, it sleeps when not logged in to x/wayland and on ac power.
615 sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
616 systemctl --user stop gvfs-daemon
617 systemctl --user disable gvfs-daemon
622 if [[ $codename_compat == flidas ]]; then
623 # doesnt exist in newer
627 # abrowser is not in etiona yet, abrowser version is 68,
628 # abrowser won't run on a firefox profile that was on firefox
629 # version 70. firefox in ubuntu is at version 70.
630 # have to rm compabibility.ini to even try downgrade.
632 sudo update-alternatives --set x-www-browser /usr/bin/firefox
634 # TODO: some of the X programs can be removed from pall when using wayland
636 # depends gcc is a way to install suggests. this is apparently the only
637 # way to install suggests even if the main package is already
638 # installed. reinstall doesn't work, uninstalling can cause removing
639 # dependent packages.
640 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)
643 # website is dead june 14 2019. back in october, but meh
644 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
649 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
652 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
653 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
655 # f=/etc/apt/sources.list.d/iridium-browser.list
656 # if ! diff -q $t $f; then
666 ### begin home vpn server setup
669 # # this section done initially to make persistent keys.
670 # # Also note, I temporarily set /etc/hosts so my host was
671 # # b8.nz when running this, since the vpn client config
672 # # generator assumes we need to go to that server to get
674 # vpn-server-setup -rds
675 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
676 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
677 # # kw = kgpe work machine.
678 # for host in x2 x3 kw; do
679 # vpn-mk-client-cert -b $host -n home b8.nz 1196
680 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
682 # s bash -c "cp /etc/openvpn/client/home* $dir"
683 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
686 # key already exists, so this won't generate one, just the configs.
687 m vpn-server-setup -rds
688 sudo tee -a /etc/openvpn/server/server.conf <<'EOF'
689 push "dhcp-option DNS 10.0.0.1"
690 push "route 10.0.0.0 255.255.0.0"
691 client-connect /a/bin/distro-setup/vpn-client-connect
693 sudo sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
695 if [[ $HOSTNAME == tp ]]; then
696 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
697 vpn_service=openvpn-server@server
699 vpn_service=openvpn@server
703 ### end vpn server setup
707 # note, see bashrc for more documentation.
709 sd /etc/systemd/system/rss2email.service <<'EOF'
711 Description=rss2email
712 After=multi-user.target
717 # about 24 hours of failures
718 # it copies over its files without respecting symlinks, so
719 # we pass options to use different location.
720 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
722 sd /etc/systemd/system/rss2email.timer <<'EOF'
724 Description=rss2email
727 # for initial run. required.
729 # for subsequent runs.
730 OnUnitInactiveSec=300
733 WantedBy=timers.target
735 sudo systemctl daemon-reload
738 ######### begin pump.io periodic backup #############
739 if [[ $HOSTNAME == frodo ]]; then
740 sd /etc/systemd/system/pumpbackup.service <<'EOF'
742 Description=pump li backup
743 After=multi-user.target
748 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
750 sd /etc/systemd/system/pumpbackup.timer <<'EOF'
752 Description=pump li backup hourly
758 WantedBy=timers.target
763 ######### end pump.io periodic backup #############
766 ######### begin irc periodic backup #############
767 if [[ $HOSTNAME == frodo ]]; then
768 sd /etc/systemd/system/ircbackup.service <<'EOF'
770 Description=irc li backup
771 After=multi-user.target
776 ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
778 sd /etc/systemd/system/ircbackup.timer <<'EOF'
780 Description=irc li backup hourly
786 WantedBy=timers.target
788 sudo systemctl daemon-reload
793 ######### end irc periodic backup #############
797 debian|trisquel|ubuntu)
798 # suggests resolvconf package. installing it here is redundant, but make sure anyways.
799 # todo: check other distros to make sure it\'s installed
800 pi-nostart openvpn resolvconf
801 # pi-nostart does not disable
807 m /a/bin/distro-setup/radicale-setup
810 ############# begin syncthing setup ###########
811 if [[ $HOSTNAME == frodo ]]; then
812 # It\'s simpler to just worry about running it in one place for now.
813 # I assume it would work to clone it\'s config to another non-phone
814 # and just run it in one place instead of the normal having a
815 # separate config. I lean toward using the same config, since btrfs
816 # syncs between comps.
817 # testing has relatively up to date packages
818 if ! isdebian-testing; then
819 # based on error when doing apt-get update:
820 # E: The method driver /usr/lib/apt/methods/https could not be found.
821 pi apt-transport-https
822 # google led me here:
823 # https://apt.syncthing.net/
824 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
825 s="deb http://apt.syncthing.net/ syncthing release"
826 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
827 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
832 m lnf -T /w/syncthing /home/iank/.config/syncthing
833 ser daemon-reload # syncthing likely not properly packaged
834 sgo syncthing@iank # runs as iank
836 # these things persist in ~/.config/syncthing, which I save in
837 # /w/syncthing (not in /p, because syncthing should continue to
838 # run on home server even when using laptop as primary device)
839 # open http://localhost:8384/
840 # change listen address from default to tcp://:22001,
841 # this is because we do port forward so it doesn\'t have to use
842 # some external server, but the syncthing is broken for port forward,
843 # you get a message, something "like connected to myself, this should not happen"
844 # when connecting to other local devices, so I bump the port up by 1,
846 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
847 # Without this, it was being stuck syncing at 0%.
848 # Set gui username and password.
850 # install syncthing via f-droid,
851 # folder setting, turn off send only.
852 # on phone, add device, click bar code icon
853 # on dekstop, top right, actions, device id
854 # after adding, notification will appear on desktop to confirm
856 # syncing folder. from phone to desktop: select desktop in the
857 # folder on phone\'s sync options, notification will appear in
858 # desktop\'s web ui within a minute. For the reverse, the
859 # notification will appear in android\'s notifications, you have to
860 # swipe down and tap it to add the folder. It won\'t appear in the
861 # syncthing ui, which would be intuitive, but don\'t wait for it
862 # there. The notification may not work, instead open the web gui
863 # from in the app, there should be a notification within there.
865 # On phone, set settings to run syncthing all the time, and
866 # show no notification.
868 # Folder versioning would make sense if I didn\'t already use btrfs
869 # for backups. I would choose staggered, or trash can for more space.
871 # if needed to install on a remote comp:
872 # ssh -L 8384:localhost:8384 -N frodo
873 # open http://localhost:8384/
875 # Note, the other thing i did was port forward port 22000,
876 # per https://docs.syncthing.net/users/firewall.html
879 ############# end syncthing setup ###########
883 ####### begin misc packages ###########
892 # sakura config is owned by ian
895 m sudo -u user2 -i reset-konsole
896 # user2 xscreensaver we don't want to reset
900 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
901 # this is also in primary-setup
902 # pi libxss-dev # dependency based on build failure
904 # cabal install --upgrade-dependencies --force-reinstalls arbtt
905 # also, i assume syncing this between machines somehow messed thin
906 #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log
910 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
911 m cp /p/.linphonerc-initial ~/.linphonerc
915 ### begin spd install
916 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
918 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
921 # this guesses at the appropriate directory, adjust if needed
922 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
923 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
924 # newer distro had gpg2 as default, older one, flidas, need to make it that way
925 gpgpath=$(which gpg2)
927 sudo mkdir -p /usr/local/spdhackfix
928 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
933 # nagstamon setting which were set through the ui
935 # all unknown sources
936 # all warning services
937 # acknowledged hosts & services
938 # hosts & services down for maintenence
939 # services on down hosts
940 # services on hosts in maintenece
941 # services on unreachable osts
942 # hosts in soft state
943 # services in soft state
944 # in display tab: fullscreen
946 # these translate to these settings I think
947 # filter_acknowledged_hosts_services = True
948 # filter_all_unknown_services = True
949 # filter_all_warning_services = True
950 # filter_hosts_in_soft_state = True
951 # filter_hosts_services_maintenance = True
952 # filter_services_in_soft_state = True
953 # filter_services_on_down_hosts = True
954 # filter_services_on_hosts_in_maintenance = True
955 # filter_services_on_unreachable_hosts = True
956 # notify_if_up = False
957 # statusbar_floating = False
959 # but i'm just going to rely on the webpage plus sms for now.
962 # it asks if it should make users in it's group capture packets without root,
963 # which is arguably more secure than running wireshark as root. default is no,
964 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
965 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
967 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
968 # listed in the default config as suggested.
969 # /run/usr/1000 i noticed was missing for pulseaudio
970 # /run/user/0 just seemed like a not bad idea, given the above
971 tu /etc/schroot/desktop/fstab <<'EOF'
972 /run /run none rw,bind 0 0
973 /run/lock /run/lock none rw,bind 0 0
974 /dev/shm /dev/shm none rw,bind 0 0
975 /run/shm /run/shm none rw,bind 0 0
976 /run/user/1000 /run/user/1000 none rw,bind 0 0
977 /run/user/1001 /run/user/1001 none rw,bind 0 0
978 /run/user/0 /run/user/0 none rw,bind 0 0
986 repo=http://archive.ubuntu.com/ubuntu/
989 repo=http://deb.debian.org/debian/
994 if schroot -l | grep -xFq chroot:$n; then
995 echo "$0: $n schroot already installed, skipping"
1000 sd /etc/schroot/chroot.d/$n.conf <<EOF
1006 preserve-environment=true
1009 if [[ -e $d/bin ]]; then
1010 sudo chroot $d apt-get update
1011 sudo chroot $d apt-get -y dist-upgrade --purge --auto-remove
1012 cd; sudo schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1016 sudo debootstrap $n $d $repo
1017 cd; sudo schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1019 sudo cp -P {,$d}/etc/localtime
1021 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1023 Description=schrootupdate
1024 After=multi-user.target
1028 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1030 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1032 Description=schrootupdate
1035 OnCalendar=*-*-* 04:20:00
1038 WantedBy=timers.target
1041 sgo schrootupdate.timer
1048 m mkschroot debian stretch firefox-esr pulseaudio chromium
1055 sudo mkdir -p /nocow/user
1056 sudo chown $USER:$USER /nocow/user
1060 ####### begin transmission
1071 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1072 # 450 seems likely to be unused. we need to specify one or else
1073 # it won't be stable across installs.
1074 if ! getent passwd debian-transmission > /dev/null; then
1075 sudo groupadd -g 450 debian-transmission
1076 sudo adduser --quiet \
1081 --disabled-password \
1082 --home /var/lib/transmission-daemon \
1085 # We want group writable stuff from transmission.
1086 # However, after setting this, I learn that transmission sets it's
1087 # own umask based on it's settings file. Well, no harm leaving this
1088 # so it's set right from the beginning.
1089 sudo chfn debian-transmission -o umask=0002
1091 # note i had to do this, which is persistent:
1093 # s chgrp debian-transmission torrents partial-torrents
1095 # syslog says things like
1096 # 'Failed to set receive buffer: requested 4194304, got 425984'
1097 # google suggets giving it even more than that
1098 tu /etc/sysctl.conf<<'EOF'
1099 net.core.rmem_max = 67108864
1100 net.core.wmem_max = 16777216
1104 # some reason it doesn\'t seem to start automatically anyways
1105 pi-nostart transmission-daemon
1106 # be extra sure its not started
1107 ser disable transmission-daemon
1108 ser stop transmission-daemon
1110 # the folder was moved here after an install around 02/2017.
1111 # it contains runtime data,
1112 # plus a simple symlink to the config file which it\'s
1113 # not worth separating out.
1114 # between comps, the uid can change
1115 f=$tdir/transmission-daemon
1117 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1118 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1119 sudo chown -R debian-transmission:debian-transmission $f
1120 for f in $tdir/partial-torrents $tdir/torrents; do
1121 if [[ -e $f ]]; then
1122 sudo chown -R debian-transmission:user2 $f
1125 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1127 # config file documented here, and it\'s the same config
1128 # for daemon vs client, so it\'s documented in the gui.
1129 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1131 # I originaly setup rpc-whitelist, but after using
1132 # routing to a network namespace, it doesn\'t see the
1133 # real source address, so it\'s disabled.
1135 # Changed the cache-size to 256 mb, reduces disk use.
1136 # It is a read & write cache.
1139 p = '/etc/transmission-daemon/settings.json'
1140 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1141 'rpc-whitelist-enabled' => false,
1142 'rpc-authentication-required' => false,
1143 'incomplete-dir' => '$tdir/partial-torrents',
1144 'incomplete-dir-enabled' => true,
1145 'download-dir' => '$tdir/torrents',
1146 "speed-limit-up" => 800,
1147 "speed-limit-up-enabled" => true,
1148 "peer-port" => 61486,
1149 "cache-size-mb" => 256,
1150 "ratio-limit" => 5.0,
1151 "ratio-limit-enabled" => true,
1154 ####### end transmission
1158 # trisquel 8 = openvpn, debian stretch = openvpn-client
1159 vpn_ser=openvpn-client
1160 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1164 sd /etc/systemd/system/transmission-daemon-nn.service <<EOF
1166 Description=Transmission BitTorrent Daemon netns
1167 After=network.target
1168 Requires=${vpn_ser}-nn@client.service
1169 After=${vpn_ser}-nn@client.service
1170 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1173 #User=debian-transmission
1174 # notify type doesn't work with sudo
1176 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1177 ExecReload=/bin/kill -s HUP \$MAINPID
1182 WantedBy=multi-user.target
1186 if [[ $HOSTNAME == frodo ]]; then
1187 sgo transmission-daemon-nn
1191 ######### begin transmission client setup ######
1193 if [[ -e /p/transmission-rpc-pass ]]; then
1194 # arch had a default config,
1195 # debian had nothing until you start it.
1196 # With a little trial an error, here is a minimal config
1197 # taken from the generated one, plus changes that the
1198 # settings ui does, without a bunch of ui crap settings.
1200 # only settings I set were
1205 # the password is randomly generated on first run, i copied it out
1206 # so it could be used by other hosts.
1209 p = '/etc/transmission-daemon/settings.json'
1210 s = JSON.parse(File.read(p))
1211 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1212 # default is 0022 (18 in decimal)
1214 File.write p, JSON.pretty_generate(s)
1217 rpc_pass=$(</p/transmission-rpc-pass)
1218 for f in /home/*; do
1220 uid=$(id -u $u 2>/dev/null) || continue
1221 if [[ ! $uid -ge 1000 ]]; then
1224 d=$f/.config/transmission-remote-gtk
1225 sudo -u $u mkdir -p $d
1226 sudo -u $u dd of=$d/config.json <<EOF
1230 "profile-name" : "Default",
1231 "hostname" : "transmission.b8.nz",
1233 "rpc-url-path" : "/transmission/rpc",
1235 "password" : "$rpc_pass",
1236 "auto-connect" : true,
1240 "update-active-only" : false,
1241 "activeonly-fullsync-enabled" : false,
1242 "activeonly-fullsync-every" : 2,
1243 "update-interval" : 3,
1244 "min-update-interval" : 3,
1245 "session-update-interval" : 60,
1246 "exec-commands" : [],
1250 "profile-name" : "local",
1251 "hostname" : "10.173.0.2",
1254 "password" : "$rpc_pass",
1255 "auto-connect" : true,
1259 "update-active-only" : false,
1260 "activeonly-fullsync-enabled" : false,
1261 "activeonly-fullsync-every" : 2,
1262 "update-interval" : 3,
1263 "min-update-interval" : 3,
1264 "session-update-interval" : 60,
1265 "exec-commands" : [],
1270 "add-options-dialog" : false
1275 ######### end transmission client setup ######
1280 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1281 # goto http://127.0.0.1:631
1282 # administration tab, add new printer button.
1283 # In debian, I could use hte recommended driver,
1284 # in arch, I had to pick out the 6L driver.
1287 # bridge networking as user fails. google lead here, but it doesn\'t work:
1288 # oh well, I give up.
1289 # http://wiki.qemu.org/Features-Done/HelperNetworking
1291 # f=/etc/qemu/bridge.conf
1295 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1298 # general known for debian/ubuntu, not for fedora
1300 m /a/bin/buildscripts/go
1301 m /a/bin/buildscripts/rust
1302 m /a/bin/buildscripts/misc
1304 pi-nostart virtinst virt-manager
1305 # allow user to run vms, from debian handbook
1306 for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
1309 pi --no-install-recommends kdeconnect
1310 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1311 ### but gnome + xmonad not working in flidas, so i disabled it
1312 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1313 # cd /a/opt/indicator-kdeconnect
1316 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1319 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1320 # # it seems, according to
1321 # # /etc/xdg/autostart/kdeconnectd.desktop
1322 # # I'm not seeing the icon, but the clipboard replication is working
1325 ### model 01 arduino support ###
1326 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1327 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1328 # set arduino var in bashrc,
1329 # have system config file setup too.
1330 sudo adduser $USER dialout
1332 # this is for the mail command too. update-alternatives is kind of misleading
1333 # since at least it's main commands pretend mail does not exist.
1334 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1335 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1337 ######### end misc packages #########
1340 # packages I once used before and liked, but don\'t want installed now for
1342 # python-sqlite is used for offlineimap
1343 # lxappearance python-sqlite dolphin paman dconf-editor
1349 # todo, finish configuring smart.
1352 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1353 # turn on smart. background on options:
1354 # first line, -a = test everyting on all devices.
1355 # -S on, turn on disk internal saving of vendor specific info,
1356 # from google, seems like this is usually already on and fairly standard.
1357 # -o on, turn on 4 hour period non-performance degrading testing.
1358 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1359 sched="-s (S/../.././02|L/../../6/03)"
1360 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1361 DEVICESCAN -a -o on -S on -n standby,q $sched \
1362 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1364 # in the default configuration of at least ubuntu 14.04, resolvconf is
1365 # configured to order any nameservers associated with tun* or tap*
1366 # before the normal internet interfaces, which means they are always
1367 # consulted first. This is often slower and undesirable, ie. local dns
1368 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1370 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1371 # however, this breaks dns lookup for hosts on the openvpn lan.
1372 # I can\'t figure out why hosts on the normal lan would not be
1373 # broken under the default ordering, except the host I was
1374 # testing with previously had an entry in /etc/hosts.
1376 ############# end unfinished
1378 ########### misc stuff
1380 pi-nostart network-manager
1381 # make networkmanager use resolvconf instead of its own dnsmasq which
1382 # conflicts with the normal dnsmasq package.
1383 f=/etc/NetworkManager/NetworkManager.conf
1385 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1386 sudo sed -ri '/ *\[main\]/a dns=default' $f
1387 if [[ $m != $(md5sum $f) ]]; then
1388 srestart NetworkManager
1391 # make my /etc/fonts/conf.d/ get used.
1392 # I have a new sans-serif font there because the default one
1393 # displays l and I as the same char, grrrrr.
1396 pi desktop-file-utils
1397 m /a/bin/distro-setup/mymimes
1403 # stop autopoping windows when i plug in an android phone.
1404 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1405 # with still 0 exit code.
1406 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1407 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1410 # on grub upgrade, we get prompts unless we do this
1412 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1413 devs+=("$(devbyid $dev),")
1415 devs[-1]=${devs[-1]%,} # jonied by commas
1416 sudo debconf-set-selections <<EOF
1417 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1421 sgo btrfsmaint.timer
1422 sgo btrfsmaintstop.timer
1424 # aren't autoupdating this, but I do check on it somewhat regularly.
1429 # note: to see when it was last run,
1434 In mate settings settings, change scrolling to two-finger,
1435 because the default edge scroll doesn\'t work. Originally found this in debian.
1438 # Remove dep that came in with desktop to fix associations.
1439 m pu transmission-gtk
1442 m /a/bin/buildscripts/pithosfly
1445 # # Based on guix manual instructions, also added code to profile.
1446 # # disabled since i'm not using it now.
1448 # if ! type -p guix >/dev/null; then
1450 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1451 # # added some stuff to envonment.sh for profile based on
1452 # # manual instructions
1453 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1454 # # echo is to get past prompt
1455 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1456 # guix install glibc-utf8-locales
1457 # guix package --install guile
1463 m /a/bin/buildscripts/tor-browser
1466 pi-nostart nfs-kernel-server
1468 # networkmanager has this nasty behavior on flidas: if the machine
1469 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1470 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1472 # This can be manually fixed by stoping dnsmasq,
1473 # then based on whats in /run/dnsmasq/, i see we can run
1474 # s resolvconf -d NetworkManager
1475 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1476 ser disable NetworkManager
1479 if [[ $HOSTNAME == frodo ]]; then
1480 # nohide = export filesystems mounted deeper than the export point
1481 # fsid=0 makes this export the "root" export
1482 # not documented in the man page, but this means
1483 # 1. it can be mounted with a shorthand of server:/
1484 # 2. exports that are subdirectories of this one will automatically be mounted
1485 tu /etc/exports <<'EOF'
1486 /k 10.0.0.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1495 # if I was going to create a persistent vm, i might do it like this:
1496 # variant=something # from: virt-install --os-variant list
1497 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1498 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1499 # -n some_name --import --os-variant $variant --cpu host-model-only
1503 ######### begin stuff belonging at the end ##########