2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
6 source /a
/bin
/errhandle
/err
7 src
="$(readlink -f -- "${BASH_SOURCE[0]}")"; src
=${src%/*} # directory of this file
9 if [[ $EUID == 0 ]]; then
10 echo "$0: error: run as regular user" >&2
15 echo 1 >~
/.local
/distro-end
18 # shellcheck source=./pkgs
22 exec &> >(sudo
tee -a /var
/log
/distro-end
)
23 echo "$0: $(date): starting now)"
24 # see example of usage to understand.
27 IFS
= read -r -d '' y ||
:
32 echo 0 >~
/.local
/distro-end
33 if $pending_reboot; then
34 echo "$0: pending reboot and then finished. doing it now."
37 echo "$0: $(date): ending now)"
42 printf "$0: %s\n" "$*" >&2; exit 1
44 spa
() { # simple package add
48 codename
=$
(debian-codename
)
49 codename_compat
=$
(debian-codename-compat
)
51 sed="sed --follow-symlinks"
63 s debconf-set-selections
<<EOF
64 popularity-contest popularity-contest/participate boolean true
67 ########### begin section including linode ################
79 # not needed for deb, dependency of at.
84 # no equivalent in other distros:
85 if isdeb
&& pcheck apt-file
; then
86 # this condition is just a speed optimization
95 # allows me to pipe with ssh -t, and gets rid of spam
96 # http://forums.debian.net/viewtopic.php?f=5&t=85822
97 # i'd rather disable the service than comment the init file
98 # this says disabling the service, it will still get restarted
99 # but this script doesn't do anything on restart, so it should be fine
100 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
103 # this isn't a complete solution. It still shows me when updates are available,
104 # but it's no big deal.
105 s
rm -f /etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
112 ### begin certbot install ###
113 if [[ $distro == debian
]]; then
114 # note, need python-certbot-nginx for nginx, but it depends on nginx,
115 # and I'm not installing nginx by default right now.
116 pi certbot python-certbot-apache
117 elif [[ $codename_compat == xenial
]]; then
118 # not packaged in xenial or flidas
119 pi software-properties-common
120 l
="deb http://ppa.launchpad.net/certbot/certbot/ubuntu xenial main"
121 if ! grep -xFq "$l" /etc
/apt
/sources.list
{,.d
/*.list
}; then
122 s add-apt-repository
-y ppa
:certbot
/certbot ||
:
125 pi python-certbot-apache
127 die
"distro unknown for certbot"
129 # make a version of the certbot timer that emails me.
130 x
=/systemd
/system
/certbot
131 $sed -r -f - /lib
$x.timer
<<'EOF' |s dd of=/etc${x}mail.timer
132 s,^Description.*,\0 mail version,
134 $sed -r -f - /lib
$x.service
<<'EOF' |s dd of=/etc${x}mail.service
135 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
138 sgo certbotmail.timer
139 ### end certbot install ###
142 # dogcam setup. not using atm
145 # /a/bin/webcam/install-server
148 # /a/bin/webcam/install-client
153 ## not actually using prometheus just yet
154 # # office is not exposed to internet yet
155 # if [[ $HOSTNAME != kw ]]; then
156 # ## prometheus node exporter setup
157 # web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF'
158 # #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
159 # # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
163 # AuthName "Authentication Required"
164 # # setup one time, with root:www-data, 640
165 # AuthUserFile "/etc/prometheus-htpasswd"
172 ######### begin flidas pinned packages ######
173 case $
(debian-codename
) in
174 # needed for debootstrap scripts for fai since fai requires debian
176 curl http
://archive.ubuntu.com
/ubuntu
/project
/ubuntu-archive-keyring.gpg | s apt-key add
-
177 s
dd of
=/etc
/apt
/preferences.d
/flidas-xenial
<<EOF
179 Pin: release a=xenial
183 Pin: release a=xenial-updates
187 Pin: release a=xenial-security
190 s
dd of
=/etc
/apt
/sources.list.d
/xenial.list
2>/dev
/null
<<EOF
191 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
192 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
193 deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
196 s apt-key adv
--keyserver keyserver.ubuntu.com
--recv-keys 3B4FE6ACC0B21F32
197 s
dd of
=/etc
/apt
/preferences.d
/flidas-bionic
<<EOF
199 Pin: release a=bionic
203 Pin: release a=bionic-updates
207 Pin: release a=bionic-security
211 # better to run btrfs-progs which matches our kernel version
212 # (note, renamed from btrfs-tools)
213 s
dd of
=/etc
/apt
/preferences.d
/btrfs-progs
<<EOF
214 Package: btrfs-progs libzstd1
215 Pin: release a=bionic
218 Package: btrfs-progs libzstd1
219 Pin: release a=bionic-updates
222 Package: btrfs-progs libzstd1
223 Pin: release a=bionic-security
230 deb http://us.archive.ubuntu.com/ubuntu/ bionic main
231 deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main
232 deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main
234 f
=/etc
/apt
/sources.list.d
/bionic.list
235 if ! diff -q $t $f; then
241 # no special reason, but its better for btrfs-progs to
242 # be closer to our kernel version
247 aptitude download debootstrap
/xenial
249 s
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
251 s
dd of
=/etc
/apt
/preferences.d
/flidas-etiona
<<EOF
253 Pin: release a=etiona
257 Pin: release a=etiona-updates
261 Pin: release a=etiona-security
265 Pin: release a=etiona-backports
271 deb http://mirror.fsf.org/trisquel/ etiona main
272 deb http://mirror.fsf.org/trisquel/ etiona-updates main
273 deb http://archive.trisquel.info/trisquel/ etiona-security main
274 deb http://mirror.fsf.org/trisquel/ etiona-backports main
276 f
=/etc
/apt
/sources.list.d
/etiona.list
277 if ! diff -q $t $f; then
283 s
dd of
=/etc
/apt
/preferences.d
/debian-goodies
<<EOF
284 Package: debian-goodies
285 Pin: release n=etiona
290 s
dd of
=/etc
/apt
/preferences.d
/flidas-buster
<<EOF
292 Pin: release n=buster
296 Pin: release n=buster-updates
300 # dont use buster because it causes dist-upgrade to think its downgrading
301 # packages while really just reinstalling the same version.
302 f
=/etc
/apt
/apt.conf.d
/01iank
304 # # stupid buster uses some key algorithm not supported by flidas gpg that apt uses.
305 # s dd of=/etc/apt/apt.conf.d/01iank <<'EOF'
306 # Acquire::AllowInsecureRepositories "true";
309 f
=/etc
/apt
/sources.list.d
/buster.list
313 # deb http://http.us.debian.org/debian buster main
314 # deb-src http://http.us.debian.org/debian buster main
316 # deb http://security.debian.org/ buster/updates main
317 # deb-src http://security.debian.org/ buster/updates main
319 # deb http://http.us.debian.org/debian buster-updates main
320 # deb-src http://http.us.debian.org/debian buster-updates main
322 # if ! diff -q $t $f; then
328 # newer version needed for false positive in checkrestart.
329 # I did buster at first, but other problem above with having
330 # buster repos. not sure if the false positive exists in etiona.
331 p
install -y --allow-unauthenticated debian-goodies
333 s
dd of
=/etc
/apt
/preferences.d
/shellcheck
<<EOF
335 Pin: release a=etiona
339 Pin: release a=etiona-updates
343 Pin: release a=etiona-security
347 s
dd of
=/etc
/apt
/preferences.d
/bash
<<EOF
349 Pin: release a=etiona
353 Pin: release a=etiona-updates
357 Pin: release a=etiona-security
365 pi debian-goodies shellcheck
369 ######### end flidas pinned packages ######
371 ##### begin automatic upgrades (after checkrestart has been installed) ####
372 s
dd of
=/etc
/apt
/apt.conf.d
/10periodic
<<'EOF'
373 # this file was mostly just comments.
374 APT::Periodic::Update-Package-Lists "1";
375 APT::Periodic::Download-Upgradeable-Packages "1";
376 APT::Periodic::AutocleanInterval "7";
377 APT::Periodic::Unattended-Upgrade "1";
380 s
dd of
=/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
381 # fyi: default file has comments about available options,
382 # you may want to read that, do pkx unattended-upgrades
383 Unattended-Upgrade::Mail "root";
384 Unattended-Upgrade::MailOnlyOnError "true";
385 Unattended-Upgrade::Remove-Unused-Dependencies "true";
386 Unattended-Upgrade::Origins-Pattern {
387 # default is just security updates. this list found from reading
388 # match_whitelist_string() in `which unattended-upgrades`
389 "o=*,l=*,a=*,c=*,site=*,n=*";
393 # old names, too verbose
394 s
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
396 s
dd of
=/etc
/cron.d
/myupgrade
<<'EOF'
397 # Setup reboots when running outdated stuff, unattended upgrades happen
398 # at 6 am + rand(60 min).
399 20 7 * * * root /usr/local/bin/myupgrade | /usr/local/bin/log-once -1 myupgrade
400 0 * * * * root /usr/local/bin/mycheckrestart | /usr/local/bin/log-once -1 mycheckrestart
402 ##### end automatic upgrades ####
406 ###### begin website setup
409 f
=/var
/lib
/bind
/db.b8.nz
410 if [[ ! -e $f ]]; then
413 s
install -m 644 -o bind -g bind /p
/c
/machine_specific
/linode
/bind-initial
/db.b8.nz
$f
423 li
) domain
=iankelling.org
;;
425 /a
/h
/setup.sh
$domain
428 # start mumble only when im going to use it, since i dont use it much
429 pi-nostart mumble-server
430 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
432 # do certificate to avoid warning about unsigned cert,
433 # which is overkill for my use, but hey, I'm cool, I know
435 web-conf apache2 mumble.iankelling.org
436 s
rm -f /etc
/apache
2/sites-enabled
/mumble.iankelling.org
438 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
439 /a/bin/distro-setup/certbot-renew-hook
443 # requested from linode via a support ticket.
444 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
445 # ipv6 stuff pieced together
446 # via slightly wrong information from
447 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
448 # https://community.openvpn.net/openvpn/wiki/IPv6
451 vpn-server-setup
-rd 2600:3c00
:e000
:280::1/64 2600:3c00
::f03c
:91ff
:feb4
:0bf3
452 s
tee /etc
/openvpn
/client-config
/mail <<'EOF'
453 ifconfig-push 10.8.0.4 255.255.255.0
454 ifconfig-ipv6-push 2600:3c00:e000:280::2/64
457 if [[ -e /lib
/systemd
/system
/openvpn-server@.service
]]; then
458 vpn_service
=openvpn-server@server
460 vpn_service
=openvpn@server
463 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
465 Description=Turns on iptables mail nat
470 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
471 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
474 WantedBy=$vpn_service.service
478 # needed for li's local mail delivery.
479 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
481 # setup let's encrypt cert
482 web-conf apache2 mail.iankelling.org
483 s rm /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
486 domain=cal.iankelling.org
487 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
488 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
489 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
491 Options +FollowSymLinks +Multiviews +Indexes
494 AuthName "Authentication Required"
495 # setup one time, with root:www-data, 640
496 AuthUserFile "/etc/caldav-htpasswd"
500 # nginx version of above would be:
501 # auth_basic "Not currently available";
502 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
506 ###### begin znc setup #####
509 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
510 # to get into the web interface,
511 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
512 # https://iankelling.org:12533/
514 export RENEWED_LINEAGE=/etc/letsencrypt/live/iankelling.org
515 /a/bin/distro-setup/certbot-renew-hook
518 # znc config generated by doing
520 # selected port is also used in erc config
521 # comma separated channel list worked.
522 # while figuring things out, running znc -D for debug in foreground.
523 # to exit and save config:
524 # /msg *status shutdown
525 # configed auth on freenode by following
526 # https://wiki.znc.in/Sasl:
527 # /msg *sasl RequireAuth yes
528 # /msg *sasl Mechanism PLAIN
529 # /msg *sasl Set ident_name password
530 # created the system service after, and had to do
531 # mv /home/iank/.znc/* /var/lib/znc
532 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
533 # and made a copy of the config files into /p/c
534 # /msg *status LoadMod --type=global log -sanitize
535 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
536 # /msg *status LoadMod --type=network perform
537 # /msg *perform add PRIVMSG ChanServ :invite #fsf-office
538 # /msg *perform add JOIN #fsf-office
541 # also ran /znc LoadMod clearbufferonmsg
542 # it would be nice if erc supported erc query buffers by doing
543 # /msg *status clearbuffer <name of the query/receiver
545 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
546 # if that was the case i could remove the module clearbufferonmsg
547 # also would be nice if erc supported
548 # https://wiki.znc.in/self-message
549 # https://wiki.znc.in/Query_buffers \
551 s useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc || [[ $? == 9 ]] # 9 if it exists already
552 s chmod 700 /var/lib/znc
553 s chown -R znc:znc /var/lib/znc
554 s dd of=/etc/systemd/system/znc.service 2>/dev/null <<'EOF'
556 Description=ZNC, an advanced IRC bouncer
557 After=network-online.target
560 ExecStart=/usr/bin/znc -f --datadir=/var/lib/znc
564 WantedBy=multi-user.target
568 ###### stop znc setup #####
573 ###### end website setup
575 ########### end section including li/lj ###############
578 case $codename_compat in
580 # mate-indicator-applet and beyond are msc things I noticed diffing a
581 # standard install with mine.
582 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
588 # mate doesnt have wayland support yet
589 pi task-gnome-desktop
596 # TODO: some of the X programs can be removed from pall when using wayland
598 # depends gcc is a way to install suggests. this is apparently the only
599 # way to install suggests even if the main package is already
600 # installed. reinstall doesn't work, uninstalling can cause removing
601 # dependent packages.
602 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)
606 wget -O$x https://bootstrap.pypa.io/get-pip.py
610 sgo fsf-vpn-dns-cleanup
613 # website is dead june 14 2019
614 s rm -f /etc/apt/sources.list.d/iridium-browser.list
619 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
622 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
623 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
625 # f=/etc/apt/sources.list.d/iridium-browser.list
626 # if ! diff -q $t $f; then
636 ### begin home vpn server setup
639 # # this section done initially to make persistent keys.
640 # # Also note, I temporarily set /etc/hosts so my host was
641 # # b8.nz when running this, since the vpn client config
642 # # generator assumes we need to go to that server to get
644 # vpn-server-setup -rds
645 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
646 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
647 # # kw = kgpe work machine.
648 # for host in x2 x3 kw; do
649 # vpn-mk-client-cert -b $host -n home b8.nz 1196
650 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
652 # s bash -c "cp /etc/openvpn/client/home* $dir"
653 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
656 # key already exists, so this won't generate one, just the configs.
657 vpn-server-setup -rds
658 s tee -a /etc/openvpn/server/server.conf <<'EOF'
659 push "dhcp-option DNS 10.0.0.1"
660 push "route 10.0.0.0 255.255.0.0"
661 client-connect /a/bin/distro-setup/vpn-client-connect
663 s sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
665 if [[ $HOSTNAME == tp ]]; then
666 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
667 vpn_service=openvpn-server@server
669 vpn_service=openvpn@server
673 ### end vpn server setup
677 # note, see bashrc for more documentation.
679 s dd of=/etc/systemd/system/rss2email.service <<'EOF'
681 Description=rss2email
682 After=multi-user.target
687 # about 24 hours of failures
688 # it copies over its files without respecting symlinks, so
689 # we pass options to use different location.
690 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
692 s dd of=/etc/systemd/system/rss2email.timer <<'EOF'
694 Description=rss2email
697 # for initial run. required.
699 # for subsequent runs.
700 OnUnitInactiveSec=300
703 WantedBy=timers.target
705 s systemctl daemon-reload
708 ######### begin pump.io periodic backup #############
709 if [[ $HOSTNAME == frodo ]]; then
710 s dd of=/etc/systemd/system/pumpbackup.service <<'EOF'
712 Description=pump li backup
713 After=multi-user.target
718 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
720 s dd of=/etc/systemd/system/pumpbackup.timer <<'EOF'
722 Description=pump li backup hourly
728 WantedBy=timers.target
730 s systemctl daemon-reload
733 ######### end pump.io periodic backup #############
736 ######### begin irc periodic backup #############
737 if [[ $HOSTNAME == frodo ]]; then
738 s dd of=/etc/systemd/system/ircbackup.service <<'EOF'
740 Description=irc li backup
741 After=multi-user.target
746 ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
748 s dd of=/etc/systemd/system/ircbackup.timer <<'EOF'
750 Description=irc li backup hourly
756 WantedBy=timers.target
758 s systemctl daemon-reload
763 ######### end irc periodic backup #############
766 # https://github.com/jlebon/textern
768 make native-install USER=1
771 debian|trisquel|ubuntu)
772 # suggests resolvconf package. installing it here is redundant, but make sure anyways.
773 # todo: check other distros to make sure it\'s installed
774 pi-nostart openvpn resolvconf
775 # pi-nostart does not disable
781 /a/bin/distro-setup/radicale-setup
783 ## android studio setup
784 # this contains the setting for android sdk to point to
785 # /a/opt/androidsdk, which is asked upon first run
786 lnf /a/opt/.AndroidStudio2.2 ~
787 # android site says it needs a bunch of packages for ubuntu,
788 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
790 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
791 # see w.org for more android studio details
792 spa lib32stdc++6 default-jdk
795 ############# begin syncthing setup ###########
796 if [[ $HOSTNAME == frodo ]]; then
797 # It\'s simpler to just worry about running it in one place for now.
798 # I assume it would work to clone it\'s config to another non-phone
799 # and just run it in one place instead of the normal having a
800 # separate config. I lean toward using the same config, since btrfs
801 # syncs between comps.
803 arch) pi syncthing ;;
804 trisquel|ubuntu|debian)
805 # testing has relatively up to date packages
806 if ! isdebian-testing; then
807 # based on error when doing apt-get update:
808 # E: The method driver /usr/lib/apt/methods/https could not be found.
809 pi apt-transport-https
810 # google led me here:
811 # https://apt.syncthing.net/
812 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
813 s="deb http://apt.syncthing.net/ syncthing release"
814 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
815 echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
822 lnf -T /w/syncthing /home/iank/.config/syncthing
823 ser daemon-reload # syncthing likely not properly packaged
824 sgo syncthing@iank # runs as iank
826 # these things persist in ~/.config/syncthing, which I save in
827 # /w/syncthing (not in /p, because syncthing should continue to
828 # run on home server even when using laptop as primary device)
829 # open http://localhost:8384/
830 # change listen address from default to tcp://:22001,
831 # this is because we do port forward so it doesn\'t have to use
832 # some external server, but the syncthing is broken for port forward,
833 # you get a message, something "like connected to myself, this should not happen"
834 # when connecting to other local devices, so I bump the port up by 1,
836 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
837 # Without this, it was being stuck syncing at 0%.
838 # Set gui username and password.
840 # install syncthing via f-droid,
841 # folder setting, turn off send only.
842 # on phone, add device, click bar code icon
843 # on dekstop, top right, actions, device id
844 # after adding, notification will appear on desktop to confirm
846 # syncing folder. from phone to desktop: select desktop in the
847 # folder on phone\'s sync options, notification will appear in
848 # desktop\'s web ui within a minute. For the reverse, the
849 # notification will appear in android\'s notifications, you have to
850 # swipe down and tap it to add the folder. It won\'t appear in the
851 # syncthing ui, which would be intuitive, but don\'t wait for it
852 # there. The notification may not work, instead open the web gui
853 # from in the app, there should be a notification within there.
855 # On phone, set settings to run syncthing all the time, and
856 # show no notification.
858 # Folder versioning would make sense if I didn\'t already use btrfs
859 # for backups. I would choose staggered, or trash can for more space.
861 # if needed to install on a remote comp:
862 # ssh -L 8384:localhost:8384 -N frodo
863 # open http://localhost:8384/
865 # Note, the other thing i did was port forward port 22000,
866 # per https://docs.syncthing.net/users/firewall.html
869 ############# end syncthing setup ###########
873 ####### begin misc packages ###########
882 # sakura config is owned by ian
885 sudo -u user2 -i reset-konsole
886 # user2 xscreensaver we don't want to reset
890 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
891 # this is also in primary-setup
892 # pi libxss-dev # dependency based on build failure
894 # cabal install --upgrade-dependencies --force-reinstalls arbtt
895 # also, i assume syncing this between machines somehow messed thin
896 #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log
900 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
901 cp /p/.linphonerc-initial ~/.linphonerc
905 ### begin spd install
906 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
908 wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
911 # this guesses at the appropriate directory, adjust if needed
912 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
913 sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
914 # newer distro had gpg2 as default, older one, flidas, need to make it that way
915 gpgpath=$(which gpg2)
917 s mkdir -p /usr/local/spdhackfix
918 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
923 if [[ $HOSTNAME == kw ]]; then
925 NOTE: after this finishes, i did
927 # remove br from auto:
928 s vim /etc/network/interfaces
932 # nagstamon setting which were set through the ui
934 # all unknown sources
935 # all warning services
936 # acknowledged hosts & services
937 # hosts & services down for maintenence
938 # services on down hosts
939 # services on hosts in maintenece
940 # services on unreachable osts
941 # hosts in soft state
942 # services in soft state
943 # in display tab: fullscreen
945 # these translate to these settings I think
946 # filter_acknowledged_hosts_services = True
947 # filter_all_unknown_services = True
948 # filter_all_warning_services = True
949 # filter_hosts_in_soft_state = True
950 # filter_hosts_services_maintenance = True
951 # filter_services_in_soft_state = True
952 # filter_services_on_down_hosts = True
953 # filter_services_on_hosts_in_maintenance = True
954 # filter_services_on_unreachable_hosts = True
955 # notify_if_up = False
956 # statusbar_floating = False
958 # but i'm just going to rely on the webpage plus sms for now.
962 debian|trisquel|ubuntu)
963 # it asks if it should make users in it's group capture packets without root,
964 # which is arguably more secure than running wireshark as root. default is no,
965 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
966 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
971 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
972 # listed in the default config as suggested.
973 # /run/usr/1000 i noticed was missing for pulseaudio
974 # /run/user/0 just seemed like a not bad idea, given the above
975 tu /etc/schroot/desktop/fstab <<'EOF'
976 /run /run none rw,bind 0 0
977 /run/lock /run/lock none rw,bind 0 0
978 /dev/shm /dev/shm none rw,bind 0 0
979 /run/shm /run/shm none rw,bind 0 0
980 /run/user/1000 /run/user/1000 none rw,bind 0 0
981 /run/user/1001 /run/user/1001 none rw,bind 0 0
982 /run/user/0 /run/user/0 none rw,bind 0 0
990 repo=http://archive.ubuntu.com/ubuntu/
993 repo=http://deb.debian.org/debian/
998 if schroot -l | grep -xFq chroot:$n; then
999 echo "$0: $n schroot already installed, skipping"
1004 s dd of=/etc/schroot/chroot.d/$n.conf <<EOF
1010 preserve-environment=true
1013 if [[ -e $d/bin ]]; then
1014 s chroot $d apt-get update
1015 s chroot $d apt-get -y dist-upgrade --purge --auto-remove
1016 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1020 s debootstrap $n $d $repo
1021 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1023 s cp -P {,$d}/etc/localtime
1025 s dd of=/etc/systemd/system/schrootupdate.service <<'EOF'
1027 Description=schrootupdate
1028 After=multi-user.target
1032 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1034 s dd of=/etc/systemd/system/schrootupdate.timer <<'EOF'
1036 Description=schrootupdate
1039 OnCalendar=*-*-* 04:20:00
1042 WantedBy=timers.target
1044 s systemctl daemon-reload
1045 sgo schrootupdate.timer
1052 mkschroot debian stretch firefox-esr pulseaudio chromium
1059 s mkdir -p /nocow/user
1060 s chown $USER:$USER /nocow/user
1064 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1065 # 450 seems likely to be unused. we need to specify one or else
1066 # it won't be stable across installs.
1067 if ! getent passwd debian-transmission > /dev/null; then
1068 s groupadd -g 450 debian-transmission
1076 --home-dir /var/lib/transmission-daemon \
1077 --shell /bin/false \
1086 --disabled-password \
1087 --home /var/lib/transmission-daemon \
1092 # We want group writable stuff from transmission.
1093 # However, after setting this, I learn that transmission sets it's
1094 # own umask based on it's settings file. Well, no harm leaving this
1095 # so it's set right from the beginning.
1096 s chfn debian-transmission -o umask=0002
1099 debian|trisquel|ubuntu)
1100 # note i had to do this, which is persistent:
1102 # s chgrp debian-transmission torrents partial-torrents
1104 # syslog says things like
1105 # 'Failed to set receive buffer: requested 4194304, got 425984'
1106 # google suggets giving it even more than that
1107 tu /etc/sysctl.conf<<'EOF'
1108 net.core.rmem_max = 67108864
1109 net.core.wmem_max = 16777216
1113 # some reason it doesn\'t seem to start automatically anyways
1114 pi-nostart transmission-daemon
1115 # be extra sure its not started
1116 ser disable transmission-daemon
1117 ser stop transmission-daemon
1119 # the folder was moved here after an install around 02/2017.
1120 # it contains runtime data,
1121 # plus a simple symlink to the config file which it\'s
1122 # not worth separating out.
1123 # between comps, the uid can change
1124 f=/i/transmission-daemon
1125 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1126 if [[ -e $f ]]; then
1127 s chown -R debian-transmission:debian-transmission $f
1129 for f in /i/k/partial-torrents /i/k/torrents; do
1130 if [[ -e $f ]]; then
1131 s chown -R debian-transmission:user2 $f
1134 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1136 # config file documented here, and it\'s the same config
1137 # for daemon vs client, so it\'s documented in the gui.
1138 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1140 # I originaly setup rpc-whitelist, but after using
1141 # routing to a network namespace, it doesn\'t see the
1142 # real source address, so it\'s disabled.
1144 # Changed the cache-size to 256 mb, reduces disk use.
1145 # It is a read & write cache.
1149 p = '/etc/transmission-daemon/settings.json'
1150 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1151 'rpc-whitelist-enabled' => false,
1152 'rpc-authentication-required' => false,
1153 'incomplete-dir' => '/i/k/partial-torrents',
1154 'incomplete-dir-enabled' => true,
1155 'download-dir' => '/i/k/torrents',
1156 "speed-limit-up" => 800,
1157 "speed-limit-up-enabled" => true,
1158 "peer-port" => 61486,
1159 "cache-size-mb" => 256,
1160 "ratio-limit" => 5.0,
1161 "ratio-limit-enabled" => true,
1166 # todo: others unknown
1171 # trisquel 8 = openvpn, debian stretch = openvpn-client
1172 vpn_ser=openvpn-client
1173 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1177 s dd of=/etc/systemd/system/transmission-daemon-nn.service <<EOF
1179 Description=Transmission BitTorrent Daemon netns
1180 After=network.target
1181 Requires=${vpn_ser}-nn@client.service
1182 After=${vpn_ser}-nn@client.service
1183 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1186 #User=debian-transmission
1187 # notify type doesn't work with sudo
1189 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1190 ExecReload=/bin/kill -s HUP \$MAINPID
1195 WantedBy=multi-user.target
1199 if [[ $HOSTNAME == frodo ]]; then
1200 sgo transmission-daemon-nn
1204 ######### begin transmission client setup ######
1206 if [[ -e /p/transmission-rpc-pass ]]; then
1207 # arch had a default config,
1208 # debian had nothing until you start it.
1209 # With a little trial an error, here is a minimal config
1210 # taken from the generated one, plus changes that the
1211 # settings ui does, without a bunch of ui crap settings.
1213 # only settings I set were
1218 # the password is randomly generated on first run, i copied it out
1219 # so it could be used by other hosts.
1222 p = '/etc/transmission-daemon/settings.json'
1223 s = JSON.parse(File.read(p))
1224 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1225 # default is 0022 (18 in decimal)
1227 File.write p, JSON.pretty_generate(s)
1230 rpc_pass=$(</p/transmission-rpc-pass)
1231 for f in /home/*; do
1233 if [[ ! $(id -u $u) -ge 1000 ]]; then
1236 d=$f/.config/transmission-remote-gtk
1238 s -u $u dd of=$d/config.json <<EOF
1242 "profile-name" : "Default",
1243 "hostname" : "transmission.b8.nz",
1244 "rpc-url-path" : "/transmission/rpc",
1246 "password" : "$rpc_pass",
1247 "auto-connect" : true,
1251 "update-active-only" : false,
1252 "activeonly-fullsync-enabled" : false,
1253 "activeonly-fullsync-every" : 2,
1254 "update-interval" : 3,
1255 "min-update-interval" : 3,
1256 "session-update-interval" : 60,
1264 "add-options-dialog" : false
1269 ######### end transmission client setup ######
1271 # dunno why it\'s there, but get rid of it
1273 li|lj) s rm -rf /home/linode ;;
1280 pi cups ghostscript gsfonts # from arch wiki cups page
1281 pi hplip # from google
1282 s gpasswd -a $USER sys # from arch wiki
1283 sgo org.cups.cupsd.service
1285 debian|trisquel|ubuntu)
1287 s gpasswd -a $USER lpadmin # based on ubuntu wiki
1290 # other distros unknown
1292 # goto http://127.0.0.1:631
1293 # administration tab, add new printer button.
1294 # In debian, I could use hte recommended driver,
1295 # in arch, I had to pick out the 6L driver.
1298 # allow user to run vms, from debian handbook
1299 for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
1300 # bridge networking as user fails. google lead here, but it doesn\'t work:
1301 # oh well, I give up.
1302 # http://wiki.qemu.org/Features-Done/HelperNetworking
1304 # f=/etc/qemu/bridge.conf
1305 # s dd of=$f <<'EOF'
1308 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1311 # general known for debian/ubuntu, not for fedora
1314 debian|trisquel|ubuntu)
1315 if ! type -p go &>/dev/null; then
1317 # just the latest stable at the time of writing
1318 # TODO, maybe put this all into a build script,
1319 # and do some automatic updates
1320 wget -q https://dl.google.com/go/go1.12.4.linux-amd64.tar.gz
1321 s tar -C /usr/local -xzf go1.12.4.linux-amd64.tar.gz
1324 go get -u mvdan.cc/fdroidcl
1325 # a bit of googling, and added settings to bashrc
1332 # otherwise we get error about accessing kvm module.
1333 # seems like there might be a better way, but google was a bit vague.
1334 s $sed -ri '/^ *user *=/d' /etc/libvirt/qemu.conf
1335 echo 'user = "root"' | s tee -a /etc/libvirt/qemu.conf
1336 # guessing this is not needed
1337 #sgo virtlogd.service
1339 # iank: disabed as im not using libvirt usually
1340 # # https://bbs.archlinux.org/viewtopic.php?id=206206
1341 # # # this should prolly go in the wiki
1342 # sgo virtlogd.socket
1345 debian|trisquel|ubuntu)
1346 pi-nostart virtinst virt-manager
1355 wget ftp://ftp.gnu.org/pub/gnu/global/global-6.5.7.tar.gz
1358 # based on https://github.com/leoliu/ggtags
1359 ./configure --with-exuberant-ctags=/usr/bin/ctags
1362 pip install pygments
1370 debian|trisquel|ubuntu)
1377 # removed synergy since ive not used it in a long time
1380 pi --no-install-recommends kdeconnect
1381 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1382 ### but gnome + xmonad not working in flidas, so i disabled it
1383 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1384 # cd /a/opt/indicator-kdeconnect
1387 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1390 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1391 # # it seems, according to
1392 # # /etc/xdg/autostart/kdeconnectd.desktop
1393 # # I'm not seeing the icon, but the clipboard replication is working
1396 ### model 01 arduino support ###
1397 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1398 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1399 # set arduino var in bashrc,
1400 # have system config file setup too.
1401 sudo adduser $USER dialout
1404 sudo usermod -a -G uucp $USER
1408 # this is for the mail command too. update-alternatives is kind of misleading
1409 # since at least it's main commands pretend mail does not exist.
1410 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1411 s update-alternatives --set mailx /usr/bin/mail.mailutils
1413 ######### end misc packages #########
1416 # packages I once used before and liked, but don\'t want installed now for
1418 # python-sqlite is used for offlineimap
1419 # lxappearance python-sqlite dolphin paman dconf-editor
1425 # todo, finish configuring smart.
1428 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1429 # turn on smart. background on options:
1430 # first line, -a = test everyting on all devices.
1431 # -S on, turn on disk internal saving of vendor specific info,
1432 # from google, seems like this is usually already on and fairly standard.
1433 # -o on, turn on 4 hour period non-performance degrading testing.
1434 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1435 sched="-s (S/../.././02|L/../../6/03)"
1436 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1437 DEVICESCAN -a -o on -S on -n standby,q $sched \
1438 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1440 # in the default configuration of at least ubuntu 14.04, resolvconf is
1441 # configured to order any nameservers associated with tun* or tap*
1442 # before the normal internet interfaces, which means they are always
1443 # consulted first. This is often slower and undesirable, ie. local dns
1444 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1446 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1447 # however, this breaks dns lookup for hosts on the openvpn lan.
1448 # I can\'t figure out why hosts on the normal lan would not be
1449 # broken under the default ordering, except the host I was
1450 # testing with previously had an entry in /etc/hosts.
1452 ############# end unfinished
1454 ########### misc stuff
1456 # make networkmanager use resolvconf instead of its own dnsmasq which
1457 # conflicts with the normal dnsmasq package.
1458 f=/etc/NetworkManager/NetworkManager.conf
1460 s sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1461 if [[ $m != $(md5sum $f) ]]; then
1462 srestart NetworkManager
1465 # make my /etc/fonts/conf.d/ get used.
1466 # I have a new sans-serif font there because the default one
1467 # displays l and I as the same char, grrrrr.
1470 /a/bin/distro-setup/mymimes
1476 # stop autopoping windows when i plug in an android phone.
1477 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1478 # with still 0 exit code.
1479 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1480 dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1483 # on grub upgrade, we get prompts unless we do this
1485 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1486 devs+=("$(devbyid $dev),")
1488 devs[-1]=${devs[-1]%,} # jonied by commas
1489 s debconf-set-selections <<EOF
1490 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1494 sgo btrfsmaint.timer
1495 sgo btrfsmaintstop.timer
1498 # the wiki backup script from ofswiki.org uses generic paths
1499 s lnf /p/c/machine_specific/li/mw_vars /root
1500 s lnf /k/backup/wiki_backup /root
1504 trisquel|ubuntu|debian)
1505 # unison-gtk second, i want it to be default, not sure if that works
1506 # with spa. note, I used to install from testing repo when using stable,
1507 # but it shouldn't be needed since I wrote a script to handle mismatching
1509 spa unison unison-gtk
1518 # default is alsa, doesn\'t work with with pianobar
1519 s dd of=/etc/libao.conf <<'EOF'
1520 default_driver=pulse
1525 # # disabled due to my patch being in btrbk
1527 # arch|debian|trisquel|ubuntu) pi btrbk ;;
1534 # note: to see when it was last run,
1539 In mate settings settings, change scrolling to two-finger,
1540 because the default edge scroll doesn\'t work. Originally found this in debian.
1545 # remove dep that came in with desktop
1552 debian|trisquel|ubuntu) s gpasswd -a iank adm ;; #needed for reading logs
1555 /a/bin/buildscripts/pithosfly
1558 # based on guix manual instructions, also added code to profile
1560 if ! type -p guix >/dev/null; then
1562 wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1563 # added some stuff to envonment.sh for profile based on
1564 # manual instructions
1565 # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1566 # echo is to get past prompt
1567 yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1568 guix install glibc-utf8-locales
1569 guix package --install guile
1573 curl https://sh.rustup.rs -sSf | bash -s -- -y
1574 # todo: update this. updates in rust are stupidly complicate
1575 if ! which rg &>/dev/null; then
1576 cargo install ripgrep
1582 # https://www.torproject.org/docs/rpms.html.en
1583 # https://www.torproject.org/docs/debian.html.en
1584 # todo: figure out if the running service needs to be restarted upon updates
1585 # todo on fedora: setup non-dev packages
1587 s dd of=/etc/yum.repos.d/torproject.repo <<'EOF'
1589 name=Tor experimental repo
1591 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1593 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1596 name=Tor experimental source repo
1599 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1601 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1604 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1605 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1607 /a/bin/buildscripts/tor-browser
1610 tu /etc/apt/sources.list "deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1611 gpg --keyserver keys.gnupg.net --recv 886DDD89
1612 gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
1614 pi deb.torproject.org-keyring
1616 /a/bin/buildscripts/tor-browser
1620 /a/bin/buildscripts/tor-browser
1623 pi tor tor-browser-en
1633 fedora todo: disable the firewall or find a way to automate it.
1634 there's an unused section in t.org for tramikssion firewall setup
1636 fedora manual config for nfs:
1638 change to permanent configuration
1639 check the box for nfs
1640 was hard to figure this out, not sure if this is all needed, but
1642 mountd: udp/tcp 20048
1643 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1644 troubleshooting, unblock things in rpcinfo -p
1645 make sure to reload the firewall to load the persistent configuration
1651 debian|trisquel|ubuntu)
1652 pi-nostart nfs-server
1655 pi nfs-utils || pending_reboot=true
1659 # networkmanager has this nasty behavior on flidas: if the machine
1660 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1661 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1663 # This can be manually fixed by stoping dnsmasq,
1664 # then based on whats in /run/dnsmasq/, i see we can run
1665 # s resolvconf -d NetworkManager
1666 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1667 ser stop NetworkManager
1668 ser disable NetworkManager
1671 if [[ $HOSTNAME == frodo ]]; then
1672 # nohide = export filesystems mounted deeper than the export point
1673 # fsid=0 makes this export the "root" export
1674 # not documented in the man page, but this means
1675 # 1. it can be mounted with a shorthand of server:/
1676 # 2. exports that are subdirectories of this one will automatically be mounted
1677 tu /etc/exports <<'EOF'
1678 /k 10.0.0.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1687 # if I was going to create a persistent vm, i might do it like this:
1688 # variant=something # from: virt-install --os-variant list
1689 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1690 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1691 # -n some_name --import --os-variant $variant --cpu host-model-only
1695 ######### begin stuff belonging at the end ##########