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
153 $
(aptitude show ruby |
sed -rn 's/Depends: (.*)/\1/p')-doc
161 transmission-remote-gtk
170 spa $
(apt-cache search ruby
[.0-9]+-doc|
awk '{print $1}')
175 ########### begin section including li ################
181 # ubuntu 14.04 uses b-cron,
182 # but its not maintained in arch.
183 # of the ones in the main repos, cronie is only one maintained.
184 # fcron appears abandoned software.
188 *) : ;; # other distros come with cron.
200 debian|trisquel|ubuntu
) pi curl
;;
212 arch
) spa the_silver_searcher
;;
213 debian|trisquel|ubuntu
) spa silversearcher-ag
;;
218 debian|trisquel|ubuntu
) spa ntp
;;
227 # no equivalent in other distros:
229 debian|trisquel|ubuntu
)
231 if ! dpkg
-s apt-file
&>/dev
/null
; then
232 # this condition is just a speed optimization
236 # for debconf-get-selections
243 arch|debian|trisquel|ubuntu
)
256 # allows me to pipe with ssh -t, and gets rid of spam
257 # http://forums.debian.net/viewtopic.php?f=5&t=85822
258 # i'd rather disable the service than comment the init file
259 # this says disabling the service, it will still get restarted
260 # but this script doesn't do anything on restart, so it should be fine
261 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
262 # stretch doesn't have initscripts pkg installed by default
263 if [[ $
(debian-codename
) == jessie
]]; then
264 s update-rc.d motd disable
268 # this isn't a complete solution. It still shows me when updates are available,
269 # but it's no big deal.
270 s t
/etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
276 # https://debian-handbook.info/browse/stable/sect.regular-upgrades.html
277 # /etc/cron.daily/apt calls unattended-upgrades
278 # /usr/share/doc/unattended-upgrades# cat README.md
279 # /etc/apt/apt.conf.d/50unattended-upgrades
281 setup-debian-auto-update
284 # we've got a few dependencies later on, so install them now.
285 pi eatmydata
; PI_PREFIX
=eatmydata
286 pi
"${simple_packages[@]}"
290 ### begin docker install ####
293 # https://store.docker.com/editions/community/docker-ce-server-debian?tab=description
294 pi software-properties-common apt-transport-https
295 curl
-fsSL https
://download.docker.com
/linux
/$
(distro-name-compat
)/gpg | sudo apt-key add
-
296 sudo add-apt-repository \
297 "deb [arch=amd64] https://download.docker.com/linux/$(distro-name-compat) \
298 $(debian-codename-compat) \
303 # other distros unknown
305 ### end docker install ####
310 # note, need python-certbot-nginx for nginx, but it depends on nginx,
311 # and I'm not installing nginx by default right now.
312 # note python-certbot-apache is in suggests, but so is a doc package that brought in xorg
313 if [[ $
(debian-codename
) == jessie
]]; then
314 pi
-t jessie-backports certbot python-certbot-apache
316 pi certbot python-certbot-apache
318 # make a version of the certbot timer that emails me.
319 x
=/systemd
/system
/certbot
320 $sed -r -f - /lib
$x.timer
<<'EOF' |s dd of=/etc${x}mail.timer
321 s,^Description.*,\0 mail version,
323 $sed -r -f - /lib
$x.service
<<'EOF' |s dd of=/etc${x}mail.service
324 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2 --renew-hook /a/bin/distro-setup/certbot-renew-hook,
327 sgo certbotmail.timer
331 # not packaged in xenial or flidas
332 pi software-properties-common
333 s add-apt-repository
-y ppa
:certbot
/certbot
335 pi python-certbot-apache
337 # todo: other distros unknown
343 /a
/bin
/webcam
/install-server
346 /a
/bin
/webcam
/install-client
355 lj
) domain
=iank.bid
; exit 0 ;;
356 li
) domain
=iankelling.org
;;
358 /a
/h
/setup.sh
$domain
361 sudo
-E /a
/bin
/mediawiki-setup
/mw-setup-script
363 pi-nostart mumble-server
364 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
366 # do certificate to avoid warning about unsigned cert,
367 # which is overkill for my use, but hey, I'm cool, I know
369 web-conf apache2 mumble.iankelling.org
370 s
rm -f /etc
/apache
2/sites-enabled
/mumble.iankelling.org
372 export RENEWED_LINEAGE=/etc/letsencrypt/live/mumble.iankelling.org
373 /a/bin/distro-setup/certbot-renew-hook
379 s
tee /etc
/openvpn
/client-config
/mail <<'EOF'
380 ifconfig-push 10.8.0.4 255.255.255.0
383 # it\'s strange. docker seems to make the default for forward
384 # be drop, but then I set it to accept and it\'s stuck that way,
385 # I dun know why. But, let\'s make sure we can forward anyways.
386 s DEBIAN_FRONTEND
=noninteractive pi iptables-persistent
387 rm /etc
/iptables
/rules.v6
388 s
tee /etc
/iptables
/rules.v4
<<'EOF'
390 -A FORWARD -i tun+ -o eth0 -j ACCEPT
391 -A FORWARD -i eth0 -o tun+ -j ACCEPT
397 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
399 Description=Turns on iptables mail nat
404 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
405 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
408 WantedBy=openvpn.service
411 ser
enable vpnmail.service
412 # needed for li's local mail delivery.
413 tu
/etc
/hosts
<<<"10.8.0.4 mail.iankelling.org"
414 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
415 vpn_service=openvpn-server@server
417 vpn_service=openvpn@server
420 # setup let's encrypt cert
421 web-conf apache2 mail.iankelling.org
422 s rm /etc/apache2/sites-enabled/mail.iankelling.org{,-redir}.conf
425 domain=cal.iankelling.org
426 web-conf -f 10.8.0.4:5232 - apache2 $domain <<'EOF'
427 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
428 # https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication
430 Options +FollowSymLinks +Multiviews +Indexes
433 AuthName "Authentication Required"
434 # setup one time, with root:www-data, 640
435 AuthUserFile "/etc/caldav-htpasswd"
439 # nginx version of above would be:
440 # auth_basic "Not currently available";
441 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
444 ########## begin pump.io setup ##########
446 # once pump adds a logrotation script, turn off nologger,
448 # "logfile": "/var/log/pumpio/pumpio.log",
450 s dd of=/etc/pump.io.json <<'EOF'
452 "secret": "SECRET_REPLACE_ME",
454 "params": { "dbname": "pumpio" },
456 "site": "pump.iankelling.org",
457 "owner": "Ian Kelling",
458 "ownerURL": "https://iankelling.org/",
461 "hostname": "pump.iankelling.org",
463 "datadir": "/home/pumpio/pumpdata",
464 "enableUploads": true,
465 "debugClient": false,
466 "disableRegistration": true,
468 "key": "/home/pumpio/privkey.pem",
469 "cert": "/home/pumpio/fullchain.pem",
470 "address": "localhost",
474 s sed -i "s#SECRET_REPLACE_ME#$(cat /p/c/machine_specific/li/pump-secret)#" /etc/pump.io.json
476 # stretch node is too old
477 # https://nodejs.org/en/download/package-manager/
478 curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
481 if [[ -e pump.io ]]; then
485 git clone https://github.com/pump-io/pump.io.git
488 # note: doing this or the npm install pump.io as root had problems.
491 # normally, next command would be
492 # s npm install -g databank-mongodb
493 # but it\'s this until a bug in pump gets fixed
494 # https://github.com/pump-io/pump.io/issues/1287
495 s npm install -g databank-mongodb@0.19.2
496 if ! getent passwd pumpio &>/dev/null; then
497 s useradd -m -s /bin/false pumpio
499 sudo -u pumpio mkdir -p /home/pumpio/pumpdata
500 # for testing browser when only listening to localhost,
501 # in the pump.io.json, set hostname localhost, urlPort 5233
502 #ssh -L 5233:localhost:5233 li
504 s mkdir -p /var/log/pumpio/
505 s chown pumpio:pumpio /var/log/pumpio/
507 web-conf - apache2 pump.iankelling.org <<'EOF'
508 # currently a bug in pump that we cant terminate ssl
511 ProxyPass / https://127.0.0.1:8001/
512 ProxyPassReverse / https://127.0.0.1:8001/
513 # i have sockjs disabled per people suggesting that
514 # it won\'t work with apache right now.
515 # not sure if it would work with this,
516 # but afaik, this is pointless atm.
517 <Location /main/realtime/sockjs/>
518 ProxyPass wss://127.0.0.1:8001/main/realtime/sockjs/
519 ProxyPassReverse wss://127.0.0.1:8001/main/realtime/sockjs/
524 export RENEWED_LINEAGE=/etc/letsencrypt/live/pump.iankelling.org
525 /a/bin/distro-setup/certbot-renew-hook
528 s dd of=/etc/systemd/system/pump.service <<'EOF'
531 After=syslog.target network.target
537 ExecStart=/home/iank/pump.io/bin/pump
538 Environment=NODE_ENV=production
539 # failed to find databank-mongodb without this.
540 # I just looked at my environment variables took a guess.
541 Environment=NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
544 WantedBy=multi-user.target
548 ########## end pump.io setup ############
551 ############# begin setup mastodon ##############
553 # main doc is Docker-Guide.md in docs repo
555 # I'd like to try gnu social just cuz of gnu, but it's not being
556 # well maintained, for example, simple pull requests
558 # https://git.gnu.io/gnu/gnu-social/merge_requests/143
559 # and I submitted my own bugs, basic docs are broken
560 # https://git.gnu.io/gnu/gnu-social/issues/269
562 # note, docker required, but we installed it earlier
564 # i subscrubed to https://github.com/docker/compose/releases.atom
565 # to deal with updates manually. So far, it means just reving the
566 # version number, then restarting docker-compose with
568 # docker-compose up -d
569 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
570 s chmod +x /usr/local/bin/docker-compose
575 i clone https://github.com/tootsuite/mastodon
577 # subbed to atom feed to deal with updates
578 git checkout $(git tag | grep -v rc | tail -n1)
580 # per instructions, uncomment redis/postgres persistence in docker-compose.yml
581 sed -i 's/^#//' docker-compose.yml
583 cat >.env.production <<'EOF'
592 LOCAL_DOMAIN=mast.iankelling.org
595 SINGLE_USER_MODE=true
600 SMTP_FROM_ADDRESS=notifications@mast.iankelling.org
601 SMTP_DOMAIN=mast.iankelling.org
602 SMTP_DELIVERY_METHOD=smtp
605 for key in PAPERCLIP_SECRET SECRET_KEY_BASE OTP_SECRET; do
606 # 1 minute 7 seconds to run this docker command
607 # to generate a secret. wtf, wtf, wtf, wtf
608 printf "%s=%s\n" $key "$(docker-compose run --rm web rake secret|tail -n1)" >>.env.production
611 s cat /etc/mailpass| while read -r domain port pass; do
612 if [[ $domain == mail.iankelling.org ]]; then
614 printf "SMTP_PASSWORD=%s\n" "$pass" >>.env.production
619 echo "$0: error, failed to find mailpass domain for mastadon"
623 docker-compose run --rm web rake mastodon:webpush:generate_vapid_key | grep -E '^VAPID_PUBLIC_KEY=|^VAPID_PRIVATE_KEY=' >> .env.production
624 logq docker-compose run --rm web rake db:migrate
625 docker-compose run --rm web rails assets:precompile
627 # docker daemon takes care of starting on boot.
630 s a2enmod proxy_wstunnel headers
631 web-conf -f 3000 - apache2 mast.iankelling.org <<'EOF'
633 RequestHeader set X-Forwarded-Proto "https"
634 ProxyPass /500.html !
635 ProxyPass /oops.png !
636 ProxyPass /api/v1/streaming/ ws://localhost:4000/
637 ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
638 ErrorDocument 500 /500.html
639 ErrorDocument 501 /500.html
640 ErrorDocument 502 /500.html
641 ErrorDocument 503 /500.html
642 ErrorDocument 504 /500.html
646 ############### !!!!!!!!!!!!!!!!!
647 ############### manual steps:
649 # only following 2 people atm, so not bothering to figure out backups
650 # when mastodon has not documented it at all.
655 # johns@status.fsf.org
657 # sign in page is at https://mast.iankelling.org/auth/sign_in
658 # register as iank, then
659 # https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Administration-guide.md
660 # docker-compose run --rm web bundle exec rails mastodon:make_admin USERNAME=iank
662 ############# end setup mastodon ##############
664 # we use nsupdate to update the ip of home
667 echo "$0: $(date): ending now)"
673 ########### end section including li/lj ###############
676 debian) spa gnome-session-flashback ;;
677 # flidas is missing dependency gnome-panel. others unknown
683 trisquel|ubuntu|debian) spa ack-grep ;;
684 arch|fedora) spa ack ;;
698 wget -qO - https://downloads.iridiumbrowser.de/ubuntu/iridium-release-sign-01.pub|sudo apt-key add -
699 cat <<EOF | sudo tee /etc/apt/sources.list.d/iridium-browser.list
700 deb [arch=amd64] https://downloads.iridiumbrowser.de/deb/ stable main
701 #deb-src https://downloads.iridiumbrowser.de/deb/ stable main
711 # not packaged in flidas. others unknown. gfdl nonfree issue
725 ### begin home vpn server setup
728 # # this section done initially to make persistent keys.
729 # # Also note, I temporarily set /etc/hosts so my host was
730 # # b8.nz when running this, since the vpn client config
731 # # generator assumes we need to go to that server to get
733 # vpn-server-setup -rds
734 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
735 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
736 # for host in x2 kw; do
737 # vpn-mk-client-cert -b $host -n home b8.nz
738 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
740 # s bash -c "cp /etc/openvpn/client/home* $dir"
741 # # note: /etc/update-resolv-conf-home also exists for all systems with /p
745 vpn-server-setup -rds
746 s tee -a /etc/openvpn/server/server.conf <<'EOF'
747 push "dhcp-option DNS 192.168.1.1"
748 push "route 192.168.1.0 255.255.255.0"
749 client-connect /a/bin/distro-setup/vpn-client-connect
751 s sed -i --follow-symlinks 's/10.8./10.9./g' /etc/openvpn/server/server.conf
753 if [[ $HOSTNAME == tp ]]; then
754 if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then
755 vpn_service=openvpn-server@server
757 vpn_service=openvpn@server
761 ### end vpn server setup
763 if [[ $HOSTNAME == tp ]]; then
765 # note, see bashrc for more documentation.
767 s dd of=/etc/systemd/system/rss2email.service <<'EOF'
769 Description=rss2email
770 After=multi-user.target
775 # about 24 hours of failures
776 # it copies over its files without respecting symlinks, so
777 # we pass options to use different location.
778 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
780 s dd of=/etc/systemd/system/rss2email.timer <<'EOF'
782 Description=rss2email
785 # for initial run. required.
787 # for subsequent runs.
788 OnUnitInactiveSec=300
791 WantedBy=timers.target
793 s systemctl daemon-reload
797 ######### begin pump.io periodic backup #############
798 if [[ $HOSTNAME == tp ]]; then
799 s dd of=/etc/systemd/system/pumpbackup.service <<'EOF'
801 Description=pump li backup
802 After=multi-user.target
807 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
809 s dd of=/etc/systemd/system/pumpbackup.timer <<'EOF'
811 Description=pump li backup hourly
817 WantedBy=timers.target
819 s systemctl daemon-reload
822 ######### end pump.io periodic backup #############
825 debian|trisquel|ubuntu)
826 # suggests because we want the resolvconf package.
827 # todo: check other distros to make sure it\'s installed
828 pi-nostart --install-suggests openvpn
829 # pi-nostart does not disable
835 /a/bin/distro-setup/radicale-setup
837 ## android studio setup
838 # this contains the setting for android sdk to point to
839 # /a/opt/androidsdk, which is asked upon first run
840 lnf /a/opt/.AndroidStudio2.2 ~
841 # android site says it needs a bunch of packages for ubuntu,
842 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
844 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
845 # see w.org for more android studio details
846 spa lib32stdc++6 default-jdk
849 if [[ $HOSTNAME == frodo ]]; then
850 ############# begin syncthing setup ###########
852 # It\'s simpler to just worry about running it in one place for now.
853 # I assume it would work to clone it\'s config to another non-phone
854 # and just run it in one place instead of the normal having a
855 # separate config. I lean toward using the same config, since btrfs
856 # syncs between comps.
858 arch) pi syncthing ;;
859 trisquel|ubuntu|debian)
860 # testing has relatively up to date packages
861 if ! isdebian-testing; then
862 # based on error when doing apt-get update:
863 # E: The method driver /usr/lib/apt/methods/https could not be found.
864 pi apt-transport-https
865 # google led me here:
866 # https://apt.syncthing.net/
867 curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
868 s="deb http://apt.syncthing.net/ syncthing release"
869 if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != $s ]]; then
870 echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
877 lnf -T /w/syncthing /home/iank/.config/syncthing
878 ser daemon-reload # syncthing likely not properly packaged
879 sgo syncthing@iank # runs as iank
881 # these things persist in ~/.config/syncthing, which I save in
882 # /w/syncthing (not in /p, because syncthing should continue to
883 # run on home server even when using laptop as primary device)
884 # open http://localhost:8384/
885 # change listen address from default to tcp://:22001,
886 # this is because we do port forward so it doesn\'t have to use
887 # some external server, but the syncthing is broken for port forward,
888 # you get a message, something "like connected to myself, this should not happen"
889 # when connecting to other local devices, so I bump the port up by 1,
891 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
892 # Without this, it was being stuck syncing at 0%.
893 # Set gui username and password.
895 # install syncthing via f-droid,
896 # folder setting, turn off send only.
897 # on phone, add device, click bar code icon
898 # on dekstop, top right, actions, device id
899 # after adding, notification will appear on desktop to confirm
901 # syncing folder. from phone to desktop: select desktop in the
902 # folder on phone\'s sync options, notification will appear in
903 # desktop\'s web ui within a minute. For the reverse, the
904 # notification will appear in android\'s notifications, you have to
905 # swipe down and tap it to add the folder. It won\'t appear in the
906 # syncthing ui, which would be intuitive, but don\'t wait for it
907 # there. The notification may not work, instead open the web gui
908 # from in the app, there should be a notification within there.
910 # On phone, set settings to run syncthing all the time, and
911 # show no notification.
913 # Folder versioning would make sense if I didn\'t already use btrfs
914 # for backups. I would choose staggered, or trash can for more space.
916 # if needed to install on a remote comp:
917 # ssh -L 8384:localhost:8384 -N frodo
918 # open http://localhost:8384/
920 # Note, the other thing i did was port forward port 22000,
921 # per https://docs.syncthing.net/users/firewall.html
923 ############# end syncthing setup ###########
928 # no equivalent in other distros:
930 debian|trisquel|ubuntu)
931 # for gui bug reporting
937 ####### begin misc packages ###########
940 ### begin spd install
942 pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl
944 wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb
947 # this guesses at the appropriate directory, adjust if needed
948 x=(/usr/lib/x86_64-linux-gnu/perl/5.*)
949 sudo ln -s ../../../perl/5.18.2/SPD/ $x
950 # newer distro had gpg2 as default, older one, flidas, need to make it that way
953 lnf -T $x /usr/local/bin/gpg
958 if [[ $HOSTNAME == kw ]]; then
960 NOTE: after this finishes, i did
962 # remove br from auto:
963 s vim /etc/network/interfaces
967 # nagstamon setting which were set through the ui
969 # all unknown sources
970 # all warning services
971 # acknowledged hosts & services
972 # hosts & services down for maintenence
973 # services on down hosts
974 # services on hosts in maintenece
975 # services on unreachable osts
976 # hosts in soft state
977 # services in soft state
978 # in display tab: icon in systray.
981 debian|trisquel|ubuntu)
982 # it asks if it should make users in it's group capture packets without root,
983 # which is arguably more secure than running wireshark as root. default is no,
984 # which is what i prefer, since I plan to use tcpdump to input to wireshark.
985 s DEBIAN_FRONTEND=noninteractive pi wireshark-gtk
990 # /run and /dev/shm are listed as required for pulseaudio. All 4 in the group
991 # listed in the default config as suggested.
992 # /run/usr/1000 i noticed was missing for pulseaudio
993 # /run/user/0 just seemed like a not bad idea, given the above
994 tu /etc/schroot/desktop/fstab <<'EOF'
995 /run /run none rw,bind 0 0
996 /run/lock /run/lock none rw,bind 0 0
997 /dev/shm /dev/shm none rw,bind 0 0
998 /run/shm /run/shm none rw,bind 0 0
999 /run/user/1000 /run/user/1000 none rw,bind 0 0
1000 /run/user/0 /run/user/0 none rw,bind 0 0
1008 s dd of=/etc/schroot/chroot.d/$n.conf <<EOF
1014 preserve-environment=true
1017 if [[ -e $d/bin ]]; then
1018 s chroot $d apt-get update
1019 s chroot $d apt-get -y dist-upgrade --purge --auto-remove
1020 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1023 s debootstrap $n $d http://deb.debian.org/debian/
1024 cd; s schroot -c $n -- apt-get install --allow-unauthenticated -y ${apps[@]}
1026 s cp -P {,$d}/etc/localtime
1033 mkschroot stretch firefox-esr pulseaudio chromium
1037 s mkdir -p /nocow/user
1038 s chown $USER:$USER /nocow/user
1041 case $(debian-codename) in
1046 mkschroot jessie anki pulsaudio mplayer
1057 debian|trisquel|ubuntu)
1058 # note i had to do this, which is persistent:
1060 # s chgrp debian-transmission torrents partial-torrents
1062 # syslog says things like
1063 # 'Failed to set receive buffer: requested 4194304, got 425984'
1064 # google suggets giving it even more than that
1065 tu /etc/sysctl.conf<<'EOF'
1066 net.core.rmem_max = 67108864
1067 net.core.wmem_max = 16777216
1071 # some reason it doesn\'t seem to start automatically anyways
1072 pi-nostart transmission-daemon
1074 # the folder was moved here after an install around 02/2017.
1075 # it contains runtime data,
1076 # plus a simple symlink to the config file which it\'s
1077 # not worth separating out.
1078 # between comps, the uid can change
1079 f=/i/transmission-daemon
1080 s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon
1081 if [[ -e $f ]]; then
1082 s chown -R debian-transmission:debian-transmission $f
1084 for f in /i/k/partial-torrents /i/k/torrents; do
1085 if [[ -e $f ]]; then
1086 s chown -R debian-transmission:traci $f
1089 s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon
1091 # config file documented here, and it\'s the same config
1092 # for daemon vs client, so it\'s documented in the gui.
1093 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
1095 # I originaly setup rpc-whitelist, but after using
1096 # routing to a network namespace, it doesn\'t see the
1097 # real source address, so it\'s disabled.
1099 # Changed the cache-size to 256 mb, reduces disk use.
1100 # It is a read & write cache.
1104 p = '/etc/transmission-daemon/settings.json'
1105 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
1106 'rpc-whitelist-enabled' => false,
1107 'rpc-authentication-required' => false,
1108 'incomplete-dir' => '/i/k/partial-torrents',
1109 'incomplete-dir-enabled' => true,
1110 'download-dir' => '/i/k/torrents',
1111 "speed-limit-up" => 800,
1112 "speed-limit-up-enabled" => true,
1113 "peer-port" => 61486,
1114 "cache-size-mb" => 256,
1115 "ratio-limit" => 5.0,
1116 "ratio-limit-enabled" => true,
1120 # make sure its not enabled, not sure if this is needed
1121 ser disable transmission-daemon
1123 # todo: others unknown
1125 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
1126 if ! getent passwd debian-transmission > /dev/null; then
1132 --home-dir /var/lib/transmission-daemon \
1133 --shell /bin/false \
1141 --disabled-password \
1142 --home /var/lib/transmission-daemon \
1149 # trisquel 8 = openvpn, debian stretch = openvpn-client
1150 vpn_ser=openvpn-client
1151 if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then
1155 s dd of=/etc/systemd/system/transmission-daemon-nn.service <<EOF
1157 Description=Transmission BitTorrent Daemon netns
1158 After=network.target
1159 Requires=${vpn_ser}-nn@client.service
1160 After=${vpn_ser}-nn@client.service
1161 JoinsNamespaceOf=${vpn_ser}-nn@client.service
1164 #User=debian-transmission
1165 # notify type doesn't work with sudo
1167 ExecStart=/usr/bin/nsenter --mount=/root/mount_namespaces/client sudo -u debian-transmission /usr/bin/transmission-daemon -f --log-error
1168 ExecReload=/bin/kill -s HUP \$MAINPID
1173 WantedBy=multi-user.target
1177 if [[ $HOSTNAME == frodo ]]; then
1178 sgo transmission-daemon-nn
1182 ######### begin transmission client setup ######
1184 if [[ -e /p/transmission-rpc-pass ]]; then
1185 # arch had a default config,
1186 # debian had nothing until you start it.
1187 # With a little trial an error, here is a minimal config
1188 # taken from the generated one, plus changes that the
1189 # settings ui does, without a bunch of ui crap settings.
1191 # only settings I set were
1196 # the password is randomly generated on first run, i copied it out
1197 # so it could be used by other hosts.
1200 p = '/etc/transmission-daemon/settings.json'
1201 s = JSON.parse(File.read(p))
1202 s["rpc-password"] = File.read("/p/transmission-rpc-pass").chomp
1203 File.write p, JSON.pretty_generate(s)
1206 rpc_pass=$(</p/transmission-rpc-pass)
1207 for f in /home/*; do
1208 d=$f/.config/transmission-remote-gtk
1211 s -u $u dd of=$d/config.json <<EOF
1215 "profile-name" : "Default",
1216 "hostname" : "transmission.b8.nz",
1217 "rpc-url-path" : "/transmission/rpc",
1219 "password" : "$rpc_pass",
1220 "auto-connect" : true,
1224 "update-active-only" : false,
1225 "activeonly-fullsync-enabled" : false,
1226 "activeonly-fullsync-every" : 2,
1227 "update-interval" : 3,
1228 "min-update-interval" : 3,
1229 "session-update-interval" : 60,
1237 "add-options-dialog" : false
1243 # dunno why it\'s there, but get rid of it
1245 li|lj) s rm -rf /home/linode ;;
1252 pi cups ghostscript gsfonts # from arch wiki cups page
1253 pi hplip # from google
1254 s gpasswd -a $USER sys # from arch wiki
1255 sgo org.cups.cupsd.service
1256 # goto http://127.0.0.1:631
1257 # administration tab, add new printer button.
1258 # In debian, I could use hte recommended driver,
1259 # in arch, I had to pick out the 6L driver.
1261 debian|trisquel|ubuntu)
1264 # other distros unknown
1269 trisquel|ubuntu|debian) pi --no-install-recommends mairix notmuch ;;
1270 fedora|arch) spa mairix notmuch ;;
1273 arch) spa nfs-utils ;;
1274 trisquel|ubuntu|debian) spa nfs-client ;;
1277 trisquel|ubuntu|debian) spa par2 ;;
1278 arch|fedora) spa par2cmdline ;;
1281 # needed for my tex resume
1283 trisquel|ubuntu|debian) spa texlive-full ;;
1284 arch) spa texlive-most ;;
1290 # optional dep for firefox for h.264 video
1291 arch) spa gst-libav ;;
1292 # other distros, probably come by default
1296 fedora|trisquel|ubuntu|debian) spa gnupg-agent ;;
1302 fedora) spa pinentry-gtk ;;
1303 *) : ;; # comes default or with other packages
1307 arch) spa firefox pulseaudio;;
1308 trisquel) spa abrowser ;;
1309 *) : ;; # comes default or with other packages, or uknown
1314 arch) spa ttf-dejavu;;
1315 debian|trisquel|ubuntu) spa fonts-dejavu ;;
1321 arch) spa xorg-xev;;
1322 debian|trisquel|ubuntu) spa x11-utils ;;
1327 arch) pi virt-install;;&
1328 debian|trisquel|ubuntu) pi virtinst ;;&
1329 *) pi virt-manager ;; # creates the libvirt group in debian at least
1332 # allow user to run vms, from debian handbook
1333 for x in iank traci; do s usermod -a -G libvirt,kvm $x; done
1334 # bridge networking as user fails. google lead here, but it doesn\'t work:
1335 # oh well, I give up.
1336 # http://wiki.qemu.org/Features-Done/HelperNetworking
1338 # f=/etc/qemu/bridge.conf
1339 # s dd of=$f <<'EOF'
1342 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1348 debian|trisquel|ubuntu) spa genisoimage;;
1353 arch) spa spice-gtk3 ;;
1354 debian|trisquel|ubuntu) spa spice-client-gtk;;
1358 # general known for debian/ubuntu, not for fedora
1361 debian|trisquel|ubuntu)
1363 # a bit of googling, and added settings to bashrc
1364 go get -u github.com/mvdan/fdroidcl/cmd/fdroidcl
1372 # cdrkit for cloud-init isos
1373 # dnsmasq & ebtables for nat networking in libvirt
1374 # qemu for qemu-img, bind-tools for dig
1375 # dmidecode just because syslog complains
1376 pi unzip xorg-xmodmap dmidecode ebtables\
1377 bridge-utils dnsmasq qemu bind-tools
1378 # otherwise we get error about accessing kvm module.
1379 # seems like there might be a better way, but google was a bit vague.
1380 s $sed -ri '/^ *user *=/d' /etc/libvirt/qemu.conf
1381 echo 'user = "root"' | s tee -a /etc/libvirt/qemu.conf
1382 # https://bbs.archlinux.org/viewtopic.php?id=206206
1383 # # this should prolly go in the wiki
1385 # guessing this is not needed
1386 #sgo virtlogd.service
1393 arch) pi virtviewer ;;
1394 *) : ;; # other distros have it as a dependency afaik.
1400 fedora) cabal install shellcheck ;;
1401 *) spa shellcheck ;;
1402 # unknown for older ubuntu
1407 arch|debian|trisquel|ubuntu) spa pumpa ;;
1408 # others unknown. do have a buildscript:
1409 # /a/bin/buildscripts/pumpa ;;
1415 debian|trisquel|ubuntu) spa android-tools-adbd ;;
1416 # todo: not sure this is needed anymore, or if trisqel etc works even
1417 # debian) spa android-tools-adbd/unstable ;;
1418 arch) spa android-tools ;;
1419 # other distros unknown
1427 wget ftp://ftp.gnu.org/pub/gnu/global/global-6.5.7.tar.gz
1430 # based on https://github.com/leoliu/ggtags
1431 ./configure --with-exuberant-ctags=/usr/bin/ctags
1434 s pip install pygments
1442 debian|trisquel|ubuntu)
1450 pi task-mate-desktop
1451 # in settings, change scrolling to two-finger,
1452 # because the default edge scroll doesn\'t work.
1456 # mate-indicator-applet and beyond are msc things I noticed diffing a
1457 # standard install with mine.
1458 pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
1472 # note this failed running at the beginning of this file,
1473 # because no systemd user instance was running.
1474 # Doing systemd --user resulted in
1475 # Trying to run as user instance, but $XDG_RUNTIME_DIR is not set
1477 if isdebian-testing; then
1478 # as of 7/2016, has no unstable deps, and is not in testing anymore.
1485 # # ubuntu unknown. probably the same as debian, just check if the
1486 # # init scripts come with the package.
1488 # # copied from arch, but moved to etc
1489 # s dd of=/etc/systemd/user/synergys.service <<'EOF'
1491 # Description=Synergy Server Daemon
1492 # After=network.target
1496 # ExecStart=/usr/bin/synergys --no-daemon --config /etc/synergy.conf
1497 # Restart=on-failure
1500 # WantedBy=multi-user.target
1502 # s dd of=/etc/systemd/user/synergys.socket <<'EOF'
1504 # Conflicts=synergys@.service
1507 # ListenStream=24800
1511 # WantedBy=sockets.target
1513 # # had this fail with 'Failed to connect to bus: No such file or directory'
1514 # # then when I tried it manually, it worked fine...
1515 # if ! systemctl --user daemon-reload; then
1517 # echo retrying systemd user daemon reload
1518 # systemctl --user daemon-reload
1522 # # taken from arch wiki.
1523 # s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
1525 # Description=Synergy Client
1526 # After=network.target
1530 # ExecStart=/usr/bin/synergyc --no-daemon frodo
1531 # Restart=on-failure
1532 # # per man systemd.unit, StartLimitInterval, by default we
1533 # # restart more than 5 times in 10 seconds.
1534 # # And this param defaults too 200 miliseconds.
1538 # WantedBy=multi-user.target
1540 # s systemctl daemon-reload
1543 # ser enable synergyc@iank
1544 # ser start synergyc@iank ||: # X might not be running yet
1547 # systemctl --user start synergys ||:
1548 # systemctl --user enable synergys
1556 ### kdeconnect for gnome. started in /a/bin/distro-setup/desktop-20-autostart.sh
1557 pi libgtk-3-dev python3-requests-oauthlib valac cmake python-nautilus libappindicator3-dev
1558 cd /a/opt/indicator-kdeconnect
1561 cmake .. -DCMAKE_INSTALL_PREFIX=/usr
1564 # we can start it manually with /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
1565 # it seems, according to
1566 # /etc/xdg/autostart/kdeconnectd.desktop
1567 # I'm not seeing the icon, but the clipboard replication is working
1569 ######### end misc packages #########
1572 # packages I once used before and liked, but don\'t want installed now for
1574 # python-sqlite is used for offlineimap
1575 # lxappearance python-sqlite dolphin paman dconf-editor
1581 # todo, finish configuring smart.
1584 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1585 # turn on smart. background on options:
1586 # first line, -a = test everyting on all devices.
1587 # -S on, turn on disk internal saving of vendor specific info,
1588 # from google, seems like this is usually already on and fairly standard.
1589 # -o on, turn on 4 hour period non-performance degrading testing.
1590 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1591 sched="-s (S/../.././02|L/../../6/03)"
1592 s sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1593 DEVICESCAN -a -o on -S on -n standby,q $sched \
1594 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc/smartd.conf
1596 # in the default configuration of at least ubuntu 14.04, resolvconf is
1597 # configured to order any nameservers associated with tun* or tap*
1598 # before the normal internet interfaces, which means they are always
1599 # consulted first. This is often slower and undesirable, ie. local dns
1600 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1602 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1603 # however, this breaks dns lookup for hosts on the openvpn lan.
1604 # I can\'t figure out why hosts on the normal lan would not be
1605 # broken under the default ordering, except the host I was
1606 # testing with previously had an entry in /etc/hosts.
1608 ############# end unfinished
1610 ########### misc stuff
1615 # stop autopoping windows when i plug in an android phone.
1616 # dbus-launch makes this work within an ssh connection, otherwise you get this message,
1617 # with still 0 exit code.
1618 # dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
1619 dbus-launch gsettings set org.gnome.desktop.media-handling automount-open false
1622 for dev in $(s btrfs fi show /boot | sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1623 devs+=($(devbyid $dev),)
1625 devs[-1]=${devs[-1]%,} # jonied by commas
1627 # on grub upgrade, we get prompts unless we do this
1628 s debconf-set-selections <<EOF
1629 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1633 # the wiki backup script from ofswiki.org uses generic paths
1634 s lnf /p/c/machine_specific/li/mw_vars /root
1635 s lnf /k/backup/wiki_backup /root
1637 s cedit /etc/goaccess.conf <<'EOF' || [[ $? == 1 ]]
1638 # all things found from looking around the default config
1639 # copied existing NCSA Combined Log Format with Virtual Host, plus %L
1640 log-format %^:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %D
1641 time-format %H:%M:%S
1642 date-format %d/%b/%Y
1643 log-file /var/log/apache2/access.log
1646 # tip: copy access.log files to a stretch host directory, then run
1647 # jessie's goaccess is too old for some options, and it\'s
1648 # not easily installed from a testing.
1649 # goaccess --ignore-crawlers -f <(cat *) -a -o html > x.html
1654 trisquel|ubuntu|debian)
1655 # unison-gtk second, i want it to be default, not sure if that works
1656 # with spa. note, I used to install from testing repo when using stable,
1657 # but it shouldn't be needed since I wrote a script to handle mismatching
1659 spa unison unison-gtk
1668 # default is alsa, doesn\'t work with with pianobar
1669 s dd of=/etc/libao.conf <<'EOF'
1670 default_driver=pulse
1675 # note, for jessie, it depends on a higher version of btrfs-tools.
1677 # # disabled due to my patch being in btrbk
1679 # arch|debian|trisquel|ubuntu) pi btrbk ;;
1684 spa pv # for progress bar when running interactively.
1686 # ian: temporarily disabled while hosts are in flux.
1687 # if [[ $HOSTNAME == tp ]]; then
1688 # # backup/sync manually on others hosts for now.
1690 # # note: to see when it was last run,
1698 debian|trisquel|ubuntu) s gpasswd -a iank adm ;; #needed for reading logs
1704 # https://www.torproject.org/docs/rpms.html.en
1705 # https://www.torproject.org/docs/debian.html.en
1706 # todo: figure out if the running service needs to be restarted upon updates
1709 # todo on fedora: setup non-dev packages
1711 s dd of=/etc/yum.repos.d/torproject.repo <<'EOF'
1713 name=Tor experimental repo
1715 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1717 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1720 name=Tor experimental source repo
1723 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1725 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1728 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1729 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1731 /a/bin/buildscripts/tor-browser
1734 tu /etc/apt/sources.list "deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1735 gpg --keyserver keys.gnupg.net --recv 886DDD89
1736 gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
1738 pi deb.torproject.org-keyring
1740 /a/bin/buildscripts/tor-browser
1744 /a/bin/buildscripts/tor-browser
1747 pi tor tor-browser-en
1757 fedora todo: disable the firewall or find a way to automate it.
1758 there's an unused section in t.org for tramikssion firewall setup
1760 fedora manual config for nfs:
1762 change to permanent configuration
1763 check the box for nfs
1764 was hard to figure this out, not sure if this is all needed, but
1766 mountd: udp/tcp 20048
1767 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1768 troubleshooting, unblock things in rpcinfo -p
1769 make sure to reload the firewall to load the persistent configuration
1776 debian|trisquel|ubuntu)
1780 pi nfs-utils || pending_reboot=true
1782 # this failed until I rebooted
1790 if [[ $HOSTNAME == frodo ]]; then
1791 # nohide = export filesystems mounted deeper than the export point
1792 # fsid=0 makes this export the "root" export
1793 # not documented in the man page, but this means
1794 # 1. it can be mounted with a shorthand of server:/
1795 # 2. exports that are subdirectories of this one will automatically be mounted
1796 tu /etc/exports <<'EOF'
1797 /k 192.168.1.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1806 # persistent virtual machines
1808 debian|trisquel|ubuntu)
1812 # if I was going to create a persistent vm, i might do it like this:
1813 # variant=something # from: virt-install --os-variant list
1814 # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
1815 # --disk=/a/images/some_name.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
1816 # -n some_name --import --os-variant $variant --cpu host-model-only
1820 ######### begin stuff belonging at the end ##########
1823 # Apps we want to override others for default file handler:
1824 # simplest way in debian is to just install them last.
1837 pi "${simple_packages[@]}"
1840 if $pending_reboot; then
1841 echo "$0: pending reboot and then finished. doing it now."
1844 echo "$0: $(date): ending now)"