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.
20 exec &> >(sudo
tee -a /var
/log
/distro-end
)
21 echo "$0: $(date): starting now)"
23 src
="${BASH_SOURCE%/*}"
25 # see example of usage to understand.
28 IFS
= read -r -d '' y ||
:
32 spa
() { # simple package add
39 sed="sed --follow-symlinks"
66 # swh-plugins is for karaoke pulsaudio filter.
68 # guvcview set webcam brightness to highest
69 # pidgin-otr, i went into pidgin pluggin settings and generated a key for some accounts
149 $
(aptitude show ruby |
sed -rn 's/Depends: (.*)/\1/p')-doc
156 transmission-remote-gtk
161 spa $
(apt-cache search ruby
[.0-9]+-doc|
awk '{print $1}')
166 ########### begin section including li ################
171 # ubuntu 14.04 uses b-cron,
172 # but its not maintained in arch.
173 # of the ones in the main repos, cronie is only one maintained.
174 # fcron appears abandoned software.
178 *) : ;; # other distros come with cron.
190 debian|trisquel|ubuntu
) pi curl
;;
202 arch
) spa the_silver_searcher
;;
203 debian|trisquel|ubuntu
) spa silversearcher-ag
;;
208 debian|trisquel|ubuntu
) spa ntp
;;
217 # no equivalent in other distros:
219 debian|trisquel|ubuntu
)
221 if ! dpkg
-s apt-file
&>/dev
/null
; then
222 # this condition is just a speed optimization
226 # for debconf-get-selections
233 arch|debian|trisquel|ubuntu
)
246 # allows me to pipe with ssh -t, and gets rid of spam
247 # http://forums.debian.net/viewtopic.php?f=5&t=85822
248 # i'd rather disable the service than comment the init file
249 # this says disabling the service, it will still get restarted
250 # but this script doesn't do anything on restart, so it should be fine
251 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
252 # stretch doesn't have initscripts pkg installed by default
253 if [[ $
(debian-codename
) == jessie
]]; then
254 s update-rc.d motd disable
258 # this isn't a complete solution. It still shows me when updates are available,
259 # but it's no big deal.
260 s t
/etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
266 # https://debian-handbook.info/browse/stable/sect.regular-upgrades.html
267 # /etc/cron.daily/apt calls unattended-upgrades
268 # /usr/share/doc/unattended-upgrades# cat README.md
269 # /etc/apt/apt.conf.d/50unattended-upgrades
271 setup-debian-auto-update
274 # we've got a few dependencies later on, so install them now.
276 s eatmydata apt-get
-y install --purge --auto-remove "${simple_packages[@]}"
280 ### begin docker install ####
283 # https://store.docker.com/editions/community/docker-ce-server-debian?tab=description
284 pi software-properties-common apt-transport-https
285 curl
-fsSL https
://download.docker.com
/linux
/$
(distro-name-compat
)/gpg | sudo apt-key add
-
286 sudo add-apt-repository \
287 "deb [arch=amd64] https://download.docker.com/linux/$(distro-name-compat) \
288 $(debian-codename-compat) \
293 # other distros unknown
295 ### end docker install ####
300 # note, need python-certbot-nginx for nginx, but it depends on nginx,
301 # and I'm not installing nginx by default right now
302 if isdebian-testing
; then
303 pi
--install-suggests certbot
305 pi
--install-suggests -t jessie-backports certbot
307 # make a version of the certbot timer that emails me.
308 x
=/systemd
/system
/certbot
309 $sed -r -f - /lib
$x.timer
<<'EOF' |s dd of=/etc${x}mail.timer
310 s,^Description.*,\0 mail version,
312 $sed -r -f - /lib
$x.service
<<'EOF' |s dd of=/etc${x}mail.service
313 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
316 sgo certbotmail.timer
320 # not packaged in xenial or flidas
321 pi software-properties-common
322 s add-apt-repository
-y ppa
:certbot
/certbot
324 pi python-certbot-apache
326 # todo: other distros unknown
334 lj
) domain
=iank.bid
; exit 0 ;;
335 li
) domain
=iankelling.org
;;
337 /a
/h
/setup.sh
$domain
340 sudo
-E /a
/bin
/mediawiki-setup
/mw-setup-script
343 pi-nostart mumble-server
344 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
346 # do certificate to avoid warning about unsigned cert,
347 # which is overkill for my use, but hey, I'm cool, I know
349 web-conf apache2 mumble.iankelling.org
350 s
rm -f /etc
/apache
2/sites-enabled
/mumble.iankelling.org
352 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
353 /a/bin/distro-setup/certbot-renew-hook
359 tee /etc
/openvpn
/client-config
/mail <<'EOF'
360 ifconfig-push 10.8.0.4 255.255.255.0
364 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
366 Description=Turns on iptables mail nat
371 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
372 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
375 WantedBy=openvpn.service
378 ser
enable vpnmail.service
379 # needed for li's local mail delivery.
380 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
382 # setup let's encrypt cert
383 web-conf apache2 mail.iankelling.org
384 s rm /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
387 domain=cal.iankelling.org
388 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
389 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
390 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
392 Options +FollowSymLinks +Multiviews +Indexes
395 AuthName "Authentication Required"
396 # setup one time, with root:www-data, 640
397 AuthUserFile "/etc/caldav-htpasswd"
401 # nginx version of above would be:
402 # auth_basic "Not currently available";
403 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
406 ########## begin pump.io setup ##########
408 # once pump adds a logrotation script, turn off nologger,
410 # "logfile": "/var/log/pumpio/pumpio.log",
412 s dd of=/etc/pump.io.json <<'EOF'
414 "secret": "SECRET_REPLACE_ME",
416 "params": { "dbname": "pumpio" },
418 "site": "pump.iankelling.org",
419 "owner": "Ian Kelling",
420 "ownerURL": "https://iankelling.org/",
423 "hostname": "pump.iankelling.org",
425 "datadir": "/home/pumpio/pumpdata",
426 "enableUploads": true,
427 "debugClient": false,
428 "disableRegistration": true,
430 "key": "/home/pumpio/privkey.pem",
431 "cert": "/home/pumpio/fullchain.pem",
432 "address": "localhost",
436 s sed -i "s#SECRET_REPLACE_ME#$(cat /p/c/machine_specific/li/pump-secret)#" /etc/pump.io.json
438 # jessie\'s node is too old
439 # https://nodejs.org/en/download/package-manager/
440 curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
444 git clone https://github.com/pump-io/pump.io.git
446 # note: doing this or the npm install pump.io as root had problems.
449 # normally, next command would be
450 # s npm install -g databank-mongodb
451 # but it\'s this until a bug in pump gets fixed
452 s npm install -g databank-mongodb@0.19.2
453 s useradd -m -s /bin/false pumpio
454 sudo -u pumpio mkdir -p /home/pumpio/pumpdata
455 # for testing browser when only listening to localhost,
456 # in the pump.io.json, set hostname localhost, urlPort 5233
457 #ssh -L 5233:localhost:5233 li
459 s mkdir -p /var/log/pumpio/
460 s chown pumpio:pumpio /var/log/pumpio/
462 web-conf - apache2 pump.iankelling.org <<'EOF'
463 # currently a bug in pump that we cant terminate ssl
466 ProxyPass / https://127.0.0.1:8001/
467 ProxyPassReverse / https://127.0.0.1:8001/
468 # i have sockjs disabled per people suggesting that
469 # it won\'t work with apache right now.
470 # not sure if it would work with this,
471 # but afaik, this is pointless atm.
472 <Location /main/realtime/sockjs/>
473 ProxyPass wss://127.0.0.1:8001/main/realtime/sockjs/
474 ProxyPassReverse wss://127.0.0.1:8001/main/realtime/sockjs/
479 export RENEWED_LINEAGE=/etc/letsencrypt/live/pump.iankelling.org
480 /a/bin/distro-setup/certbot-renew-hook
483 s dd of=/etc/systemd/system/pump.service <<'EOF'
486 After=syslog.target network.target
492 ExecStart=/home/iank/pump.io/bin/pump
493 Environment=NODE_ENV=production
494 # failed to find databank-mongodb without this.
495 # I just looked at my environment variables took a guess.
496 Environment=NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
499 WantedBy=multi-user.target
503 ########## end pump.io setup ############
506 ############# begin setup mastodon ##############
508 # I'd like to try gnu social just cuz of gnu, but it's not being
509 # well maintained, for example, simple pull requests
511 # https://git.gnu.io/gnu/gnu-social/merge_requests/143
512 # and I submitted my own bugs, basic docs are broken
513 # https://git.gnu.io/gnu/gnu-social/issues/269
515 # note, docker required, but we installed it earlier
517 # i subscrubed to https://github.com/docker/compose/releases.atom
518 # to deal with updates manually. So far, it means just reving the
519 # version number, then restarting docker-compose with
521 # docker-compose up -d
522 curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` | s dd of=/usr/local/bin/docker-compose
523 s chmod +x /usr/local/bin/docker-compose
527 i clone https://github.com/tootsuite/mastodon
529 # subbed to atom feed to deal with updates
530 git checkout $(git tag | grep -v rc | tail -n1)
532 # per instructions, uncomment redis/postgres persistence in docker-compose.yml
533 sed -i 's/^#//' docker-compose.yml
535 cat >.env.production <<'EOF'
544 LOCAL_DOMAIN=mast.iankelling.org
547 SINGLE_USER_MODE=true
552 SMTP_FROM_ADDRESS=notifications@mast.iankelling.org
553 SMTP_DOMAIN=mast.iankelling.org
554 SMTP_DELIVERY_METHOD=smtp
557 for key in PAPERCLIP_SECRET SECRET_KEY_BASE OTP_SECRET; do
558 printf "%s=%s" $key "$(docker-compose run --rm web rake secret)" >>.env.production
560 s cat /etc/mailpass| while read -r domain port pass; do
561 if [[ $domain == mail.iankelling.org ]]; then
562 printf "SMTP_PASSWORD=%s" "$pass" >>.env.production
569 docker-compose run --rm web rails assets:precompile
571 # docker daemon takes care of starting on boot.
574 s a2enmod proxy_wstunnel headers
575 web-conf -f 3000 - apache2 mast.iankelling.org <<'EOF'
577 RequestHeader set X-Forwarded-Proto "https"
578 ProxyPass /500.html !
579 ProxyPass /oops.png !
580 ProxyPass /api/v1/streaming/ ws://localhost:4000/
581 ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
582 ErrorDocument 500 /500.html
583 ErrorDocument 501 /500.html
584 ErrorDocument 502 /500.html
585 ErrorDocument 503 /500.html
586 ErrorDocument 504 /500.html
590 ############### !!!!!!!!!!!!!!!!!
591 ############### manual steps:
593 # only following 2 people atm, so not bothering to figure out backups
594 # when mastodon has not documented it at all.
599 # johns@status.fsf.org
601 # sign in page is at https://mast.iankelling.org/auth/sign_in
602 # register as iank, then
603 # https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Administration-guide.md
604 # docker-compose run --rm web bundle exec rails mastodon:make_admin USERNAME=iank
606 ############# end setup mastodon ##############
608 # we use nsupdate to update the ip of home
611 echo "$0: $(date): ending now)"
617 ########### end section including li/lj ###############
620 debian) spa gnome-session-flashback ;;
621 # flidas is missing dependency gnome-panel. others unknown
627 trisquel|ubuntu|debian) spa ack-grep ;;
628 arch|fedora) spa ack ;;
642 wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
643 cat <<EOF | sudo tee /etc/apt/sources.list.d/iridium-browser.list
644 deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
645 #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
655 # not packaged in flidas. others unknown. gfdl nonfree issue
668 if [[ $HOSTNAME == treetowl ]]; then
670 # vpn-server setup via:
672 vpn-server-setup -r -d
673 s tee -a /etc/openvpn/server/server.conf <<'EOF'
674 push "dhcp-option DNS 192.168.1.1"
675 push "route 192.168.1.0 255.255.255.0"
676 client-connect /a/bin/distro-setup/vpn-client-connect
678 s sed -i --follow-symlinks 's/10.8./10.9./g' /etc/openvpn/server/server.conf
679 ser restart openvpn-server@server
680 vpn-mk-client-cert -s /etc/update-resolv-conf-home -c x2 -n home b8.nz
681 dir=/p/c/machine_specific/x2/filesystem/etc/openvpn/client
683 # background: We have these files locally, but we\'d have to duplicate the logic
684 # in vpn-mk-client-cert to get them, and this is just simpler.
685 scp root@x2:/etc/openvpn/client/home* $dir
689 # note, see bashrc for more documentation.
691 s dd of=/etc/systemd/system/rss2email.service <<'EOF'
693 Description=rss2email
694 After=multi-user.target
699 # about 24 hours of failures
700 # it copies over its files without respecting symlinks, so
701 # we pass options to use different location.
702 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
704 s dd of=/etc/systemd/system/rss2email.timer <<'EOF'
706 Description=rss2email
709 # for initial run. required.
711 # for subsequent runs.
712 OnUnitInactiveSec=300
715 WantedBy=timers.target
717 s systemctl daemon-reload
721 ######### begin pump.io periodic backup #############
722 if [[ $HOSTNAME == treetowl ]]; then
723 s dd of=/etc/systemd/system/pumpbackup.service <<'EOF'
725 Description=pump li backup
726 After=multi-user.target
731 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
733 s dd of=/etc/systemd/system/pumpbackup.timer <<'EOF'
735 Description=pump li backup hourly
741 WantedBy=timers.target
743 s systemctl daemon-reload
746 ######### end pump.io periodic backup #############
749 debian|trisquel|ubuntu)
750 # suggests because we want the resolvconf package.
751 # todo: check other distros to make sure it\'s installed
752 pi-nostart --install-suggests openvpn
753 # pi-nostart does not disable
759 /a/bin/distro-setup/radicale-setup
761 ## android studio setup
762 # this contains the setting for android sdk to point to
763 # /a/opt/androidsdk, which is asked upon first run
764 lnf /a/opt/.AndroidStudio2.2 ~
765 # android site says it needs a bunch of packages for ubuntu,
766 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
768 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
769 # see w.org for more android studio details
770 spa lib32stdc++6 default-jdk
773 if [[ $HOSTNAME == treetowl ]]; then
774 ############# begin syncthing setup ###########
776 # It\'s simpler to just worry about running it in one place for now.
777 # I assume it would work to clone it\'s config to another non-phone
778 # and just run it in one place instead of the normal having a
779 # separate config. I lean toward using the same config, since btrfs
780 # syncs between comps.
782 arch) pi syncthing ;;
783 trisquel|ubuntu|debian)
784 # testing has relatively up to date packages
785 if ! isdebian-testing; then
786 # based on error when doing apt-get update:
787 # E: The method driver /usr/lib/apt/methods/https could not be found.
788 pi apt-transport-https
789 # google led me here:
790 # https://apt.syncthing.net/
791 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
792 s="deb http://apt.syncthing.net/ syncthing release"
793 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != $s ]]; then
794 echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
801 lnf -T /w/syncthing /home/iank/.config/syncthing
802 sgo syncthing@iank # runs as iank
804 # these things persist in ~/.config/syncthing, which I save in
805 # /w/syncthing (not in /p, because syncthing should continue to
806 # run on home server even when using laptop as primary device)
807 # open http://localhost:8384/
808 # change listen address from default to tcp://:22001,
809 # this is because we do port forward so it doesn\'t have to use
810 # some external server, but the syncthing is broken for port forward,
811 # you get a message, something "like connected to myself, this should not happen"
812 # when connecting to other local devices, so I bump the port up by 1,
814 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
815 # Without this, it was being stuck syncing at 0%.
816 # Set gui username and password.
818 # install syncthing via f-droid,
819 # folder setting, turn off master folder (makes it read only).
820 # on phone, add device, click bar code icon
821 # on dekstop, top right, actions, device id
822 # after adding, notification will appear on desktop to confirm
824 # syncing folder. from phone to desktop: select desktop in the
825 # folder on phone\'s sync options, notification will appear in
826 # desktop\'s web ui within a minute. For the reverse, the
827 # notification will appear in android\'s notifications, you have to
828 # swipe down and tap it to add the folder. It won\'t appear in the
829 # syncthing ui, which would be intuitive, but don\'t wait for it
832 # On phone, set settings to run syncthing all the time, and
833 # show no notification.
835 # Folder versioning would make sense if I didn\'t already use btrfs
836 # for backups. I would choose staggered, or trash can for more space.
838 # if needed to install on a remote comp:
839 # ssh -L 8384:localhost:8384 -N frodo
840 # open http://localhost:8384/
842 # Note, the other thing i did was port forward port 22000,
843 # per https://docs.syncthing.net/users/firewall.html
845 ############# end syncthing setup ###########
850 # no equivalent in other distros:
852 debian|trisquel|ubuntu)
853 # for gui bug reporting
859 ####### misc packages ###########
861 # nagstamon setting which were set through the ui
863 # all unknown sources
864 # all warning services
865 # acknowledged hosts & services
866 # hosts & services down for maintenence
867 # services on down hosts
868 # services on hosts in maintenece
869 # services on unreachable osts
870 # hosts in soft state
871 # services in soft state
872 # in display tab: icon in systray.
875 debian|trisquel|ubuntu)
876 # it asks if it should make users in it's group capture packets without root,
877 # which is arguably more secure than running wireshark as root. default is no,
878 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
879 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
887 # no recommends because it wanted some other unstable package, something to
888 # do with math or something, which I didn't want to deal with.
889 p -y --no-install-recommends install python3-send2trash/unstable anki/unstable
898 debian|trisquel|ubuntu)
899 # note i had to do this, which is persistent:
901 # s chgrp debian-transmission torrents partial-torrents
903 # syslog says things like
904 # 'Failed to set receive buffer: requested 4194304, got 425984'
905 # google suggets giving it even more than that
906 tu /etc/sysctl.conf<<'EOF'
907 net.core.rmem_max = 67108864
908 net.core.wmem_max = 16777216
912 # some reason it doesn\'t seem to start automatically anyways
913 pi-nostart transmission-daemon
915 # the folder was moved here after an install around 02/2017.
916 # it contains runtime data,
917 # plus a simple symlink to the config file which it\'s
918 # not worth separating out.
919 s lnf -T /i/transmission-daemon /var/lib/transmission-daemon/.config/transmission-daemon
920 # between comps, the uid can change
921 s chown -R debian-transmission:debian-transmission /i/transmission-daemon /var/lib/transmission-daemon
922 s chown -R debian-transmission:traci /i/k/partial-torrents /i/k/torrents
924 # config file documented here, and it\'s the same config
925 # for daemon vs client, so it\'s documented in the gui.
926 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
928 # I originaly setup rpc-whitelist, but after using
929 # routing to a network namespace, it doesn\'t see the
930 # real source address, so it\'s disabled.
932 # Changed the cache-size to 256 mb, reduces disk use.
933 # It is a read & write cache.
937 p = '/etc/transmission-daemon/settings.json'
938 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
939 'rpc-whitelist-enabled' => false,
940 'rpc-authentication-required' => false,
941 'incomplete-dir' => '/i/k/partial-torrents',
942 'incomplete-dir-enabled' => true,
943 'download-dir' => '/i/k/torrents',
944 "speed-limit-up" => 800,
945 "speed-limit-up-enabled" => true,
946 "peer-port" => 61486,
947 "cache-size-mb" => 256,
948 "ratio-limit" => 5.0,
949 "ratio-limit-enabled" => true,
953 # make sure its not enabled, not sure if this is needed
954 ser disable transmission-daemon
956 # todo: others unknown
958 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
959 if ! getent passwd debian-transmission > /dev/null; then
965 --home-dir /var/lib/transmission-daemon \
974 --disabled-password \
975 --home /var/lib/transmission-daemon \
982 # trisquel 8 = openvpn, debian stretch = openvpn-client
983 vpn_ser=openvpn-client
984 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
988 s dd of=/etc/systemd/system/transmission-daemon-nn.service <<EOF
990 Description=Transmission BitTorrent Daemon netns
992 Requires=${vpn_ser}-nn@client.service
993 After=${vpn_ser}-nn@client.service
994 JoinsNamespaceOf=${vpn_ser}-nn@client.service
997 #User=debian-transmission
998 # notify type doesn't work with sudo
1000 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1001 ExecReload=/bin/kill -s HUP \$MAINPID
1006 WantedBy=multi-user.target
1010 if [[ $HOSTNAME == frodo ]]; then
1011 sgo transmission-daemon-nn
1015 ######### begin transmission client setup ######
1017 if [[ -e /p/transmission-rpc-pass ]]; then
1018 # arch had a default config,
1019 # debian had nothing until you start it.
1020 # With a little trial an error, here is a minimal config
1021 # taken from the generated one, plus changes that the
1022 # settings ui does, without a bunch of ui crap settings.
1024 # only settings I set were
1029 # the password is randomly generated on first run, i copied it out
1030 # so it could be used by other hosts.
1033 p = '/etc/transmission-daemon/settings.json'
1034 s = JSON.parse(File.read(p))
1035 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1036 File.write p, JSON.pretty_generate(s)
1039 rpc_pass=$(</p/transmission-rpc-pass)
1040 for f in /home/*; do
1041 d=$f/.config/transmission-remote-gtk
1044 s -u $u dd of=$d/config.json <<EOF
1048 "profile-name" : "Default",
1049 "hostname" : "transmission.b8.nz",
1050 "rpc-url-path" : "/transmission/rpc",
1052 "password" : "$rpc_pass",
1053 "auto-connect" : true,
1057 "update-active-only" : false,
1058 "activeonly-fullsync-enabled" : false,
1059 "activeonly-fullsync-every" : 2,
1060 "update-interval" : 3,
1061 "min-update-interval" : 3,
1062 "session-update-interval" : 60,
1070 "add-options-dialog" : false
1076 # dunno why it\'s there, but get rid of it
1078 li|lj) s rm -rf /home/linode ;;
1085 pi cups ghostscript gsfonts # from arch wiki cups page
1086 pi hplip # from google
1087 s gpasswd -a $USER sys # from arch wiki
1088 sgo org.cups.cupsd.service
1089 # goto http://127.0.0.1:631
1090 # administration tab, add new printer button.
1091 # In debian, I could use hte recommended driver,
1092 # in arch, I had to pick out the 6L driver.
1094 debian|trisquel|ubuntu)
1097 # other distros unknown
1102 trisquel|ubuntu|debian) pi --no-install-recommends mairix notmuch ;;
1103 fedora|arch) spa mairix notmuch ;;
1106 arch) spa nfs-utils ;;
1107 trisquel|ubuntu|debian) spa nfs-client ;;
1110 trisquel|ubuntu|debian) spa par2 ;;
1111 arch|fedora) spa par2cmdline ;;
1114 # needed for my tex resume
1116 trisquel|ubuntu|debian) spa texlive-full ;;
1117 arch) spa texlive-most ;;
1123 # optional dep for firefox for h.264 video
1124 arch) spa gst-libav ;;
1125 # other distros, probably come by default
1129 fedora|trisquel|ubuntu|debian) spa gnupg-agent ;;
1135 fedora) spa pinentry-gtk ;;
1136 *) : ;; # comes default or with other packages
1140 arch) spa firefox pulseaudio;;
1141 *) : ;; # comes default or with other packages
1146 arch) spa ttf-dejavu;;
1147 debian|trisquel|ubuntu) spa fonts-dejavu ;;
1153 arch) spa xorg-xev;;
1154 debian|trisquel|ubuntu) spa x11-utils ;;
1159 arch) pi virt-install;;&
1160 debian|trisquel|ubuntu) pi virtinst ;;&
1161 *) pi virt-manager ;; # creates the libvirt group in debian at least
1164 # allow user to run vms, from debian handbook
1165 for x in iank traci; do s usermod -a -G libvirt,kvm $x; done
1166 # bridge networking as user fails. google lead here, but it doesn\'t work:
1167 # oh well, I give up.
1168 # http://wiki.qemu.org/Features-Done/HelperNetworking
1170 # f=/etc/qemu/bridge.conf
1171 # s dd of=$f <<'EOF'
1174 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1180 debian|trisquel|ubuntu) spa genisoimage;;
1185 arch) spa spice-gtk3 ;;
1186 debian|trisquel|ubuntu) spa spice-client-gtk;;
1190 # general known for debian/ubuntu, not for fedora
1193 debian|trisquel|ubuntu)
1195 # a bit of googling, and added settings to bashrc
1196 go get -u github.com/mvdan/fdroidcl/cmd/fdroidcl
1204 # cdrkit for cloud-init isos
1205 # dnsmasq & ebtables for nat networking in libvirt
1206 # qemu for qemu-img, bind-tools for dig
1207 # dmidecode just because syslog complains
1208 pi unzip xorg-xmodmap dmidecode ebtables\
1209 bridge-utils dnsmasq qemu bind-tools
1210 # otherwise we get error about accessing kvm module.
1211 # seems like there might be a better way, but google was a bit vague.
1212 s $sed -ri '/^ *user *=/d' /etc/libvirt/qemu.conf
1213 echo 'user = "root"' | s tee -a /etc/libvirt/qemu.conf
1214 # https://bbs.archlinux.org/viewtopic.php?id=206206
1215 # # this should prolly go in the wiki
1217 # guessing this is not needed
1218 #sgo virtlogd.service
1225 arch) pi virtviewer ;;
1226 *) : ;; # other distros have it as a dependency afaik.
1232 fedora) cabal install shellcheck ;;
1233 *) spa shellcheck ;;
1234 # unknown for older ubuntu
1239 arch|debian|trisquel|ubuntu) spa pumpa ;;
1240 # others unknown. do have a buildscript:
1241 # /a/bin/buildscripts/pumpa ;;
1247 debian|trisquel|ubuntu) spa android-tools-adbd ;;
1248 # todo: not sure this is needed anymore, or if trisqel etc works even
1249 # debian) spa android-tools-adbd/unstable ;;
1250 arch) spa android-tools ;;
1251 # other distros unknown
1254 if [[ $HOSTNAME == treetowl ]]; then
1256 ## bitcoin disabled. fees too high
1259 # if [[ `debian-archive` == testing ]]; then
1260 # # has no unstable dependencies
1261 # pi bitcoind/unstable
1262 # src=/a/opt/bitcoin/contrib/init/bitcoind.service
1263 # s cp $src /etc/systemd/system
1264 # p=/etc/bitcoin/bitcoin
1265 # dst=/etc/systemd/system/bitcoinjm.service
1266 # # jm for joinmarket
1267 # $sed -r "/^\s*ExecStart/s,${p}.conf,${p}jm.conf," $src \
1268 # >/etc/systemd/system/bitcoinjm.service
1270 # d=jm; jm=d # being clever for succinctness
1272 # s $sed -ri "/^\s*\[Unit\]/a Conflicts=bitcoin${!s}.service" \
1273 # /etc/systemd/system/bitcoin${s}.service
1278 # dir=/nocow/.bitcoin
1280 # s chown -R bitcoin:bitcoin $dir
1283 # s chown -R root:bitcoin $dir
1286 # # pruning decreases the bitcoin dir to 2 gb, keeps
1287 # # just the recent blocks. can\'t do a few things like
1288 # # import a wallet dump.
1289 # # pruning works, but people had to do
1290 # # some manual stuff in joinmarket. I dun need the
1291 # # disk space, so not bothering yet, maybe in a year or so.
1292 # # https://github.com/JoinMarket-Org/joinmarket/issues/431
1293 # #https://bitcoin.org/en/release/v0.12.0#wallet-pruning
1296 # f=$dir/bitcoin.conf
1299 # # necessary for joinmarket, not bad in general
1300 # rpcpassword=$(openssl rand -base64 32)
1301 # rpcuser=$(openssl rand -base64 32)
1304 # # dunno about sharing a wallet between multiple instances
1305 # # manually did, wallet.dat symlinked in /nocow/.bitcoin
1309 # # other distros unknown
1314 # ## disabling joinmarket, its too expensive
1315 # ### begin joinmarket setup ###
1319 # f=$dir/bitcoin.conf
1320 # f2=$dir/bitcoinjm.conf
1322 # s tee -a $f2 >/dev/null <<EOF
1324 # walletnotify=curl -sI --connect-timeout 1 http://localhost:62602/walletnotify?%s
1325 # alertnotify=curl -sI --connect-timeout 1 http://localhost:62602/alertnotify?%s
1326 # wallet=joinmarket.dat
1330 # # other distros unknown
1333 # pi libsodium-dev python-pip
1334 # cd /a/opt/joinmarket
1335 # # using develop branch, as it seems to be mostly bug fixes,
1336 # # and this is quite new software.
1337 # # note: python3 does not work.
1338 # # has seg fault error due to some bug, but it still works
1339 # pip install -r requirements.txt || [[ $? == 139 ]]
1340 # # note, the target must exist ahead of time, or bitcoin
1341 # # just overwrites the link, and it\'s not happy with an empty file,
1342 # # so we have to create the wallet, then move and link it.
1343 # s lnf -T /q/bitcoin/wallet.dat /nocow/.bitcoin/wallet.dat
1344 # s lnf -T /q/bitcoin/joinmarket.dat /nocow/.bitcoin/joinmarket.dat
1345 # # not technically needed, but seems cleaner not to have
1346 # # symlinks be root owned unlike everything else
1347 # s chown -h bitcoin:bitcoin /nocow/.bitcoin/*
1349 # for var in rpcuser rpcpassword; do
1350 # u="$(s sed -rn "s/^$var=(.*)/\1/p" /etc/bitcoin/bitcoin.conf)"
1351 # # escape backslashes
1352 # u="${u//\\/\\\\\\\\}"
1355 # sed -ri "s,^(rpc_${var#rpc}\s*=).*,\1 $u," joinmarket.cfg
1357 # sed -ri "s/^\s*(blockchain_source\s*=).*/\1 bitcoin-rpc/" joinmarket.cfg
1358 # ### end joinmarket setup ###
1367 wget ftp://ftp.gnu.org/pub/gnu/global/global-6.5.7.tar.gz
1370 # based on https://github.com/leoliu/ggtags
1371 ./configure --with-exuberant-ctags=/usr/bin/ctags
1374 s pip install pygments
1382 debian|trisquel|ubuntu)
1390 s eatmydata apt-get -y install --purge --auto-remove task-mate-desktop
1391 # in settings, change scrolling to two-finger,
1392 # because the default edge scroll doesn\'t work.
1396 # mate-indicator-applet and beyond are msc things I noticed diffing a
1397 # standard install with mine.
1398 s eatmydata apt-get -y install --purge --auto-remove xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
1406 # already in debian jessie
1413 # note this failed running at the beginning of this file,
1414 # because no systemd user instance was running.
1415 # Doing systemd --user resulted in
1416 # Trying to run as user instance, but $XDG_RUNTIME_DIR is not set
1418 if isdebian-testing; then
1419 # as of 7/2016, has no unstable deps, and is not in testing anymore.
1426 # # ubuntu unknown. probably the same as debian, just check if the
1427 # # init scripts come with the package.
1429 # # copied from arch, but moved to etc
1430 # s dd of=/etc/systemd/user/synergys.service <<'EOF'
1432 # Description=Synergy Server Daemon
1433 # After=network.target
1437 # ExecStart=/usr/bin/synergys --no-daemon --config /etc/synergy.conf
1438 # Restart=on-failure
1441 # WantedBy=multi-user.target
1443 # s dd of=/etc/systemd/user/synergys.socket <<'EOF'
1445 # Conflicts=synergys@.service
1448 # ListenStream=24800
1452 # WantedBy=sockets.target
1454 # # had this fail with 'Failed to connect to bus: No such file or directory'
1455 # # then when I tried it manually, it worked fine...
1456 # if ! systemctl --user daemon-reload; then
1458 # echo retrying systemd user daemon reload
1459 # systemctl --user daemon-reload
1463 # # taken from arch wiki.
1464 # s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
1466 # Description=Synergy Client
1467 # After=network.target
1471 # ExecStart=/usr/bin/synergyc --no-daemon frodo
1472 # Restart=on-failure
1473 # # per man systemd.unit, StartLimitInterval, by default we
1474 # # restart more than 5 times in 10 seconds.
1475 # # And this param defaults too 200 miliseconds.
1479 # WantedBy=multi-user.target
1481 # s systemctl daemon-reload
1484 # ser enable synergyc@iank
1485 # ser start synergyc@iank ||: # X might not be running yet
1488 # systemctl --user start synergys ||:
1489 # systemctl --user enable synergys
1497 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1498 pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1499 cd /a/opt/indicator-kdeconnect
1502 cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1505 # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1506 # it seems, according to
1507 # /etc/xdg/autostart/kdeconnectd.desktop
1508 # I'm not seeing the icon, but the clipboard replication is working
1510 ######### end misc packages #########
1513 # packages I once used before and liked, but don\'t want installed now for
1515 # python-sqlite is used for offlineimap
1516 # lxappearance python-sqlite dolphin paman dconf-editor
1522 # todo, finish configuring smart.
1525 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1526 # turn on smart. background on options:
1527 # first line, -a = test everyting on all devices.
1528 # -S on, turn on disk internal saving of vendor specific info,
1529 # from google, seems like this is usually already on and fairly standard.
1530 # -o on, turn on 4 hour period non-performance degrading testing.
1531 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1532 sched="-s (S/../.././02|L/../../6/03)"
1533 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1534 DEVICESCAN -a -o on -S on -n standby,q $sched \
1535 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1537 # in the default configuration of at least ubuntu 14.04, resolvconf is
1538 # configured to order any nameservers associated with tun* or tap*
1539 # before the normal internet interfaces, which means they are always
1540 # consulted first. This is often slower and undesirable, ie. local dns
1541 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1543 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1544 # however, this breaks dns lookup for hosts on the openvpn lan.
1545 # I can\'t figure out why hosts on the normal lan would not be
1546 # broken under the default ordering, except the host I was
1547 # testing with previously had an entry in /etc/hosts.
1549 ############# end unfinished
1551 ########### misc stuff
1553 # stop autopoping windows when i plug in an android phone.
1554 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1555 # with still 0 exit code.
1556 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1557 dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1560 for dev in $(s btrfs fi show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1561 devs+=($(devbyid $dev),)
1563 devs[-1]=${devs[-1]%,} # jonied by commas
1565 # on grub upgrade, we get prompts unless we do this
1566 s debconf-set-selections <<EOF
1567 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1571 # the wiki backup script from ofswiki.org uses generic paths
1572 s lnf /p/c/machine_specific/li/mw_vars /root
1573 s lnf /k/backup/wiki_backup /root
1575 s cedit /etc/goaccess.conf <<'EOF' || [[ $? == 1 ]]
1576 # all things found from looking around the default config
1577 # copied existing NCSA Combined Log Format with Virtual Host, plus %L
1578 log-format %^:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %D
1579 time-format %H:%M:%S
1580 date-format %d/%b/%Y
1581 log-file /var/log/apache2/access.log
1584 # tip: copy access.log files to a stretch host directory, then run
1585 # jessie's goaccess is too old for some options, and it\'s
1586 # not easily installed from a testing.
1587 # goaccess --ignore-crawlers -f <(cat *) -a -o html > x.html
1592 trisquel|ubuntu|debian)
1593 # unison-gtk second, i want it to be default, not sure if that works
1594 # with spa. note, I used to install from testing repo when using stable,
1595 # but it shouldn't be needed since I wrote a script to handle mismatching
1597 spa unison unison-gtk
1606 # default is alsa, doesn\'t work with with pianobar
1607 s dd of=/etc/libao.conf <<'EOF'
1608 default_driver=pulse
1613 # note, for jessie, it depends on a higher version of btrfs-tools.
1615 # # disabled due to my patch being in btrbk
1617 # arch|debian|trisquel|ubuntu) pi btrbk ;;
1622 spa pv # for progress bar when running interactively.
1623 if [[ $HOSTNAME == treetowl ]]; then
1624 # backup/sync manually on others hosts for now.
1626 # note: to see when it was last run,
1634 debian|trisquel|ubuntu) s gpasswd -a iank adm ;; #needed for reading logs
1640 # https://www.torproject.org/docs/rpms.html.en
1641 # https://www.torproject.org/docs/debian.html.en
1642 # todo: figure out if the running service needs to be restarted upon updates
1645 # todo on fedora: setup non-dev packages
1647 s dd of=/etc/yum.repos.d/torproject.repo <<'EOF'
1649 name=Tor experimental repo
1651 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1653 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1656 name=Tor experimental source repo
1659 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1661 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1664 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1665 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1667 /a/bin/buildscripts/tor-browser
1670 tu /etc/apt/sources.list "deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1671 gpg --keyserver keys.gnupg.net --recv 886DDD89
1672 gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
1674 pi deb.torproject.org-keyring
1676 /a/bin/buildscripts/tor-browser
1680 /a/bin/buildscripts/tor-browser
1683 pi tor tor-browser-en
1693 fedora todo: disable the firewall or find a way to automate it.
1694 there's an unused section in t.org for tramikssion firewall setup
1696 fedora manual config for nfs:
1698 change to permanent configuration
1699 check the box for nfs
1700 was hard to figure this out, not sure if this is all needed, but
1702 mountd: udp/tcp 20048
1703 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1704 troubleshooting, unblock things in rpcinfo -p
1705 make sure to reload the firewall to load the persistent configuration
1712 debian|trisquel|ubuntu)
1716 pi nfs-utils || pending_reboot=true
1718 # this failed until I rebooted
1726 if [[ $HOSTNAME == frodo ]]; then
1727 # nohide = export filesystems mounted deeper than the export point
1728 # fsid=0 makes this export the "root" export
1729 # not documented in the man page, but this means
1730 # 1. it can be mounted with a shorthand of server:/
1731 # 2. exports that are subdirectories of this one will automatically be mounted
1732 tu /etc/exports <<'EOF'
1733 /k 192.168.1.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1742 # persistent virtual machines
1744 debian|trisquel|ubuntu)
1748 # if I was going to create a persistent vm, i might do it like this:
1749 # variant=something # from: virt-install --os-variant list
1750 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1751 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1752 # -n some_name --import --os-variant $variant --cpu host-model-only
1756 ######### begin stuff belonging at the end ##########
1759 # Apps we want to override others for default file handler:
1760 # simplest way in debian is to just install them last.
1773 pi "${simple_packages[@]}"
1776 if $pending_reboot; then
1777 echo "$0: pending reboot and then finished. doing it now."
1780 echo "$0: $(date): ending now)"