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 ||
:
31 printf "$0: %s\n" "$*" >&2; exit 1
33 spa
() { # simple package add
37 codename
=$
(debian-codename
)
38 codename_compat
=$
(debian-codename-compat
)
40 sed="sed --follow-symlinks"
52 s debconf-set-selections
<<EOF
53 popularity-contest popularity-contest/participate boolean true
56 ########### begin section including li ################
68 # not needed for deb, dependency of at.
73 # no equivalent in other distros:
74 if isdeb
&& pcheck apt-file
; then
75 # this condition is just a speed optimization
84 # allows me to pipe with ssh -t, and gets rid of spam
85 # http://forums.debian.net/viewtopic.php?f=5&t=85822
86 # i'd rather disable the service than comment the init file
87 # this says disabling the service, it will still get restarted
88 # but this script doesn't do anything on restart, so it should be fine
89 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
92 # this isn't a complete solution. It still shows me when updates are available,
93 # but it's no big deal.
94 s
rm -f /etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
101 ### begin certbot install ###
102 if [[ $distro == debian
]]; then
103 # note, need python-certbot-nginx for nginx, but it depends on nginx,
104 # and I'm not installing nginx by default right now.
105 pi certbot python-certbot-apache
106 elif [[ $codename_compat == xenial
]]; then
107 # not packaged in xenial or flidas
108 pi software-properties-common
109 l
="deb http://ppa.launchpad.net/certbot/certbot/ubuntu xenial main"
110 if ! grep -xFq "$l" /etc
/apt
/sources.list
{,.d
/*.list
}; then
111 s add-apt-repository
-y ppa
:certbot
/certbot ||
:
114 pi python-certbot-apache
116 die
"distro unknown for certbot"
118 # make a version of the certbot timer that emails me.
119 x
=/systemd
/system
/certbot
120 $sed -r -f - /lib
$x.timer
<<'EOF' |s dd of=/etc${x}mail.timer
121 s,^Description.*,\0 mail version,
123 $sed -r -f - /lib
$x.service
<<'EOF' |s dd of=/etc${x}mail.service
124 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
127 sgo certbotmail.timer
128 ### end certbot install ###
131 # dogcam setup. not using atm
134 # /a/bin/webcam/install-server
137 # /a/bin/webcam/install-client
142 ## not actually using prometheus just yet
143 # # office is not exposed to internet yet
144 # if [[ $HOSTNAME != kw ]]; then
145 # ## prometheus node exporter setup
146 # web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF'
147 # #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
148 # # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
152 # AuthName "Authentication Required"
153 # # setup one time, with root:www-data, 640
154 # AuthUserFile "/etc/prometheus-htpasswd"
165 f
=/var
/lib
/bind
/db.b8.nz
166 if [[ ! -e $f ]]; then
169 install -m 644 -o bind -g bind /p
/c
/machine_specific
/li
/bind-initial
/db.b8.nz
$f
174 li
) domain
=iankelling.org
;;
176 /a
/h
/setup.sh
$domain
179 # start mumble only when im going to use it, since i dont use it much
180 pi-nostart mumble-server
181 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
183 # do certificate to avoid warning about unsigned cert,
184 # which is overkill for my use, but hey, I'm cool, I know
186 web-conf apache2 mumble.iankelling.org
187 s
rm -f /etc
/apache
2/sites-enabled
/mumble.iankelling.org
189 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
190 /a/bin/distro-setup/certbot-renew-hook
194 # requested from linode via a support ticket.
195 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
196 # ipv6 stuff pieced together
197 # via slightly wrong information from
198 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
199 # https://community.openvpn.net/openvpn/wiki/IPv6
202 vpn-server-setup
-rd 2600:3c00
:e000
:280::1/64 2600:3c00
::f03c
:91ff
:feb4
:0bf3
203 s
tee /etc
/openvpn
/client-config
/mail <<'EOF'
204 ifconfig-push 10.8.0.4 255.255.255.0
205 ifconfig-ipv6-push 2600:3c00:e000:280::2/64
208 if [[ -e /lib
/systemd
/system
/openvpn-server@.service
]]; then
209 vpn_service
=openvpn-server@server
211 vpn_service
=openvpn@server
214 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
216 Description=Turns on iptables mail nat
221 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
222 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
225 WantedBy=$vpn_service.service
229 # needed for li's local mail delivery.
230 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
232 # setup let's encrypt cert
233 web-conf apache2 mail.iankelling.org
234 s rm /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
237 domain=cal.iankelling.org
238 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
239 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
240 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
242 Options +FollowSymLinks +Multiviews +Indexes
245 AuthName "Authentication Required"
246 # setup one time, with root:www-data, 640
247 AuthUserFile "/etc/caldav-htpasswd"
251 # nginx version of above would be:
252 # auth_basic "Not currently available";
253 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
257 ###### begin znc setup #####
260 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
261 # to get into the web interface,
262 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
263 # https://iankelling.org:12533/
265 export RENEWED_LINEAGE=/etc/letsencrypt/live/iankelling.org
266 /a/bin/distro-setup/certbot-renew-hook
269 # znc config generated by doing
271 # selected port is also used in erc config
272 # comma separated channel list worked.
273 # while figuring things out, running znc -D for debug in foreground.
274 # to exit and save config:
275 # /msg *status shutdown
276 # configed auth on freenode by following
277 # https://wiki.znc.in/Sasl:
278 # /msg *sasl RequireAuth yes
279 # /msg *sasl Mechanism PLAIN
280 # /msg *sasl Set ident_name password
281 # created the system service after, and had to do
282 # mv /home/iank/.znc/* /var/lib/znc
283 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
284 # and made a copy of the config files into /p/c
285 # /msg *status LoadMod --type=global log -sanitize
286 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
287 # /msg *status LoadMod --type=network perform
288 # /msg *perform add PRIVMSG ChanServ :invite #fsf-office
289 # /msg *perform add JOIN #fsf-office
292 # also ran /znc LoadMod clearbufferonmsg
293 # it would be nice if erc supported erc query buffers by doing
294 # /msg *status clearbuffer <name of the query/receiver
296 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
297 # if that was the case i could remove the module clearbufferonmsg
298 # also would be nice if erc supported
299 # https://wiki.znc.in/self-message
300 # https://wiki.znc.in/Query_buffers \
302 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
303 s chmod 700 /var/lib/znc
304 s chown -R znc:znc /var/lib/znc
305 s dd of=/etc/systemd/system/znc.service 2>/dev/null <<'EOF'
307 Description=ZNC, an advanced IRC bouncer
308 After=network-online.target
311 ExecStart=/usr/bin/znc -f --datadir=/var/lib/znc
315 WantedBy=multi-user.target
319 ###### stop znc setup #####
322 ######### begin flidas pinned packages ######
323 case $(debian-codename) in
324 # needed for debootstrap scripts for fai since fai requires debian
326 curl http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg | s apt-key add -
327 s dd of=/etc/apt/preferences.d/flidas-xenial <<EOF
329 Pin: release a=xenial
333 Pin: release a=xenial-updates
337 Pin: release a=xenial-security
340 s dd of=/etc/apt/sources.list.d/xenial.list 2>/dev/null <<EOF
341 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
342 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
343 deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
346 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
347 s dd of=/etc/apt/preferences.d/flidas-bionic <<EOF
349 Pin: release a=bionic
353 Pin: release a=bionic-updates
357 Pin: release a=bionic-security
361 # better to run btrfs-progs which matches our kernel version
362 # (note, renamed from btrfs-tools)
363 s dd of=/etc/apt/preferences.d/btrfs-progs <<EOF
364 Package: btrfs-progs libzstd1
365 Pin: release a=bionic
368 Package: btrfs-progs libzstd1
369 Pin: release a=bionic-updates
372 Package: btrfs-progs libzstd1
373 Pin: release a=bionic-security
380 deb http://us.archive.ubuntu.com/ubuntu/ bionic main
381 deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main
382 deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main
384 f=/etc/apt/sources.list.d/bionic.list
385 if ! diff -q $t $f; then
391 # no special reason, but its better for btrfs-progs to
392 # be closer to our kernel version
397 aptitude download debootstrap/xenial
399 s cp ./usr/share/debootstrap/scripts/* /usr/share/debootstrap/scripts
401 s dd of=/etc/apt/preferences.d/flidas-etiona <<EOF
403 Pin: release a=etiona
407 Pin: release a=etiona-updates
411 Pin: release a=etiona-security
415 Pin: release a=etiona-backports
421 deb http://mirror.fsf.org/trisquel/ etiona main
422 deb http://mirror.fsf.org/trisquel/ etiona-updates main
423 deb http://archive.trisquel.info/trisquel/ etiona-security main
424 deb http://mirror.fsf.org/trisquel/ etiona-backports main
426 f=/etc/apt/sources.list.d/etiona.list
427 if ! diff -q $t $f; then
433 s dd of=/etc/apt/preferences.d/debian-goodies <<EOF
434 Package: debian-goodies
435 Pin: release n=etiona
440 s dd of=/etc/apt/preferences.d/flidas-buster <<EOF
442 Pin: release n=buster
446 Pin: release n=buster-updates
450 # dont use buster because it causes dist-upgrade to think its downgrading
451 # packages while really just reinstalling the same version.
452 f=/etc/apt/apt.conf.d/01iank
454 # # stupid buster uses some key algorithm not supported by flidas gpg that apt uses.
455 # s dd of=/etc/apt/apt.conf.d/01iank <<'EOF'
456 # Acquire::AllowInsecureRepositories "true";
459 f=/etc/apt/sources.list.d/buster.list
463 # deb http://http.us.debian.org/debian buster main
464 # deb-src http://http.us.debian.org/debian buster main
466 # deb http://security.debian.org/ buster/updates main
467 # deb-src http://security.debian.org/ buster/updates main
469 # deb http://http.us.debian.org/debian buster-updates main
470 # deb-src http://http.us.debian.org/debian buster-updates main
472 # if ! diff -q $t $f; then
478 # newer version needed for false positive in checkrestart.
479 # I did buster at first, but other problem above with having
480 # buster repos. not sure if the false positive exists in etiona.
481 p install -y --allow-unauthenticated debian-goodies
483 s dd of=/etc/apt/preferences.d/shellcheck <<EOF
485 Pin: release a=etiona
489 Pin: release a=etiona-updates
493 Pin: release a=etiona-security
497 s dd of=/etc/apt/preferences.d/bash <<EOF
499 Pin: release a=etiona
503 Pin: release a=etiona-updates
507 Pin: release a=etiona-security
515 pi debian-goodies shellcheck
519 ######### end flidas pinned packages ######
521 ##### begin automatic upgrades (after checkrestart has been installed) ####
522 s dd of=/etc/apt/apt.conf.d/10periodic <<'EOF'
523 # this file was mostly just comments.
524 APT::Periodic::Update-Package-Lists "1";
525 APT::Periodic::Download-Upgradeable-Packages "1";
526 APT::Periodic::AutocleanInterval "7";
527 APT::Periodic::Unattended-Upgrade "1";
530 s dd of=/etc/apt/apt.conf.d/50unattended-upgrades <<EOF
531 # fyi: default file has comments about available options,
532 # you may want to read that, do pkx unattended-upgrades
533 Unattended-Upgrade::Mail "root";
534 Unattended-Upgrade::MailOnlyOnError "true";
535 Unattended-Upgrade::Remove-Unused-Dependencies "true";
536 Unattended-Upgrade::Origins-Pattern {
537 # default is just security updates. this list found from reading
538 # match_whitelist_string() in `which unattended-upgrades`
539 "o=*,l=*,a=*,c=*,site=*,n=*";
543 # old names, too verbose
544 s rm -f /etc/cron.d/unattended-upgrade-reboot /usr/local/bin/zelous-unattended-reboot
546 s dd of=/etc/cron.d/myupgrade <<'EOF'
547 # Setup reboots when running outdated stuff, unattended upgrades happen
548 # at 6 am + rand(60 min).
549 20 7 * * * root /usr/local/bin/myupgrade | /usr/local/bin/log-once -1 myupgrade
550 0 * * * * root /usr/local/bin/mycheckrestart | /usr/local/bin/log-once -1 mycheckrestart
552 ##### end automatic upgrades ####
555 echo "$0: $(date): ending now)"
560 ########### end section including li/lj ###############
563 case $codename_compat in
565 # mate-indicator-applet and beyond are msc things I noticed diffing a
566 # standard install with mine.
567 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
573 # mate doesnt have wayland support yet
574 pi task-gnome-desktop
581 # TODO: some of the X programs can be removed from pall when using wayland
583 # depends gcc is a way to install suggests. this is apparently the only
584 # way to install suggests even if the main package is already
585 # installed. reinstall doesn't work, uninstalling can cause removing
586 # dependent packages.
587 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)
591 wget -O$x https://bootstrap.pypa.io/get-pip.py
595 sgo fsf-vpn-dns-cleanup
598 # website is dead june 14 2019
599 s rm -f /etc/apt/sources.list.d/iridium-browser.list
604 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
607 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
608 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
610 # f=/etc/apt/sources.list.d/iridium-browser.list
611 # if ! diff -q $t $f; then
621 ### begin home vpn server setup
624 # # this section done initially to make persistent keys.
625 # # Also note, I temporarily set /etc/hosts so my host was
626 # # b8.nz when running this, since the vpn client config
627 # # generator assumes we need to go to that server to get
629 # vpn-server-setup -rds
630 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
631 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
632 # # kw = kgpe work machine.
633 # for host in x2 x3 kw; do
634 # vpn-mk-client-cert -b $host -n home b8.nz 1196
635 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
637 # s bash -c "cp /etc/openvpn/client/home* $dir"
638 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
641 # key already exists, so this won't generate one, just the configs.
642 vpn-server-setup -rds
643 s tee -a /etc/openvpn/server/server.conf <<'EOF'
644 push "dhcp-option DNS 10.0.0.1"
645 push "route 10.0.0.0 255.255.0.0"
646 client-connect /a/bin/distro-setup/vpn-client-connect
648 s sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
650 if [[ $HOSTNAME == tp ]]; then
651 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
652 vpn_service=openvpn-server@server
654 vpn_service=openvpn@server
658 ### end vpn server setup
662 # note, see bashrc for more documentation.
664 s dd of=/etc/systemd/system/rss2email.service <<'EOF'
666 Description=rss2email
667 After=multi-user.target
672 # about 24 hours of failures
673 # it copies over its files without respecting symlinks, so
674 # we pass options to use different location.
675 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
677 s dd of=/etc/systemd/system/rss2email.timer <<'EOF'
679 Description=rss2email
682 # for initial run. required.
684 # for subsequent runs.
685 OnUnitInactiveSec=300
688 WantedBy=timers.target
690 s systemctl daemon-reload
693 ######### begin pump.io periodic backup #############
694 if [[ $HOSTNAME == frodo ]]; then
695 s dd of=/etc/systemd/system/pumpbackup.service <<'EOF'
697 Description=pump li backup
698 After=multi-user.target
703 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
705 s dd of=/etc/systemd/system/pumpbackup.timer <<'EOF'
707 Description=pump li backup hourly
713 WantedBy=timers.target
715 s systemctl daemon-reload
718 ######### end pump.io periodic backup #############
721 ######### begin irc periodic backup #############
722 if [[ $HOSTNAME == frodo ]]; then
723 s dd of=/etc/systemd/system/ircbackup.service <<'EOF'
725 Description=irc li backup
726 After=multi-user.target
731 ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
733 s dd of=/etc/systemd/system/ircbackup.timer <<'EOF'
735 Description=irc li backup hourly
741 WantedBy=timers.target
743 s systemctl daemon-reload
748 ######### end irc periodic backup #############
751 # https://github.com/jlebon/textern
753 make native-install USER=1
756 debian|trisquel|ubuntu)
757 # suggests resolvconf package. installing it here is redundant, but make sure anyways.
758 # todo: check other distros to make sure it\'s installed
759 pi-nostart openvpn resolvconf
760 # pi-nostart does not disable
766 /a/bin/distro-setup/radicale-setup
768 ## android studio setup
769 # this contains the setting for android sdk to point to
770 # /a/opt/androidsdk, which is asked upon first run
771 lnf /a/opt/.AndroidStudio2.2 ~
772 # android site says it needs a bunch of packages for ubuntu,
773 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
775 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
776 # see w.org for more android studio details
777 spa lib32stdc++6 default-jdk
780 ############# begin syncthing setup ###########
781 if [[ $HOSTNAME == frodo ]]; then
782 # It\'s simpler to just worry about running it in one place for now.
783 # I assume it would work to clone it\'s config to another non-phone
784 # and just run it in one place instead of the normal having a
785 # separate config. I lean toward using the same config, since btrfs
786 # syncs between comps.
788 arch) pi syncthing ;;
789 trisquel|ubuntu|debian)
790 # testing has relatively up to date packages
791 if ! isdebian-testing; then
792 # based on error when doing apt-get update:
793 # E: The method driver /usr/lib/apt/methods/https could not be found.
794 pi apt-transport-https
795 # google led me here:
796 # https://apt.syncthing.net/
797 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
798 s="deb http://apt.syncthing.net/ syncthing release"
799 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
800 echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
807 lnf -T /w/syncthing /home/iank/.config/syncthing
808 ser daemon-reload # syncthing likely not properly packaged
809 sgo syncthing@iank # runs as iank
811 # these things persist in ~/.config/syncthing, which I save in
812 # /w/syncthing (not in /p, because syncthing should continue to
813 # run on home server even when using laptop as primary device)
814 # open http://localhost:8384/
815 # change listen address from default to tcp://:22001,
816 # this is because we do port forward so it doesn\'t have to use
817 # some external server, but the syncthing is broken for port forward,
818 # you get a message, something "like connected to myself, this should not happen"
819 # when connecting to other local devices, so I bump the port up by 1,
821 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
822 # Without this, it was being stuck syncing at 0%.
823 # Set gui username and password.
825 # install syncthing via f-droid,
826 # folder setting, turn off send only.
827 # on phone, add device, click bar code icon
828 # on dekstop, top right, actions, device id
829 # after adding, notification will appear on desktop to confirm
831 # syncing folder. from phone to desktop: select desktop in the
832 # folder on phone\'s sync options, notification will appear in
833 # desktop\'s web ui within a minute. For the reverse, the
834 # notification will appear in android\'s notifications, you have to
835 # swipe down and tap it to add the folder. It won\'t appear in the
836 # syncthing ui, which would be intuitive, but don\'t wait for it
837 # there. The notification may not work, instead open the web gui
838 # from in the app, there should be a notification within there.
840 # On phone, set settings to run syncthing all the time, and
841 # show no notification.
843 # Folder versioning would make sense if I didn\'t already use btrfs
844 # for backups. I would choose staggered, or trash can for more space.
846 # if needed to install on a remote comp:
847 # ssh -L 8384:localhost:8384 -N frodo
848 # open http://localhost:8384/
850 # Note, the other thing i did was port forward port 22000,
851 # per https://docs.syncthing.net/users/firewall.html
854 ############# end syncthing setup ###########
858 ####### begin misc packages ###########
867 # sakura config is owned by ian
870 sudo -u user2 -i reset-konsole
871 # user2 xscreensaver we don't want to reset
875 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
876 # this is also in primary-setup
877 # pi libxss-dev # dependency based on build failure
879 # cabal install --upgrade-dependencies --force-reinstalls arbtt
880 # also, i assume syncing this between machines somehow messed thin
881 #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log
885 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
886 cp /p/.linphonerc-initial ~/.linphonerc
890 ### begin spd install
891 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
893 wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
896 # this guesses at the appropriate directory, adjust if needed
897 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
898 sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
899 # newer distro had gpg2 as default, older one, flidas, need to make it that way
900 gpgpath=$(which gpg2)
902 s mkdir -p /usr/local/spdhackfix
903 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
908 if [[ $HOSTNAME == kw ]]; then
910 NOTE: after this finishes, i did
912 # remove br from auto:
913 s vim /etc/network/interfaces
917 # nagstamon setting which were set through the ui
919 # all unknown sources
920 # all warning services
921 # acknowledged hosts & services
922 # hosts & services down for maintenence
923 # services on down hosts
924 # services on hosts in maintenece
925 # services on unreachable osts
926 # hosts in soft state
927 # services in soft state
928 # in display tab: fullscreen
930 # these translate to these settings I think
931 # filter_acknowledged_hosts_services = True
932 # filter_all_unknown_services = True
933 # filter_all_warning_services = True
934 # filter_hosts_in_soft_state = True
935 # filter_hosts_services_maintenance = True
936 # filter_services_in_soft_state = True
937 # filter_services_on_down_hosts = True
938 # filter_services_on_hosts_in_maintenance = True
939 # filter_services_on_unreachable_hosts = True
940 # notify_if_up = False
941 # statusbar_floating = False
943 # but i'm just going to rely on the webpage plus sms for now.
947 debian|trisquel|ubuntu)
948 # it asks if it should make users in it's group capture packets without root,
949 # which is arguably more secure than running wireshark as root. default is no,
950 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
951 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
956 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
957 # listed in the default config as suggested.
958 # /run/usr/1000 i noticed was missing for pulseaudio
959 # /run/user/0 just seemed like a not bad idea, given the above
960 tu /etc/schroot/desktop/fstab <<'EOF'
961 /run /run none rw,bind 0 0
962 /run/lock /run/lock none rw,bind 0 0
963 /dev/shm /dev/shm none rw,bind 0 0
964 /run/shm /run/shm none rw,bind 0 0
965 /run/user/1000 /run/user/1000 none rw,bind 0 0
966 /run/user/1001 /run/user/1001 none rw,bind 0 0
967 /run/user/0 /run/user/0 none rw,bind 0 0
975 repo=http://archive.ubuntu.com/ubuntu/
978 repo=http://deb.debian.org/debian/
983 if schroot -l | grep -xFq chroot:$n; then
984 echo "$0: $n schroot already installed, skipping"
989 s dd of=/etc/schroot/chroot.d/$n.conf <<EOF
995 preserve-environment=true
998 if [[ -e $d/bin ]]; then
999 s chroot $d apt-get update
1000 s chroot $d apt-get -y dist-upgrade --purge --auto-remove
1001 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1005 s debootstrap $n $d $repo
1006 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1008 s cp -P {,$d}/etc/localtime
1010 s dd of=/etc/systemd/system/schrootupdate.service <<'EOF'
1012 Description=schrootupdate
1013 After=multi-user.target
1017 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1019 s dd of=/etc/systemd/system/schrootupdate.timer <<'EOF'
1021 Description=schrootupdate
1024 OnCalendar=*-*-* 04:20:00
1027 WantedBy=timers.target
1029 s systemctl daemon-reload
1030 sgo schrootupdate.timer
1037 mkschroot debian stretch firefox-esr pulseaudio chromium
1044 s mkdir -p /nocow/user
1045 s chown $USER:$USER /nocow/user
1049 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1050 # 450 seems likely to be unused. we need to specify one or else
1051 # it won't be stable across installs.
1052 if ! getent passwd debian-transmission > /dev/null; then
1053 s groupadd -g 450 debian-transmission
1061 --home-dir /var/lib/transmission-daemon \
1062 --shell /bin/false \
1071 --disabled-password \
1072 --home /var/lib/transmission-daemon \
1077 # We want group writable stuff from transmission.
1078 # However, after setting this, I learn that transmission sets it's
1079 # own umask based on it's settings file. Well, no harm leaving this
1080 # so it's set right from the beginning.
1081 s chfn debian-transmission -o umask=0002
1084 debian|trisquel|ubuntu)
1085 # note i had to do this, which is persistent:
1087 # s chgrp debian-transmission torrents partial-torrents
1089 # syslog says things like
1090 # 'Failed to set receive buffer: requested 4194304, got 425984'
1091 # google suggets giving it even more than that
1092 tu /etc/sysctl.conf<<'EOF'
1093 net.core.rmem_max = 67108864
1094 net.core.wmem_max = 16777216
1098 # some reason it doesn\'t seem to start automatically anyways
1099 pi-nostart transmission-daemon
1100 # be extra sure its not started
1101 ser disable transmission-daemon
1102 ser stop transmission-daemon
1104 # the folder was moved here after an install around 02/2017.
1105 # it contains runtime data,
1106 # plus a simple symlink to the config file which it\'s
1107 # not worth separating out.
1108 # between comps, the uid can change
1109 f=/i/transmission-daemon
1110 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1111 if [[ -e $f ]]; then
1112 s chown -R debian-transmission:debian-transmission $f
1114 for f in /i/k/partial-torrents /i/k/torrents; do
1115 if [[ -e $f ]]; then
1116 s chown -R debian-transmission:user2 $f
1119 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1121 # config file documented here, and it\'s the same config
1122 # for daemon vs client, so it\'s documented in the gui.
1123 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1125 # I originaly setup rpc-whitelist, but after using
1126 # routing to a network namespace, it doesn\'t see the
1127 # real source address, so it\'s disabled.
1129 # Changed the cache-size to 256 mb, reduces disk use.
1130 # It is a read & write cache.
1134 p = '/etc/transmission-daemon/settings.json'
1135 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1136 'rpc-whitelist-enabled' => false,
1137 'rpc-authentication-required' => false,
1138 'incomplete-dir' => '/i/k/partial-torrents',
1139 'incomplete-dir-enabled' => true,
1140 'download-dir' => '/i/k/torrents',
1141 "speed-limit-up" => 800,
1142 "speed-limit-up-enabled" => true,
1143 "peer-port" => 61486,
1144 "cache-size-mb" => 256,
1145 "ratio-limit" => 5.0,
1146 "ratio-limit-enabled" => true,
1151 # todo: others unknown
1156 # trisquel 8 = openvpn, debian stretch = openvpn-client
1157 vpn_ser=openvpn-client
1158 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1162 s dd of=/etc/systemd/system/transmission-daemon-nn.service <<EOF
1164 Description=Transmission BitTorrent Daemon netns
1165 After=network.target
1166 Requires=${vpn_ser}-nn@client.service
1167 After=${vpn_ser}-nn@client.service
1168 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1171 #User=debian-transmission
1172 # notify type doesn't work with sudo
1174 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1175 ExecReload=/bin/kill -s HUP \$MAINPID
1180 WantedBy=multi-user.target
1184 if [[ $HOSTNAME == frodo ]]; then
1185 sgo transmission-daemon-nn
1189 ######### begin transmission client setup ######
1191 if [[ -e /p/transmission-rpc-pass ]]; then
1192 # arch had a default config,
1193 # debian had nothing until you start it.
1194 # With a little trial an error, here is a minimal config
1195 # taken from the generated one, plus changes that the
1196 # settings ui does, without a bunch of ui crap settings.
1198 # only settings I set were
1203 # the password is randomly generated on first run, i copied it out
1204 # so it could be used by other hosts.
1207 p = '/etc/transmission-daemon/settings.json'
1208 s = JSON.parse(File.read(p))
1209 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1210 # default is 0022 (18 in decimal)
1212 File.write p, JSON.pretty_generate(s)
1215 rpc_pass=$(</p/transmission-rpc-pass)
1216 for f in /home/*; do
1218 if [[ ! $(id -u $u) -ge 1000 ]]; then
1221 d=$f/.config/transmission-remote-gtk
1223 s -u $u dd of=$d/config.json <<EOF
1227 "profile-name" : "Default",
1228 "hostname" : "transmission.b8.nz",
1229 "rpc-url-path" : "/transmission/rpc",
1231 "password" : "$rpc_pass",
1232 "auto-connect" : true,
1236 "update-active-only" : false,
1237 "activeonly-fullsync-enabled" : false,
1238 "activeonly-fullsync-every" : 2,
1239 "update-interval" : 3,
1240 "min-update-interval" : 3,
1241 "session-update-interval" : 60,
1249 "add-options-dialog" : false
1254 ######### end transmission client setup ######
1256 # dunno why it\'s there, but get rid of it
1258 li|lj) s rm -rf /home/linode ;;
1265 pi cups ghostscript gsfonts # from arch wiki cups page
1266 pi hplip # from google
1267 s gpasswd -a $USER sys # from arch wiki
1268 sgo org.cups.cupsd.service
1270 debian|trisquel|ubuntu)
1272 s gpasswd -a $USER lpadmin # based on ubuntu wiki
1275 # other distros unknown
1277 # goto http://127.0.0.1:631
1278 # administration tab, add new printer button.
1279 # In debian, I could use hte recommended driver,
1280 # in arch, I had to pick out the 6L driver.
1283 # allow user to run vms, from debian handbook
1284 for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
1285 # bridge networking as user fails. google lead here, but it doesn\'t work:
1286 # oh well, I give up.
1287 # http://wiki.qemu.org/Features-Done/HelperNetworking
1289 # f=/etc/qemu/bridge.conf
1290 # s dd of=$f <<'EOF'
1293 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1296 # general known for debian/ubuntu, not for fedora
1299 debian|trisquel|ubuntu)
1300 if ! type -p go &>/dev/null; then
1302 # just the latest stable at the time of writing
1303 # TODO, maybe put this all into a build script,
1304 # and do some automatic updates
1305 wget -q https://dl.google.com/go/go1.12.4.linux-amd64.tar.gz
1306 s tar -C /usr/local -xzf go1.12.4.linux-amd64.tar.gz
1309 go get -u mvdan.cc/fdroidcl
1310 # a bit of googling, and added settings to bashrc
1317 # otherwise we get error about accessing kvm module.
1318 # seems like there might be a better way, but google was a bit vague.
1319 s $sed -ri '/^ *user *=/d' /etc/libvirt/qemu.conf
1320 echo 'user = "root"' | s tee -a /etc/libvirt/qemu.conf
1321 # guessing this is not needed
1322 #sgo virtlogd.service
1324 # iank: disabed as im not using libvirt usually
1325 # # https://bbs.archlinux.org/viewtopic.php?id=206206
1326 # # # this should prolly go in the wiki
1327 # sgo virtlogd.socket
1330 debian|trisquel|ubuntu)
1331 pi-nostart virtinst virt-manager
1340 wget ftp://ftp.gnu.org/pub/gnu/global/global-6.5.7.tar.gz
1343 # based on https://github.com/leoliu/ggtags
1344 ./configure --with-exuberant-ctags=/usr/bin/ctags
1347 pip install pygments
1355 debian|trisquel|ubuntu)
1362 # removed synergy since ive not used it in a long time
1365 pi --no-install-recommends kdeconnect
1366 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1367 ### but gnome + xmonad not working in flidas, so i disabled it
1368 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1369 # cd /a/opt/indicator-kdeconnect
1372 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1375 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1376 # # it seems, according to
1377 # # /etc/xdg/autostart/kdeconnectd.desktop
1378 # # I'm not seeing the icon, but the clipboard replication is working
1381 ### model 01 arduino support ###
1382 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1383 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1384 # set arduino var in bashrc,
1385 # have system config file setup too.
1386 sudo adduser $USER dialout
1389 sudo usermod -a -G uucp $USER
1393 # this is for the mail command too. update-alternatives is kind of misleading
1394 # since at least it's main commands pretend mail does not exist.
1395 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1396 s update-alternatives --set mailx /usr/bin/mail.mailutils
1398 ######### end misc packages #########
1401 # packages I once used before and liked, but don\'t want installed now for
1403 # python-sqlite is used for offlineimap
1404 # lxappearance python-sqlite dolphin paman dconf-editor
1410 # todo, finish configuring smart.
1413 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1414 # turn on smart. background on options:
1415 # first line, -a = test everyting on all devices.
1416 # -S on, turn on disk internal saving of vendor specific info,
1417 # from google, seems like this is usually already on and fairly standard.
1418 # -o on, turn on 4 hour period non-performance degrading testing.
1419 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1420 sched="-s (S/../.././02|L/../../6/03)"
1421 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1422 DEVICESCAN -a -o on -S on -n standby,q $sched \
1423 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1425 # in the default configuration of at least ubuntu 14.04, resolvconf is
1426 # configured to order any nameservers associated with tun* or tap*
1427 # before the normal internet interfaces, which means they are always
1428 # consulted first. This is often slower and undesirable, ie. local dns
1429 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1431 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1432 # however, this breaks dns lookup for hosts on the openvpn lan.
1433 # I can\'t figure out why hosts on the normal lan would not be
1434 # broken under the default ordering, except the host I was
1435 # testing with previously had an entry in /etc/hosts.
1437 ############# end unfinished
1439 ########### misc stuff
1441 # make networkmanager use resolvconf instead of its own dnsmasq which
1442 # conflicts with the normal dnsmasq package.
1443 f=/etc/NetworkManager/NetworkManager.conf
1445 s sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1446 if [[ $m != $(md5sum $f) ]]; then
1447 srestart NetworkManager
1450 # make my /etc/fonts/conf.d/ get used.
1451 # I have a new sans-serif font there because the default one
1452 # displays l and I as the same char, grrrrr.
1455 /a/bin/distro-setup/mymimes
1461 # stop autopoping windows when i plug in an android phone.
1462 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1463 # with still 0 exit code.
1464 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1465 dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1468 # on grub upgrade, we get prompts unless we do this
1470 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1471 devs+=("$(devbyid $dev),")
1473 devs[-1]=${devs[-1]%,} # jonied by commas
1474 s debconf-set-selections <<EOF
1475 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1479 sgo btrfsmaint.timer
1480 sgo btrfsmaintstop.timer
1483 # the wiki backup script from ofswiki.org uses generic paths
1484 s lnf /p/c/machine_specific/li/mw_vars /root
1485 s lnf /k/backup/wiki_backup /root
1489 trisquel|ubuntu|debian)
1490 # unison-gtk second, i want it to be default, not sure if that works
1491 # with spa. note, I used to install from testing repo when using stable,
1492 # but it shouldn't be needed since I wrote a script to handle mismatching
1494 spa unison unison-gtk
1503 # default is alsa, doesn\'t work with with pianobar
1504 s dd of=/etc/libao.conf <<'EOF'
1505 default_driver=pulse
1510 # # disabled due to my patch being in btrbk
1512 # arch|debian|trisquel|ubuntu) pi btrbk ;;
1519 # note: to see when it was last run,
1524 In mate settings settings, change scrolling to two-finger,
1525 because the default edge scroll doesn\'t work. Originally found this in debian.
1530 # remove dep that came in with desktop
1537 debian|trisquel|ubuntu) s gpasswd -a iank adm ;; #needed for reading logs
1540 /a/bin/buildscripts/pithosfly
1543 # based on guix manual instructions, also added code to profile
1545 if ! type -p guix >/dev/null; then
1547 wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1548 # added some stuff to envonment.sh for profile based on
1549 # manual instructions
1550 # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1551 # echo is to get past prompt
1552 yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1553 guix install glibc-utf8-locales
1554 guix package --install guile
1558 curl https://sh.rustup.rs -sSf | bash -s -- -y
1559 # todo: update this. updates in rust are stupidly complicate
1560 if ! which rg &>/dev/null; then
1561 cargo install ripgrep
1567 # https://www.torproject.org/docs/rpms.html.en
1568 # https://www.torproject.org/docs/debian.html.en
1569 # todo: figure out if the running service needs to be restarted upon updates
1570 # todo on fedora: setup non-dev packages
1572 s dd of=/etc/yum.repos.d/torproject.repo <<'EOF'
1574 name=Tor experimental repo
1576 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1578 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1581 name=Tor experimental source repo
1584 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1586 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1589 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1590 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1592 /a/bin/buildscripts/tor-browser
1595 tu /etc/apt/sources.list "deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1596 gpg --keyserver keys.gnupg.net --recv 886DDD89
1597 gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
1599 pi deb.torproject.org-keyring
1601 /a/bin/buildscripts/tor-browser
1605 /a/bin/buildscripts/tor-browser
1608 pi tor tor-browser-en
1618 fedora todo: disable the firewall or find a way to automate it.
1619 there's an unused section in t.org for tramikssion firewall setup
1621 fedora manual config for nfs:
1623 change to permanent configuration
1624 check the box for nfs
1625 was hard to figure this out, not sure if this is all needed, but
1627 mountd: udp/tcp 20048
1628 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1629 troubleshooting, unblock things in rpcinfo -p
1630 make sure to reload the firewall to load the persistent configuration
1636 debian|trisquel|ubuntu)
1637 pi-nostart nfs-server
1640 pi nfs-utils || pending_reboot=true
1644 # networkmanager has this nasty behavior on flidas: if the machine
1645 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1646 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1648 # This can be manually fixed by stoping dnsmasq,
1649 # then based on whats in /run/dnsmasq/, i see we can run
1650 # s resolvconf -d NetworkManager
1651 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1652 ser stop NetworkManager
1653 ser disable NetworkManager
1656 if [[ $HOSTNAME == frodo ]]; then
1657 # nohide = export filesystems mounted deeper than the export point
1658 # fsid=0 makes this export the "root" export
1659 # not documented in the man page, but this means
1660 # 1. it can be mounted with a shorthand of server:/
1661 # 2. exports that are subdirectories of this one will automatically be mounted
1662 tu /etc/exports <<'EOF'
1663 /k 10.0.0.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1673 # if I was going to create a persistent vm, i might do it like this:
1674 # variant=something # from: virt-install --os-variant list
1675 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1676 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1677 # -n some_name --import --os-variant $variant --cpu host-model-only
1681 ######### begin stuff belonging at the end ##########
1683 echo 0 >~/.local/distro-end
1684 if $pending_reboot; then
1685 echo "$0: pending reboot and then finished. doing it now."
1688 echo "$0: $(date): ending now)"