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 ################
172 # ubuntu 14.04 uses b-cron,
173 # but its not maintained in arch.
174 # of the ones in the main repos, cronie is only one maintained.
175 # fcron appears abandoned software.
179 *) : ;; # other distros come with cron.
191 debian|trisquel|ubuntu
) pi curl
;;
203 arch
) spa the_silver_searcher
;;
204 debian|trisquel|ubuntu
) spa silversearcher-ag
;;
209 debian|trisquel|ubuntu
) spa ntp
;;
218 # no equivalent in other distros:
220 debian|trisquel|ubuntu
)
222 if ! dpkg
-s apt-file
&>/dev
/null
; then
223 # this condition is just a speed optimization
227 # for debconf-get-selections
234 arch|debian|trisquel|ubuntu
)
247 # allows me to pipe with ssh -t, and gets rid of spam
248 # http://forums.debian.net/viewtopic.php?f=5&t=85822
249 # i'd rather disable the service than comment the init file
250 # this says disabling the service, it will still get restarted
251 # but this script doesn't do anything on restart, so it should be fine
252 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
253 # stretch doesn't have initscripts pkg installed by default
254 if [[ $
(debian-codename
) == jessie
]]; then
255 s update-rc.d motd disable
259 # this isn't a complete solution. It still shows me when updates are available,
260 # but it's no big deal.
261 s t
/etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
267 # https://debian-handbook.info/browse/stable/sect.regular-upgrades.html
268 # /etc/cron.daily/apt calls unattended-upgrades
269 # /usr/share/doc/unattended-upgrades# cat README.md
270 # /etc/apt/apt.conf.d/50unattended-upgrades
272 setup-debian-auto-update
275 # we've got a few dependencies later on, so install them now.
277 s eatmydata apt-get
-y install --purge --auto-remove "${simple_packages[@]}"
281 ### begin docker install ####
284 # https://store.docker.com/editions/community/docker-ce-server-debian?tab=description
285 pi software-properties-common apt-transport-https
286 curl
-fsSL https
://download.docker.com
/linux
/$
(distro-name-compat
)/gpg | sudo apt-key add
-
287 sudo add-apt-repository \
288 "deb [arch=amd64] https://download.docker.com/linux/$(distro-name-compat) \
289 $(debian-codename-compat) \
294 # other distros unknown
296 ### end docker install ####
301 # note, need python-certbot-nginx for nginx, but it depends on nginx,
302 # and I'm not installing nginx by default right now
303 if isdebian-testing
; then
304 pi
--install-suggests certbot
306 pi
--install-suggests -t jessie-backports certbot
308 # make a version of the certbot timer that emails me.
309 x
=/systemd
/system
/certbot
310 $sed -r -f - /lib
$x.timer
<<'EOF' |s dd of=/etc${x}mail.timer
311 s,^Description.*,\0 mail version,
313 $sed -r -f - /lib
$x.service
<<'EOF' |s dd of=/etc${x}mail.service
314 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
317 sgo certbotmail.timer
321 # not packaged in xenial or flidas
322 pi software-properties-common
323 s add-apt-repository
-y ppa
:certbot
/certbot
325 pi python-certbot-apache
327 # todo: other distros unknown
335 lj
) domain
=iank.bid
; exit 0 ;;
336 li
) domain
=iankelling.org
;;
338 /a
/h
/setup.sh
$domain
341 sudo
-E /a
/bin
/mediawiki-setup
/mw-setup-script
344 pi-nostart mumble-server
345 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
347 # do certificate to avoid warning about unsigned cert,
348 # which is overkill for my use, but hey, I'm cool, I know
350 web-conf apache2 mumble.iankelling.org
351 s
rm -f /etc
/apache
2/sites-enabled
/mumble.iankelling.org
353 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
354 /a/bin/distro-setup/certbot-renew-hook
360 tee /etc
/openvpn
/client-config
/mail <<'EOF'
361 ifconfig-push 10.8.0.4 255.255.255.0
365 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
367 Description=Turns on iptables mail nat
372 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
373 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
376 WantedBy=openvpn.service
379 ser
enable vpnmail.service
380 # needed for li's local mail delivery.
381 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
383 # setup let's encrypt cert
384 web-conf apache2 mail.iankelling.org
385 s rm /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
388 domain=cal.iankelling.org
389 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
390 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
391 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
393 Options +FollowSymLinks +Multiviews +Indexes
396 AuthName "Authentication Required"
397 # setup one time, with root:www-data, 640
398 AuthUserFile "/etc/caldav-htpasswd"
402 # nginx version of above would be:
403 # auth_basic "Not currently available";
404 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
407 ########## begin pump.io setup ##########
409 # once pump adds a logrotation script, turn off nologger,
411 # "logfile": "/var/log/pumpio/pumpio.log",
413 s dd of=/etc/pump.io.json <<'EOF'
415 "secret": "SECRET_REPLACE_ME",
417 "params": { "dbname": "pumpio" },
419 "site": "pump.iankelling.org",
420 "owner": "Ian Kelling",
421 "ownerURL": "https://iankelling.org/",
424 "hostname": "pump.iankelling.org",
426 "datadir": "/home/pumpio/pumpdata",
427 "enableUploads": true,
428 "debugClient": false,
429 "disableRegistration": true,
431 "key": "/home/pumpio/privkey.pem",
432 "cert": "/home/pumpio/fullchain.pem",
433 "address": "localhost",
437 s sed -i "s#SECRET_REPLACE_ME#$(cat /p/c/machine_specific/li/pump-secret)#" /etc/pump.io.json
439 # jessie\'s node is too old
440 # https://nodejs.org/en/download/package-manager/
441 curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
445 git clone https://github.com/pump-io/pump.io.git
447 # note: doing this or the npm install pump.io as root had problems.
450 # normally, next command would be
451 # s npm install -g databank-mongodb
452 # but it\'s this until a bug in pump gets fixed
453 s npm install -g databank-mongodb@0.19.2
454 s useradd -m -s /bin/false pumpio
455 sudo -u pumpio mkdir -p /home/pumpio/pumpdata
456 # for testing browser when only listening to localhost,
457 # in the pump.io.json, set hostname localhost, urlPort 5233
458 #ssh -L 5233:localhost:5233 li
460 s mkdir -p /var/log/pumpio/
461 s chown pumpio:pumpio /var/log/pumpio/
463 web-conf - apache2 pump.iankelling.org <<'EOF'
464 # currently a bug in pump that we cant terminate ssl
467 ProxyPass / https://127.0.0.1:8001/
468 ProxyPassReverse / https://127.0.0.1:8001/
469 # i have sockjs disabled per people suggesting that
470 # it won\'t work with apache right now.
471 # not sure if it would work with this,
472 # but afaik, this is pointless atm.
473 <Location /main/realtime/sockjs/>
474 ProxyPass wss://127.0.0.1:8001/main/realtime/sockjs/
475 ProxyPassReverse wss://127.0.0.1:8001/main/realtime/sockjs/
480 export RENEWED_LINEAGE=/etc/letsencrypt/live/pump.iankelling.org
481 /a/bin/distro-setup/certbot-renew-hook
484 s dd of=/etc/systemd/system/pump.service <<'EOF'
487 After=syslog.target network.target
493 ExecStart=/home/iank/pump.io/bin/pump
494 Environment=NODE_ENV=production
495 # failed to find databank-mongodb without this.
496 # I just looked at my environment variables took a guess.
497 Environment=NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
500 WantedBy=multi-user.target
504 ########## end pump.io setup ############
507 ############# begin setup mastodon ##############
509 # I'd like to try gnu social just cuz of gnu, but it's not being
510 # well maintained, for example, simple pull requests
512 # https://git.gnu.io/gnu/gnu-social/merge_requests/143
513 # and I submitted my own bugs, basic docs are broken
514 # https://git.gnu.io/gnu/gnu-social/issues/269
516 # note, docker required, but we installed it earlier
518 # i subscrubed to https://github.com/docker/compose/releases.atom
519 # to deal with updates manually. So far, it means just reving the
520 # version number, then restarting docker-compose with
522 # docker-compose up -d
523 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
524 s chmod +x /usr/local/bin/docker-compose
528 i clone https://github.com/tootsuite/mastodon
530 # subbed to atom feed to deal with updates
531 git checkout $(git tag | grep -v rc | tail -n1)
533 # per instructions, uncomment redis/postgres persistence in docker-compose.yml
534 sed -i 's/^#//' docker-compose.yml
536 cat >.env.production <<'EOF'
545 LOCAL_DOMAIN=mast.iankelling.org
548 SINGLE_USER_MODE=true
553 SMTP_FROM_ADDRESS=notifications@mast.iankelling.org
554 SMTP_DOMAIN=mast.iankelling.org
555 SMTP_DELIVERY_METHOD=smtp
558 for key in PAPERCLIP_SECRET SECRET_KEY_BASE OTP_SECRET; do
559 printf "%s=%s" $key "$(docker-compose run --rm web rake secret)" >>.env.production
561 s cat /etc/mailpass| while read -r domain port pass; do
562 if [[ $domain == mail.iankelling.org ]]; then
563 printf "SMTP_PASSWORD=%s" "$pass" >>.env.production
570 docker-compose run --rm web rails assets:precompile
572 # docker daemon takes care of starting on boot.
575 s a2enmod proxy_wstunnel headers
576 web-conf -f 3000 - apache2 mast.iankelling.org <<'EOF'
578 RequestHeader set X-Forwarded-Proto "https"
579 ProxyPass /500.html !
580 ProxyPass /oops.png !
581 ProxyPass /api/v1/streaming/ ws://localhost:4000/
582 ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
583 ErrorDocument 500 /500.html
584 ErrorDocument 501 /500.html
585 ErrorDocument 502 /500.html
586 ErrorDocument 503 /500.html
587 ErrorDocument 504 /500.html
591 ############### !!!!!!!!!!!!!!!!!
592 ############### manual steps:
594 # only following 2 people atm, so not bothering to figure out backups
595 # when mastodon has not documented it at all.
600 # johns@status.fsf.org
602 # sign in page is at https://mast.iankelling.org/auth/sign_in
603 # register as iank, then
604 # https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Administration-guide.md
605 # docker-compose run --rm web bundle exec rails mastodon:make_admin USERNAME=iank
607 ############# end setup mastodon ##############
609 # we use nsupdate to update the ip of home
612 echo "$0: $(date): ending now)"
618 ########### end section including li/lj ###############
621 debian) spa gnome-session-flashback ;;
622 # flidas is missing dependency gnome-panel. others unknown
628 trisquel|ubuntu|debian) spa ack-grep ;;
629 arch|fedora) spa ack ;;
643 wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
644 cat <<EOF | sudo tee /etc/apt/sources.list.d/iridium-browser.list
645 deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
646 #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
656 # not packaged in flidas. others unknown. gfdl nonfree issue
670 ### begin home vpn server setup
673 # # this section done initially to make persistent keys.
674 # # Also note, I temporarily set /etc/hosts so my host was
675 # # b8.nz when running this, since the vpn client config
676 # # generator assumes we need to go to that server to get
678 # vpn-server-setup -rds
679 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
680 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
681 # for host in x2 kw; do
682 # vpn-mk-client-cert -b $host -n home b8.nz
683 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
685 # s bash -c "cp /etc/openvpn/client/home* $dir"
686 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
690 vpn-server-setup -rds
691 s tee -a /etc/openvpn/server/server.conf <<'EOF'
692 push "dhcp-option DNS 192.168.1.1"
693 push "route 192.168.1.0 255.255.255.0"
694 client-connect /a/bin/distro-setup/vpn-client-connect
696 s sed -i --follow-symlinks 's/10.8./10.9./g' /etc/openvpn/server/server.conf
698 if [[ $HOSTNAME == tp ]]; then
699 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
700 vpn_service=openvpn-server@.service
702 vpn_service=openvpn@server
706 ### end vpn server setup
708 if [[ $HOSTNAME == tp ]]; then
710 # note, see bashrc for more documentation.
712 s dd of=/etc/systemd/system/rss2email.service <<'EOF'
714 Description=rss2email
715 After=multi-user.target
720 # about 24 hours of failures
721 # it copies over its files without respecting symlinks, so
722 # we pass options to use different location.
723 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
725 s dd of=/etc/systemd/system/rss2email.timer <<'EOF'
727 Description=rss2email
730 # for initial run. required.
732 # for subsequent runs.
733 OnUnitInactiveSec=300
736 WantedBy=timers.target
738 s systemctl daemon-reload
742 ######### begin pump.io periodic backup #############
743 if [[ $HOSTNAME == tp ]]; then
744 s dd of=/etc/systemd/system/pumpbackup.service <<'EOF'
746 Description=pump li backup
747 After=multi-user.target
752 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
754 s dd of=/etc/systemd/system/pumpbackup.timer <<'EOF'
756 Description=pump li backup hourly
762 WantedBy=timers.target
764 s systemctl daemon-reload
767 ######### end pump.io periodic backup #############
770 debian|trisquel|ubuntu)
771 # suggests because we want the resolvconf package.
772 # todo: check other distros to make sure it\'s installed
773 pi-nostart --install-suggests openvpn
774 # pi-nostart does not disable
780 /a/bin/distro-setup/radicale-setup
782 ## android studio setup
783 # this contains the setting for android sdk to point to
784 # /a/opt/androidsdk, which is asked upon first run
785 lnf /a/opt/.AndroidStudio2.2 ~
786 # android site says it needs a bunch of packages for ubuntu,
787 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
789 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
790 # see w.org for more android studio details
791 spa lib32stdc++6 default-jdk
794 if [[ $HOSTNAME == frodo ]]; then
795 ############# begin syncthing setup ###########
797 # It\'s simpler to just worry about running it in one place for now.
798 # I assume it would work to clone it\'s config to another non-phone
799 # and just run it in one place instead of the normal having a
800 # separate config. I lean toward using the same config, since btrfs
801 # syncs between comps.
803 arch) pi syncthing ;;
804 trisquel|ubuntu|debian)
805 # testing has relatively up to date packages
806 if ! isdebian-testing; then
807 # based on error when doing apt-get update:
808 # E: The method driver /usr/lib/apt/methods/https could not be found.
809 pi apt-transport-https
810 # google led me here:
811 # https://apt.syncthing.net/
812 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
813 s="deb http://apt.syncthing.net/ syncthing release"
814 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != $s ]]; then
815 echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
822 lnf -T /w/syncthing /home/iank/.config/syncthing
823 sgo syncthing@iank # runs as iank
825 # these things persist in ~/.config/syncthing, which I save in
826 # /w/syncthing (not in /p, because syncthing should continue to
827 # run on home server even when using laptop as primary device)
828 # open http://localhost:8384/
829 # change listen address from default to tcp://:22001,
830 # this is because we do port forward so it doesn\'t have to use
831 # some external server, but the syncthing is broken for port forward,
832 # you get a message, something "like connected to myself, this should not happen"
833 # when connecting to other local devices, so I bump the port up by 1,
835 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
836 # Without this, it was being stuck syncing at 0%.
837 # Set gui username and password.
839 # install syncthing via f-droid,
840 # folder setting, turn off master folder (makes it read only).
841 # on phone, add device, click bar code icon
842 # on dekstop, top right, actions, device id
843 # after adding, notification will appear on desktop to confirm
845 # syncing folder. from phone to desktop: select desktop in the
846 # folder on phone\'s sync options, notification will appear in
847 # desktop\'s web ui within a minute. For the reverse, the
848 # notification will appear in android\'s notifications, you have to
849 # swipe down and tap it to add the folder. It won\'t appear in the
850 # syncthing ui, which would be intuitive, but don\'t wait for it
853 # On phone, set settings to run syncthing all the time, and
854 # show no notification.
856 # Folder versioning would make sense if I didn\'t already use btrfs
857 # for backups. I would choose staggered, or trash can for more space.
859 # if needed to install on a remote comp:
860 # ssh -L 8384:localhost:8384 -N frodo
861 # open http://localhost:8384/
863 # Note, the other thing i did was port forward port 22000,
864 # per https://docs.syncthing.net/users/firewall.html
866 ############# end syncthing setup ###########
871 # no equivalent in other distros:
873 debian|trisquel|ubuntu)
874 # for gui bug reporting
880 ####### misc packages ###########
882 # nagstamon setting which were set through the ui
884 # all unknown sources
885 # all warning services
886 # acknowledged hosts & services
887 # hosts & services down for maintenence
888 # services on down hosts
889 # services on hosts in maintenece
890 # services on unreachable osts
891 # hosts in soft state
892 # services in soft state
893 # in display tab: icon in systray.
896 debian|trisquel|ubuntu)
897 # it asks if it should make users in it's group capture packets without root,
898 # which is arguably more secure than running wireshark as root. default is no,
899 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
900 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
908 # no recommends because it wanted some other unstable package, something to
909 # do with math or something, which I didn't want to deal with.
910 p -y --no-install-recommends install python3-send2trash/unstable anki/unstable
919 debian|trisquel|ubuntu)
920 # note i had to do this, which is persistent:
922 # s chgrp debian-transmission torrents partial-torrents
924 # syslog says things like
925 # 'Failed to set receive buffer: requested 4194304, got 425984'
926 # google suggets giving it even more than that
927 tu /etc/sysctl.conf<<'EOF'
928 net.core.rmem_max = 67108864
929 net.core.wmem_max = 16777216
933 # some reason it doesn\'t seem to start automatically anyways
934 pi-nostart transmission-daemon
936 # the folder was moved here after an install around 02/2017.
937 # it contains runtime data,
938 # plus a simple symlink to the config file which it\'s
939 # not worth separating out.
940 # between comps, the uid can change
941 f=/i/transmission-daemon
942 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
944 s chown -R debian-transmission:debian-transmission $f
946 for f in /i/k/partial-torrents /i/k/torrents; do
948 s chown -R debian-transmission:traci $f
951 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
953 # config file documented here, and it\'s the same config
954 # for daemon vs client, so it\'s documented in the gui.
955 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
957 # I originaly setup rpc-whitelist, but after using
958 # routing to a network namespace, it doesn\'t see the
959 # real source address, so it\'s disabled.
961 # Changed the cache-size to 256 mb, reduces disk use.
962 # It is a read & write cache.
966 p = '/etc/transmission-daemon/settings.json'
967 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
968 'rpc-whitelist-enabled' => false,
969 'rpc-authentication-required' => false,
970 'incomplete-dir' => '/i/k/partial-torrents',
971 'incomplete-dir-enabled' => true,
972 'download-dir' => '/i/k/torrents',
973 "speed-limit-up" => 800,
974 "speed-limit-up-enabled" => true,
975 "peer-port" => 61486,
976 "cache-size-mb" => 256,
977 "ratio-limit" => 5.0,
978 "ratio-limit-enabled" => true,
982 # make sure its not enabled, not sure if this is needed
983 ser disable transmission-daemon
985 # todo: others unknown
987 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
988 if ! getent passwd debian-transmission > /dev/null; then
994 --home-dir /var/lib/transmission-daemon \
1003 --disabled-password \
1004 --home /var/lib/transmission-daemon \
1011 # trisquel 8 = openvpn, debian stretch = openvpn-client
1012 vpn_ser=openvpn-client
1013 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1017 s dd of=/etc/systemd/system/transmission-daemon-nn.service <<EOF
1019 Description=Transmission BitTorrent Daemon netns
1020 After=network.target
1021 Requires=${vpn_ser}-nn@client.service
1022 After=${vpn_ser}-nn@client.service
1023 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1026 #User=debian-transmission
1027 # notify type doesn't work with sudo
1029 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1030 ExecReload=/bin/kill -s HUP \$MAINPID
1035 WantedBy=multi-user.target
1039 if [[ $HOSTNAME == frodo ]]; then
1040 sgo transmission-daemon-nn
1044 ######### begin transmission client setup ######
1046 if [[ -e /p/transmission-rpc-pass ]]; then
1047 # arch had a default config,
1048 # debian had nothing until you start it.
1049 # With a little trial an error, here is a minimal config
1050 # taken from the generated one, plus changes that the
1051 # settings ui does, without a bunch of ui crap settings.
1053 # only settings I set were
1058 # the password is randomly generated on first run, i copied it out
1059 # so it could be used by other hosts.
1062 p = '/etc/transmission-daemon/settings.json'
1063 s = JSON.parse(File.read(p))
1064 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1065 File.write p, JSON.pretty_generate(s)
1068 rpc_pass=$(</p/transmission-rpc-pass)
1069 for f in /home/*; do
1070 d=$f/.config/transmission-remote-gtk
1073 s -u $u dd of=$d/config.json <<EOF
1077 "profile-name" : "Default",
1078 "hostname" : "transmission.b8.nz",
1079 "rpc-url-path" : "/transmission/rpc",
1081 "password" : "$rpc_pass",
1082 "auto-connect" : true,
1086 "update-active-only" : false,
1087 "activeonly-fullsync-enabled" : false,
1088 "activeonly-fullsync-every" : 2,
1089 "update-interval" : 3,
1090 "min-update-interval" : 3,
1091 "session-update-interval" : 60,
1099 "add-options-dialog" : false
1105 # dunno why it\'s there, but get rid of it
1107 li|lj) s rm -rf /home/linode ;;
1114 pi cups ghostscript gsfonts # from arch wiki cups page
1115 pi hplip # from google
1116 s gpasswd -a $USER sys # from arch wiki
1117 sgo org.cups.cupsd.service
1118 # goto http://127.0.0.1:631
1119 # administration tab, add new printer button.
1120 # In debian, I could use hte recommended driver,
1121 # in arch, I had to pick out the 6L driver.
1123 debian|trisquel|ubuntu)
1126 # other distros unknown
1131 trisquel|ubuntu|debian) pi --no-install-recommends mairix notmuch ;;
1132 fedora|arch) spa mairix notmuch ;;
1135 arch) spa nfs-utils ;;
1136 trisquel|ubuntu|debian) spa nfs-client ;;
1139 trisquel|ubuntu|debian) spa par2 ;;
1140 arch|fedora) spa par2cmdline ;;
1143 # needed for my tex resume
1145 trisquel|ubuntu|debian) spa texlive-full ;;
1146 arch) spa texlive-most ;;
1152 # optional dep for firefox for h.264 video
1153 arch) spa gst-libav ;;
1154 # other distros, probably come by default
1158 fedora|trisquel|ubuntu|debian) spa gnupg-agent ;;
1164 fedora) spa pinentry-gtk ;;
1165 *) : ;; # comes default or with other packages
1169 arch) spa firefox pulseaudio;;
1170 *) : ;; # comes default or with other packages
1175 arch) spa ttf-dejavu;;
1176 debian|trisquel|ubuntu) spa fonts-dejavu ;;
1182 arch) spa xorg-xev;;
1183 debian|trisquel|ubuntu) spa x11-utils ;;
1188 arch) pi virt-install;;&
1189 debian|trisquel|ubuntu) pi virtinst ;;&
1190 *) pi virt-manager ;; # creates the libvirt group in debian at least
1193 # allow user to run vms, from debian handbook
1194 for x in iank traci; do s usermod -a -G libvirt,kvm $x; done
1195 # bridge networking as user fails. google lead here, but it doesn\'t work:
1196 # oh well, I give up.
1197 # http://wiki.qemu.org/Features-Done/HelperNetworking
1199 # f=/etc/qemu/bridge.conf
1200 # s dd of=$f <<'EOF'
1203 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1209 debian|trisquel|ubuntu) spa genisoimage;;
1214 arch) spa spice-gtk3 ;;
1215 debian|trisquel|ubuntu) spa spice-client-gtk;;
1219 # general known for debian/ubuntu, not for fedora
1222 debian|trisquel|ubuntu)
1224 # a bit of googling, and added settings to bashrc
1225 go get -u github.com/mvdan/fdroidcl/cmd/fdroidcl
1233 # cdrkit for cloud-init isos
1234 # dnsmasq & ebtables for nat networking in libvirt
1235 # qemu for qemu-img, bind-tools for dig
1236 # dmidecode just because syslog complains
1237 pi unzip xorg-xmodmap dmidecode ebtables\
1238 bridge-utils dnsmasq qemu bind-tools
1239 # otherwise we get error about accessing kvm module.
1240 # seems like there might be a better way, but google was a bit vague.
1241 s $sed -ri '/^ *user *=/d' /etc/libvirt/qemu.conf
1242 echo 'user = "root"' | s tee -a /etc/libvirt/qemu.conf
1243 # https://bbs.archlinux.org/viewtopic.php?id=206206
1244 # # this should prolly go in the wiki
1246 # guessing this is not needed
1247 #sgo virtlogd.service
1254 arch) pi virtviewer ;;
1255 *) : ;; # other distros have it as a dependency afaik.
1261 fedora) cabal install shellcheck ;;
1262 *) spa shellcheck ;;
1263 # unknown for older ubuntu
1268 arch|debian|trisquel|ubuntu) spa pumpa ;;
1269 # others unknown. do have a buildscript:
1270 # /a/bin/buildscripts/pumpa ;;
1276 debian|trisquel|ubuntu) spa android-tools-adbd ;;
1277 # todo: not sure this is needed anymore, or if trisqel etc works even
1278 # debian) spa android-tools-adbd/unstable ;;
1279 arch) spa android-tools ;;
1280 # other distros unknown
1288 wget ftp://ftp.gnu.org/pub/gnu/global/global-6.5.7.tar.gz
1291 # based on https://github.com/leoliu/ggtags
1292 ./configure --with-exuberant-ctags=/usr/bin/ctags
1295 s pip install pygments
1303 debian|trisquel|ubuntu)
1311 s eatmydata apt-get -y install --purge --auto-remove task-mate-desktop
1312 # in settings, change scrolling to two-finger,
1313 # because the default edge scroll doesn\'t work.
1317 # mate-indicator-applet and beyond are msc things I noticed diffing a
1318 # standard install with mine.
1319 s eatmydata apt-get -y install --purge --auto-remove xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
1327 # already in debian jessie
1334 # note this failed running at the beginning of this file,
1335 # because no systemd user instance was running.
1336 # Doing systemd --user resulted in
1337 # Trying to run as user instance, but $XDG_RUNTIME_DIR is not set
1339 if isdebian-testing; then
1340 # as of 7/2016, has no unstable deps, and is not in testing anymore.
1347 # # ubuntu unknown. probably the same as debian, just check if the
1348 # # init scripts come with the package.
1350 # # copied from arch, but moved to etc
1351 # s dd of=/etc/systemd/user/synergys.service <<'EOF'
1353 # Description=Synergy Server Daemon
1354 # After=network.target
1358 # ExecStart=/usr/bin/synergys --no-daemon --config /etc/synergy.conf
1359 # Restart=on-failure
1362 # WantedBy=multi-user.target
1364 # s dd of=/etc/systemd/user/synergys.socket <<'EOF'
1366 # Conflicts=synergys@.service
1369 # ListenStream=24800
1373 # WantedBy=sockets.target
1375 # # had this fail with 'Failed to connect to bus: No such file or directory'
1376 # # then when I tried it manually, it worked fine...
1377 # if ! systemctl --user daemon-reload; then
1379 # echo retrying systemd user daemon reload
1380 # systemctl --user daemon-reload
1384 # # taken from arch wiki.
1385 # s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
1387 # Description=Synergy Client
1388 # After=network.target
1392 # ExecStart=/usr/bin/synergyc --no-daemon frodo
1393 # Restart=on-failure
1394 # # per man systemd.unit, StartLimitInterval, by default we
1395 # # restart more than 5 times in 10 seconds.
1396 # # And this param defaults too 200 miliseconds.
1400 # WantedBy=multi-user.target
1402 # s systemctl daemon-reload
1405 # ser enable synergyc@iank
1406 # ser start synergyc@iank ||: # X might not be running yet
1409 # systemctl --user start synergys ||:
1410 # systemctl --user enable synergys
1418 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1419 pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1420 cd /a/opt/indicator-kdeconnect
1423 cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1426 # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1427 # it seems, according to
1428 # /etc/xdg/autostart/kdeconnectd.desktop
1429 # I'm not seeing the icon, but the clipboard replication is working
1431 ######### end misc packages #########
1434 # packages I once used before and liked, but don\'t want installed now for
1436 # python-sqlite is used for offlineimap
1437 # lxappearance python-sqlite dolphin paman dconf-editor
1443 # todo, finish configuring smart.
1446 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1447 # turn on smart. background on options:
1448 # first line, -a = test everyting on all devices.
1449 # -S on, turn on disk internal saving of vendor specific info,
1450 # from google, seems like this is usually already on and fairly standard.
1451 # -o on, turn on 4 hour period non-performance degrading testing.
1452 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1453 sched="-s (S/../.././02|L/../../6/03)"
1454 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1455 DEVICESCAN -a -o on -S on -n standby,q $sched \
1456 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1458 # in the default configuration of at least ubuntu 14.04, resolvconf is
1459 # configured to order any nameservers associated with tun* or tap*
1460 # before the normal internet interfaces, which means they are always
1461 # consulted first. This is often slower and undesirable, ie. local dns
1462 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1464 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1465 # however, this breaks dns lookup for hosts on the openvpn lan.
1466 # I can\'t figure out why hosts on the normal lan would not be
1467 # broken under the default ordering, except the host I was
1468 # testing with previously had an entry in /etc/hosts.
1470 ############# end unfinished
1472 ########### misc stuff
1474 # stop autopoping windows when i plug in an android phone.
1475 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1476 # with still 0 exit code.
1477 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1478 dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1481 for dev in $(s btrfs fi show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1482 devs+=($(devbyid $dev),)
1484 devs[-1]=${devs[-1]%,} # jonied by commas
1486 # on grub upgrade, we get prompts unless we do this
1487 s debconf-set-selections <<EOF
1488 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1492 # the wiki backup script from ofswiki.org uses generic paths
1493 s lnf /p/c/machine_specific/li/mw_vars /root
1494 s lnf /k/backup/wiki_backup /root
1496 s cedit /etc/goaccess.conf <<'EOF' || [[ $? == 1 ]]
1497 # all things found from looking around the default config
1498 # copied existing NCSA Combined Log Format with Virtual Host, plus %L
1499 log-format %^:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %D
1500 time-format %H:%M:%S
1501 date-format %d/%b/%Y
1502 log-file /var/log/apache2/access.log
1505 # tip: copy access.log files to a stretch host directory, then run
1506 # jessie's goaccess is too old for some options, and it\'s
1507 # not easily installed from a testing.
1508 # goaccess --ignore-crawlers -f <(cat *) -a -o html > x.html
1513 trisquel|ubuntu|debian)
1514 # unison-gtk second, i want it to be default, not sure if that works
1515 # with spa. note, I used to install from testing repo when using stable,
1516 # but it shouldn't be needed since I wrote a script to handle mismatching
1518 spa unison unison-gtk
1527 # default is alsa, doesn\'t work with with pianobar
1528 s dd of=/etc/libao.conf <<'EOF'
1529 default_driver=pulse
1534 # note, for jessie, it depends on a higher version of btrfs-tools.
1536 # # disabled due to my patch being in btrbk
1538 # arch|debian|trisquel|ubuntu) pi btrbk ;;
1543 spa pv # for progress bar when running interactively.
1545 # ian: temporarily disabled while hosts are in flux.
1546 # if [[ $HOSTNAME == tp ]]; then
1547 # # backup/sync manually on others hosts for now.
1549 # # note: to see when it was last run,
1557 debian|trisquel|ubuntu) s gpasswd -a iank adm ;; #needed for reading logs
1563 # https://www.torproject.org/docs/rpms.html.en
1564 # https://www.torproject.org/docs/debian.html.en
1565 # todo: figure out if the running service needs to be restarted upon updates
1568 # todo on fedora: setup non-dev packages
1570 s dd of=/etc/yum.repos.d/torproject.repo <<'EOF'
1572 name=Tor experimental repo
1574 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1576 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1579 name=Tor experimental source repo
1582 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1584 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1587 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1588 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1590 /a/bin/buildscripts/tor-browser
1593 tu /etc/apt/sources.list "deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1594 gpg --keyserver keys.gnupg.net --recv 886DDD89
1595 gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
1597 pi deb.torproject.org-keyring
1599 /a/bin/buildscripts/tor-browser
1603 /a/bin/buildscripts/tor-browser
1606 pi tor tor-browser-en
1616 fedora todo: disable the firewall or find a way to automate it.
1617 there's an unused section in t.org for tramikssion firewall setup
1619 fedora manual config for nfs:
1621 change to permanent configuration
1622 check the box for nfs
1623 was hard to figure this out, not sure if this is all needed, but
1625 mountd: udp/tcp 20048
1626 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1627 troubleshooting, unblock things in rpcinfo -p
1628 make sure to reload the firewall to load the persistent configuration
1635 debian|trisquel|ubuntu)
1639 pi nfs-utils || pending_reboot=true
1641 # this failed until I rebooted
1649 if [[ $HOSTNAME == frodo ]]; then
1650 # nohide = export filesystems mounted deeper than the export point
1651 # fsid=0 makes this export the "root" export
1652 # not documented in the man page, but this means
1653 # 1. it can be mounted with a shorthand of server:/
1654 # 2. exports that are subdirectories of this one will automatically be mounted
1655 tu /etc/exports <<'EOF'
1656 /k 192.168.1.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1665 # persistent virtual machines
1667 debian|trisquel|ubuntu)
1671 # if I was going to create a persistent vm, i might do it like this:
1672 # variant=something # from: virt-install --os-variant list
1673 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1674 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1675 # -n some_name --import --os-variant $variant --cpu host-model-only
1679 ######### begin stuff belonging at the end ##########
1682 # Apps we want to override others for default file handler:
1683 # simplest way in debian is to just install them last.
1696 pi "${simple_packages[@]}"
1699 if $pending_reboot; then
1700 echo "$0: pending reboot and then finished. doing it now."
1703 echo "$0: $(date): ending now)"