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 ################
74 # no equivalent in other distros:
75 if isdeb
&& pcheck apt-file
; then
76 # this condition is just a speed optimization
85 # allows me to pipe with ssh -t, and gets rid of spam
86 # http://forums.debian.net/viewtopic.php?f=5&t=85822
87 # i'd rather disable the service than comment the init file
88 # this says disabling the service, it will still get restarted
89 # but this script doesn't do anything on restart, so it should be fine
90 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
93 # this isn't a complete solution. It still shows me when updates are available,
94 # but it's no big deal.
95 s
rm -f /etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
102 ### begin certbot install ###
103 if [[ $distro == debian
]]; then
104 # note, need python-certbot-nginx for nginx, but it depends on nginx,
105 # and I'm not installing nginx by default right now.
106 pi certbot python-certbot-apache
107 elif [[ $codename_compat == xenial
]]; then
108 # not packaged in xenial or flidas
109 pi software-properties-common
110 l
="deb http://ppa.launchpad.net/certbot/certbot/ubuntu xenial main"
111 if ! grep -xFq "$l" /etc
/apt
/sources.list
{,.d
/*.list
}; then
112 s add-apt-repository
-y ppa
:certbot
/certbot ||
:
115 pi python-certbot-apache
117 die
"distro unknown for certbot"
119 # make a version of the certbot timer that emails me.
120 x
=/systemd
/system
/certbot
121 $sed -r -f - /lib
$x.timer
<<'EOF' |s dd of=/etc${x}mail.timer
122 s,^Description.*,\0 mail version,
124 $sed -r -f - /lib
$x.service
<<'EOF' |s dd of=/etc${x}mail.service
125 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
128 sgo certbotmail.timer
129 ### end certbot install ###
132 # dogcam setup. not using atm
135 # /a/bin/webcam/install-server
138 # /a/bin/webcam/install-client
143 ## not actually using prometheus just yet
144 # # office is not exposed to internet yet
145 # if [[ $HOSTNAME != kw ]]; then
146 # ## prometheus node exporter setup
147 # web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF'
148 # #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
149 # # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
153 # AuthName "Authentication Required"
154 # # setup one time, with root:www-data, 640
155 # AuthUserFile "/etc/prometheus-htpasswd"
162 ######### begin flidas pinned packages ######
163 case $
(debian-codename
) in
164 # needed for debootstrap scripts for fai since fai requires debian
166 curl http
://archive.ubuntu.com
/ubuntu
/project
/ubuntu-archive-keyring.gpg | s apt-key add
-
167 s
dd of
=/etc
/apt
/preferences.d
/flidas-xenial
<<EOF
169 Pin: release a=xenial
173 Pin: release a=xenial-updates
177 Pin: release a=xenial-security
180 s
dd of
=/etc
/apt
/sources.list.d
/xenial.list
2>/dev
/null
<<EOF
181 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
182 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
183 deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
186 s apt-key adv
--keyserver keyserver.ubuntu.com
--recv-keys 3B4FE6ACC0B21F32
187 s
dd of
=/etc
/apt
/preferences.d
/flidas-bionic
<<EOF
189 Pin: release a=bionic
193 Pin: release a=bionic-updates
197 Pin: release a=bionic-security
201 # better to run btrfs-progs which matches our kernel version
202 # (note, renamed from btrfs-tools)
203 s
dd of
=/etc
/apt
/preferences.d
/btrfs-progs
<<EOF
204 Package: btrfs-progs libzstd1
205 Pin: release a=bionic
208 Package: btrfs-progs libzstd1
209 Pin: release a=bionic-updates
212 Package: btrfs-progs libzstd1
213 Pin: release a=bionic-security
220 deb http://us.archive.ubuntu.com/ubuntu/ bionic main
221 deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main
222 deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main
224 f
=/etc
/apt
/sources.list.d
/bionic.list
225 if ! diff -q $t $f; then
231 # no special reason, but its better for btrfs-progs to
232 # be closer to our kernel version
237 aptitude download debootstrap
/xenial
239 s
cp .
/usr
/share
/debootstrap
/scripts
/* /usr
/share
/debootstrap
/scripts
241 s
dd of
=/etc
/apt
/preferences.d
/flidas-etiona
<<EOF
243 Pin: release a=etiona
247 Pin: release a=etiona-updates
251 Pin: release a=etiona-security
255 Pin: release a=etiona-backports
261 deb http://mirror.fsf.org/trisquel/ etiona main
262 deb http://mirror.fsf.org/trisquel/ etiona-updates main
263 deb http://archive.trisquel.info/trisquel/ etiona-security main
264 deb http://mirror.fsf.org/trisquel/ etiona-backports main
266 f
=/etc
/apt
/sources.list.d
/etiona.list
267 if ! diff -q $t $f; then
273 s
dd of
=/etc
/apt
/preferences.d
/debian-goodies
<<EOF
274 Package: debian-goodies
275 Pin: release n=etiona
280 s
dd of
=/etc
/apt
/preferences.d
/flidas-buster
<<EOF
282 Pin: release n=buster
286 Pin: release n=buster-updates
290 # dont use buster because it causes dist-upgrade to think its downgrading
291 # packages while really just reinstalling the same version.
292 f
=/etc
/apt
/apt.conf.d
/01iank
294 # # stupid buster uses some key algorithm not supported by flidas gpg that apt uses.
295 # s dd of=/etc/apt/apt.conf.d/01iank <<'EOF'
296 # Acquire::AllowInsecureRepositories "true";
299 f
=/etc
/apt
/sources.list.d
/buster.list
303 # deb http://http.us.debian.org/debian buster main
304 # deb-src http://http.us.debian.org/debian buster main
306 # deb http://security.debian.org/ buster/updates main
307 # deb-src http://security.debian.org/ buster/updates main
309 # deb http://http.us.debian.org/debian buster-updates main
310 # deb-src http://http.us.debian.org/debian buster-updates main
312 # if ! diff -q $t $f; then
318 # newer version needed for false positive in checkrestart.
319 # I did buster at first, but other problem above with having
320 # buster repos. not sure if the false positive exists in etiona.
321 p
install -y --allow-unauthenticated debian-goodies
323 s
dd of
=/etc
/apt
/preferences.d
/shellcheck
<<EOF
325 Pin: release a=etiona
329 Pin: release a=etiona-updates
333 Pin: release a=etiona-security
337 s
dd of
=/etc
/apt
/preferences.d
/bash
<<EOF
339 Pin: release a=etiona
343 Pin: release a=etiona-updates
347 Pin: release a=etiona-security
355 pi debian-goodies shellcheck
359 ######### end flidas pinned packages ######
361 ##### begin automatic upgrades (after checkrestart has been installed) ####
362 s
dd of
=/etc
/apt
/apt.conf.d
/10periodic
<<'EOF'
363 # this file was mostly just comments.
364 APT::Periodic::Update-Package-Lists "1";
365 APT::Periodic::Download-Upgradeable-Packages "1";
366 APT::Periodic::AutocleanInterval "7";
367 APT::Periodic::Unattended-Upgrade "1";
370 s
dd of
=/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
371 # fyi: default file has comments about available options,
372 # you may want to read that, do pkx unattended-upgrades
373 Unattended-Upgrade::Mail "root";
374 Unattended-Upgrade::MailOnlyOnError "true";
375 Unattended-Upgrade::Remove-Unused-Dependencies "true";
376 Unattended-Upgrade::Origins-Pattern {
377 # default is just security updates. this list found from reading
378 # match_whitelist_string() in `which unattended-upgrades`
379 "o=*,l=*,a=*,c=*,site=*,n=*";
383 # old names, too verbose
384 s
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
386 s
dd of
=/etc
/cron.d
/myupgrade
<<'EOF'
387 # Setup reboots when running outdated stuff, unattended upgrades happen
388 # at 6 am + rand(60 min).
389 20 7 * * * root /usr/local/bin/myupgrade | /usr/local/bin/log-once -1 myupgrade
390 0 * * * * root /usr/local/bin/mycheckrestart | /usr/local/bin/log-once -1 mycheckrestart
392 ##### end automatic upgrades ####
396 ###### begin website setup
399 f
=/var
/lib
/bind
/db.b8.nz
400 if [[ ! -e $f ]]; then
403 s
install -m 644 -o bind -g bind /p
/c
/machine_specific
/linode
/bind-initial
/db.b8.nz
$f
413 li
) domain
=iankelling.org
;;
415 /a
/h
/setup.sh
$domain
418 # start mumble only when im going to use it, since i dont use it much
419 pi-nostart mumble-server
420 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
422 # do certificate to avoid warning about unsigned cert,
423 # which is overkill for my use, but hey, I'm cool, I know
425 web-conf apache2 mumble.iankelling.org
426 s
rm -f /etc
/apache
2/sites-enabled
/mumble.iankelling.org
428 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
429 /a/bin/distro-setup/certbot-renew-hook
433 # requested from linode via a support ticket.
434 # https://www.linode.com/docs/networking/an-overview-of-ipv6-on-linode/
435 # ipv6 stuff pieced together
436 # via slightly wrong information from
437 # https://github.com/angristan/openvpn-install/blob/master/openvpn-install.sh
438 # https://community.openvpn.net/openvpn/wiki/IPv6
441 vpn-server-setup
-rd 2600:3c00
:e000
:280::1/64 2600:3c00
::f03c
:91ff
:feb4
:0bf3
442 s
tee /etc
/openvpn
/client-config
/mail <<'EOF'
443 ifconfig-push 10.8.0.4 255.255.255.0
444 ifconfig-ipv6-push 2600:3c00:e000:280::2/64
447 if [[ -e /lib
/systemd
/system
/openvpn-server@.service
]]; then
448 vpn_service
=openvpn-server@server
450 vpn_service
=openvpn@server
453 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
455 Description=Turns on iptables mail nat
460 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
461 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
464 WantedBy=$vpn_service.service
468 # needed for li's local mail delivery.
469 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
471 # setup let's encrypt cert
472 web-conf apache2 mail.iankelling.org
473 s rm /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
476 domain=cal.iankelling.org
477 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
478 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
479 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
481 Options +FollowSymLinks +Multiviews +Indexes
484 AuthName "Authentication Required"
485 # setup one time, with root:www-data, 640
486 AuthUserFile "/etc/caldav-htpasswd"
490 # nginx version of above would be:
491 # auth_basic "Not currently available";
492 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
496 ###### begin znc setup #####
499 # https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart after cert change.
500 # to get into the web interface,
501 # then use non-main browser or else it doebsn't allow it based on ocsp stapling from my main site.
502 # https://iankelling.org:12533/
504 export RENEWED_LINEAGE=/etc/letsencrypt/live/iankelling.org
505 /a/bin/distro-setup/certbot-renew-hook
508 # znc config generated by doing
510 # selected port is also used in erc config
511 # comma separated channel list worked.
512 # while figuring things out, running znc -D for debug in foreground.
513 # to exit and save config:
514 # /msg *status shutdown
515 # configed auth on freenode by following
516 # https://wiki.znc.in/Sasl:
517 # /msg *sasl RequireAuth yes
518 # /msg *sasl Mechanism PLAIN
519 # /msg *sasl Set ident_name password
520 # created the system service after, and had to do
521 # mv /home/iank/.znc/* /var/lib/znc
522 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
523 # and made a copy of the config files into /p/c
524 # /msg *status LoadMod --type=global log -sanitize
525 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
526 # /msg *status LoadMod --type=network perform
527 # /msg *perform add PRIVMSG ChanServ :invite #fsf-office
528 # /msg *perform add JOIN #fsf-office
531 # also ran /znc LoadMod clearbufferonmsg
532 # it would be nice if erc supported erc query buffers by doing
533 # /msg *status clearbuffer <name of the query/receiver
535 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
536 # if that was the case i could remove the module clearbufferonmsg
537 # also would be nice if erc supported
538 # https://wiki.znc.in/self-message
539 # https://wiki.znc.in/Query_buffers \
541 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
542 s chmod 700 /var/lib/znc
543 s chown -R znc:znc /var/lib/znc
544 s dd of=/etc/systemd/system/znc.service 2>/dev/null <<'EOF'
546 Description=ZNC, an advanced IRC bouncer
547 After=network-online.target
550 ExecStart=/usr/bin/znc -f --datadir=/var/lib/znc
554 WantedBy=multi-user.target
558 ###### stop znc setup #####
563 ###### end website setup
565 ########### end section including li/lj ###############
568 case $codename_compat in
570 # mate-indicator-applet and beyond are msc things I noticed diffing a
571 # standard install with mine.
572 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
578 # mate doesnt have wayland support yet
579 pi task-gnome-desktop
586 # TODO: some of the X programs can be removed from pall when using wayland
588 # depends gcc is a way to install suggests. this is apparently the only
589 # way to install suggests even if the main package is already
590 # installed. reinstall doesn't work, uninstalling can cause removing
591 # dependent packages.
592 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)
595 sgo fsf-vpn-dns-cleanup
598 # website is dead june 14 2019. back in october, but meh
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
769 ############# begin syncthing setup ###########
770 if [[ $HOSTNAME == frodo ]]; then
771 # It\'s simpler to just worry about running it in one place for now.
772 # I assume it would work to clone it\'s config to another non-phone
773 # and just run it in one place instead of the normal having a
774 # separate config. I lean toward using the same config, since btrfs
775 # syncs between comps.
776 # testing has relatively up to date packages
777 if ! isdebian-testing; then
778 # based on error when doing apt-get update:
779 # E: The method driver /usr/lib/apt/methods/https could not be found.
780 pi apt-transport-https
781 # google led me here:
782 # https://apt.syncthing.net/
783 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
784 s="deb http://apt.syncthing.net/ syncthing release"
785 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
786 echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
791 lnf -T /w/syncthing /home/iank/.config/syncthing
792 ser daemon-reload # syncthing likely not properly packaged
793 sgo syncthing@iank # runs as iank
795 # these things persist in ~/.config/syncthing, which I save in
796 # /w/syncthing (not in /p, because syncthing should continue to
797 # run on home server even when using laptop as primary device)
798 # open http://localhost:8384/
799 # change listen address from default to tcp://:22001,
800 # this is because we do port forward so it doesn\'t have to use
801 # some external server, but the syncthing is broken for port forward,
802 # you get a message, something "like connected to myself, this should not happen"
803 # when connecting to other local devices, so I bump the port up by 1,
805 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
806 # Without this, it was being stuck syncing at 0%.
807 # Set gui username and password.
809 # install syncthing via f-droid,
810 # folder setting, turn off send only.
811 # on phone, add device, click bar code icon
812 # on dekstop, top right, actions, device id
813 # after adding, notification will appear on desktop to confirm
815 # syncing folder. from phone to desktop: select desktop in the
816 # folder on phone\'s sync options, notification will appear in
817 # desktop\'s web ui within a minute. For the reverse, the
818 # notification will appear in android\'s notifications, you have to
819 # swipe down and tap it to add the folder. It won\'t appear in the
820 # syncthing ui, which would be intuitive, but don\'t wait for it
821 # there. The notification may not work, instead open the web gui
822 # from in the app, there should be a notification within there.
824 # On phone, set settings to run syncthing all the time, and
825 # show no notification.
827 # Folder versioning would make sense if I didn\'t already use btrfs
828 # for backups. I would choose staggered, or trash can for more space.
830 # if needed to install on a remote comp:
831 # ssh -L 8384:localhost:8384 -N frodo
832 # open http://localhost:8384/
834 # Note, the other thing i did was port forward port 22000,
835 # per https://docs.syncthing.net/users/firewall.html
838 ############# end syncthing setup ###########
842 ####### begin misc packages ###########
851 # sakura config is owned by ian
854 sudo -u user2 -i reset-konsole
855 # user2 xscreensaver we don't want to reset
859 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
860 # this is also in primary-setup
861 # pi libxss-dev # dependency based on build failure
863 # cabal install --upgrade-dependencies --force-reinstalls arbtt
864 # also, i assume syncing this between machines somehow messed thin
865 #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log
869 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
870 cp /p/.linphonerc-initial ~/.linphonerc
874 ### begin spd install
875 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
877 wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
880 # this guesses at the appropriate directory, adjust if needed
881 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
882 sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
883 # newer distro had gpg2 as default, older one, flidas, need to make it that way
884 gpgpath=$(which gpg2)
886 s mkdir -p /usr/local/spdhackfix
887 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
892 # nagstamon setting which were set through the ui
894 # all unknown sources
895 # all warning services
896 # acknowledged hosts & services
897 # hosts & services down for maintenence
898 # services on down hosts
899 # services on hosts in maintenece
900 # services on unreachable osts
901 # hosts in soft state
902 # services in soft state
903 # in display tab: fullscreen
905 # these translate to these settings I think
906 # filter_acknowledged_hosts_services = True
907 # filter_all_unknown_services = True
908 # filter_all_warning_services = True
909 # filter_hosts_in_soft_state = True
910 # filter_hosts_services_maintenance = True
911 # filter_services_in_soft_state = True
912 # filter_services_on_down_hosts = True
913 # filter_services_on_hosts_in_maintenance = True
914 # filter_services_on_unreachable_hosts = True
915 # notify_if_up = False
916 # statusbar_floating = False
918 # but i'm just going to rely on the webpage plus sms for now.
921 # it asks if it should make users in it's group capture packets without root,
922 # which is arguably more secure than running wireshark as root. default is no,
923 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
924 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
926 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
927 # listed in the default config as suggested.
928 # /run/usr/1000 i noticed was missing for pulseaudio
929 # /run/user/0 just seemed like a not bad idea, given the above
930 tu /etc/schroot/desktop/fstab <<'EOF'
931 /run /run none rw,bind 0 0
932 /run/lock /run/lock none rw,bind 0 0
933 /dev/shm /dev/shm none rw,bind 0 0
934 /run/shm /run/shm none rw,bind 0 0
935 /run/user/1000 /run/user/1000 none rw,bind 0 0
936 /run/user/1001 /run/user/1001 none rw,bind 0 0
937 /run/user/0 /run/user/0 none rw,bind 0 0
945 repo=http://archive.ubuntu.com/ubuntu/
948 repo=http://deb.debian.org/debian/
953 if schroot -l | grep -xFq chroot:$n; then
954 echo "$0: $n schroot already installed, skipping"
959 s dd of=/etc/schroot/chroot.d/$n.conf <<EOF
965 preserve-environment=true
968 if [[ -e $d/bin ]]; then
969 s chroot $d apt-get update
970 s chroot $d apt-get -y dist-upgrade --purge --auto-remove
971 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
975 s debootstrap $n $d $repo
976 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
978 s cp -P {,$d}/etc/localtime
980 s dd of=/etc/systemd/system/schrootupdate.service <<'EOF'
982 Description=schrootupdate
983 After=multi-user.target
987 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
989 s dd of=/etc/systemd/system/schrootupdate.timer <<'EOF'
991 Description=schrootupdate
994 OnCalendar=*-*-* 04:20:00
997 WantedBy=timers.target
999 s systemctl daemon-reload
1000 sgo schrootupdate.timer
1007 mkschroot debian stretch firefox-esr pulseaudio chromium
1014 s mkdir -p /nocow/user
1015 s chown $USER:$USER /nocow/user
1019 ####### begin transmission
1021 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1022 # 450 seems likely to be unused. we need to specify one or else
1023 # it won't be stable across installs.
1024 if ! getent passwd debian-transmission > /dev/null; then
1025 s groupadd -g 450 debian-transmission
1031 --disabled-password \
1032 --home /var/lib/transmission-daemon \
1035 # We want group writable stuff from transmission.
1036 # However, after setting this, I learn that transmission sets it's
1037 # own umask based on it's settings file. Well, no harm leaving this
1038 # so it's set right from the beginning.
1039 s chfn debian-transmission -o umask=0002
1041 # note i had to do this, which is persistent:
1043 # s chgrp debian-transmission torrents partial-torrents
1045 # syslog says things like
1046 # 'Failed to set receive buffer: requested 4194304, got 425984'
1047 # google suggets giving it even more than that
1048 tu /etc/sysctl.conf<<'EOF'
1049 net.core.rmem_max = 67108864
1050 net.core.wmem_max = 16777216
1054 # some reason it doesn\'t seem to start automatically anyways
1055 pi-nostart transmission-daemon
1056 # be extra sure its not started
1057 ser disable transmission-daemon
1058 ser stop transmission-daemon
1060 # the folder was moved here after an install around 02/2017.
1061 # it contains runtime data,
1062 # plus a simple symlink to the config file which it\'s
1063 # not worth separating out.
1064 # between comps, the uid can change
1065 f=/i/transmission-daemon
1066 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1067 if [[ -e $f ]]; then
1068 s chown -R debian-transmission:debian-transmission $f
1070 for f in /i/k/partial-torrents /i/k/torrents; do
1071 if [[ -e $f ]]; then
1072 s chown -R debian-transmission:user2 $f
1075 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1077 # config file documented here, and it\'s the same config
1078 # for daemon vs client, so it\'s documented in the gui.
1079 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1081 # I originaly setup rpc-whitelist, but after using
1082 # routing to a network namespace, it doesn\'t see the
1083 # real source address, so it\'s disabled.
1085 # Changed the cache-size to 256 mb, reduces disk use.
1086 # It is a read & write cache.
1090 p = '/etc/transmission-daemon/settings.json'
1091 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1092 'rpc-whitelist-enabled' => false,
1093 'rpc-authentication-required' => false,
1094 'incomplete-dir' => '/i/k/partial-torrents',
1095 'incomplete-dir-enabled' => true,
1096 'download-dir' => '/i/k/torrents',
1097 "speed-limit-up" => 800,
1098 "speed-limit-up-enabled" => true,
1099 "peer-port" => 61486,
1100 "cache-size-mb" => 256,
1101 "ratio-limit" => 5.0,
1102 "ratio-limit-enabled" => true,
1105 ####### end transmission
1109 # trisquel 8 = openvpn, debian stretch = openvpn-client
1110 vpn_ser=openvpn-client
1111 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1115 s dd of=/etc/systemd/system/transmission-daemon-nn.service <<EOF
1117 Description=Transmission BitTorrent Daemon netns
1118 After=network.target
1119 Requires=${vpn_ser}-nn@client.service
1120 After=${vpn_ser}-nn@client.service
1121 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1124 #User=debian-transmission
1125 # notify type doesn't work with sudo
1127 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1128 ExecReload=/bin/kill -s HUP \$MAINPID
1133 WantedBy=multi-user.target
1137 if [[ $HOSTNAME == frodo ]]; then
1138 sgo transmission-daemon-nn
1142 ######### begin transmission client setup ######
1144 if [[ -e /p/transmission-rpc-pass ]]; then
1145 # arch had a default config,
1146 # debian had nothing until you start it.
1147 # With a little trial an error, here is a minimal config
1148 # taken from the generated one, plus changes that the
1149 # settings ui does, without a bunch of ui crap settings.
1151 # only settings I set were
1156 # the password is randomly generated on first run, i copied it out
1157 # so it could be used by other hosts.
1160 p = '/etc/transmission-daemon/settings.json'
1161 s = JSON.parse(File.read(p))
1162 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1163 # default is 0022 (18 in decimal)
1165 File.write p, JSON.pretty_generate(s)
1168 rpc_pass=$(</p/transmission-rpc-pass)
1169 for f in /home/*; do
1171 if [[ ! $(id -u $u) -ge 1000 ]]; then
1174 d=$f/.config/transmission-remote-gtk
1176 s -u $u dd of=$d/config.json <<EOF
1180 "profile-name" : "Default",
1181 "hostname" : "transmission.b8.nz",
1182 "rpc-url-path" : "/transmission/rpc",
1184 "password" : "$rpc_pass",
1185 "auto-connect" : true,
1189 "update-active-only" : false,
1190 "activeonly-fullsync-enabled" : false,
1191 "activeonly-fullsync-every" : 2,
1192 "update-interval" : 3,
1193 "min-update-interval" : 3,
1194 "session-update-interval" : 60,
1202 "add-options-dialog" : false
1207 ######### end transmission client setup ######
1212 s gpasswd -a $USER lpadmin # based on ubuntu wiki
1213 # goto http://127.0.0.1:631
1214 # administration tab, add new printer button.
1215 # In debian, I could use hte recommended driver,
1216 # in arch, I had to pick out the 6L driver.
1219 # allow user to run vms, from debian handbook
1220 for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
1221 # bridge networking as user fails. google lead here, but it doesn\'t work:
1222 # oh well, I give up.
1223 # http://wiki.qemu.org/Features-Done/HelperNetworking
1225 # f=/etc/qemu/bridge.conf
1226 # s dd of=$f <<'EOF'
1229 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1232 # general known for debian/ubuntu, not for fedora
1234 /a/bin/buildscripts/go
1236 pi-nostart virtinst virt-manager
1240 pi --no-install-recommends kdeconnect
1241 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1242 ### but gnome + xmonad not working in flidas, so i disabled it
1243 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1244 # cd /a/opt/indicator-kdeconnect
1247 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1250 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1251 # # it seems, according to
1252 # # /etc/xdg/autostart/kdeconnectd.desktop
1253 # # I'm not seeing the icon, but the clipboard replication is working
1256 ### model 01 arduino support ###
1257 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1258 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1259 # set arduino var in bashrc,
1260 # have system config file setup too.
1261 sudo adduser $USER dialout
1263 # this is for the mail command too. update-alternatives is kind of misleading
1264 # since at least it's main commands pretend mail does not exist.
1265 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1266 s update-alternatives --set mailx /usr/bin/mail.mailutils
1268 ######### end misc packages #########
1271 # packages I once used before and liked, but don\'t want installed now for
1273 # python-sqlite is used for offlineimap
1274 # lxappearance python-sqlite dolphin paman dconf-editor
1280 # todo, finish configuring smart.
1283 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1284 # turn on smart. background on options:
1285 # first line, -a = test everyting on all devices.
1286 # -S on, turn on disk internal saving of vendor specific info,
1287 # from google, seems like this is usually already on and fairly standard.
1288 # -o on, turn on 4 hour period non-performance degrading testing.
1289 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1290 sched="-s (S/../.././02|L/../../6/03)"
1291 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1292 DEVICESCAN -a -o on -S on -n standby,q $sched \
1293 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1295 # in the default configuration of at least ubuntu 14.04, resolvconf is
1296 # configured to order any nameservers associated with tun* or tap*
1297 # before the normal internet interfaces, which means they are always
1298 # consulted first. This is often slower and undesirable, ie. local dns
1299 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1301 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1302 # however, this breaks dns lookup for hosts on the openvpn lan.
1303 # I can\'t figure out why hosts on the normal lan would not be
1304 # broken under the default ordering, except the host I was
1305 # testing with previously had an entry in /etc/hosts.
1307 ############# end unfinished
1309 ########### misc stuff
1311 # make networkmanager use resolvconf instead of its own dnsmasq which
1312 # conflicts with the normal dnsmasq package.
1313 f=/etc/NetworkManager/NetworkManager.conf
1315 s sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1316 if [[ $m != $(md5sum $f) ]]; then
1317 srestart NetworkManager
1320 # make my /etc/fonts/conf.d/ get used.
1321 # I have a new sans-serif font there because the default one
1322 # displays l and I as the same char, grrrrr.
1325 /a/bin/distro-setup/mymimes
1331 # stop autopoping windows when i plug in an android phone.
1332 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1333 # with still 0 exit code.
1334 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1335 dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1338 # on grub upgrade, we get prompts unless we do this
1340 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1341 devs+=("$(devbyid $dev),")
1343 devs[-1]=${devs[-1]%,} # jonied by commas
1344 s debconf-set-selections <<EOF
1345 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1349 sgo btrfsmaint.timer
1350 sgo btrfsmaintstop.timer
1352 # aren't autoupdating this, but I do check on it somewhat regularly.
1357 # note: to see when it was last run,
1362 In mate settings settings, change scrolling to two-finger,
1363 because the default edge scroll doesn\'t work. Originally found this in debian.
1368 # remove dep that came in with desktop
1374 s gpasswd -a iank adm ;; #needed for reading logs
1376 /a/bin/buildscripts/pithosfly
1379 # # Based on guix manual instructions, also added code to profile.
1380 # # disabled since i'm not using it now.
1382 # if ! type -p guix >/dev/null; then
1384 # wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1385 # # added some stuff to envonment.sh for profile based on
1386 # # manual instructions
1387 # # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1388 # # echo is to get past prompt
1389 # yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1390 # guix install glibc-utf8-locales
1391 # guix package --install guile
1397 /a/bin/buildscripts/tor-browser
1400 pi-nostart nfs-server
1402 # networkmanager has this nasty behavior on flidas: if the machine
1403 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1404 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1406 # This can be manually fixed by stoping dnsmasq,
1407 # then based on whats in /run/dnsmasq/, i see we can run
1408 # s resolvconf -d NetworkManager
1409 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1410 ser stop NetworkManager
1411 ser disable NetworkManager
1414 if [[ $HOSTNAME == frodo ]]; then
1415 # nohide = export filesystems mounted deeper than the export point
1416 # fsid=0 makes this export the "root" export
1417 # not documented in the man page, but this means
1418 # 1. it can be mounted with a shorthand of server:/
1419 # 2. exports that are subdirectories of this one will automatically be mounted
1420 tu /etc/exports <<'EOF'
1421 /k 10.0.0.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1430 # if I was going to create a persistent vm, i might do it like this:
1431 # variant=something # from: virt-install --os-variant list
1432 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1433 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1434 # -n some_name --import --os-variant $variant --cpu host-model-only
1438 ######### begin stuff belonging at the end ##########