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
154 $
(aptitude show ruby |
sed -rn 's/Depends: (.*)/\1/p')-doc
162 transmission-remote-gtk
170 xscreensaver-data-extra
172 xscreensaver-gl-extra
174 spa $
(apt-cache search ruby
[.0-9]+-doc|
awk '{print $1}')
179 ########### begin section including li ################
185 # ubuntu 14.04 uses b-cron,
186 # but its not maintained in arch.
187 # of the ones in the main repos, cronie is only one maintained.
188 # fcron appears abandoned software.
192 *) : ;; # other distros come with cron.
204 debian|trisquel|ubuntu
) pi curl
;;
216 arch
) spa the_silver_searcher
;;
217 debian|trisquel|ubuntu
) spa silversearcher-ag
;;
222 debian|trisquel|ubuntu
) spa ntp
;;
231 # no equivalent in other distros:
233 debian|trisquel|ubuntu
)
235 if ! dpkg
-s apt-file
&>/dev
/null
; then
236 # this condition is just a speed optimization
240 # for debconf-get-selections
247 arch|debian|trisquel|ubuntu
)
260 # allows me to pipe with ssh -t, and gets rid of spam
261 # http://forums.debian.net/viewtopic.php?f=5&t=85822
262 # i'd rather disable the service than comment the init file
263 # this says disabling the service, it will still get restarted
264 # but this script doesn't do anything on restart, so it should be fine
265 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
266 # stretch doesn't have initscripts pkg installed by default
267 if [[ $
(debian-codename
) == jessie
]]; then
268 s update-rc.d motd disable
272 # this isn't a complete solution. It still shows me when updates are available,
273 # but it's no big deal.
274 s t
/etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
280 # https://debian-handbook.info/browse/stable/sect.regular-upgrades.html
281 # /etc/cron.daily/apt calls unattended-upgrades
282 # /usr/share/doc/unattended-upgrades# cat README.md
283 # /etc/apt/apt.conf.d/50unattended-upgrades
285 setup-debian-auto-update
288 # we've got a few dependencies later on, so install them now.
289 pi eatmydata
; PI_PREFIX
=eatmydata
290 pi
"${simple_packages[@]}"
294 ### begin docker install ####
297 # https://store.docker.com/editions/community/docker-ce-server-debian?tab=description
298 pi software-properties-common apt-transport-https
299 curl
-fsSL https
://download.docker.com
/linux
/$
(distro-name-compat
)/gpg | sudo apt-key add
-
300 sudo add-apt-repository \
301 "deb [arch=amd64] https://download.docker.com/linux/$(distro-name-compat) \
302 $(debian-codename-compat) \
307 # other distros unknown
309 ### end docker install ####
312 ### begin certbot install ###
315 # note, need python-certbot-nginx for nginx, but it depends on nginx,
316 # and I'm not installing nginx by default right now.
317 # note python-certbot-apache is in suggests, but so is a doc package that brought in xorg
318 if [[ $
(debian-codename
) == jessie
]]; then
319 pi
-t jessie-backports certbot python-certbot-apache
321 pi certbot python-certbot-apache
325 # not packaged in xenial or flidas
326 pi software-properties-common
329 # gpg: key 75BCA694: public key "Launchpad PPA for certbot" imported
330 # gpg: Total number processed: 1
332 # gpg: no valid OpenPGP data found.
335 # but it seems to work fine, perhaps it's only failing on the second run.
336 s add-apt-repository
-y ppa
:certbot
/certbot ||
:
338 pi python-certbot-apache
340 # todo: other distros unknown
342 # make a version of the certbot timer that emails me.
343 x
=/systemd
/system
/certbot
344 $sed -r -f - /lib
$x.timer
<<'EOF' |s dd of=/etc${x}mail.timer
345 s,^Description.*,\0 mail version,
347 $sed -r -f - /lib
$x.service
<<'EOF' |s dd of=/etc${x}mail.service
348 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
351 sgo certbotmail.timer
352 ### end certbot install ###
358 /a
/bin
/webcam
/install-server
361 /a
/bin
/webcam
/install-client
370 lj
) domain
=iank.bid
; exit 0 ;;
371 li
) domain
=iankelling.org
;;
373 /a
/h
/setup.sh
$domain
376 sudo
-E /a
/bin
/mediawiki-setup
/mw-setup-script
378 pi-nostart mumble-server
379 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
381 # do certificate to avoid warning about unsigned cert,
382 # which is overkill for my use, but hey, I'm cool, I know
384 web-conf apache2 mumble.iankelling.org
385 s
rm -f /etc
/apache
2/sites-enabled
/mumble.iankelling.org
387 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
388 /a/bin/distro-setup/certbot-renew-hook
394 s
tee /etc
/openvpn
/client-config
/mail <<'EOF'
395 ifconfig-push 10.8.0.4 255.255.255.0
398 # it\'s strange. docker seems to make the default for forward
399 # be drop, but then I set it to accept and it\'s stuck that way,
400 # I dun know why. But, let\'s make sure we can forward anyways.
401 s DEBIAN_FRONTEND
=noninteractive pi iptables-persistent
402 rm /etc
/iptables
/rules.v6
403 s
tee /etc
/iptables
/rules.v4
<<'EOF'
405 -A FORWARD -i tun+ -o eth0 -j ACCEPT
406 -A FORWARD -i eth0 -o tun+ -j ACCEPT
412 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
414 Description=Turns on iptables mail nat
419 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
420 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
423 WantedBy=openvpn.service
426 ser
enable vpnmail.service
427 # needed for li's local mail delivery.
428 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
429 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
430 vpn_service=openvpn-server@server
432 vpn_service=openvpn@server
435 # setup let's encrypt cert
436 web-conf apache2 mail.iankelling.org
437 s rm /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
440 domain=cal.iankelling.org
441 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
442 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
443 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
445 Options +FollowSymLinks +Multiviews +Indexes
448 AuthName "Authentication Required"
449 # setup one time, with root:www-data, 640
450 AuthUserFile "/etc/caldav-htpasswd"
454 # nginx version of above would be:
455 # auth_basic "Not currently available";
456 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
459 ########## begin pump.io setup ##########
461 # once pump adds a logrotation script, turn off nologger,
463 # "logfile": "/var/log/pumpio/pumpio.log",
465 s dd of=/etc/pump.io.json <<'EOF'
467 "secret": "SECRET_REPLACE_ME",
469 "params": { "dbname": "pumpio" },
471 "site": "pump.iankelling.org",
472 "owner": "Ian Kelling",
473 "ownerURL": "https://iankelling.org/",
476 "hostname": "pump.iankelling.org",
478 "datadir": "/home/pumpio/pumpdata",
479 "enableUploads": true,
480 "debugClient": false,
481 "disableRegistration": true,
483 "key": "/home/pumpio/privkey.pem",
484 "cert": "/home/pumpio/fullchain.pem",
485 "address": "localhost",
489 s sed -i "s#SECRET_REPLACE_ME#$(cat /p/c/machine_specific/li/pump-secret)#" /etc/pump.io.json
491 # stretch node is too old
492 # https://nodejs.org/en/download/package-manager/
493 curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
496 if [[ -e pump.io ]]; then
500 git clone https://github.com/pump-io/pump.io.git
503 # note: doing this or the npm install pump.io as root had problems.
506 # normally, next command would be
507 # s npm install -g databank-mongodb
508 # but it\'s this until a bug in pump gets fixed
509 # https://github.com/pump-io/pump.io/issues/1287
510 s npm install -g databank-mongodb@0.19.2
511 if ! getent passwd pumpio &>/dev/null; then
512 s useradd -m -s /bin/false pumpio
514 sudo -u pumpio mkdir -p /home/pumpio/pumpdata
515 # for testing browser when only listening to localhost,
516 # in the pump.io.json, set hostname localhost, urlPort 5233
517 #ssh -L 5233:localhost:5233 li
519 s mkdir -p /var/log/pumpio/
520 s chown pumpio:pumpio /var/log/pumpio/
522 web-conf - apache2 pump.iankelling.org <<'EOF'
523 # currently a bug in pump that we cant terminate ssl
526 ProxyPass / https://127.0.0.1:8001/
527 ProxyPassReverse / https://127.0.0.1:8001/
528 # i have sockjs disabled per people suggesting that
529 # it won\'t work with apache right now.
530 # not sure if it would work with this,
531 # but afaik, this is pointless atm.
532 <Location /main/realtime/sockjs/>
533 ProxyPass wss://127.0.0.1:8001/main/realtime/sockjs/
534 ProxyPassReverse wss://127.0.0.1:8001/main/realtime/sockjs/
539 export RENEWED_LINEAGE=/etc/letsencrypt/live/pump.iankelling.org
540 /a/bin/distro-setup/certbot-renew-hook
543 s dd of=/etc/systemd/system/pump.service <<'EOF'
546 After=syslog.target network.target
552 ExecStart=/home/iank/pump.io/bin/pump
553 Environment=NODE_ENV=production
554 # failed to find databank-mongodb without this.
555 # I just looked at my environment variables took a guess.
556 Environment=NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
559 WantedBy=multi-user.target
563 ########## end pump.io setup ############
566 ############# begin setup mastodon ##############
568 # main doc is Docker-Guide.md in docs repo
570 # I'd like to try gnu social just cuz of gnu, but it's not being
571 # well maintained, for example, simple pull requests
573 # https://git.gnu.io/gnu/gnu-social/merge_requests/143
574 # and I submitted my own bugs, basic docs are broken
575 # https://git.gnu.io/gnu/gnu-social/issues/269
577 # note, docker required, but we installed it earlier
579 # i subscrubed to https://github.com/docker/compose/releases.atom
580 # to deal with updates manually. So far, it means just reving the
581 # version number, then restarting docker-compose with
583 # docker-compose up -d
584 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
585 s chmod +x /usr/local/bin/docker-compose
590 i clone https://github.com/tootsuite/mastodon
592 # subbed to atom feed to deal with updates
593 git checkout $(git tag | grep -v rc | tail -n1)
595 # per instructions, uncomment redis/postgres persistence in docker-compose.yml
596 sed -i 's/^#//' docker-compose.yml
598 cat >.env.production <<'EOF'
607 LOCAL_DOMAIN=mast.iankelling.org
610 SINGLE_USER_MODE=true
615 SMTP_FROM_ADDRESS=notifications@mast.iankelling.org
616 SMTP_DOMAIN=mast.iankelling.org
617 SMTP_DELIVERY_METHOD=smtp
620 for key in PAPERCLIP_SECRET SECRET_KEY_BASE OTP_SECRET; do
621 # 1 minute 7 seconds to run this docker command
622 # to generate a secret. wtf, wtf, wtf, wtf
623 printf "%s=%s\n" $key "$(docker-compose run --rm web rake secret|tail -n1)" >>.env.production
626 s cat /etc/mailpass| while read -r domain port pass; do
627 if [[ $domain == mail.iankelling.org ]]; then
629 printf "SMTP_PASSWORD=%s\n" "$pass" >>.env.production
634 echo "$0: error, failed to find mailpass domain for mastadon"
638 docker-compose run --rm web rake mastodon:webpush:generate_vapid_key | grep -E '^VAPID_PUBLIC_KEY=|^VAPID_PRIVATE_KEY=' >> .env.production
639 logq docker-compose run --rm web rake db:migrate
640 docker-compose run --rm web rails assets:precompile
642 # docker daemon takes care of starting on boot.
645 s a2enmod proxy_wstunnel headers
646 web-conf -f 3000 - apache2 mast.iankelling.org <<'EOF'
648 RequestHeader set X-Forwarded-Proto "https"
649 ProxyPass /500.html !
650 ProxyPass /oops.png !
651 ProxyPass /api/v1/streaming/ ws://localhost:4000/
652 ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
653 ErrorDocument 500 /500.html
654 ErrorDocument 501 /500.html
655 ErrorDocument 502 /500.html
656 ErrorDocument 503 /500.html
657 ErrorDocument 504 /500.html
661 ############### !!!!!!!!!!!!!!!!!
662 ############### manual steps:
664 # only following 2 people atm, so not bothering to figure out backups
665 # when mastodon has not documented it at all.
670 # johns@status.fsf.org
672 # sign in page is at https://mast.iankelling.org/auth/sign_in
673 # register as iank, then
674 # https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Administration-guide.md
675 # docker-compose run --rm web bundle exec rails mastodon:make_admin USERNAME=iank
677 ############# end setup mastodon ##############
679 # we use nsupdate to update the ip of home
682 echo "$0: $(date): ending now)"
688 # needed for checkrestart
695 ########### end section including li/lj ###############
698 debian) spa gnome-session-flashback ;;
699 # flidas is missing dependency gnome-panel. others unknown
705 trisquel|ubuntu|debian) spa ack-grep ;;
706 arch|fedora) spa ack ;;
716 wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
717 cat <<EOF | sudo tee /etc/apt/sources.list.d/iridium-browser.list
718 deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
719 #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
729 # not packaged in flidas. others unknown. gfdl nonfree issue
741 ### begin home vpn server setup
744 # # this section done initially to make persistent keys.
745 # # Also note, I temporarily set /etc/hosts so my host was
746 # # b8.nz when running this, since the vpn client config
747 # # generator assumes we need to go to that server to get
749 # vpn-server-setup -rds
750 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
751 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
752 # # kw = kgpe work machine.
753 # for host in x2 kw; do
754 # vpn-mk-client-cert -b $host -n home b8.nz 1196
755 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
757 # s bash -c "cp /etc/openvpn/client/home* $dir"
758 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
761 # key already exists, so this won't generate one, just the configs.
762 vpn-server-setup -rds
763 s tee -a /etc/openvpn/server/server.conf <<'EOF'
764 push "dhcp-option DNS 192.168.1.1"
765 push "route 192.168.1.0 255.255.255.0"
766 client-connect /a/bin/distro-setup/vpn-client-connect
768 s sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf
770 if [[ $HOSTNAME == tp ]]; then
771 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
772 vpn_service=openvpn-server@server
774 vpn_service=openvpn@server
778 ### end vpn server setup
780 if [[ $HOSTNAME == tp ]]; then
782 # note, see bashrc for more documentation.
784 s dd of=/etc/systemd/system/rss2email.service <<'EOF'
786 Description=rss2email
787 After=multi-user.target
792 # about 24 hours of failures
793 # it copies over its files without respecting symlinks, so
794 # we pass options to use different location.
795 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
797 s dd of=/etc/systemd/system/rss2email.timer <<'EOF'
799 Description=rss2email
802 # for initial run. required.
804 # for subsequent runs.
805 OnUnitInactiveSec=300
808 WantedBy=timers.target
810 s systemctl daemon-reload
814 ######### begin pump.io periodic backup #############
815 if [[ $HOSTNAME == tp ]]; then
816 s dd of=/etc/systemd/system/pumpbackup.service <<'EOF'
818 Description=pump li backup
819 After=multi-user.target
824 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
826 s dd of=/etc/systemd/system/pumpbackup.timer <<'EOF'
828 Description=pump li backup hourly
834 WantedBy=timers.target
836 s systemctl daemon-reload
839 ######### end pump.io periodic backup #############
842 debian|trisquel|ubuntu)
843 # suggests because we want the resolvconf package.
844 # todo: check other distros to make sure it\'s installed
845 pi-nostart --install-suggests openvpn
846 # pi-nostart does not disable
852 /a/bin/distro-setup/radicale-setup
854 ## android studio setup
855 # this contains the setting for android sdk to point to
856 # /a/opt/androidsdk, which is asked upon first run
857 lnf /a/opt/.AndroidStudio2.2 ~
858 # android site says it needs a bunch of packages for ubuntu,
859 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
861 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
862 # see w.org for more android studio details
863 spa lib32stdc++6 default-jdk
866 if [[ $HOSTNAME == frodo ]]; then
867 ############# begin syncthing setup ###########
869 # It\'s simpler to just worry about running it in one place for now.
870 # I assume it would work to clone it\'s config to another non-phone
871 # and just run it in one place instead of the normal having a
872 # separate config. I lean toward using the same config, since btrfs
873 # syncs between comps.
875 arch) pi syncthing ;;
876 trisquel|ubuntu|debian)
877 # testing has relatively up to date packages
878 if ! isdebian-testing; then
879 # based on error when doing apt-get update:
880 # E: The method driver /usr/lib/apt/methods/https could not be found.
881 pi apt-transport-https
882 # google led me here:
883 # https://apt.syncthing.net/
884 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
885 s="deb http://apt.syncthing.net/ syncthing release"
886 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != $s ]]; then
887 echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
894 lnf -T /w/syncthing /home/iank/.config/syncthing
895 ser daemon-reload # syncthing likely not properly packaged
896 sgo syncthing@iank # runs as iank
898 # these things persist in ~/.config/syncthing, which I save in
899 # /w/syncthing (not in /p, because syncthing should continue to
900 # run on home server even when using laptop as primary device)
901 # open http://localhost:8384/
902 # change listen address from default to tcp://:22001,
903 # this is because we do port forward so it doesn\'t have to use
904 # some external server, but the syncthing is broken for port forward,
905 # you get a message, something "like connected to myself, this should not happen"
906 # when connecting to other local devices, so I bump the port up by 1,
908 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
909 # Without this, it was being stuck syncing at 0%.
910 # Set gui username and password.
912 # install syncthing via f-droid,
913 # folder setting, turn off send only.
914 # on phone, add device, click bar code icon
915 # on dekstop, top right, actions, device id
916 # after adding, notification will appear on desktop to confirm
918 # syncing folder. from phone to desktop: select desktop in the
919 # folder on phone\'s sync options, notification will appear in
920 # desktop\'s web ui within a minute. For the reverse, the
921 # notification will appear in android\'s notifications, you have to
922 # swipe down and tap it to add the folder. It won\'t appear in the
923 # syncthing ui, which would be intuitive, but don\'t wait for it
924 # there. The notification may not work, instead open the web gui
925 # from in the app, there should be a notification within there.
927 # On phone, set settings to run syncthing all the time, and
928 # show no notification.
930 # Folder versioning would make sense if I didn\'t already use btrfs
931 # for backups. I would choose staggered, or trash can for more space.
933 # if needed to install on a remote comp:
934 # ssh -L 8384:localhost:8384 -N frodo
935 # open http://localhost:8384/
937 # Note, the other thing i did was port forward port 22000,
938 # per https://docs.syncthing.net/users/firewall.html
940 ############# end syncthing setup ###########
945 # no equivalent in other distros:
947 debian|trisquel|ubuntu)
948 # for gui bug reporting
954 ####### begin misc packages ###########
957 sudo -u traci -i reset-sakura
959 sudo -u traci -i reset-konsole
961 if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then
962 cp /p/.linphonerc-initial ~/.linphonerc
966 ### begin spd install
967 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
969 wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
972 # this guesses at the appropriate directory, adjust if needed
973 x=(/usr/lib/x86_64-linux-gnu/perl/5.*)
974 sudo ln -sf ../../../perl/5.18.2/SPD/ $x
975 # newer distro had gpg2 as default, older one, flidas, need to make it that way
978 s lnf -T $x /usr/local/bin/gpg
983 if [[ $HOSTNAME == kw ]]; then
985 NOTE: after this finishes, i did
987 # remove br from auto:
988 s vim /etc/network/interfaces
992 # nagstamon setting which were set through the ui
994 # all unknown sources
995 # all warning services
996 # acknowledged hosts & services
997 # hosts & services down for maintenence
998 # services on down hosts
999 # services on hosts in maintenece
1000 # services on unreachable osts
1001 # hosts in soft state
1002 # services in soft state
1003 # in display tab: fullscreen
1005 # these translate to these settings I think
1006 # filter_acknowledged_hosts_services = True
1007 # filter_all_unknown_services = True
1008 # filter_all_warning_services = True
1009 # filter_hosts_in_soft_state = True
1010 # filter_hosts_services_maintenance = True
1011 # filter_services_in_soft_state = True
1012 # filter_services_on_down_hosts = True
1013 # filter_services_on_hosts_in_maintenance = True
1014 # filter_services_on_unreachable_hosts = True
1015 # notify_if_up = False
1016 # statusbar_floating = False
1018 # but i'm just going to rely on the webpage plus sms for now.
1022 debian|trisquel|ubuntu)
1023 # it asks if it should make users in it's group capture packets without root,
1024 # which is arguably more secure than running wireshark as root. default is no,
1025 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
1026 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
1031 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
1032 # listed in the default config as suggested.
1033 # /run/usr/1000 i noticed was missing for pulseaudio
1034 # /run/user/0 just seemed like a not bad idea, given the above
1035 tu /etc/schroot/desktop/fstab <<'EOF'
1036 /run /run none rw,bind 0 0
1037 /run/lock /run/lock none rw,bind 0 0
1038 /dev/shm /dev/shm none rw,bind 0 0
1039 /run/shm /run/shm none rw,bind 0 0
1040 /run/user/1000 /run/user/1000 none rw,bind 0 0
1041 /run/user/1001 /run/user/1001 none rw,bind 0 0
1042 /run/user/0 /run/user/0 none rw,bind 0 0
1050 s dd of=/etc/schroot/chroot.d/$n.conf <<EOF
1056 preserve-environment=true
1059 if [[ -e $d/bin ]]; then
1060 s chroot $d apt-get update
1061 s chroot $d apt-get -y dist-upgrade --purge --auto-remove
1062 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1065 s debootstrap $n $d http://deb.debian.org/debian/
1066 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1068 s cp -P {,$d}/etc/localtime
1070 s dd of=/etc/systemd/system/schrootupdate.service <<'EOF'
1072 Description=schrootupdate
1073 After=multi-user.target
1077 ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate
1079 s dd of=/etc/systemd/system/schrootupdate.timer <<'EOF'
1081 Description=schrootupdate
1084 OnCalendar=*-*-* 04:20:00
1087 WantedBy=timers.target
1089 s systemctl daemon-reload
1090 sgo schrootupdate.timer
1098 mkschroot stretch firefox-esr pulseaudio chromium
1102 s mkdir -p /nocow/user
1103 s chown $USER:$USER /nocow/user
1106 case $(debian-codename) in
1111 mkschroot jessie anki pulsaudio mplayer
1122 debian|trisquel|ubuntu)
1123 # note i had to do this, which is persistent:
1125 # s chgrp debian-transmission torrents partial-torrents
1127 # syslog says things like
1128 # 'Failed to set receive buffer: requested 4194304, got 425984'
1129 # google suggets giving it even more than that
1130 tu /etc/sysctl.conf<<'EOF'
1131 net.core.rmem_max = 67108864
1132 net.core.wmem_max = 16777216
1136 # some reason it doesn\'t seem to start automatically anyways
1137 pi-nostart transmission-daemon
1139 # the folder was moved here after an install around 02/2017.
1140 # it contains runtime data,
1141 # plus a simple symlink to the config file which it\'s
1142 # not worth separating out.
1143 # between comps, the uid can change
1144 f=/i/transmission-daemon
1145 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1146 if [[ -e $f ]]; then
1147 s chown -R debian-transmission:debian-transmission $f
1149 for f in /i/k/partial-torrents /i/k/torrents; do
1150 if [[ -e $f ]]; then
1151 s chown -R debian-transmission:traci $f
1154 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1156 # config file documented here, and it\'s the same config
1157 # for daemon vs client, so it\'s documented in the gui.
1158 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1160 # I originaly setup rpc-whitelist, but after using
1161 # routing to a network namespace, it doesn\'t see the
1162 # real source address, so it\'s disabled.
1164 # Changed the cache-size to 256 mb, reduces disk use.
1165 # It is a read & write cache.
1169 p = '/etc/transmission-daemon/settings.json'
1170 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1171 'rpc-whitelist-enabled' => false,
1172 'rpc-authentication-required' => false,
1173 'incomplete-dir' => '/i/k/partial-torrents',
1174 'incomplete-dir-enabled' => true,
1175 'download-dir' => '/i/k/torrents',
1176 "speed-limit-up" => 800,
1177 "speed-limit-up-enabled" => true,
1178 "peer-port" => 61486,
1179 "cache-size-mb" => 256,
1180 "ratio-limit" => 5.0,
1181 "ratio-limit-enabled" => true,
1185 # make sure its not enabled, not sure if this is needed
1186 ser disable transmission-daemon
1188 # todo: others unknown
1190 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1191 if ! getent passwd debian-transmission > /dev/null; then
1197 --home-dir /var/lib/transmission-daemon \
1198 --shell /bin/false \
1206 --disabled-password \
1207 --home /var/lib/transmission-daemon \
1214 # trisquel 8 = openvpn, debian stretch = openvpn-client
1215 vpn_ser=openvpn-client
1216 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1220 s dd of=/etc/systemd/system/transmission-daemon-nn.service <<EOF
1222 Description=Transmission BitTorrent Daemon netns
1223 After=network.target
1224 Requires=${vpn_ser}-nn@client.service
1225 After=${vpn_ser}-nn@client.service
1226 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1229 #User=debian-transmission
1230 # notify type doesn't work with sudo
1232 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1233 ExecReload=/bin/kill -s HUP \$MAINPID
1238 WantedBy=multi-user.target
1242 if [[ $HOSTNAME == frodo ]]; then
1243 sgo transmission-daemon-nn
1247 ######### begin transmission client setup ######
1249 if [[ -e /p/transmission-rpc-pass ]]; then
1250 # arch had a default config,
1251 # debian had nothing until you start it.
1252 # With a little trial an error, here is a minimal config
1253 # taken from the generated one, plus changes that the
1254 # settings ui does, without a bunch of ui crap settings.
1256 # only settings I set were
1261 # the password is randomly generated on first run, i copied it out
1262 # so it could be used by other hosts.
1265 p = '/etc/transmission-daemon/settings.json'
1266 s = JSON.parse(File.read(p))
1267 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1268 File.write p, JSON.pretty_generate(s)
1271 rpc_pass=$(</p/transmission-rpc-pass)
1272 for f in /home/*; do
1273 d=$f/.config/transmission-remote-gtk
1276 s -u $u dd of=$d/config.json <<EOF
1280 "profile-name" : "Default",
1281 "hostname" : "transmission.b8.nz",
1282 "rpc-url-path" : "/transmission/rpc",
1284 "password" : "$rpc_pass",
1285 "auto-connect" : true,
1289 "update-active-only" : false,
1290 "activeonly-fullsync-enabled" : false,
1291 "activeonly-fullsync-every" : 2,
1292 "update-interval" : 3,
1293 "min-update-interval" : 3,
1294 "session-update-interval" : 60,
1302 "add-options-dialog" : false
1308 # dunno why it\'s there, but get rid of it
1310 li|lj) s rm -rf /home/linode ;;
1317 pi cups ghostscript gsfonts # from arch wiki cups page
1318 pi hplip # from google
1319 s gpasswd -a $USER sys # from arch wiki
1320 sgo org.cups.cupsd.service
1321 # goto http://127.0.0.1:631
1322 # administration tab, add new printer button.
1323 # In debian, I could use hte recommended driver,
1324 # in arch, I had to pick out the 6L driver.
1326 debian|trisquel|ubuntu)
1329 # other distros unknown
1334 trisquel|ubuntu|debian) pi --no-install-recommends mairix notmuch ;;
1335 fedora|arch) spa mairix notmuch ;;
1338 arch) spa nfs-utils ;;
1339 trisquel|ubuntu|debian) spa nfs-client ;;
1342 trisquel|ubuntu|debian) spa par2 ;;
1343 arch|fedora) spa par2cmdline ;;
1346 # needed for my tex resume
1348 trisquel|ubuntu|debian) spa texlive-full ;;
1349 arch) spa texlive-most ;;
1355 # optional dep for firefox for h.264 video
1356 arch) spa gst-libav ;;
1357 # other distros, probably come by default
1361 fedora|trisquel|ubuntu|debian) spa gnupg-agent ;;
1367 fedora) spa pinentry-gtk ;;
1368 *) : ;; # comes default or with other packages
1372 arch) spa firefox pulseaudio;;
1373 trisquel) spa abrowser ;;
1374 *) : ;; # comes default or with other packages, or uknown
1379 arch) spa ttf-dejavu;;
1380 debian|trisquel|ubuntu) spa fonts-dejavu ;;
1386 arch) spa xorg-xev;;
1387 debian|trisquel|ubuntu) spa x11-utils ;;
1392 arch) pi virt-install;;&
1393 debian|trisquel|ubuntu) pi virtinst ;;&
1394 *) pi virt-manager ;; # creates the libvirt group in debian at least
1397 # allow user to run vms, from debian handbook
1398 for x in iank traci; do s usermod -a -G libvirt,kvm $x; done
1399 # bridge networking as user fails. google lead here, but it doesn\'t work:
1400 # oh well, I give up.
1401 # http://wiki.qemu.org/Features-Done/HelperNetworking
1403 # f=/etc/qemu/bridge.conf
1404 # s dd of=$f <<'EOF'
1407 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1413 debian|trisquel|ubuntu) spa genisoimage;;
1418 arch) spa spice-gtk3 ;;
1419 debian|trisquel|ubuntu) spa spice-client-gtk;;
1423 # general known for debian/ubuntu, not for fedora
1426 debian|trisquel|ubuntu)
1428 # a bit of googling, and added settings to bashrc
1429 go get -u github.com/mvdan/fdroidcl/cmd/fdroidcl
1437 # cdrkit for cloud-init isos
1438 # dnsmasq & ebtables for nat networking in libvirt
1439 # qemu for qemu-img, bind-tools for dig
1440 # dmidecode just because syslog complains
1441 pi unzip xorg-xmodmap dmidecode ebtables\
1442 bridge-utils dnsmasq qemu bind-tools
1443 # otherwise we get error about accessing kvm module.
1444 # seems like there might be a better way, but google was a bit vague.
1445 s $sed -ri '/^ *user *=/d' /etc/libvirt/qemu.conf
1446 echo 'user = "root"' | s tee -a /etc/libvirt/qemu.conf
1447 # https://bbs.archlinux.org/viewtopic.php?id=206206
1448 # # this should prolly go in the wiki
1450 # guessing this is not needed
1451 #sgo virtlogd.service
1458 arch) pi virtviewer ;;
1459 *) : ;; # other distros have it as a dependency afaik.
1465 fedora) cabal install shellcheck ;;
1466 *) spa shellcheck ;;
1467 # unknown for older ubuntu
1472 arch|debian|trisquel|ubuntu) spa pumpa ;;
1473 # others unknown. do have a buildscript:
1474 # /a/bin/buildscripts/pumpa ;;
1480 debian|trisquel|ubuntu) spa android-tools-adbd ;;
1481 # todo: not sure this is needed anymore, or if trisqel etc works even
1482 # debian) spa android-tools-adbd/unstable ;;
1483 arch) spa android-tools ;;
1484 # other distros unknown
1492 wget ftp://ftp.gnu.org/pub/gnu/global/global-6.5.7.tar.gz
1495 # based on https://github.com/leoliu/ggtags
1496 ./configure --with-exuberant-ctags=/usr/bin/ctags
1499 s pip install pygments
1507 debian|trisquel|ubuntu)
1515 pi task-mate-desktop
1516 # in settings, change scrolling to two-finger,
1517 # because the default edge scroll doesn\'t work.
1521 # mate-indicator-applet and beyond are msc things I noticed diffing a
1522 # standard install with mine.
1523 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
1537 # note this failed running at the beginning of this file,
1538 # because no systemd user instance was running.
1539 # Doing systemd --user resulted in
1540 # Trying to run as user instance, but $XDG_RUNTIME_DIR is not set
1542 if isdebian-testing; then
1543 # as of 7/2016, has no unstable deps, and is not in testing anymore.
1550 # # ubuntu unknown. probably the same as debian, just check if the
1551 # # init scripts come with the package.
1553 # # copied from arch, but moved to etc
1554 # s dd of=/etc/systemd/user/synergys.service <<'EOF'
1556 # Description=Synergy Server Daemon
1557 # After=network.target
1561 # ExecStart=/usr/bin/synergys --no-daemon --config /etc/synergy.conf
1562 # Restart=on-failure
1565 # WantedBy=multi-user.target
1567 # s dd of=/etc/systemd/user/synergys.socket <<'EOF'
1569 # Conflicts=synergys@.service
1572 # ListenStream=24800
1576 # WantedBy=sockets.target
1578 # # had this fail with 'Failed to connect to bus: No such file or directory'
1579 # # then when I tried it manually, it worked fine...
1580 # if ! systemctl --user daemon-reload; then
1582 # echo retrying systemd user daemon reload
1583 # systemctl --user daemon-reload
1587 # # taken from arch wiki.
1588 # s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
1590 # Description=Synergy Client
1591 # After=network.target
1595 # ExecStart=/usr/bin/synergyc --no-daemon frodo
1596 # Restart=on-failure
1597 # # per man systemd.unit, StartLimitInterval, by default we
1598 # # restart more than 5 times in 10 seconds.
1599 # # And this param defaults too 200 miliseconds.
1603 # WantedBy=multi-user.target
1605 # s systemctl daemon-reload
1608 # ser enable synergyc@iank
1609 # ser start synergyc@iank ||: # X might not be running yet
1612 # systemctl --user start synergys ||:
1613 # systemctl --user enable synergys
1620 pi --no-install-recommends kdeconnect-plasma
1621 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1622 ### but gnome + xmonad not working in flidas, so i disabled it
1623 pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1624 cd /a/opt/indicator-kdeconnect
1627 cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1630 # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1631 # it seems, according to
1632 # /etc/xdg/autostart/kdeconnectd.desktop
1633 # I'm not seeing the icon, but the clipboard replication is working
1636 ### model 01 arduino support ###
1637 # https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
1638 # also built latest arduino in /a/opt/Arduino, (just cd build; ant build; ant run )
1639 # set arduino var in bashrc,
1640 # have system config file setup too.
1641 sudo adduser $USER dialout
1644 sudo usermod -a -G uucp $USER
1647 lnf -T /a/opt/sketches ~/Arduino
1649 ######### end misc packages #########
1652 # packages I once used before and liked, but don\'t want installed now for
1654 # python-sqlite is used for offlineimap
1655 # lxappearance python-sqlite dolphin paman dconf-editor
1661 # todo, finish configuring smart.
1664 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1665 # turn on smart. background on options:
1666 # first line, -a = test everyting on all devices.
1667 # -S on, turn on disk internal saving of vendor specific info,
1668 # from google, seems like this is usually already on and fairly standard.
1669 # -o on, turn on 4 hour period non-performance degrading testing.
1670 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1671 sched="-s (S/../.././02|L/../../6/03)"
1672 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1673 DEVICESCAN -a -o on -S on -n standby,q $sched \
1674 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1676 # in the default configuration of at least ubuntu 14.04, resolvconf is
1677 # configured to order any nameservers associated with tun* or tap*
1678 # before the normal internet interfaces, which means they are always
1679 # consulted first. This is often slower and undesirable, ie. local dns
1680 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1682 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1683 # however, this breaks dns lookup for hosts on the openvpn lan.
1684 # I can\'t figure out why hosts on the normal lan would not be
1685 # broken under the default ordering, except the host I was
1686 # testing with previously had an entry in /etc/hosts.
1688 ############# end unfinished
1690 ########### misc stuff
1693 /a/bin/distro-setup/mymimes
1696 # stop autopoping windows when i plug in an android phone.
1697 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1698 # with still 0 exit code.
1699 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1700 dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1703 # on grub upgrade, we get prompts unless we do this
1705 for dev in $(s btrfs fi show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1706 devs+=($(devbyid $dev),)
1708 devs[-1]=${devs[-1]%,} # jonied by commas
1709 s debconf-set-selections <<EOF
1710 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1714 sgo btrfsmaint.timer
1715 sgo btrfsmaintstop.timer
1718 # the wiki backup script from ofswiki.org uses generic paths
1719 s lnf /p/c/machine_specific/li/mw_vars /root
1720 s lnf /k/backup/wiki_backup /root
1722 s cedit /etc/goaccess.conf <<'EOF' || [[ $? == 1 ]]
1723 # all things found from looking around the default config
1724 # copied existing NCSA Combined Log Format with Virtual Host, plus %L
1725 log-format %^:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %D
1726 time-format %H:%M:%S
1727 date-format %d/%b/%Y
1728 log-file /var/log/apache2/access.log
1731 # tip: copy access.log files to a stretch host directory, then run
1732 # jessie's goaccess is too old for some options, and it\'s
1733 # not easily installed from a testing.
1734 # goaccess --ignore-crawlers -f <(cat *) -a -o html > x.html
1739 trisquel|ubuntu|debian)
1740 # unison-gtk second, i want it to be default, not sure if that works
1741 # with spa. note, I used to install from testing repo when using stable,
1742 # but it shouldn't be needed since I wrote a script to handle mismatching
1744 spa unison unison-gtk
1753 # default is alsa, doesn\'t work with with pianobar
1754 s dd of=/etc/libao.conf <<'EOF'
1755 default_driver=pulse
1760 # note, for jessie, it depends on a higher version of btrfs-tools.
1762 # # disabled due to my patch being in btrbk
1764 # arch|debian|trisquel|ubuntu) pi btrbk ;;
1769 spa pv # for progress bar when running interactively.
1771 # ian: temporarily disabled while hosts are in flux.
1772 # if [[ $HOSTNAME == tp ]]; then
1773 # # backup/sync manually on others hosts for now.
1775 # # note: to see when it was last run,
1783 debian|trisquel|ubuntu) s gpasswd -a iank adm ;; #needed for reading logs
1789 # https://www.torproject.org/docs/rpms.html.en
1790 # https://www.torproject.org/docs/debian.html.en
1791 # todo: figure out if the running service needs to be restarted upon updates
1794 # todo on fedora: setup non-dev packages
1796 s dd of=/etc/yum.repos.d/torproject.repo <<'EOF'
1798 name=Tor experimental repo
1800 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1802 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1805 name=Tor experimental source repo
1808 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1810 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1813 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1814 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1816 /a/bin/buildscripts/tor-browser
1819 tu /etc/apt/sources.list "deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1820 gpg --keyserver keys.gnupg.net --recv 886DDD89
1821 gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
1823 pi deb.torproject.org-keyring
1825 /a/bin/buildscripts/tor-browser
1829 /a/bin/buildscripts/tor-browser
1832 pi tor tor-browser-en
1842 fedora todo: disable the firewall or find a way to automate it.
1843 there's an unused section in t.org for tramikssion firewall setup
1845 fedora manual config for nfs:
1847 change to permanent configuration
1848 check the box for nfs
1849 was hard to figure this out, not sure if this is all needed, but
1851 mountd: udp/tcp 20048
1852 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1853 troubleshooting, unblock things in rpcinfo -p
1854 make sure to reload the firewall to load the persistent configuration
1861 debian|trisquel|ubuntu)
1865 pi nfs-utils || pending_reboot=true
1867 # this failed until I rebooted
1875 if [[ $HOSTNAME == frodo ]]; then
1876 # nohide = export filesystems mounted deeper than the export point
1877 # fsid=0 makes this export the "root" export
1878 # not documented in the man page, but this means
1879 # 1. it can be mounted with a shorthand of server:/
1880 # 2. exports that are subdirectories of this one will automatically be mounted
1881 tu /etc/exports <<'EOF'
1882 /k 192.168.1.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1891 # persistent virtual machines
1893 debian|trisquel|ubuntu)
1897 # if I was going to create a persistent vm, i might do it like this:
1898 # variant=something # from: virt-install --os-variant list
1899 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1900 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1901 # -n some_name --import --os-variant $variant --cpu host-model-only
1905 ######### begin stuff belonging at the end ##########
1908 # Apps we want to override others for default file handler:
1909 # simplest way in debian is to just install them last.
1922 pi "${simple_packages[@]}"
1925 if $pending_reboot; then
1926 echo "$0: pending reboot and then finished. doing it now."
1929 echo "$0: $(date): ending now)"