2 # Copyright (C) 2016 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 source /a
/bin
/errhandle
/err
18 src
="$(readlink -f -- "${BASH_SOURCE[0]}")"; src
=${src%/*} # directory of this file
20 # shellcheck source=./pkgs
24 exec &> >(sudo
tee -a /var
/log
/distro-end
)
25 echo "$0: $(date): starting now)"
26 # see example of usage to understand.
29 IFS
= read -r -d '' y ||
:
33 printf "$0: %s\n" "$*" >&2; exit 1
35 spa
() { # simple package add
39 codename
=$
(debian-codename
)
40 codename_compat
=$
(debian-codename-compat
)
42 sed="sed --follow-symlinks"
54 s debconf-set-selections
<<EOF
55 popularity-contest popularity-contest/participate boolean true
58 ########### begin section including li ################
62 case $codename_compat in
64 # mate-indicator-applet and beyond are msc things I noticed diffing a
65 # standard install with mine.
66 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
72 # mate doesnt have wayland support yet
94 # no equivalent in other distros:
95 if isdeb
&& ! dpkg
-s -- "$@" |
grep -Fx "Status: install ok installed" &> /dev
/null
; then
96 # this condition is just a speed optimization
105 # allows me to pipe with ssh -t, and gets rid of spam
106 # http://forums.debian.net/viewtopic.php?f=5&t=85822
107 # i'd rather disable the service than comment the init file
108 # this says disabling the service, it will still get restarted
109 # but this script doesn't do anything on restart, so it should be fine
110 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
113 # this isn't a complete solution. It still shows me when updates are available,
114 # but it's no big deal.
115 s t
/etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
120 ### begin docker install ####
122 # https://store.docker.com/editions/community/docker-ce-server-debian?tab=description
123 pi software-properties-common apt-transport-https
124 curl
-fsSL https
://download.docker.com
/linux
/$
(distro-name-compat
)/gpg | sudo apt-key add
-
125 url
=https
://download.docker.com
/linux
/$
(distro-name-compat
)
126 l
="deb [arch=amd64] $url $codename_compat stable"
128 if ! grep -xFq "$l" /etc
/apt
/sources.list
{,.d
/*.list
}; then
129 sudo add-apt-repository
"$l"
132 # docker eats up a fair amount of cpu when doing nothing, so don't enable it unless
135 # and docker is even more crap, it ignores that it shouldnt start
142 ### end docker install ####
146 ### begin certbot install ###
147 if [[ $distro == debian
]]; then
148 # note, need python-certbot-nginx for nginx, but it depends on nginx,
149 # and I'm not installing nginx by default right now.
150 pi certbot python-certbot-apache
151 elif [[ $codename_compat == xenial
]]; then
152 # not packaged in xenial or flidas
153 pi software-properties-common
154 l
="deb http://ppa.launchpad.net/certbot/certbot/ubuntu xenial main"
155 if ! grep -xFq "$l" /etc
/apt
/sources.list
{,.d
/*.list
}; then
156 s add-apt-repository
-y ppa
:certbot
/certbot ||
:
159 pi python-certbot-apache
161 die
"distro unknown for certbot"
163 # make a version of the certbot timer that emails me.
164 x
=/systemd
/system
/certbot
165 $sed -r -f - /lib
$x.timer
<<'EOF' |s dd of=/etc${x}mail.timer
166 s,^Description.*,\0 mail version,
168 $sed -r -f - /lib
$x.service
<<'EOF' |s dd of=/etc${x}mail.service
169 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
172 sgo certbotmail.timer
173 ### end certbot install ###
176 # dogcam setup. not using atm
179 # /a/bin/webcam/install-server
182 # /a/bin/webcam/install-client
188 ##### begin automatic upgrades ####
190 s
dd of
=/etc
/apt
/apt.conf.d
/10periodic
<<'EOF'
191 # this file was mostly just comments.
192 APT::Periodic::Update-Package-Lists "1";
193 APT::Periodic::Download-Upgradeable-Packages "1";
194 APT::Periodic::AutocleanInterval "7";
195 APT::Periodic::Unattended-Upgrade "1";
198 s
dd of
=/etc
/apt
/apt.conf.d
/50unattended
-upgrades <<EOF
199 # fyi: default file has comments about available options,
200 # you may want to read that.
201 Unattended-Upgrade::Mail "root";
202 Unattended-Upgrade::MailOnlyOnError "true";
203 Unattended-Upgrade::Remove-Unused-Dependencies "true";
204 Unattended-Upgrade::Origins-Pattern {
205 # default is just security updates.
210 # Setup reboots when running outdated stuff, unattended upgrades happen
211 # at 6 am + rand(60 min).
212 /usr
/local
/bin
/log-once checkrestart
214 # old names, too verbose
215 s
rm -f /etc
/cron.d
/unattended-upgrade-reboot
/usr
/local
/bin
/zelous-unattended-reboot
217 s
dd of
=/etc
/cron.d
/myupgrade
<<'EOF'
218 20 7 * * * root /usr/local/bin/myupgrade | /usr/local/bin/log-once -1 myupgrade
219 0 * * * * root /usr/local/bin/mycheckrestart | /usr/local/bin/log-once -1 mycheckrestart
221 ##### end automatic upgrades ####
223 # office is not exposed to internet yet
224 if [[ $
(hostname
-f) != *.office.fsf.org
]]; then
225 ## prometheus node exporter setup
226 web-conf
-f 9100 -p 9101 apache2 $
(hostname
-f) <<'EOF'
227 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
228 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
232 AuthName "Authentication Required"
233 # setup one time, with root:www-data, 640
234 AuthUserFile "/etc/prometheus-htpasswd"
244 lj
) domain
=iank.bid
; exit 0 ;;
245 li
) domain
=iankelling.org
;;
247 /a
/h
/setup.sh
$domain
250 sudo
-E /a
/bin
/mediawiki-setup
/mw-setup-script
252 pi-nostart mumble-server
253 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
255 # do certificate to avoid warning about unsigned cert,
256 # which is overkill for my use, but hey, I'm cool, I know
258 web-conf apache2 mumble.iankelling.org
259 s
rm -f /etc
/apache
2/sites-enabled
/mumble.iankelling.org
261 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
262 /a/bin/distro-setup/certbot-renew-hook
268 s
tee /etc
/openvpn
/client-config
/mail <<'EOF'
269 ifconfig-push 10.8.0.4 255.255.255.0
272 # it\'s strange. docker seems to make the default for forward
273 # be drop, but then I set it to accept and it\'s stuck that way,
274 # I dun know why. But, let\'s make sure we can forward anyways.
275 s DEBIAN_FRONTEND
=noninteractive pi iptables-persistent
276 rm /etc
/iptables
/rules.v6
277 s
tee /etc
/iptables
/rules.v4
<<'EOF'
279 -A FORWARD -i tun+ -o eth0 -j ACCEPT
280 -A FORWARD -i eth0 -o tun+ -j ACCEPT
285 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
287 Description=Turns on iptables mail nat
292 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
293 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
296 WantedBy=openvpn.service
299 ser
enable vpnmail.service
300 # needed for li's local mail delivery.
301 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
302 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
303 vpn_service=openvpn-server@server
305 vpn_service=openvpn@server
308 # setup let's encrypt cert
309 web-conf apache2 mail.iankelling.org
310 s rm /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
313 domain=cal.iankelling.org
314 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
315 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
316 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
318 Options +FollowSymLinks +Multiviews +Indexes
321 AuthName "Authentication Required"
322 # setup one time, with root:www-data, 640
323 AuthUserFile "/etc/caldav-htpasswd"
327 # nginx version of above would be:
328 # auth_basic "Not currently available";
329 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
332 ########## begin pump.io setup ##########
334 # once pump adds a logrotation script, turn off nologger,
336 # "logfile": "/var/log/pumpio/pumpio.log",
338 s dd of=/etc/pump.io.json <<'EOF'
340 "secret": "SECRET_REPLACE_ME",
342 "params": { "dbname": "pumpio" },
344 "site": "pump.iankelling.org",
345 "owner": "Ian Kelling",
346 "ownerURL": "https://iankelling.org/",
349 "hostname": "pump.iankelling.org",
351 "datadir": "/home/pumpio/pumpdata",
352 "enableUploads": true,
353 "debugClient": false,
354 "disableRegistration": true,
356 "key": "/home/pumpio/privkey.pem",
357 "cert": "/home/pumpio/fullchain.pem",
358 "address": "localhost",
362 s sed -i "s#SECRET_REPLACE_ME#$(cat /p/c/machine_specific/li/pump-secret)#" /etc/pump.io.json
364 # stretch node is too old
365 # https://nodejs.org/en/download/package-manager/
366 curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
367 pi nodejs graphicsmagick mongodb
369 if [[ -e pump.io ]]; then
373 git clone https://github.com/pump-io/pump.io.git
376 # note: these 2 commands seem
377 # note: doing this or the npm install pump.io as root had problems.
380 # normally, next command would be
381 # s npm install -g odb
382 # but it\'s this until a bug in pump gets fixed
383 # https://github.com/pump-io/pump.io/issues/1287
384 s npm install -g databank-mongodb@0.19.2
385 if ! getent passwd pumpio &>/dev/null; then
386 s useradd -Um -s /bin/false pumpio
388 sudo -u pumpio mkdir -p /home/pumpio/pumpdata
389 # for testing browser when only listening to localhost,
390 # in the pump.io.json, set hostname localhost, urlPort 5233
391 #ssh -L 5233:localhost:5233 li
393 s mkdir -p /var/log/pumpio/
394 s chown pumpio:pumpio /var/log/pumpio/
396 web-conf - apache2 pump.iankelling.org <<'EOF'
397 # currently a bug in pump that we cant terminate ssl
400 ProxyPass / https://127.0.0.1:8001/
401 ProxyPassReverse / https://127.0.0.1:8001/
402 # i have sockjs disabled per people suggesting that
403 # it won\'t work with apache right now.
404 # not sure if it would work with this,
405 # but afaik, this is pointless atm.
406 <Location /main/realtime/sockjs/>
407 ProxyPass wss://127.0.0.1:8001/main/realtime/sockjs/
408 ProxyPassReverse wss://127.0.0.1:8001/main/realtime/sockjs/
413 export RENEWED_LINEAGE=/etc/letsencrypt/live/pump.iankelling.org
414 /a/bin/distro-setup/certbot-renew-hook
417 s dd of=/etc/systemd/system/pump.service <<'EOF'
420 After=syslog.target network.target mongodb.service
421 Requires=mongodb.service
427 ExecStart=/home/iank/pump.io/bin/pump
428 Environment=NODE_ENV=production
429 # failed to find databank-mongodb without this.
430 # I just looked at my environment variables took a guess.
431 Environment=NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
434 WantedBy=multi-user.target
438 ########## end pump.io setup ############
441 ############# begin setup mastodon ##############
443 # main doc is Docker-Guide.md in docs repo
445 # I'd like to try gnu social just cuz of gnu, but it's not being
446 # well maintained, for example, simple pull requests
448 # https://git.gnu.io/gnu/gnu-social/merge_requests/143
449 # and I submitted my own bugs, basic docs are broken
450 # https://git.gnu.io/gnu/gnu-social/issues/269
452 # note, docker required, but we installed it earlier
454 # i subscrubed to https://github.com/docker/compose/releases.atom
455 # to see release notes.
456 # i had some problems upgrading. blew things away with
457 # docker-compose down
458 # docker rmi $(docker images -q)
460 # when running docker-compose run, kernel stack traces are printed to the journal.
461 # things seem to succeed, google says nothing, so ignoring them.
462 curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-$(uname -s)-$(uname -m) | s dd of=/usr/local/bin/docker-compose
463 s chmod +x /usr/local/bin/docker-compose
468 i clone https://github.com/tootsuite/mastodon
470 # subbed to atom feed to deal with updates
471 git checkout $(git tag | grep -v rc | tail -n1)
473 # per instructions, uncomment redis/postgres persistence in docker-compose.yml
474 sed -i 's/^#//' docker-compose.yml
476 cat >.env.production <<'EOF'
485 LOCAL_DOMAIN=mast.iankelling.org
488 SINGLE_USER_MODE=true
490 SMTP_SERVER=mail.iankelling.org
493 SMTP_FROM_ADDRESS=notifications@mast.iankelling.org
494 SMTP_DOMAIN=mast.iankelling.org
495 SMTP_DELIVERY_METHOD=smtp
498 for key in PAPERCLIP_SECRET SECRET_KEY_BASE OTP_SECRET; do
499 # 1 minute 7 seconds to run this docker command
500 # to generate a secret, and it has ^M chars at the end. wtf. really dumb
501 printf "%s=%s\n" $key "$(docker-compose run --rm web rake secret|dos2unix|tail -n1)" >>.env.production
504 while read -r domain _ pass; do
505 if [[ $domain == mail.iankelling.org ]]; then
507 # remove the username part
509 printf "SMTP_PASSWORD=%s\n" "$pass" >>.env.production
512 done < <(s cat /etc/mailpass)
514 echo "$0: error, failed to find mailpass domain for mastadon"
518 # docker compose makes an interface named like br-8f3e208558f2. we need mail to
520 if ! s /sbin/iptables -t nat -C PREROUTING -i br-+ -p tcp -m tcp --dport 25 -j DNAT --to-destination 10.8.0.4:25; then
521 s /sbin/iptables -t nat -A PREROUTING -i br-+ -p tcp -m tcp --dport 25 -j DNAT --to-destination 10.8.0.4:25
524 docker-compose run --rm web rake mastodon:webpush:generate_vapid_key | grep -E '^VAPID_PUBLIC_KEY=|^VAPID_PRIVATE_KEY=' >> .env.production
525 logq docker-compose run --rm web rake db:migrate
526 docker-compose run --rm web rails assets:precompile
528 # avatar failed to upload, did
529 # docker logs mastodon_web_1
530 # google lead me to this
531 s chown -R 991:991 public/system
533 # docker daemon takes care of starting on boot.
536 s a2enmod proxy_wstunnel headers
537 web-conf -f 3000 - apache2 mast.iankelling.org <<'EOF'
539 RequestHeader set X-Forwarded-Proto "https"
540 ProxyPass /500.html !
541 ProxyPass /oops.png !
542 ProxyPass /api/v1/streaming/ ws://localhost:4000/
543 ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
544 ErrorDocument 500 /500.html
545 ErrorDocument 501 /500.html
546 ErrorDocument 502 /500.html
547 ErrorDocument 503 /500.html
548 ErrorDocument 504 /500.html
552 ############### !!!!!!!!!!!!!!!!!
553 ############### manual steps:
555 # only following a few people atm, so not bothering to figure out backups
556 # when mastodon has not documented it at all.
561 # johns@status.fsf.org
563 # sign in page is at https://mast.iankelling.org/auth/sign_in
564 # register as iank, then
565 # https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Administration-guide.md
566 # docker-compose run --rm web bundle exec rails mastodon:make_admin USERNAME=iank
568 ############# end setup mastodon ##############
570 # we use nsupdate to update the ip of home
574 # znc config generated by doing
576 # selected port is also used in erc config
577 # comma separated channel list worked.
578 # while figuring things out, running znc -D for debug in foreground.
579 # to exit and save config:
580 # /msg *status shutdown
581 # configed auth on freenode by following
582 # https://wiki.znc.in/Sasl:
583 # /msg *sasl RequireAuth yes
584 # /msg *sasl Mechanism PLAIN
585 # /msg *sasl Set ident_name password
586 # created the system service after, and had to do
587 # mv /home/iank/.znc/* /var/lib/znc
588 # sed -i 's,/home/iank/.znc/,/var/lib/znc,' /var/lib/znc/config/znc.conf
589 # and made a copy of the config files into /p/c
590 # /msg *status LoadMod --type=global log -sanitize
591 # to get into the web interface,
592 # cat /etc/letsencrypt/live/iankelling.org/{privkey,cert,chain}.pem > /var/lib/znc/znc.pem
593 # then use non-main browser or else it doesn't allow it based on ocsp stapling from my main site.
594 # https://iankelling.org:12533/
595 # i'm going to figure out how to automate this when it expires. i know i can hook a script into the renewal. https://wiki.znc.in/FAQ seems to imply that znc doesn\'t need restart.
596 # todo: in config file AllowWeb = true should be false. better security if that is off unless we need it.
597 # /msg *status LoadMod --type=network perform
598 # /msg *perform add PRIVMSG ChanServ :invite #fsf-office
599 # /msg *perform add JOIN #fsf-office
602 # also ran /znc LoadMod clearbufferonmsg
603 # it would be nice if erc supported erc query buffers by doing
604 # /msg *status clearbuffer <name of the query/receiver
606 # an example seems to be here: https://github.com/zenspider/elisp/blob/master/rwd-irc.el
607 # if that was the case i could remove the module clearbufferonmsg
608 # alo would be nice if erc supported
609 # https://wiki.znc.in/self-message
610 # https://wiki.znc.in/Query_buffers \
612 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
613 chmod 700 /var/lib/znc
614 s chown -R znc:znc /var/lib/znc
615 s dd of=/etc/systemd/system/znc.service 2>/dev/null <<'EOF'
617 Description=ZNC, an advanced IRC bouncer
618 After=network-online.target
621 ExecStart=/usr/bin/znc -f --datadir=/var/lib/znc
625 WantedBy=multi-user.target
630 echo "$0: $(date): ending now)"
635 ########### end section including li/lj ###############
638 case $(debian-codename) in
639 # needed for debootstrap scripts for fai since fai requires debian
641 curl http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg | s apt-key add -
642 s dd of=/etc/apt/preferences.d/flidas-xenial <<EOF
644 Pin: release a=xenial
648 Pin: release a=xenial-updates
652 Pin: release a=xenial-security
655 s dd of=/etc/apt/sources.list.d/xenial.list 2>/dev/null <<EOF
656 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
657 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
658 deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
661 s apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
662 s dd of=/etc/apt/preferences.d/flidas-bionic <<EOF
664 Pin: release a=bionic
668 Pin: release a=bionic-updates
672 Pin: release a=bionic-security
676 # better to run btrfs-progs which matches our kernel version
677 # (note, renamed from btrfs-tools)
678 s dd of=/etc/apt/preferences.d/btrfs-progs <<EOF
679 Package: btrfs-progs libzstd1
680 Pin: release a=bionic
683 Package: btrfs-progs libzstd1
684 Pin: release a=bionic-updates
687 Package: btrfs-progs libzstd1
688 Pin: release a=bionic-security
695 deb http://us.archive.ubuntu.com/ubuntu/ bionic main
696 deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main
697 deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main
699 f=/etc/apt/sources.list.d/bionic.list
700 if ! diff -q $t $f; then
706 # no special reason, but its better for btrfs-progs to
707 # be closer to our kernel version
712 aptitude download debootstrap/xenial
714 s cp ./usr/share/debootstrap/scripts/* /usr/share/debootstrap/scripts
716 s dd of=/etc/apt/preferences.d/flidas-etiona <<EOF
718 Pin: release a=etiona
722 Pin: release a=etiona-updates
726 Pin: release a=etiona-security
730 Pin: release a=etiona-backports
736 deb http://mirror.fsf.org/trisquel/ etiona main
737 deb http://mirror.fsf.org/trisquel/ etiona-updates main
738 deb http://archive.trisquel.info/trisquel/ etiona-security main
739 deb http://mirror.fsf.org/trisquel/ etiona-backports main
741 f=/etc/apt/sources.list.d/etiona.list
742 if ! diff -q $t $f; then
748 s dd of=/etc/apt/preferences.d/debian-goodies <<EOF
749 Package: debian-goodies
750 Pin: release n=buster
755 s dd of=/etc/apt/preferences.d/flidas-buster <<EOF
757 Pin: release n=buster
761 # stupid buster uses some key algorithm not supported by flidas gpg that apt uses.
762 s dd of=/etc/apt/apt.conf.d/01iank <<'EOF'
763 Acquire::AllowInsecureRepositories "true";
768 deb http://http.us.debian.org/debian buster main
769 deb-src http://http.us.debian.org/debian buster main
771 deb http://security.debian.org/ buster/updates main
772 deb-src http://security.debian.org/ buster/updates main
774 deb http://http.us.debian.org/debian buster-updates main
775 deb-src http://http.us.debian.org/debian buster-updates main
777 f=/etc/apt/sources.list.d/buster.list
778 if ! diff -q $t $f; then
784 # newer version needed for false positive in checkrestart
785 p install -y --allow-unauthenticated debian-goodies
787 s dd of=/etc/apt/preferences.d/shellcheck <<EOF
789 Pin: release a=etiona
793 Pin: release a=etiona-updates
797 Pin: release a=etiona-security
806 # TODO: some of the X programs can be removed from pall when using wayland
808 # depends gcc is a way to install suggests. this is apparently the only
809 # way to install suggests even if the main package is already
810 # installed. reinstall doesn't work, uninstalling can cause removing
811 # dependent packages.
812 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)
816 wget -O$x https://bootstrap.pypa.io/get-pip.py
820 sgo fsf-vpn-dns-cleanup
823 # website is dead june 14 2019
824 s rm -f /etc/apt/sources.list.d/iridium-browser.list
829 # wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
832 # deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
833 # #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
835 # f=/etc/apt/sources.list.d/iridium-browser.list
836 # if ! diff -q $t $f; then
846 ### begin home vpn server setup
849 # # this section done initially to make persistent keys.
850 # # Also note, I temporarily set /etc/hosts so my host was
851 # # b8.nz when running this, since the vpn client config
852 # # generator assumes we need to go to that server to get
854 # vpn-server-setup -rds
855 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
856 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
857 # # kw = kgpe work machine.
858 # for host in x2 x3 kw; do
859 # vpn-mk-client-cert -b $host -n home b8.nz 1196
860 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
862 # s bash -c "cp /etc/openvpn/client/home* $dir"
863 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
866 # key already exists, so this won't generate one, just the configs.
867 vpn-server-setup -rds
868 s tee -a /etc/openvpn/server/server.conf <<'EOF'
869 push "dhcp-option DNS 10.0.0.1"
870 push "route 10.0.0.0 255.255.0.0"
871 client-connect /a/bin/distro-setup/vpn-client-connect
873 s sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
875 if [[ $HOSTNAME == tp ]]; then
876 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
877 vpn_service=openvpn-server@server
879 vpn_service=openvpn@server
883 ### end vpn server setup
887 # note, see bashrc for more documentation.
889 s dd of=/etc/systemd/system/rss2email.service <<'EOF'
891 Description=rss2email
892 After=multi-user.target
897 # about 24 hours of failures
898 # it copies over its files without respecting symlinks, so
899 # we pass options to use different location.
900 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
902 s dd of=/etc/systemd/system/rss2email.timer <<'EOF'
904 Description=rss2email
907 # for initial run. required.
909 # for subsequent runs.
910 OnUnitInactiveSec=300
913 WantedBy=timers.target
915 s systemctl daemon-reload
918 ######### begin pump.io periodic backup #############
919 if [[ $HOSTNAME == frodo ]]; then
920 s dd of=/etc/systemd/system/pumpbackup.service <<'EOF'
922 Description=pump li backup
923 After=multi-user.target
928 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
930 s dd of=/etc/systemd/system/pumpbackup.timer <<'EOF'
932 Description=pump li backup hourly
938 WantedBy=timers.target
940 s systemctl daemon-reload
943 ######### end pump.io periodic backup #############
946 ######### begin irc periodic backup #############
947 if [[ $HOSTNAME == frodo ]]; then
948 s dd of=/etc/systemd/system/ircbackup.service <<'EOF'
950 Description=irc li backup
951 After=multi-user.target
956 ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX --delete root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs
958 s dd of=/etc/systemd/system/ircbackup.timer <<'EOF'
960 Description=irc li backup hourly
966 WantedBy=timers.target
968 s systemctl daemon-reload
973 ######### end irc periodic backup #############
976 # https://github.com/jlebon/textern
978 make native-install USER=1
981 debian|trisquel|ubuntu)
982 # suggests resolvconf package. installing it here is redundant, but make sure anyways.
983 # todo: check other distros to make sure it\'s installed
984 pi-nostart openvpn resolvconf
985 # pi-nostart does not disable
991 /a/bin/distro-setup/radicale-setup
993 ## android studio setup
994 # this contains the setting for android sdk to point to
995 # /a/opt/androidsdk, which is asked upon first run
996 lnf /a/opt/.AndroidStudio2.2 ~
997 # android site says it needs a bunch of packages for ubuntu,
998 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
1000 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
1001 # see w.org for more android studio details
1002 spa lib32stdc++6 default-jdk
1005 ############# begin syncthing setup ###########
1006 if [[ $HOSTNAME == frodo ]]; then
1007 # It\'s simpler to just worry about running it in one place for now.
1008 # I assume it would work to clone it\'s config to another non-phone
1009 # and just run it in one place instead of the normal having a
1010 # separate config. I lean toward using the same config, since btrfs
1011 # syncs between comps.
1013 arch) pi syncthing ;;
1014 trisquel|ubuntu|debian)
1015 # testing has relatively up to date packages
1016 if ! isdebian-testing; then
1017 # based on error when doing apt-get update:
1018 # E: The method driver /usr/lib/apt/methods/https could not be found.
1019 pi apt-transport-https
1020 # google led me here:
1021 # https://apt.syncthing.net/
1022 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
1023 s="deb http://apt.syncthing.net/ syncthing release"
1024 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then
1025 echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
1032 lnf -T /w/syncthing /home/iank/.config/syncthing
1033 ser daemon-reload # syncthing likely not properly packaged
1034 sgo syncthing@iank # runs as iank
1036 # these things persist in ~/.config/syncthing, which I save in
1037 # /w/syncthing (not in /p, because syncthing should continue to
1038 # run on home server even when using laptop as primary device)
1039 # open http://localhost:8384/
1040 # change listen address from default to tcp://:22001,
1041 # this is because we do port forward so it doesn\'t have to use
1042 # some external server, but the syncthing is broken for port forward,
1043 # you get a message, something "like connected to myself, this should not happen"
1044 # when connecting to other local devices, so I bump the port up by 1,
1046 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
1047 # Without this, it was being stuck syncing at 0%.
1048 # Set gui username and password.
1050 # install syncthing via f-droid,
1051 # folder setting, turn off send only.
1052 # on phone, add device, click bar code icon
1053 # on dekstop, top right, actions, device id
1054 # after adding, notification will appear on desktop to confirm
1056 # syncing folder. from phone to desktop: select desktop in the
1057 # folder on phone\'s sync options, notification will appear in
1058 # desktop\'s web ui within a minute. For the reverse, the
1059 # notification will appear in android\'s notifications, you have to
1060 # swipe down and tap it to add the folder. It won\'t appear in the
1061 # syncthing ui, which would be intuitive, but don\'t wait for it
1062 # there. The notification may not work, instead open the web gui
1063 # from in the app, there should be a notification within there.
1065 # On phone, set settings to run syncthing all the time, and
1066 # show no notification.
1068 # Folder versioning would make sense if I didn\'t already use btrfs
1069 # for backups. I would choose staggered, or trash can for more space.
1071 # if needed to install on a remote comp:
1072 # ssh -L 8384:localhost:8384 -N frodo
1073 # open http://localhost:8384/
1075 # Note, the other thing i did was port forward port 22000,
1076 # per https://docs.syncthing.net/users/firewall.html
1079 ############# end syncthing setup ###########
1083 ####### begin misc packages ###########
1092 # sakura config is owned by ian
1095 sudo -u user2 -i reset-konsole
1096 # user2 xscreensaver we don't want to reset
1100 # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now.
1101 # this is also in primary-setup
1102 # pi libxss-dev # dependency based on build failure
1104 # cabal install --upgrade-dependencies --force-reinstalls arbtt
1105 # also, i assume syncing this between machines somehow messed thin
1106 #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log
1110 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
1111 cp /p/.linphonerc-initial ~/.linphonerc
1115 ### begin spd install
1116 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
1118 wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
1121 # this guesses at the appropriate directory, adjust if needed
1122 perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*)
1123 sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]}
1124 # newer distro had gpg2 as default, older one, flidas, need to make it that way
1125 gpgpath=$(which gpg2)
1127 s mkdir -p /usr/local/spdhackfix
1128 s lnf -T $gpgpath /usr/local/spdhackfix/gpg
1133 if [[ $HOSTNAME == kw ]]; then
1135 NOTE: after this finishes, i did
1137 # remove br from auto:
1138 s vim /etc/network/interfaces
1142 # nagstamon setting which were set through the ui
1144 # all unknown sources
1145 # all warning services
1146 # acknowledged hosts & services
1147 # hosts & services down for maintenence
1148 # services on down hosts
1149 # services on hosts in maintenece
1150 # services on unreachable osts
1151 # hosts in soft state
1152 # services in soft state
1153 # in display tab: fullscreen
1155 # these translate to these settings I think
1156 # filter_acknowledged_hosts_services = True
1157 # filter_all_unknown_services = True
1158 # filter_all_warning_services = True
1159 # filter_hosts_in_soft_state = True
1160 # filter_hosts_services_maintenance = True
1161 # filter_services_in_soft_state = True
1162 # filter_services_on_down_hosts = True
1163 # filter_services_on_hosts_in_maintenance = True
1164 # filter_services_on_unreachable_hosts = True
1165 # notify_if_up = False
1166 # statusbar_floating = False
1168 # but i'm just going to rely on the webpage plus sms for now.
1172 debian|trisquel|ubuntu)
1173 # it asks if it should make users in it's group capture packets without root,
1174 # which is arguably more secure than running wireshark as root. default is no,
1175 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
1176 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
1181 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
1182 # listed in the default config as suggested.
1183 # /run/usr/1000 i noticed was missing for pulseaudio
1184 # /run/user/0 just seemed like a not bad idea, given the above
1185 tu /etc/schroot/desktop/fstab <<'EOF'
1186 /run /run none rw,bind 0 0
1187 /run/lock /run/lock none rw,bind 0 0
1188 /dev/shm /dev/shm none rw,bind 0 0
1189 /run/shm /run/shm none rw,bind 0 0
1190 /run/user/1000 /run/user/1000 none rw,bind 0 0
1191 /run/user/1001 /run/user/1001 none rw,bind 0 0
1192 /run/user/0 /run/user/0 none rw,bind 0 0
1200 repo=http://archive.ubuntu.com/ubuntu/
1203 repo=http://deb.debian.org/debian/
1208 if schroot -l | grep -xFq chroot:$n; then
1209 echo "$0: $n schroot already installed, skipping"
1214 s dd of=/etc/schroot/chroot.d/$n.conf <<EOF
1220 preserve-environment=true
1223 if [[ -e $d/bin ]]; then
1224 s chroot $d apt-get update
1225 s chroot $d apt-get -y dist-upgrade --purge --auto-remove
1226 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1230 s debootstrap $n $d $repo
1231 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1233 s cp -P {,$d}/etc/localtime
1235 s dd of=/etc/systemd/system/schrootupdate.service <<'EOF'
1237 Description=schrootupdate
1238 After=multi-user.target
1242 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1244 s dd of=/etc/systemd/system/schrootupdate.timer <<'EOF'
1246 Description=schrootupdate
1249 OnCalendar=*-*-* 04:20:00
1252 WantedBy=timers.target
1254 s systemctl daemon-reload
1255 sgo schrootupdate.timer
1262 mkschroot debian stretch firefox-esr pulseaudio chromium
1269 s mkdir -p /nocow/user
1270 s chown $USER:$USER /nocow/user
1274 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1275 # 450 seems likely to be unused. we need to specify one or else
1276 # it won't be stable across installs.
1277 if ! getent passwd debian-transmission > /dev/null; then
1278 s groupadd -g 450 debian-transmission
1286 --home-dir /var/lib/transmission-daemon \
1287 --shell /bin/false \
1296 --disabled-password \
1297 --home /var/lib/transmission-daemon \
1302 # We want group writable stuff from transmission.
1303 # However, after setting this, I learn that transmission sets it's
1304 # own umask based on it's settings file. Well, no harm leaving this
1305 # so it's set right from the beginning.
1306 s chfn debian-transmission -o umask=0002
1309 debian|trisquel|ubuntu)
1310 # note i had to do this, which is persistent:
1312 # s chgrp debian-transmission torrents partial-torrents
1314 # syslog says things like
1315 # 'Failed to set receive buffer: requested 4194304, got 425984'
1316 # google suggets giving it even more than that
1317 tu /etc/sysctl.conf<<'EOF'
1318 net.core.rmem_max = 67108864
1319 net.core.wmem_max = 16777216
1323 # some reason it doesn\'t seem to start automatically anyways
1324 pi-nostart transmission-daemon
1325 # be extra sure its not started
1326 ser disable transmission-daemon
1327 ser stop transmission-daemon
1329 # the folder was moved here after an install around 02/2017.
1330 # it contains runtime data,
1331 # plus a simple symlink to the config file which it\'s
1332 # not worth separating out.
1333 # between comps, the uid can change
1334 f=/i/transmission-daemon
1335 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1336 if [[ -e $f ]]; then
1337 s chown -R debian-transmission:debian-transmission $f
1339 for f in /i/k/partial-torrents /i/k/torrents; do
1340 if [[ -e $f ]]; then
1341 s chown -R debian-transmission:user2 $f
1344 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1346 # config file documented here, and it\'s the same config
1347 # for daemon vs client, so it\'s documented in the gui.
1348 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1350 # I originaly setup rpc-whitelist, but after using
1351 # routing to a network namespace, it doesn\'t see the
1352 # real source address, so it\'s disabled.
1354 # Changed the cache-size to 256 mb, reduces disk use.
1355 # It is a read & write cache.
1359 p = '/etc/transmission-daemon/settings.json'
1360 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1361 'rpc-whitelist-enabled' => false,
1362 'rpc-authentication-required' => false,
1363 'incomplete-dir' => '/i/k/partial-torrents',
1364 'incomplete-dir-enabled' => true,
1365 'download-dir' => '/i/k/torrents',
1366 "speed-limit-up" => 800,
1367 "speed-limit-up-enabled" => true,
1368 "peer-port" => 61486,
1369 "cache-size-mb" => 256,
1370 "ratio-limit" => 5.0,
1371 "ratio-limit-enabled" => true,
1376 # todo: others unknown
1381 # trisquel 8 = openvpn, debian stretch = openvpn-client
1382 vpn_ser=openvpn-client
1383 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1387 s dd of=/etc/systemd/system/transmission-daemon-nn.service <<EOF
1389 Description=Transmission BitTorrent Daemon netns
1390 After=network.target
1391 Requires=${vpn_ser}-nn@client.service
1392 After=${vpn_ser}-nn@client.service
1393 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1396 #User=debian-transmission
1397 # notify type doesn't work with sudo
1399 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1400 ExecReload=/bin/kill -s HUP \$MAINPID
1405 WantedBy=multi-user.target
1409 if [[ $HOSTNAME == frodo ]]; then
1410 sgo transmission-daemon-nn
1414 ######### begin transmission client setup ######
1416 if [[ -e /p/transmission-rpc-pass ]]; then
1417 # arch had a default config,
1418 # debian had nothing until you start it.
1419 # With a little trial an error, here is a minimal config
1420 # taken from the generated one, plus changes that the
1421 # settings ui does, without a bunch of ui crap settings.
1423 # only settings I set were
1428 # the password is randomly generated on first run, i copied it out
1429 # so it could be used by other hosts.
1432 p = '/etc/transmission-daemon/settings.json'
1433 s = JSON.parse(File.read(p))
1434 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1435 # default is 0022 (18 in decimal)
1437 File.write p, JSON.pretty_generate(s)
1440 rpc_pass=$(</p/transmission-rpc-pass)
1441 for f in /home/*; do
1443 if [[ ! $(id -u $u) -ge 1000 ]]; then
1446 d=$f/.config/transmission-remote-gtk
1448 s -u $u dd of=$d/config.json <<EOF
1452 "profile-name" : "Default",
1453 "hostname" : "transmission.b8.nz",
1454 "rpc-url-path" : "/transmission/rpc",
1456 "password" : "$rpc_pass",
1457 "auto-connect" : true,
1461 "update-active-only" : false,
1462 "activeonly-fullsync-enabled" : false,
1463 "activeonly-fullsync-every" : 2,
1464 "update-interval" : 3,
1465 "min-update-interval" : 3,
1466 "session-update-interval" : 60,
1474 "add-options-dialog" : false
1479 ######### end transmission client setup ######
1481 # dunno why it\'s there, but get rid of it
1483 li|lj) s rm -rf /home/linode ;;
1490 pi cups ghostscript gsfonts # from arch wiki cups page
1491 pi hplip # from google
1492 s gpasswd -a $USER sys # from arch wiki
1493 sgo org.cups.cupsd.service
1495 debian|trisquel|ubuntu)
1497 s gpasswd -a $USER lpadmin # based on ubuntu wiki
1500 # other distros unknown
1502 # goto http://127.0.0.1:631
1503 # administration tab, add new printer button.
1504 # In debian, I could use hte recommended driver,
1505 # in arch, I had to pick out the 6L driver.
1508 # allow user to run vms, from debian handbook
1509 for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
1510 # bridge networking as user fails. google lead here, but it doesn\'t work:
1511 # oh well, I give up.
1512 # http://wiki.qemu.org/Features-Done/HelperNetworking
1514 # f=/etc/qemu/bridge.conf
1515 # s dd of=$f <<'EOF'
1518 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1521 # general known for debian/ubuntu, not for fedora
1524 debian|trisquel|ubuntu)
1525 if ! type -p go &>/dev/null; then
1527 # just the latest stable at the time of writing
1528 # TODO, maybe put this all into a build script,
1529 # and do some automatic updates
1530 wget -q https://dl.google.com/go/go1.12.4.linux-amd64.tar.gz
1531 s tar -C /usr/local -xzf go1.12.4.linux-amd64.tar.gz
1534 go get -u mvdan.cc/fdroidcl
1535 # a bit of googling, and added settings to bashrc
1542 # otherwise we get error about accessing kvm module.
1543 # seems like there might be a better way, but google was a bit vague.
1544 s $sed -ri '/^ *user *=/d' /etc/libvirt/qemu.conf
1545 echo 'user = "root"' | s tee -a /etc/libvirt/qemu.conf
1546 # guessing this is not needed
1547 #sgo virtlogd.service
1549 # iank: disabed as im not using libvirt usually
1550 # # https://bbs.archlinux.org/viewtopic.php?id=206206
1551 # # # this should prolly go in the wiki
1552 # sgo virtlogd.socket
1555 debian|trisquel|ubuntu)
1556 pi-nostart virtinst virt-manager
1565 wget ftp://ftp.gnu.org/pub/gnu/global/global-6.5.7.tar.gz
1568 # based on https://github.com/leoliu/ggtags
1569 ./configure --with-exuberant-ctags=/usr/bin/ctags
1572 pip install pygments
1580 debian|trisquel|ubuntu)
1587 # removed synergy since ive not used it in a long time
1590 pi --no-install-recommends kdeconnect
1591 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1592 ### but gnome + xmonad not working in flidas, so i disabled it
1593 # pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1594 # cd /a/opt/indicator-kdeconnect
1597 # cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1600 # # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1601 # # it seems, according to
1602 # # /etc/xdg/autostart/kdeconnectd.desktop
1603 # # I'm not seeing the icon, but the clipboard replication is working
1606 ### model 01 arduino support ###
1607 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1608 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1609 # set arduino var in bashrc,
1610 # have system config file setup too.
1611 sudo adduser $USER dialout
1614 sudo usermod -a -G uucp $USER
1618 # this is for the mail command too. update-alternatives is kind of misleading
1619 # since at least it's main commands pretend mail does not exist.
1620 # bsd's mail got pulled in on some dumb dependency, i dunno how.
1621 s update-alternatives --set mailx /usr/bin/mail.mailutils
1623 ######### end misc packages #########
1626 # packages I once used before and liked, but don\'t want installed now for
1628 # python-sqlite is used for offlineimap
1629 # lxappearance python-sqlite dolphin paman dconf-editor
1635 # todo, finish configuring smart.
1638 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1639 # turn on smart. background on options:
1640 # first line, -a = test everyting on all devices.
1641 # -S on, turn on disk internal saving of vendor specific info,
1642 # from google, seems like this is usually already on and fairly standard.
1643 # -o on, turn on 4 hour period non-performance degrading testing.
1644 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1645 sched="-s (S/../.././02|L/../../6/03)"
1646 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1647 DEVICESCAN -a -o on -S on -n standby,q $sched \
1648 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1650 # in the default configuration of at least ubuntu 14.04, resolvconf is
1651 # configured to order any nameservers associated with tun* or tap*
1652 # before the normal internet interfaces, which means they are always
1653 # consulted first. This is often slower and undesirable, ie. local dns
1654 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1656 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1657 # however, this breaks dns lookup for hosts on the openvpn lan.
1658 # I can\'t figure out why hosts on the normal lan would not be
1659 # broken under the default ordering, except the host I was
1660 # testing with previously had an entry in /etc/hosts.
1662 ############# end unfinished
1664 ########### misc stuff
1666 # make networkmanager use resolvconf instead of its own dnsmasq which
1667 # conflicts with the normal dnsmasq package.
1668 f=/etc/NetworkManager/NetworkManager.conf
1670 s sed -ri '/ *\[main\]/,/^ *\[[^]]+\]/{/^\s*dns[[:space:]=]/d}' $f
1671 if [[ $m != $(md5sum $f) ]]; then
1672 srestart NetworkManager
1675 # make my /etc/fonts/conf.d/ get used.
1676 # I have a new sans-serif font there because the default one
1677 # displays l and I as the same char, grrrrr.
1680 /a/bin/distro-setup/mymimes
1686 # stop autopoping windows when i plug in an android phone.
1687 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1688 # with still 0 exit code.
1689 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1690 dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1693 # on grub upgrade, we get prompts unless we do this
1695 for dev in $(s btrfs fil show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1696 devs+=("$(devbyid $dev),")
1698 devs[-1]=${devs[-1]%,} # jonied by commas
1699 s debconf-set-selections <<EOF
1700 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1704 sgo btrfsmaint.timer
1705 sgo btrfsmaintstop.timer
1708 # the wiki backup script from ofswiki.org uses generic paths
1709 s lnf /p/c/machine_specific/li/mw_vars /root
1710 s lnf /k/backup/wiki_backup /root
1714 trisquel|ubuntu|debian)
1715 # unison-gtk second, i want it to be default, not sure if that works
1716 # with spa. note, I used to install from testing repo when using stable,
1717 # but it shouldn't be needed since I wrote a script to handle mismatching
1719 spa unison unison-gtk
1728 # default is alsa, doesn\'t work with with pianobar
1729 s dd of=/etc/libao.conf <<'EOF'
1730 default_driver=pulse
1735 # # disabled due to my patch being in btrbk
1737 # arch|debian|trisquel|ubuntu) pi btrbk ;;
1744 # note: to see when it was last run,
1749 In mate settings settings, change scrolling to two-finger,
1750 because the default edge scroll doesn\'t work. Originally found this in debian.
1755 # remove dep that came in with desktop
1762 debian|trisquel|ubuntu) s gpasswd -a iank adm ;; #needed for reading logs
1765 /a/bin/buildscripts/pithosfly
1768 # based on guix manual instructions, also added code to profile
1770 if ! type -p guix >/dev/null; then
1772 wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
1773 # added some stuff to envonment.sh for profile based on
1774 # manual instructions
1775 # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -
1776 # echo is to get past prompt
1777 yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]]
1778 guix install glibc-utf8-locales
1779 guix package --install guile
1783 curl https://sh.rustup.rs -sSf | bash -s -- -y
1784 # todo: update this. updates in rust are stupidly complicate
1785 if ! which rg &>/dev/null; then
1786 cargo install ripgrep
1792 # https://www.torproject.org/docs/rpms.html.en
1793 # https://www.torproject.org/docs/debian.html.en
1794 # todo: figure out if the running service needs to be restarted upon updates
1795 # todo on fedora: setup non-dev packages
1797 s dd of=/etc/yum.repos.d/torproject.repo <<'EOF'
1799 name=Tor experimental repo
1801 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1803 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1806 name=Tor experimental source repo
1809 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1811 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1814 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1815 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1817 /a/bin/buildscripts/tor-browser
1820 tu /etc/apt/sources.list "deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1821 gpg --keyserver keys.gnupg.net --recv 886DDD89
1822 gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
1824 pi deb.torproject.org-keyring
1826 /a/bin/buildscripts/tor-browser
1830 /a/bin/buildscripts/tor-browser
1833 pi tor tor-browser-en
1843 fedora todo: disable the firewall or find a way to automate it.
1844 there's an unused section in t.org for tramikssion firewall setup
1846 fedora manual config for nfs:
1848 change to permanent configuration
1849 check the box for nfs
1850 was hard to figure this out, not sure if this is all needed, but
1852 mountd: udp/tcp 20048
1853 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1854 troubleshooting, unblock things in rpcinfo -p
1855 make sure to reload the firewall to load the persistent configuration
1861 debian|trisquel|ubuntu)
1862 pi-nostart nfs-server
1865 pi nfs-utils || pending_reboot=true
1869 # networkmanager has this nasty behavior on flidas: if the machine
1870 # crashes with dnsmasq running, on subsequent boot, it adds an entry to
1871 # resolvconf for 127.0.0.1 in some stupid attempt to restore
1873 # This can be manually fixed by stoping dnsmasq,
1874 # then based on whats in /run/dnsmasq/, i see we can run
1875 # s resolvconf -d NetworkManager
1876 # oh ya, and stoping NetworkManager leaves this crap behind without cleaning it up.
1877 ser stop NetworkManager
1878 ser disable NetworkManager
1881 if [[ $HOSTNAME == frodo ]]; then
1882 # nohide = export filesystems mounted deeper than the export point
1883 # fsid=0 makes this export the "root" export
1884 # not documented in the man page, but this means
1885 # 1. it can be mounted with a shorthand of server:/
1886 # 2. exports that are subdirectories of this one will automatically be mounted
1887 tu /etc/exports <<'EOF'
1888 /k 10.0.0.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1898 # if I was going to create a persistent vm, i might do it like this:
1899 # variant=something # from: virt-install --os-variant list
1900 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1901 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1902 # -n some_name --import --os-variant $variant --cpu host-model-only
1906 ######### begin stuff belonging at the end ##########
1909 if $pending_reboot; then
1910 echo "$0: pending reboot and then finished. doing it now."
1913 echo "$0: $(date): ending now)"