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
70 # xawtv has webcam cli control. v4lctl bright 80%; v4lctl list
71 # guvcview also adjusts webcam
151 $
(aptitude show ruby |
sed -rn 's/Depends: (.*)/\1/p')-doc
159 transmission-remote-gtk
168 spa $
(apt-cache search ruby
[.0-9]+-doc|
awk '{print $1}')
173 ########### begin section including li ################
179 # ubuntu 14.04 uses b-cron,
180 # but its not maintained in arch.
181 # of the ones in the main repos, cronie is only one maintained.
182 # fcron appears abandoned software.
186 *) : ;; # other distros come with cron.
198 debian|trisquel|ubuntu
) pi curl
;;
210 arch
) spa the_silver_searcher
;;
211 debian|trisquel|ubuntu
) spa silversearcher-ag
;;
216 debian|trisquel|ubuntu
) spa ntp
;;
225 # no equivalent in other distros:
227 debian|trisquel|ubuntu
)
229 if ! dpkg
-s apt-file
&>/dev
/null
; then
230 # this condition is just a speed optimization
234 # for debconf-get-selections
241 arch|debian|trisquel|ubuntu
)
254 # allows me to pipe with ssh -t, and gets rid of spam
255 # http://forums.debian.net/viewtopic.php?f=5&t=85822
256 # i'd rather disable the service than comment the init file
257 # this says disabling the service, it will still get restarted
258 # but this script doesn't do anything on restart, so it should be fine
259 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
260 # stretch doesn't have initscripts pkg installed by default
261 if [[ $
(debian-codename
) == jessie
]]; then
262 s update-rc.d motd disable
266 # this isn't a complete solution. It still shows me when updates are available,
267 # but it's no big deal.
268 s t
/etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
274 # https://debian-handbook.info/browse/stable/sect.regular-upgrades.html
275 # /etc/cron.daily/apt calls unattended-upgrades
276 # /usr/share/doc/unattended-upgrades# cat README.md
277 # /etc/apt/apt.conf.d/50unattended-upgrades
279 setup-debian-auto-update
282 # we've got a few dependencies later on, so install them now.
283 pi eatmydata
; PI_PREFIX
=eatmydata
284 pi
"${simple_packages[@]}"
288 ### begin docker install ####
291 # https://store.docker.com/editions/community/docker-ce-server-debian?tab=description
292 pi software-properties-common apt-transport-https
293 curl
-fsSL https
://download.docker.com
/linux
/$
(distro-name-compat
)/gpg | sudo apt-key add
-
294 sudo add-apt-repository \
295 "deb [arch=amd64] https://download.docker.com/linux/$(distro-name-compat) \
296 $(debian-codename-compat) \
301 # other distros unknown
303 ### end docker install ####
308 # note, need python-certbot-nginx for nginx, but it depends on nginx,
309 # and I'm not installing nginx by default right now.
310 # note python-certbot-apache is in suggests, but so is a doc package that brought in xorg
311 if [[ $
(debian-codename
) == jessie
]]; then
312 pi
-t jessie-backports certbot python-certbot-apache
314 pi certbot python-certbot-apache
316 # make a version of the certbot timer that emails me.
317 x
=/systemd
/system
/certbot
318 $sed -r -f - /lib
$x.timer
<<'EOF' |s dd of=/etc${x}mail.timer
319 s,^Description.*,\0 mail version,
321 $sed -r -f - /lib
$x.service
<<'EOF' |s dd of=/etc${x}mail.service
322 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
325 sgo certbotmail.timer
329 # not packaged in xenial or flidas
330 pi software-properties-common
331 s add-apt-repository
-y ppa
:certbot
/certbot
333 pi python-certbot-apache
335 # todo: other distros unknown
341 /a
/bin
/webcam
/install-server
344 /a
/bin
/webcam
/install-client
353 lj
) domain
=iank.bid
; exit 0 ;;
354 li
) domain
=iankelling.org
;;
356 /a
/h
/setup.sh
$domain
359 sudo
-E /a
/bin
/mediawiki-setup
/mw-setup-script
361 pi-nostart mumble-server
362 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
364 # do certificate to avoid warning about unsigned cert,
365 # which is overkill for my use, but hey, I'm cool, I know
367 web-conf apache2 mumble.iankelling.org
368 s
rm -f /etc
/apache
2/sites-enabled
/mumble.iankelling.org
370 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
371 /a/bin/distro-setup/certbot-renew-hook
377 s
tee /etc
/openvpn
/client-config
/mail <<'EOF'
378 ifconfig-push 10.8.0.4 255.255.255.0
381 # it\'s strange. docker seems to make the default for forward
382 # be drop, but then I set it to accept and it\'s stuck that way,
383 # I dun know why. But, let\'s make sure we can forward anyways.
384 s DEBIAN_FRONTEND
=noninteractive pi iptables-persistent
385 rm /etc
/iptables
/rules.v6
386 s
tee /etc
/iptables
/rules.v4
<<'EOF'
388 -A FORWARD -i tun+ -o eth0 -j ACCEPT
389 -A FORWARD -i eth0 -o tun+ -j ACCEPT
395 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
397 Description=Turns on iptables mail nat
402 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
403 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
406 WantedBy=openvpn.service
409 ser
enable vpnmail.service
410 # needed for li's local mail delivery.
411 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
412 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
413 vpn_service=openvpn-server@server
415 vpn_service=openvpn@server
418 # setup let's encrypt cert
419 web-conf apache2 mail.iankelling.org
420 s rm /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
423 domain=cal.iankelling.org
424 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
425 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
426 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
428 Options +FollowSymLinks +Multiviews +Indexes
431 AuthName "Authentication Required"
432 # setup one time, with root:www-data, 640
433 AuthUserFile "/etc/caldav-htpasswd"
437 # nginx version of above would be:
438 # auth_basic "Not currently available";
439 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
442 ########## begin pump.io setup ##########
444 # once pump adds a logrotation script, turn off nologger,
446 # "logfile": "/var/log/pumpio/pumpio.log",
448 s dd of=/etc/pump.io.json <<'EOF'
450 "secret": "SECRET_REPLACE_ME",
452 "params": { "dbname": "pumpio" },
454 "site": "pump.iankelling.org",
455 "owner": "Ian Kelling",
456 "ownerURL": "https://iankelling.org/",
459 "hostname": "pump.iankelling.org",
461 "datadir": "/home/pumpio/pumpdata",
462 "enableUploads": true,
463 "debugClient": false,
464 "disableRegistration": true,
466 "key": "/home/pumpio/privkey.pem",
467 "cert": "/home/pumpio/fullchain.pem",
468 "address": "localhost",
472 s sed -i "s#SECRET_REPLACE_ME#$(cat /p/c/machine_specific/li/pump-secret)#" /etc/pump.io.json
474 # stretch node is too old
475 # https://nodejs.org/en/download/package-manager/
476 curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
479 if [[ -e pump.io ]]; then
483 git clone https://github.com/pump-io/pump.io.git
486 # note: doing this or the npm install pump.io as root had problems.
489 # normally, next command would be
490 # s npm install -g databank-mongodb
491 # but it\'s this until a bug in pump gets fixed
492 # https://github.com/pump-io/pump.io/issues/1287
493 s npm install -g databank-mongodb@0.19.2
494 if ! getent passwd pumpio &>/dev/null; then
495 s useradd -m -s /bin/false pumpio
497 sudo -u pumpio mkdir -p /home/pumpio/pumpdata
498 # for testing browser when only listening to localhost,
499 # in the pump.io.json, set hostname localhost, urlPort 5233
500 #ssh -L 5233:localhost:5233 li
502 s mkdir -p /var/log/pumpio/
503 s chown pumpio:pumpio /var/log/pumpio/
505 web-conf - apache2 pump.iankelling.org <<'EOF'
506 # currently a bug in pump that we cant terminate ssl
509 ProxyPass / https://127.0.0.1:8001/
510 ProxyPassReverse / https://127.0.0.1:8001/
511 # i have sockjs disabled per people suggesting that
512 # it won\'t work with apache right now.
513 # not sure if it would work with this,
514 # but afaik, this is pointless atm.
515 <Location /main/realtime/sockjs/>
516 ProxyPass wss://127.0.0.1:8001/main/realtime/sockjs/
517 ProxyPassReverse wss://127.0.0.1:8001/main/realtime/sockjs/
522 export RENEWED_LINEAGE=/etc/letsencrypt/live/pump.iankelling.org
523 /a/bin/distro-setup/certbot-renew-hook
526 s dd of=/etc/systemd/system/pump.service <<'EOF'
529 After=syslog.target network.target
535 ExecStart=/home/iank/pump.io/bin/pump
536 Environment=NODE_ENV=production
537 # failed to find databank-mongodb without this.
538 # I just looked at my environment variables took a guess.
539 Environment=NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
542 WantedBy=multi-user.target
546 ########## end pump.io setup ############
549 ############# begin setup mastodon ##############
551 # main doc is Docker-Guide.md in docs repo
553 # I'd like to try gnu social just cuz of gnu, but it's not being
554 # well maintained, for example, simple pull requests
556 # https://git.gnu.io/gnu/gnu-social/merge_requests/143
557 # and I submitted my own bugs, basic docs are broken
558 # https://git.gnu.io/gnu/gnu-social/issues/269
560 # note, docker required, but we installed it earlier
562 # i subscrubed to https://github.com/docker/compose/releases.atom
563 # to deal with updates manually. So far, it means just reving the
564 # version number, then restarting docker-compose with
566 # docker-compose up -d
567 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
568 s chmod +x /usr/local/bin/docker-compose
573 i clone https://github.com/tootsuite/mastodon
575 # subbed to atom feed to deal with updates
576 git checkout $(git tag | grep -v rc | tail -n1)
578 # per instructions, uncomment redis/postgres persistence in docker-compose.yml
579 sed -i 's/^#//' docker-compose.yml
581 cat >.env.production <<'EOF'
590 LOCAL_DOMAIN=mast.iankelling.org
593 SINGLE_USER_MODE=true
598 SMTP_FROM_ADDRESS=notifications@mast.iankelling.org
599 SMTP_DOMAIN=mast.iankelling.org
600 SMTP_DELIVERY_METHOD=smtp
603 for key in PAPERCLIP_SECRET SECRET_KEY_BASE OTP_SECRET; do
604 # 1 minute 7 seconds to run this docker command
605 # to generate a secret. wtf, wtf, wtf, wtf
606 printf "%s=%s\n" $key "$(docker-compose run --rm web rake secret|tail -n1)" >>.env.production
609 s cat /etc/mailpass| while read -r domain port pass; do
610 if [[ $domain == mail.iankelling.org ]]; then
612 printf "SMTP_PASSWORD=%s\n" "$pass" >>.env.production
617 echo "$0: error, failed to find mailpass domain for mastadon"
621 docker-compose run --rm web rake mastodon:webpush:generate_vapid_key | grep -E '^VAPID_PUBLIC_KEY=|^VAPID_PRIVATE_KEY=' >> .env.production
622 logq docker-compose run --rm web rake db:migrate
623 docker-compose run --rm web rails assets:precompile
625 # docker daemon takes care of starting on boot.
628 s a2enmod proxy_wstunnel headers
629 web-conf -f 3000 - apache2 mast.iankelling.org <<'EOF'
631 RequestHeader set X-Forwarded-Proto "https"
632 ProxyPass /500.html !
633 ProxyPass /oops.png !
634 ProxyPass /api/v1/streaming/ ws://localhost:4000/
635 ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
636 ErrorDocument 500 /500.html
637 ErrorDocument 501 /500.html
638 ErrorDocument 502 /500.html
639 ErrorDocument 503 /500.html
640 ErrorDocument 504 /500.html
644 ############### !!!!!!!!!!!!!!!!!
645 ############### manual steps:
647 # only following 2 people atm, so not bothering to figure out backups
648 # when mastodon has not documented it at all.
653 # johns@status.fsf.org
655 # sign in page is at https://mast.iankelling.org/auth/sign_in
656 # register as iank, then
657 # https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Administration-guide.md
658 # docker-compose run --rm web bundle exec rails mastodon:make_admin USERNAME=iank
660 ############# end setup mastodon ##############
662 # we use nsupdate to update the ip of home
665 echo "$0: $(date): ending now)"
671 ########### end section including li/lj ###############
674 debian) spa gnome-session-flashback ;;
675 # flidas is missing dependency gnome-panel. others unknown
681 trisquel|ubuntu|debian) spa ack-grep ;;
682 arch|fedora) spa ack ;;
696 wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
697 cat <<EOF | sudo tee /etc/apt/sources.list.d/iridium-browser.list
698 deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
699 #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
709 # not packaged in flidas. others unknown. gfdl nonfree issue
723 ### begin home vpn server setup
726 # # this section done initially to make persistent keys.
727 # # Also note, I temporarily set /etc/hosts so my host was
728 # # b8.nz when running this, since the vpn client config
729 # # generator assumes we need to go to that server to get
731 # vpn-server-setup -rds
732 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
733 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
734 # for host in x2 kw; do
735 # vpn-mk-client-cert -b $host -n home b8.nz
736 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
738 # s bash -c "cp /etc/openvpn/client/home* $dir"
739 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
743 vpn-server-setup -rds
744 s tee -a /etc/openvpn/server/server.conf <<'EOF'
745 push "dhcp-option DNS 192.168.1.1"
746 push "route 192.168.1.0 255.255.255.0"
747 client-connect /a/bin/distro-setup/vpn-client-connect
749 s sed -i --follow-symlinks 's/10.8./10.9./g' /etc/openvpn/server/server.conf
751 if [[ $HOSTNAME == tp ]]; then
752 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
753 vpn_service=openvpn-server@server
755 vpn_service=openvpn@server
759 ### end vpn server setup
761 if [[ $HOSTNAME == tp ]]; then
763 # note, see bashrc for more documentation.
765 s dd of=/etc/systemd/system/rss2email.service <<'EOF'
767 Description=rss2email
768 After=multi-user.target
773 # about 24 hours of failures
774 # it copies over its files without respecting symlinks, so
775 # we pass options to use different location.
776 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
778 s dd of=/etc/systemd/system/rss2email.timer <<'EOF'
780 Description=rss2email
783 # for initial run. required.
785 # for subsequent runs.
786 OnUnitInactiveSec=300
789 WantedBy=timers.target
791 s systemctl daemon-reload
795 ######### begin pump.io periodic backup #############
796 if [[ $HOSTNAME == tp ]]; then
797 s dd of=/etc/systemd/system/pumpbackup.service <<'EOF'
799 Description=pump li backup
800 After=multi-user.target
805 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
807 s dd of=/etc/systemd/system/pumpbackup.timer <<'EOF'
809 Description=pump li backup hourly
815 WantedBy=timers.target
817 s systemctl daemon-reload
820 ######### end pump.io periodic backup #############
823 debian|trisquel|ubuntu)
824 # suggests because we want the resolvconf package.
825 # todo: check other distros to make sure it\'s installed
826 pi-nostart --install-suggests openvpn
827 # pi-nostart does not disable
833 /a/bin/distro-setup/radicale-setup
835 ## android studio setup
836 # this contains the setting for android sdk to point to
837 # /a/opt/androidsdk, which is asked upon first run
838 lnf /a/opt/.AndroidStudio2.2 ~
839 # android site says it needs a bunch of packages for ubuntu,
840 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
842 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
843 # see w.org for more android studio details
844 spa lib32stdc++6 default-jdk
847 if [[ $HOSTNAME == frodo ]]; then
848 ############# begin syncthing setup ###########
850 # It\'s simpler to just worry about running it in one place for now.
851 # I assume it would work to clone it\'s config to another non-phone
852 # and just run it in one place instead of the normal having a
853 # separate config. I lean toward using the same config, since btrfs
854 # syncs between comps.
856 arch) pi syncthing ;;
857 trisquel|ubuntu|debian)
858 # testing has relatively up to date packages
859 if ! isdebian-testing; then
860 # based on error when doing apt-get update:
861 # E: The method driver /usr/lib/apt/methods/https could not be found.
862 pi apt-transport-https
863 # google led me here:
864 # https://apt.syncthing.net/
865 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
866 s="deb http://apt.syncthing.net/ syncthing release"
867 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != $s ]]; then
868 echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
875 lnf -T /w/syncthing /home/iank/.config/syncthing
876 ser daemon-reload # syncthing likely not properly packaged
877 sgo syncthing@iank # runs as iank
879 # these things persist in ~/.config/syncthing, which I save in
880 # /w/syncthing (not in /p, because syncthing should continue to
881 # run on home server even when using laptop as primary device)
882 # open http://localhost:8384/
883 # change listen address from default to tcp://:22001,
884 # this is because we do port forward so it doesn\'t have to use
885 # some external server, but the syncthing is broken for port forward,
886 # you get a message, something "like connected to myself, this should not happen"
887 # when connecting to other local devices, so I bump the port up by 1,
889 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
890 # Without this, it was being stuck syncing at 0%.
891 # Set gui username and password.
893 # install syncthing via f-droid,
894 # folder setting, turn off master folder (makes it read only).
895 # on phone, add device, click bar code icon
896 # on dekstop, top right, actions, device id
897 # after adding, notification will appear on desktop to confirm
899 # syncing folder. from phone to desktop: select desktop in the
900 # folder on phone\'s sync options, notification will appear in
901 # desktop\'s web ui within a minute. For the reverse, the
902 # notification will appear in android\'s notifications, you have to
903 # swipe down and tap it to add the folder. It won\'t appear in the
904 # syncthing ui, which would be intuitive, but don\'t wait for it
907 # On phone, set settings to run syncthing all the time, and
908 # show no notification.
910 # Folder versioning would make sense if I didn\'t already use btrfs
911 # for backups. I would choose staggered, or trash can for more space.
913 # if needed to install on a remote comp:
914 # ssh -L 8384:localhost:8384 -N frodo
915 # open http://localhost:8384/
917 # Note, the other thing i did was port forward port 22000,
918 # per https://docs.syncthing.net/users/firewall.html
920 ############# end syncthing setup ###########
925 # no equivalent in other distros:
927 debian|trisquel|ubuntu)
928 # for gui bug reporting
934 ####### begin misc packages ###########
937 if [[ $HOSTNAME == kw ]]; then
939 NOTE: after this finishes, i did
941 # remove br from auto:
942 s vim /etc/network/interfaces
946 # nagstamon setting which were set through the ui
948 # all unknown sources
949 # all warning services
950 # acknowledged hosts & services
951 # hosts & services down for maintenence
952 # services on down hosts
953 # services on hosts in maintenece
954 # services on unreachable osts
955 # hosts in soft state
956 # services in soft state
957 # in display tab: icon in systray.
960 debian|trisquel|ubuntu)
961 # it asks if it should make users in it's group capture packets without root,
962 # which is arguably more secure than running wireshark as root. default is no,
963 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
964 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
969 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
970 # listed in the default config as suggested.
971 # /run/usr/1000 i noticed was missing for pulseaudio
972 # /run/user/0 just seemed like a not bad idea, given the above
973 tu /etc/schroot/desktop/fstab <<'EOF'
974 /run /run none rw,bind 0 0
975 /run/lock /run/lock none rw,bind 0 0
976 /dev/shm /dev/shm none rw,bind 0 0
977 /run/shm /run/shm none rw,bind 0 0
978 /run/user/1000 /run/user/1000 none rw,bind 0 0
979 /run/user/0 /run/user/0 none rw,bind 0 0
987 if [[ -e $d/bin ]]; then
988 s chroot $d apt-get update
989 s chroot $d apt-get -y dist-upgrade --purge --auto-remove
990 s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
993 s debootstrap $n $d http://deb.debian.org/debian/
994 s dd of=/etc/schroot/chroot.d/$n.conf <<EOF
1000 preserve-environment=true
1004 s cp -P {,$d}/etc/localtime
1005 cd #schroot fails if our current directory is not in the chroot
1006 s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1013 mkschroot stretch firefox-esr pulseaudio chromium
1017 s mkdir -p /nocow/user
1018 s chown $USER:$USER /nocow/user
1021 case $(debian-codename) in
1026 mkschroot jessie anki pulsaudio mplayer
1037 debian|trisquel|ubuntu)
1038 # note i had to do this, which is persistent:
1040 # s chgrp debian-transmission torrents partial-torrents
1042 # syslog says things like
1043 # 'Failed to set receive buffer: requested 4194304, got 425984'
1044 # google suggets giving it even more than that
1045 tu /etc/sysctl.conf<<'EOF'
1046 net.core.rmem_max = 67108864
1047 net.core.wmem_max = 16777216
1051 # some reason it doesn\'t seem to start automatically anyways
1052 pi-nostart transmission-daemon
1054 # the folder was moved here after an install around 02/2017.
1055 # it contains runtime data,
1056 # plus a simple symlink to the config file which it\'s
1057 # not worth separating out.
1058 # between comps, the uid can change
1059 f=/i/transmission-daemon
1060 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1061 if [[ -e $f ]]; then
1062 s chown -R debian-transmission:debian-transmission $f
1064 for f in /i/k/partial-torrents /i/k/torrents; do
1065 if [[ -e $f ]]; then
1066 s chown -R debian-transmission:traci $f
1069 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1071 # config file documented here, and it\'s the same config
1072 # for daemon vs client, so it\'s documented in the gui.
1073 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1075 # I originaly setup rpc-whitelist, but after using
1076 # routing to a network namespace, it doesn\'t see the
1077 # real source address, so it\'s disabled.
1079 # Changed the cache-size to 256 mb, reduces disk use.
1080 # It is a read & write cache.
1084 p = '/etc/transmission-daemon/settings.json'
1085 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1086 'rpc-whitelist-enabled' => false,
1087 'rpc-authentication-required' => false,
1088 'incomplete-dir' => '/i/k/partial-torrents',
1089 'incomplete-dir-enabled' => true,
1090 'download-dir' => '/i/k/torrents',
1091 "speed-limit-up" => 800,
1092 "speed-limit-up-enabled" => true,
1093 "peer-port" => 61486,
1094 "cache-size-mb" => 256,
1095 "ratio-limit" => 5.0,
1096 "ratio-limit-enabled" => true,
1100 # make sure its not enabled, not sure if this is needed
1101 ser disable transmission-daemon
1103 # todo: others unknown
1105 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1106 if ! getent passwd debian-transmission > /dev/null; then
1112 --home-dir /var/lib/transmission-daemon \
1113 --shell /bin/false \
1121 --disabled-password \
1122 --home /var/lib/transmission-daemon \
1129 # trisquel 8 = openvpn, debian stretch = openvpn-client
1130 vpn_ser=openvpn-client
1131 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1135 s dd of=/etc/systemd/system/transmission-daemon-nn.service <<EOF
1137 Description=Transmission BitTorrent Daemon netns
1138 After=network.target
1139 Requires=${vpn_ser}-nn@client.service
1140 After=${vpn_ser}-nn@client.service
1141 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1144 #User=debian-transmission
1145 # notify type doesn't work with sudo
1147 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1148 ExecReload=/bin/kill -s HUP \$MAINPID
1153 WantedBy=multi-user.target
1157 if [[ $HOSTNAME == frodo ]]; then
1158 sgo transmission-daemon-nn
1162 ######### begin transmission client setup ######
1164 if [[ -e /p/transmission-rpc-pass ]]; then
1165 # arch had a default config,
1166 # debian had nothing until you start it.
1167 # With a little trial an error, here is a minimal config
1168 # taken from the generated one, plus changes that the
1169 # settings ui does, without a bunch of ui crap settings.
1171 # only settings I set were
1176 # the password is randomly generated on first run, i copied it out
1177 # so it could be used by other hosts.
1180 p = '/etc/transmission-daemon/settings.json'
1181 s = JSON.parse(File.read(p))
1182 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1183 File.write p, JSON.pretty_generate(s)
1186 rpc_pass=$(</p/transmission-rpc-pass)
1187 for f in /home/*; do
1188 d=$f/.config/transmission-remote-gtk
1191 s -u $u dd of=$d/config.json <<EOF
1195 "profile-name" : "Default",
1196 "hostname" : "transmission.b8.nz",
1197 "rpc-url-path" : "/transmission/rpc",
1199 "password" : "$rpc_pass",
1200 "auto-connect" : true,
1204 "update-active-only" : false,
1205 "activeonly-fullsync-enabled" : false,
1206 "activeonly-fullsync-every" : 2,
1207 "update-interval" : 3,
1208 "min-update-interval" : 3,
1209 "session-update-interval" : 60,
1217 "add-options-dialog" : false
1223 # dunno why it\'s there, but get rid of it
1225 li|lj) s rm -rf /home/linode ;;
1232 pi cups ghostscript gsfonts # from arch wiki cups page
1233 pi hplip # from google
1234 s gpasswd -a $USER sys # from arch wiki
1235 sgo org.cups.cupsd.service
1236 # goto http://127.0.0.1:631
1237 # administration tab, add new printer button.
1238 # In debian, I could use hte recommended driver,
1239 # in arch, I had to pick out the 6L driver.
1241 debian|trisquel|ubuntu)
1244 # other distros unknown
1249 trisquel|ubuntu|debian) pi --no-install-recommends mairix notmuch ;;
1250 fedora|arch) spa mairix notmuch ;;
1253 arch) spa nfs-utils ;;
1254 trisquel|ubuntu|debian) spa nfs-client ;;
1257 trisquel|ubuntu|debian) spa par2 ;;
1258 arch|fedora) spa par2cmdline ;;
1261 # needed for my tex resume
1263 trisquel|ubuntu|debian) spa texlive-full ;;
1264 arch) spa texlive-most ;;
1270 # optional dep for firefox for h.264 video
1271 arch) spa gst-libav ;;
1272 # other distros, probably come by default
1276 fedora|trisquel|ubuntu|debian) spa gnupg-agent ;;
1282 fedora) spa pinentry-gtk ;;
1283 *) : ;; # comes default or with other packages
1287 arch) spa firefox pulseaudio;;
1288 *) : ;; # comes default or with other packages
1293 arch) spa ttf-dejavu;;
1294 debian|trisquel|ubuntu) spa fonts-dejavu ;;
1300 arch) spa xorg-xev;;
1301 debian|trisquel|ubuntu) spa x11-utils ;;
1306 arch) pi virt-install;;&
1307 debian|trisquel|ubuntu) pi virtinst ;;&
1308 *) pi virt-manager ;; # creates the libvirt group in debian at least
1311 # allow user to run vms, from debian handbook
1312 for x in iank traci; do s usermod -a -G libvirt,kvm $x; done
1313 # bridge networking as user fails. google lead here, but it doesn\'t work:
1314 # oh well, I give up.
1315 # http://wiki.qemu.org/Features-Done/HelperNetworking
1317 # f=/etc/qemu/bridge.conf
1318 # s dd of=$f <<'EOF'
1321 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1327 debian|trisquel|ubuntu) spa genisoimage;;
1332 arch) spa spice-gtk3 ;;
1333 debian|trisquel|ubuntu) spa spice-client-gtk;;
1337 # general known for debian/ubuntu, not for fedora
1340 debian|trisquel|ubuntu)
1342 # a bit of googling, and added settings to bashrc
1343 go get -u github.com/mvdan/fdroidcl/cmd/fdroidcl
1351 # cdrkit for cloud-init isos
1352 # dnsmasq & ebtables for nat networking in libvirt
1353 # qemu for qemu-img, bind-tools for dig
1354 # dmidecode just because syslog complains
1355 pi unzip xorg-xmodmap dmidecode ebtables\
1356 bridge-utils dnsmasq qemu bind-tools
1357 # otherwise we get error about accessing kvm module.
1358 # seems like there might be a better way, but google was a bit vague.
1359 s $sed -ri '/^ *user *=/d' /etc/libvirt/qemu.conf
1360 echo 'user = "root"' | s tee -a /etc/libvirt/qemu.conf
1361 # https://bbs.archlinux.org/viewtopic.php?id=206206
1362 # # this should prolly go in the wiki
1364 # guessing this is not needed
1365 #sgo virtlogd.service
1372 arch) pi virtviewer ;;
1373 *) : ;; # other distros have it as a dependency afaik.
1379 fedora) cabal install shellcheck ;;
1380 *) spa shellcheck ;;
1381 # unknown for older ubuntu
1386 arch|debian|trisquel|ubuntu) spa pumpa ;;
1387 # others unknown. do have a buildscript:
1388 # /a/bin/buildscripts/pumpa ;;
1394 debian|trisquel|ubuntu) spa android-tools-adbd ;;
1395 # todo: not sure this is needed anymore, or if trisqel etc works even
1396 # debian) spa android-tools-adbd/unstable ;;
1397 arch) spa android-tools ;;
1398 # other distros unknown
1406 wget ftp://ftp.gnu.org/pub/gnu/global/global-6.5.7.tar.gz
1409 # based on https://github.com/leoliu/ggtags
1410 ./configure --with-exuberant-ctags=/usr/bin/ctags
1413 s pip install pygments
1421 debian|trisquel|ubuntu)
1429 pi task-mate-desktop
1430 # in settings, change scrolling to two-finger,
1431 # because the default edge scroll doesn\'t work.
1435 # mate-indicator-applet and beyond are msc things I noticed diffing a
1436 # standard install with mine.
1437 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
1451 # note this failed running at the beginning of this file,
1452 # because no systemd user instance was running.
1453 # Doing systemd --user resulted in
1454 # Trying to run as user instance, but $XDG_RUNTIME_DIR is not set
1456 if isdebian-testing; then
1457 # as of 7/2016, has no unstable deps, and is not in testing anymore.
1464 # # ubuntu unknown. probably the same as debian, just check if the
1465 # # init scripts come with the package.
1467 # # copied from arch, but moved to etc
1468 # s dd of=/etc/systemd/user/synergys.service <<'EOF'
1470 # Description=Synergy Server Daemon
1471 # After=network.target
1475 # ExecStart=/usr/bin/synergys --no-daemon --config /etc/synergy.conf
1476 # Restart=on-failure
1479 # WantedBy=multi-user.target
1481 # s dd of=/etc/systemd/user/synergys.socket <<'EOF'
1483 # Conflicts=synergys@.service
1486 # ListenStream=24800
1490 # WantedBy=sockets.target
1492 # # had this fail with 'Failed to connect to bus: No such file or directory'
1493 # # then when I tried it manually, it worked fine...
1494 # if ! systemctl --user daemon-reload; then
1496 # echo retrying systemd user daemon reload
1497 # systemctl --user daemon-reload
1501 # # taken from arch wiki.
1502 # s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
1504 # Description=Synergy Client
1505 # After=network.target
1509 # ExecStart=/usr/bin/synergyc --no-daemon frodo
1510 # Restart=on-failure
1511 # # per man systemd.unit, StartLimitInterval, by default we
1512 # # restart more than 5 times in 10 seconds.
1513 # # And this param defaults too 200 miliseconds.
1517 # WantedBy=multi-user.target
1519 # s systemctl daemon-reload
1522 # ser enable synergyc@iank
1523 # ser start synergyc@iank ||: # X might not be running yet
1526 # systemctl --user start synergys ||:
1527 # systemctl --user enable synergys
1535 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1536 pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1537 cd /a/opt/indicator-kdeconnect
1540 cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1543 # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1544 # it seems, according to
1545 # /etc/xdg/autostart/kdeconnectd.desktop
1546 # I'm not seeing the icon, but the clipboard replication is working
1548 ######### end misc packages #########
1551 # packages I once used before and liked, but don\'t want installed now for
1553 # python-sqlite is used for offlineimap
1554 # lxappearance python-sqlite dolphin paman dconf-editor
1560 # todo, finish configuring smart.
1563 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1564 # turn on smart. background on options:
1565 # first line, -a = test everyting on all devices.
1566 # -S on, turn on disk internal saving of vendor specific info,
1567 # from google, seems like this is usually already on and fairly standard.
1568 # -o on, turn on 4 hour period non-performance degrading testing.
1569 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1570 sched="-s (S/../.././02|L/../../6/03)"
1571 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1572 DEVICESCAN -a -o on -S on -n standby,q $sched \
1573 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1575 # in the default configuration of at least ubuntu 14.04, resolvconf is
1576 # configured to order any nameservers associated with tun* or tap*
1577 # before the normal internet interfaces, which means they are always
1578 # consulted first. This is often slower and undesirable, ie. local dns
1579 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1581 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1582 # however, this breaks dns lookup for hosts on the openvpn lan.
1583 # I can\'t figure out why hosts on the normal lan would not be
1584 # broken under the default ordering, except the host I was
1585 # testing with previously had an entry in /etc/hosts.
1587 ############# end unfinished
1589 ########### misc stuff
1591 # stop autopoping windows when i plug in an android phone.
1592 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1593 # with still 0 exit code.
1594 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1595 dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1598 for dev in $(s btrfs fi show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1599 devs+=($(devbyid $dev),)
1601 devs[-1]=${devs[-1]%,} # jonied by commas
1603 # on grub upgrade, we get prompts unless we do this
1604 s debconf-set-selections <<EOF
1605 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1609 # the wiki backup script from ofswiki.org uses generic paths
1610 s lnf /p/c/machine_specific/li/mw_vars /root
1611 s lnf /k/backup/wiki_backup /root
1613 s cedit /etc/goaccess.conf <<'EOF' || [[ $? == 1 ]]
1614 # all things found from looking around the default config
1615 # copied existing NCSA Combined Log Format with Virtual Host, plus %L
1616 log-format %^:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %D
1617 time-format %H:%M:%S
1618 date-format %d/%b/%Y
1619 log-file /var/log/apache2/access.log
1622 # tip: copy access.log files to a stretch host directory, then run
1623 # jessie's goaccess is too old for some options, and it\'s
1624 # not easily installed from a testing.
1625 # goaccess --ignore-crawlers -f <(cat *) -a -o html > x.html
1630 trisquel|ubuntu|debian)
1631 # unison-gtk second, i want it to be default, not sure if that works
1632 # with spa. note, I used to install from testing repo when using stable,
1633 # but it shouldn't be needed since I wrote a script to handle mismatching
1635 spa unison unison-gtk
1644 # default is alsa, doesn\'t work with with pianobar
1645 s dd of=/etc/libao.conf <<'EOF'
1646 default_driver=pulse
1651 # note, for jessie, it depends on a higher version of btrfs-tools.
1653 # # disabled due to my patch being in btrbk
1655 # arch|debian|trisquel|ubuntu) pi btrbk ;;
1660 spa pv # for progress bar when running interactively.
1662 # ian: temporarily disabled while hosts are in flux.
1663 # if [[ $HOSTNAME == tp ]]; then
1664 # # backup/sync manually on others hosts for now.
1666 # # note: to see when it was last run,
1674 debian|trisquel|ubuntu) s gpasswd -a iank adm ;; #needed for reading logs
1680 # https://www.torproject.org/docs/rpms.html.en
1681 # https://www.torproject.org/docs/debian.html.en
1682 # todo: figure out if the running service needs to be restarted upon updates
1685 # todo on fedora: setup non-dev packages
1687 s dd of=/etc/yum.repos.d/torproject.repo <<'EOF'
1689 name=Tor experimental repo
1691 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1693 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1696 name=Tor experimental source repo
1699 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1701 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1704 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1705 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1707 /a/bin/buildscripts/tor-browser
1710 tu /etc/apt/sources.list "deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1711 gpg --keyserver keys.gnupg.net --recv 886DDD89
1712 gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
1714 pi deb.torproject.org-keyring
1716 /a/bin/buildscripts/tor-browser
1720 /a/bin/buildscripts/tor-browser
1723 pi tor tor-browser-en
1733 fedora todo: disable the firewall or find a way to automate it.
1734 there's an unused section in t.org for tramikssion firewall setup
1736 fedora manual config for nfs:
1738 change to permanent configuration
1739 check the box for nfs
1740 was hard to figure this out, not sure if this is all needed, but
1742 mountd: udp/tcp 20048
1743 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1744 troubleshooting, unblock things in rpcinfo -p
1745 make sure to reload the firewall to load the persistent configuration
1752 debian|trisquel|ubuntu)
1756 pi nfs-utils || pending_reboot=true
1758 # this failed until I rebooted
1766 if [[ $HOSTNAME == frodo ]]; then
1767 # nohide = export filesystems mounted deeper than the export point
1768 # fsid=0 makes this export the "root" export
1769 # not documented in the man page, but this means
1770 # 1. it can be mounted with a shorthand of server:/
1771 # 2. exports that are subdirectories of this one will automatically be mounted
1772 tu /etc/exports <<'EOF'
1773 /k 192.168.1.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1782 # persistent virtual machines
1784 debian|trisquel|ubuntu)
1788 # if I was going to create a persistent vm, i might do it like this:
1789 # variant=something # from: virt-install --os-variant list
1790 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1791 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1792 # -n some_name --import --os-variant $variant --cpu host-model-only
1796 ######### begin stuff belonging at the end ##########
1799 # Apps we want to override others for default file handler:
1800 # simplest way in debian is to just install them last.
1813 pi "${simple_packages[@]}"
1816 if $pending_reboot; then
1817 echo "$0: pending reboot and then finished. doing it now."
1820 echo "$0: $(date): ending now)"