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
185 sd
/etc
/apt
/sources.list.d
/xenial.list
2>/dev
/null
<<EOF
186 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
187 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
188 deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
191 if ! apt-key list |
grep /C0B21F32
&>/dev
/null
; then
192 sudo apt-key adv
--keyserver keyserver.ubuntu.com
--recv-keys 3B4FE6ACC0B21F32
193 sd
/etc
/apt
/preferences.d
/flidas-bionic
<<EOF
195 Pin: release a=bionic
199 Pin: release a=bionic-updates
203 Pin: release a=bionic-security
208 # better to run btrfs-progs which matches our kernel version
209 # (note, renamed from btrfs-tools)
210 sd
/etc
/apt
/preferences.d
/btrfs-progs
<<EOF
211 Package: btrfs-progs libzstd1
212 Pin: release a=bionic
215 Package: btrfs-progs libzstd1
216 Pin: release a=bionic-updates
219 Package: btrfs-progs libzstd1
220 Pin: release a=bionic-security
227 deb http://us.archive.ubuntu.com/ubuntu/ bionic main
228 deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main
229 deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main
231 f
=/etc
/apt
/sources.list.d
/bionic.list
232 if ! diff -q $t $f; then
238 # no special reason, but its better for btrfs-progs to
239 # be closer to our kernel version
242 if [[ ! -e /usr
/share
/debootstrap
/scripts
/xenial
]]; then
245 m aptitude download debootstrap
/xenial
247 sudo
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
250 sd
/etc
/apt
/preferences.d
/flidas-etiona
<<EOF
252 Pin: release a=etiona
256 Pin: release a=etiona-updates
260 Pin: release a=etiona-security
264 Pin: release a=etiona-backports
270 deb http://mirror.fsf.org/trisquel/ etiona main
271 deb http://mirror.fsf.org/trisquel/ etiona-updates main
272 deb http://archive.trisquel.info/trisquel/ etiona-security main
273 deb http://mirror.fsf.org/trisquel/ etiona-backports main
275 f
=/etc
/apt
/sources.list.d
/etiona.list
276 if ! diff -q $t $f; then
282 sd
/etc
/apt
/preferences.d
/debian-goodies
<<EOF
283 Package: debian-goodies
284 Pin: release n=etiona
289 sd
/etc
/apt
/preferences.d
/flidas-buster
<<EOF
291 Pin: release n=buster
295 Pin: release n=buster-updates
299 # dont use buster because it causes dist-upgrade to think its downgrading
300 # packages while really just reinstalling the same version.
301 f
=/etc
/apt
/apt.conf.d
/01iank
303 # # stupid buster uses some key algorithm not supported by flidas gpg that apt uses.
304 # sd /etc/apt/apt.conf.d/01iank <<'EOF'
305 # Acquire::AllowInsecureRepositories "true";
308 f
=/etc
/apt
/sources.list.d
/buster.list
312 # deb http://http.us.debian.org/debian buster main
313 # deb-src http://http.us.debian.org/debian buster main
315 # deb http://security.debian.org/ buster/updates main
316 # deb-src http://security.debian.org/ buster/updates main
318 # deb http://http.us.debian.org/debian buster-updates main
319 # deb-src http://http.us.debian.org/debian buster-updates main
321 # if ! diff -q $t $f; then
327 # newer version needed for false positive in checkrestart.
328 # I did buster at first, but other problem above with having
329 # buster repos. not sure if the false positive exists in etiona.
332 sd
/etc
/apt
/preferences.d
/shellcheck
<<EOF
334 Pin: release a=etiona
338 Pin: release a=etiona-updates
342 Pin: release a=etiona-security
346 sd
/etc
/apt
/preferences.d
/bash
<<EOF
348 Pin: release a=etiona
352 Pin: release a=etiona-updates
356 Pin: release a=etiona-security
364 pi debian-goodies shellcheck
368 ######### end flidas pinned packages ######
370 ##### begin automatic upgrades (after checkrestart has been installed) ####
371 sd
/etc
/apt
/apt.conf.d
/10periodic
<<'EOF'
372 # this file was mostly just comments.
373 APT::Periodic::Update-Package-Lists "1";
374 APT::Periodic::Download-Upgradeable-Packages "1";
375 APT::Periodic::AutocleanInterval "7";
376 APT::Periodic::Unattended-Upgrade "1";
379 sd
/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
380 # fyi: default file has comments about available options,
381 # you may want to read that, do pkx unattended-upgrades
382 Unattended-Upgrade::Mail "root";
383 Unattended-Upgrade::MailOnlyOnError "true";
384 Unattended-Upgrade::Remove-Unused-Dependencies "true";
385 Unattended-Upgrade::Origins-Pattern {
386 # default is just security updates. this list found from reading
387 # match_whitelist_string() in $(which unattended-upgrades)
388 "o=*,l=*,a=*,c=*,site=*,n=*";
392 # old names, too verbose
393 sudo
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
395 sd
/etc
/cron.d
/myupgrade
<<'EOF'
396 # Setup reboots when running outdated stuff, unattended upgrades happen
397 # at 6 am + rand(60 min).
401 # default is /usr/bin:/bin
402 PATH=/usr/bin:/bin:/usr/local/bin
403 20 7 * * * iank myupgrade |& log-once -1 myupgrade
404 0 * * * * root mycheckrestart |& log-once -1 mycheckrestart
406 ##### end automatic upgrades ####
410 ###### begin website setup
414 f
=/var
/lib
/bind
/db.b8.nz
415 if [[ ! -e $f ]]; then
418 sudo
install -m 644 -o bind -g bind /p
/c
/machine_specific
/linode
/bind-initial
/db.b8.nz
$f
423 # setup let's encrypt cert
424 m web-conf apache2 l2.b8.nz
425 sudo
rm -fv /etc
/apache
2/sites-enabled
/l2.b8.nz
{,-redir}.conf
427 s lnf
-T /etc
/letsencrypt
/live
/l2.b8.nz
/fullchain.pem
/etc
/exim
4/exim.crt
428 if [[ ! -L /etc
/exim
4/exim.key
]]; then
429 s lnf
-T /etc
/letsencrypt
/live
/l2.b8.nz
/privkey.pem
/etc
/exim
4/exim.key
438 m
/a
/h
/setup.sh iankelling.org
441 m
/a
/h
/setup.sh
-s b8.nz
444 # allow symlinks on non-main hosts so i can host files in arbitrary paths
445 m
/a
/h
/setup.sh
-s -p 80
450 # start mumble only when im going to use it, since i dont use it much
451 pi-nostart mumble-server
452 sudo
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
454 # do certificate to avoid warning about unsigned cert,
455 # which is overkill for my use, but hey, I'm cool, I know
457 m web-conf apache2 mumble.iankelling.org
458 sudo
rm -fv /etc
/apache
2/sites-enabled
/mumble.iankelling.org
460 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
461 /a/bin/distro-setup/certbot-renew-hook
465 # requested from linode via a support ticket.
466 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
467 # ipv6 stuff pieced together
468 # via slightly wrong information from
469 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
470 # https://community.openvpn.net/openvpn/wiki/IPv6
473 m vpn-server-setup
-rd 2600:3c00
:e000
:280::1/64 2600:3c00
::f03c
:91ff
:feb4
:0bf3
474 sudo
tee /etc
/openvpn
/client-config
/mail <<'EOF'
475 ifconfig-push 10.8.0.4 255.255.255.0
476 ifconfig-ipv6-push 2600:3c00:e000:280::2/64
479 if [[ -e /lib
/systemd
/system
/openvpn-server@.service
]]; then
480 vpn_service
=openvpn-server@server
482 vpn_service
=openvpn@server
485 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
487 Description=Turns on iptables mail nat
492 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
493 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
496 WantedBy=$vpn_service.service
500 # needed for li's local mail delivery.
501 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
503 # setup let's encrypt cert
504 m web-conf apache2 mail.iankelling.org
505 sudo rm -fv /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
508 domain=cal.iankelling.org
509 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
510 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
511 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
513 Options +FollowSymLinks +Multiviews +Indexes
516 AuthName "Authentication Required"
517 # setup one time, with root:www-data, 640
518 AuthUserFile "/etc/caldav-htpasswd"
522 # nginx version of above would be:
523 # auth_basic "Not currently available";
524 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
528 ###### begin znc setup #####
531 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
532 # to get into the web interface,
533 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
534 # https://iankelling.org:12533/
536 export RENEWED_LINEAGE=/etc/letsencrypt/live/iankelling.org
537 /a/bin/distro-setup/certbot-renew-hook
540 # znc config generated by doing
542 # selected port is also used in erc config
543 # comma separated channel list worked.
544 # while figuring things out, running znc -D for debug in foreground.
545 # to exit and save config:
546 # /msg *status shutdown
547 # configed auth on freenode by following
548 # https://wiki.znc.in/Sasl:
549 # /msg *sasl RequireAuth yes
550 # /msg *sasl Mechanism PLAIN
551 # /msg *sasl Set ident_name password
552 # created the system service after, and had to do
553 # mv /home/iank/.znc/* /var/lib/znc
554 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
555 # and made a copy of the config files into /p/c
556 # /msg *status LoadMod --type=global log -sanitize
557 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
558 # /msg *status LoadMod --type=network perform
559 # /msg *perform add PRIVMSG ChanServ :invite #fsf-office
560 # /msg *perform add JOIN #fsf-office
563 # also ran /znc LoadMod clearbufferonmsg
564 # it would be nice if erc supported erc query buffers by doing
565 # /msg *status clearbuffer <name of the query/receiver
567 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
568 # if that was the case i could remove the module clearbufferonmsg
569 # also would be nice if erc supported
570 # https://wiki.znc.in/self-message
571 # https://wiki.znc.in/Query_buffers \
573 if ! getent passwd znc > /dev/null; then
574 sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc
576 sudo chmod 700 /var/lib/znc
577 sudo chown -R znc:znc /var/lib/znc
578 # Avoid restarting if possible, reconnecting to irc is annoying.
579 # The unit file was made active with conflink.
580 # Note, avoid using ser here because we wrap sudo to prints the command first.
581 if [[ $(systemctl is-active znc) != active ]]; then
584 ###### stop znc setup #####
589 ###### end website setup
591 ########### end section including li/lj ###############
594 case $codename_compat in
596 # mate-indicator-applet and beyond are msc things I noticed diffing a
597 # standard install with mine.
598 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
604 # mate doesnt have wayland support yet
605 pi task-gnome-desktop
613 if [[ $codename_compat == flidas ]]; then
614 # doesnt exist in newer
618 if [[ $codename == flidas ]]; then
622 sudo ln -sf /usr/bin/firefox /usr/local/bin/abrowser
625 # TODO: some of the X programs can be removed from pall when using wayland
627 # depends gcc is a way to install suggests. this is apparently the only
628 # way to install suggests even if the main package is already
629 # installed. reinstall doesn't work, uninstalling can cause removing
630 # dependent packages.
631 pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $(apt-cache depends gcc|grep -i suggests:| awk '{print $2}') $($src/distro-pkgs)
634 # website is dead june 14 2019. back in october, but meh
635 sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
640 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
643 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
644 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
646 # f=/etc/apt/sources.list.d/iridium-browser.list
647 # if ! diff -q $t $f; then
657 ### begin home vpn server setup
660 # # this section done initially to make persistent keys.
661 # # Also note, I temporarily set /etc/hosts so my host was
662 # # b8.nz when running this, since the vpn client config
663 # # generator assumes we need to go to that server to get
665 # vpn-server-setup -rds
666 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
667 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
668 # # kw = kgpe work machine.
669 # for host in x2 x3 kw; do
670 # vpn-mk-client-cert -b $host -n home b8.nz 1196
671 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
673 # s bash -c "cp /etc/openvpn/client/home* $dir"
674 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
677 # key already exists, so this won't generate one, just the configs.
678 m vpn-server-setup -rds
679 sudo tee -a /etc/openvpn/server/server.conf <<'EOF'
680 push "dhcp-option DNS 10.0.0.1"
681 push "route 10.0.0.0 255.255.0.0"
682 client-connect /a/bin/distro-setup/vpn-client-connect
684 sudo sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
686 if [[ $HOSTNAME == tp ]]; then
687 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
688 vpn_service=openvpn-server@server
690 vpn_service=openvpn@server
694 ### end vpn server setup
698 # note, see bashrc for more documentation.
700 sd /etc/systemd/system/rss2email.service <<'EOF'
702 Description=rss2email
703 After=multi-user.target
708 # about 24 hours of failures
709 # it copies over its files without respecting symlinks, so
710 # we pass options to use different location.
711 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
713 sd /etc/systemd/system/rss2email.timer <<'EOF'
715 Description=rss2email
718 # for initial run. required.
720 # for subsequent runs.
721 OnUnitInactiveSec=300
724 WantedBy=timers.target
726 sudo systemctl daemon-reload
729 ######### begin pump.io periodic backup #############
730 if [[ $HOSTNAME == frodo ]]; then
731 sd /etc/systemd/system/pumpbackup.service <<'EOF'
733 Description=pump li backup
734 After=multi-user.target
739 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
741 sd /etc/systemd/system/pumpbackup.timer <<'EOF'
743 Description=pump li backup hourly
749 WantedBy=timers.target
754 ######### end pump.io periodic backup #############
757 ######### begin irc periodic backup #############
758 if [[ $HOSTNAME == frodo ]]; then
759 sd /etc/systemd/system/ircbackup.service <<'EOF'
761 Description=irc li backup
762 After=multi-user.target
767 ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
769 sd /etc/systemd/system/ircbackup.timer <<'EOF'
771 Description=irc li backup hourly
777 WantedBy=timers.target
779 sudo systemctl daemon-reload
784 ######### end irc periodic backup #############
788 debian|trisquel|ubuntu)
789 # suggests resolvconf package. installing it here is redundant, but make sure anyways.
790 # todo: check other distros to make sure it\'s installed
791 pi-nostart openvpn resolvconf
792 # pi-nostart does not disable
798 m /a/bin/distro-setup/radicale-setup
801 ############# begin syncthing setup ###########
802 if [[ $HOSTNAME == frodo ]]; then
803 # It\'s simpler to just worry about running it in one place for now.
804 # I assume it would work to clone it\'s config to another non-phone
805 # and just run it in one place instead of the normal having a
806 # separate config. I lean toward using the same config, since btrfs
807 # syncs between comps.
808 # testing has relatively up to date packages
809 if ! isdebian-testing; then
810 # based on error when doing apt-get update:
811 # E: The method driver /usr/lib/apt/methods/https could not be found.
812 pi apt-transport-https
813 # google led me here:
814 # https://apt.syncthing.net/
815 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
816 s="deb http://apt.syncthing.net/ syncthing release"
817 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
818 echo "$s" | sd /etc/apt/sources.list.d/syncthing.list
823 m lnf -T /w/syncthing /home/iank/.config/syncthing
824 ser daemon-reload # syncthing likely not properly packaged
825 sgo syncthing@iank # runs as iank
827 # these things persist in ~/.config/syncthing, which I save in
828 # /w/syncthing (not in /p, because syncthing should continue to
829 # run on home server even when using laptop as primary device)
830 # open http://localhost:8384/
831 # change listen address from default to tcp://:22001,
832 # this is because we do port forward so it doesn\'t have to use
833 # some external server, but the syncthing is broken for port forward,
834 # you get a message, something "like connected to myself, this should not happen"
835 # when connecting to other local devices, so I bump the port up by 1,
837 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
838 # Without this, it was being stuck syncing at 0%.
839 # Set gui username and password.
841 # install syncthing via f-droid,
842 # folder setting, turn off send only.
843 # on phone, add device, click bar code icon
844 # on dekstop, top right, actions, device id
845 # after adding, notification will appear on desktop to confirm
847 # syncing folder. from phone to desktop: select desktop in the
848 # folder on phone\'s sync options, notification will appear in
849 # desktop\'s web ui within a minute. For the reverse, the
850 # notification will appear in android\'s notifications, you have to
851 # swipe down and tap it to add the folder. It won\'t appear in the
852 # syncthing ui, which would be intuitive, but don\'t wait for it
853 # there. The notification may not work, instead open the web gui
854 # from in the app, there should be a notification within there.
856 # On phone, set settings to run syncthing all the time, and
857 # show no notification.
859 # Folder versioning would make sense if I didn\'t already use btrfs
860 # for backups. I would choose staggered, or trash can for more space.
862 # if needed to install on a remote comp:
863 # ssh -L 8384:localhost:8384 -N frodo
864 # open http://localhost:8384/
866 # Note, the other thing i did was port forward port 22000,
867 # per https://docs.syncthing.net/users/firewall.html
870 ############# end syncthing setup ###########
874 ####### begin misc packages ###########
883 # sakura config is owned by ian
886 m sudo -u user2 -i reset-konsole
887 # user2 xscreensaver we don't want to reset
891 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
892 # this is also in primary-setup
893 # pi libxss-dev # dependency based on build failure
895 # cabal install --upgrade-dependencies --force-reinstalls arbtt
896 # also, i assume syncing this between machines somehow messed thin
897 #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log
901 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
902 m cp /p/.linphonerc-initial ~/.linphonerc
906 ### begin spd install
907 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
909 m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
912 # this guesses at the appropriate directory, adjust if needed
913 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
914 m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
915 # newer distro had gpg2 as default, older one, flidas, need to make it that way
916 gpgpath=$(which gpg2)
918 sudo mkdir -p /usr/local/spdhackfix
919 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
924 # nagstamon setting which were set through the ui
926 # all unknown sources
927 # all warning services
928 # acknowledged hosts & services
929 # hosts & services down for maintenence
930 # services on down hosts
931 # services on hosts in maintenece
932 # services on unreachable osts
933 # hosts in soft state
934 # services in soft state
935 # in display tab: fullscreen
937 # these translate to these settings I think
938 # filter_acknowledged_hosts_services = True
939 # filter_all_unknown_services = True
940 # filter_all_warning_services = True
941 # filter_hosts_in_soft_state = True
942 # filter_hosts_services_maintenance = True
943 # filter_services_in_soft_state = True
944 # filter_services_on_down_hosts = True
945 # filter_services_on_hosts_in_maintenance = True
946 # filter_services_on_unreachable_hosts = True
947 # notify_if_up = False
948 # statusbar_floating = False
950 # but i'm just going to rely on the webpage plus sms for now.
953 # it asks if it should make users in it's group capture packets without root,
954 # which is arguably more secure than running wireshark as root. default is no,
955 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
956 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
958 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
959 # listed in the default config as suggested.
960 # /run/usr/1000 i noticed was missing for pulseaudio
961 # /run/user/0 just seemed like a not bad idea, given the above
962 tu /etc/schroot/desktop/fstab <<'EOF'
963 /run /run none rw,bind 0 0
964 /run/lock /run/lock none rw,bind 0 0
965 /dev/shm /dev/shm none rw,bind 0 0
966 /run/shm /run/shm none rw,bind 0 0
967 /run/user/1000 /run/user/1000 none rw,bind 0 0
968 /run/user/1001 /run/user/1001 none rw,bind 0 0
969 /run/user/0 /run/user/0 none rw,bind 0 0
977 repo=http://archive.ubuntu.com/ubuntu/
980 repo=http://deb.debian.org/debian/
985 if schroot -l | grep -xFq chroot:$n; then
986 echo "$0: $n schroot already installed, skipping"
991 sd /etc/schroot/chroot.d/$n.conf <<EOF
997 preserve-environment=true
1000 if [[ -e $d/bin ]]; then
1001 sudo chroot $d apt-get update
1002 sudo chroot $d apt-get -y dist-upgrade --purge --auto-remove
1003 cd; sudo schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1007 sudo debootstrap $n $d $repo
1008 cd; sudo schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1010 sudo cp -P {,$d}/etc/localtime
1012 sd /etc/systemd/system/schrootupdate.service <<'EOF'
1014 Description=schrootupdate
1015 After=multi-user.target
1019 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1021 sd /etc/systemd/system/schrootupdate.timer <<'EOF'
1023 Description=schrootupdate
1026 OnCalendar=*-*-* 04:20:00
1029 WantedBy=timers.target
1032 sgo schrootupdate.timer
1039 m mkschroot debian stretch firefox-esr pulseaudio chromium
1046 sudo mkdir -p /nocow/user
1047 sudo chown $USER:$USER /nocow/user
1051 ####### begin transmission
1062 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1063 # 450 seems likely to be unused. we need to specify one or else
1064 # it won't be stable across installs.
1065 if ! getent passwd debian-transmission > /dev/null; then
1066 sudo groupadd -g 450 debian-transmission
1067 sudo adduser --quiet \
1072 --disabled-password \
1073 --home /var/lib/transmission-daemon \
1076 # We want group writable stuff from transmission.
1077 # However, after setting this, I learn that transmission sets it's
1078 # own umask based on it's settings file. Well, no harm leaving this
1079 # so it's set right from the beginning.
1080 sudo chfn debian-transmission -o umask=0002
1082 # note i had to do this, which is persistent:
1084 # s chgrp debian-transmission torrents partial-torrents
1086 # syslog says things like
1087 # 'Failed to set receive buffer: requested 4194304, got 425984'
1088 # google suggets giving it even more than that
1089 tu /etc/sysctl.conf<<'EOF'
1090 net.core.rmem_max = 67108864
1091 net.core.wmem_max = 16777216
1095 # some reason it doesn\'t seem to start automatically anyways
1096 pi-nostart transmission-daemon
1097 # be extra sure its not started
1098 ser disable transmission-daemon
1099 ser stop transmission-daemon
1101 # the folder was moved here after an install around 02/2017.
1102 # it contains runtime data,
1103 # plus a simple symlink to the config file which it\'s
1104 # not worth separating out.
1105 # between comps, the uid can change
1106 f=$tdir/transmission-daemon
1108 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1109 s lnf -T /etc/transmission-daemon/settings.json $f/settings.json
1110 sudo chown -R debian-transmission:debian-transmission $f
1111 for f in $tdir/partial-torrents $tdir/torrents; do
1112 if [[ -e $f ]]; then
1113 sudo chown -R debian-transmission:user2 $f
1116 sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1118 # config file documented here, and it\'s the same config
1119 # for daemon vs client, so it\'s documented in the gui.
1120 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1122 # I originaly setup rpc-whitelist, but after using
1123 # routing to a network namespace, it doesn\'t see the
1124 # real source address, so it\'s disabled.
1126 # Changed the cache-size to 256 mb, reduces disk use.
1127 # It is a read & write cache.
1130 p = '/etc/transmission-daemon/settings.json'
1131 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1132 'rpc-whitelist-enabled' => false,
1133 'rpc-authentication-required' => false,
1134 'incomplete-dir' => '$tdir/partial-torrents',
1135 'incomplete-dir-enabled' => true,
1136 'download-dir' => '$tdir/torrents',
1137 "speed-limit-up" => 800,
1138 "speed-limit-up-enabled" => true,
1139 "peer-port" => 61486,
1140 "cache-size-mb" => 256,
1141 "ratio-limit" => 5.0,
1142 "ratio-limit-enabled" => true,
1145 ####### end transmission
1149 # trisquel 8 = openvpn, debian stretch = openvpn-client
1150 vpn_ser=openvpn-client
1151 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1155 sd /etc/systemd/system/transmission-daemon-nn.service <<EOF
1157 Description=Transmission BitTorrent Daemon netns
1158 After=network.target
1159 Requires=${vpn_ser}-nn@client.service
1160 After=${vpn_ser}-nn@client.service
1161 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1164 #User=debian-transmission
1165 # notify type doesn't work with sudo
1167 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1168 ExecReload=/bin/kill -s HUP \$MAINPID
1173 WantedBy=multi-user.target
1177 if [[ $HOSTNAME == frodo ]]; then
1178 sgo transmission-daemon-nn
1182 ######### begin transmission client setup ######
1184 if [[ -e /p/transmission-rpc-pass ]]; then
1185 # arch had a default config,
1186 # debian had nothing until you start it.
1187 # With a little trial an error, here is a minimal config
1188 # taken from the generated one, plus changes that the
1189 # settings ui does, without a bunch of ui crap settings.
1191 # only settings I set were
1196 # the password is randomly generated on first run, i copied it out
1197 # so it could be used by other hosts.
1200 p = '/etc/transmission-daemon/settings.json'
1201 s = JSON.parse(File.read(p))
1202 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1203 # default is 0022 (18 in decimal)
1205 File.write p, JSON.pretty_generate(s)
1208 rpc_pass=$(</p/transmission-rpc-pass)
1209 for f in /home/*; do
1211 uid=$(id -u $u 2>/dev/null) || continue
1212 if [[ ! $uid -ge 1000 ]]; then
1215 d=$f/.config/transmission-remote-gtk
1216 sudo -u $u mkdir -p $d
1217 sudo -u $u dd of=$d/config.json <<EOF
1221 "profile-name" : "Default",
1222 "hostname" : "transmission.b8.nz",
1224 "rpc-url-path" : "/transmission/rpc",
1226 "password" : "$rpc_pass",
1227 "auto-connect" : true,
1231 "update-active-only" : false,
1232 "activeonly-fullsync-enabled" : false,
1233 "activeonly-fullsync-every" : 2,
1234 "update-interval" : 3,
1235 "min-update-interval" : 3,
1236 "session-update-interval" : 60,
1237 "exec-commands" : [],
1241 "profile-name" : "local",
1242 "hostname" : "10.173.0.2",
1245 "password" : "$rpc_pass",
1246 "auto-connect" : true,
1250 "update-active-only" : false,
1251 "activeonly-fullsync-enabled" : false,
1252 "activeonly-fullsync-every" : 2,
1253 "update-interval" : 3,
1254 "min-update-interval" : 3,
1255 "session-update-interval" : 60,
1256 "exec-commands" : [],
1261 "add-options-dialog" : false
1266 ######### end transmission client setup ######
1271 sudo gpasswd -a $USER lpadmin # based on ubuntu wiki
1272 # goto http://127.0.0.1:631
1273 # administration tab, add new printer button.
1274 # In debian, I could use hte recommended driver,
1275 # in arch, I had to pick out the 6L driver.
1278 # bridge networking as user fails. google lead here, but it doesn\'t work:
1279 # oh well, I give up.
1280 # http://wiki.qemu.org/Features-Done/HelperNetworking
1282 # f=/etc/qemu/bridge.conf
1286 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1289 # general known for debian/ubuntu, not for fedora
1291 m /a/bin/buildscripts/go
1292 m /a/bin/buildscripts/rust
1293 m /a/bin/buildscripts/misc
1295 pi-nostart virtinst virt-manager
1296 # allow user to run vms, from debian handbook
1297 for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
1300 pi --no-install-recommends kdeconnect
1301 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1302 ### but gnome + xmonad not working in flidas, so i disabled it
1303 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1304 # cd /a/opt/indicator-kdeconnect
1307 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1310 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1311 # # it seems, according to
1312 # # /etc/xdg/autostart/kdeconnectd.desktop
1313 # # I'm not seeing the icon, but the clipboard replication is working
1316 ### model 01 arduino support ###
1317 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1318 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1319 # set arduino var in bashrc,
1320 # have system config file setup too.
1321 sudo adduser $USER dialout
1323 # this is for the mail command too. update-alternatives is kind of misleading
1324 # since at least it's main commands pretend mail does not exist.
1325 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1326 sudo update-alternatives --set mailx /usr/bin/mail.mailutils
1328 ######### end misc packages #########
1331 # packages I once used before and liked, but don\'t want installed now for
1333 # python-sqlite is used for offlineimap
1334 # lxappearance python-sqlite dolphin paman dconf-editor
1340 # todo, finish configuring smart.
1343 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1344 # turn on smart. background on options:
1345 # first line, -a = test everyting on all devices.
1346 # -S on, turn on disk internal saving of vendor specific info,
1347 # from google, seems like this is usually already on and fairly standard.
1348 # -o on, turn on 4 hour period non-performance degrading testing.
1349 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1350 sched="-s (S/../.././02|L/../../6/03)"
1351 sudo sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1352 DEVICESCAN -a -o on -S on -n standby,q $sched \
1353 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1355 # in the default configuration of at least ubuntu 14.04, resolvconf is
1356 # configured to order any nameservers associated with tun* or tap*
1357 # before the normal internet interfaces, which means they are always
1358 # consulted first. This is often slower and undesirable, ie. local dns
1359 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1361 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1362 # however, this breaks dns lookup for hosts on the openvpn lan.
1363 # I can\'t figure out why hosts on the normal lan would not be
1364 # broken under the default ordering, except the host I was
1365 # testing with previously had an entry in /etc/hosts.
1367 ############# end unfinished
1369 ########### misc stuff
1371 pi-nostart network-manager
1372 # make networkmanager use resolvconf instead of its own dnsmasq which
1373 # conflicts with the normal dnsmasq package.
1374 f=/etc/NetworkManager/NetworkManager.conf
1376 sudo sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1377 sudo sed -ri '/ *\[main\]/a dns=default' $f
1378 if [[ $m != $(md5sum $f) ]]; then
1379 srestart NetworkManager
1382 # make my /etc/fonts/conf.d/ get used.
1383 # I have a new sans-serif font there because the default one
1384 # displays l and I as the same char, grrrrr.
1387 pi desktop-file-utils
1388 m /a/bin/distro-setup/mymimes
1394 # stop autopoping windows when i plug in an android phone.
1395 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1396 # with still 0 exit code.
1397 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1398 m dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1401 # on grub upgrade, we get prompts unless we do this
1403 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1404 devs+=("$(devbyid $dev),")
1406 devs[-1]=${devs[-1]%,} # jonied by commas
1407 sudo debconf-set-selections <<EOF
1408 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1412 sgo btrfsmaint.timer
1413 sgo btrfsmaintstop.timer
1415 # aren't autoupdating this, but I do check on it somewhat regularly.
1420 # note: to see when it was last run,
1425 In mate settings settings, change scrolling to two-finger,
1426 because the default edge scroll doesn\'t work. Originally found this in debian.
1429 # Remove dep that came in with desktop to fix associations.
1430 m pu transmission-gtk
1433 m /a/bin/buildscripts/pithosfly
1436 # # Based on guix manual instructions, also added code to profile.
1437 # # disabled since i'm not using it now.
1439 # if ! type -p guix >/dev/null; then
1441 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1442 # # added some stuff to envonment.sh for profile based on
1443 # # manual instructions
1444 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1445 # # echo is to get past prompt
1446 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1447 # guix install glibc-utf8-locales
1448 # guix package --install guile
1454 m /a/bin/buildscripts/tor-browser
1457 pi-nostart nfs-kernel-server
1459 # networkmanager has this nasty behavior on flidas: if the machine
1460 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1461 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1463 # This can be manually fixed by stoping dnsmasq,
1464 # then based on whats in /run/dnsmasq/, i see we can run
1465 # s resolvconf -d NetworkManager
1466 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1467 ser disable NetworkManager
1470 if [[ $HOSTNAME == frodo ]]; then
1471 # nohide = export filesystems mounted deeper than the export point
1472 # fsid=0 makes this export the "root" export
1473 # not documented in the man page, but this means
1474 # 1. it can be mounted with a shorthand of server:/
1475 # 2. exports that are subdirectories of this one will automatically be mounted
1476 tu /etc/exports <<'EOF'
1477 /k 10.0.0.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1486 # if I was going to create a persistent vm, i might do it like this:
1487 # variant=something # from: virt-install --os-variant list
1488 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1489 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1490 # -n some_name --import --os-variant $variant --cpu host-model-only
1494 ######### begin stuff belonging at the end ##########