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%/*}"
27 IFS
= read -r -d '' y ||
:
31 spa
() { # simple package add
38 sed="sed --follow-symlinks"
62 # swh-plugins is for karaoke pulsaudio filter.
123 transmission-remote-gtk
127 spa $
(apt-cache search ruby
[.0-9]+-doc|
awk '{print $1}')
132 ########### begin section including li ################
137 if [[ `debian-archive` == testing
]]; then
150 # ubuntu 14.04 uses b-cron,
151 # but its not maintained in arch.
152 # of the ones in the main repos, cronie is only one maintained.
153 # fcron appears abandoned software.
157 *) : ;; # other distros come with cron.
187 arch
) spa the_silver_searcher
;;
188 debian|ubuntu
) spa silversearcher-ag
;;
193 debian|ubuntu
) spa ntp
;;
202 # no equivalent in other distros:
206 if ! dpkg
-s apt-file
&>/dev
/null
; then
207 # this condition is just a speed optimization
211 # for debconf-get-selections
217 ubuntu|debian
) spa ack-grep
;;
218 arch|fedora
) spa ack
;;
234 case $
(distro-name
) in
236 # allows me to pipe with ssh -t, and gets rid of spam
237 # http://forums.debian.net/viewtopic.php?f=5&t=85822
238 # i'd rather disable the service than comment the init file
239 # this says disabling the service, it will still get restarted
240 # but this script doesn't do anything on restart, so it should be fine
241 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
242 # stretch doesn't have initscripts pkg installed by default
243 if [[ $
(debian-codename
) == jessie
]]; then
244 s update-rc.d motd disable
248 # this isn't a complete solution. It still shows me when updates are available,
249 # but it's no big deal.
250 s t
/etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
256 # https://debian-handbook.info/browse/stable/sect.regular-upgrades.html
257 # /etc/cron.daily/apt calls unattended-upgrades
258 # /usr/share/doc/unattended-upgrades# cat README.md
259 # /etc/apt/apt.conf.d/50unattended-upgrades
261 setup-debian-auto-update
264 # we've got a few dependencies later on, so install them now.
265 pi
"${simple_packages[@]}"
273 lj
) domain
=iank.bid
; exit 0 ;;
274 li
) domain
=iankelling.org
;;
276 /a
/h
/setup.sh
$domain
279 sudo
-E /a
/bin
/mediawiki-setup
/mw-setup-script
282 pi-nostart mumble-server
283 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
288 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
290 Description=Turns on iptables mail nat
295 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
296 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
299 WantedBy=openvpn.service
302 ser
enable vpnmail.service
303 acme-tiny-wrapper
mail.iankelling.org
304 # needed for li's local mail delivery. there might
305 # be a better way to do it that doesn't require disabling
306 # it during le verification, but whatever for now.
307 f
=/etc
/cron.daily
/lets-encrypt-mail_iankelling_org
308 l
="10.8.0.4 mail.iankelling.org"
309 tu
/etc
/hosts
<<<"$l"
310 s
sed -i '/^\s*sysv acme-tiny-wrapper/i sed -i /^10\.8\.0\.4/d /etc/hosts' $f
311 echo "echo $l >>/etc/hosts" | s
tee -a $f
313 domain
=cal.iankelling.org
314 acme-tiny-wrapper
$domain
315 apache-site
-f 10.8.0.4:5232 - $domain <<'EOF'
316 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
317 <Directory "/var/www/cal.iankelling.org/html">
318 Options +FollowSymLinks +Multiviews +Indexes
321 AuthName "Authentication Required"
322 # setup one time, with root:www-data, 640
323 AuthUserFile "/etc/caldav-htpasswd"
327 # nginx version of above would be:
328 # auth_basic "Not currently available";
329 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
332 ########## begin pump.io setup ##########
334 # once pump adds a logrotation script, turn off nologger,
336 # "logfile": "/var/log/pumpio/pumpio.log",
338 s
dd of
=/etc
/pump.io.json
<<'EOF'
340 "secret": "SECRET_REPLACE_ME",
342 "params": { "dbname": "pumpio" },
344 "site": "pump.iankelling.org",
345 "owner": "Ian Kelling",
346 "ownerURL": "https://iankelling.org/",
349 "hostname": "pump.iankelling.org",
351 "datadir": "/home/pumpio/pumpdata",
352 "enableUploads": true,
353 "debugClient": false,
354 "disableRegistration": true,
356 "key": "/home/pumpio/pump.iankelling.org-domain.key",
357 "cert": "/home/pumpio/pump.iankelling.org-chained.pem",
358 "address": "localhost",
362 s
sed -i "s#SECRET_REPLACE_ME#$(cat /p/c/machine_specific/li/pump-secret)#" /etc
/pump.io.json
364 # jessie\'s node is too old
365 # https://nodejs.org/en/download/package-manager/
366 curl
-sL https
://deb.nodesource.com
/setup_6.x | sudo
-E bash
-
370 git clone https
://github.com
/pump-io
/pump.io.git
372 # note: doing this or the npm install pump.io as root had problems.
375 # normally, next command would be
376 # s npm install -g databank-mongodb
377 # but it\'s this until a bug in pump gets fixed
378 s npm
install -g databank-mongodb@
0.19.2
379 s useradd
-m -s /bin
/false pumpio
380 sudo
-u pumpio mkdir
-p /home
/pumpio
/pumpdata
381 # for testing browser when only listening to localhost,
382 # in the pump.io.json, set hostname localhost, urlPort 5233
383 #ssh -L 5233:localhost:5233 li
384 acme-tiny-wrapper
-c /home
/pumpio pump.iankelling.org
386 s mkdir
-p /var
/log
/pumpio
/
387 s chown pumpio
:pumpio
/var
/log
/pumpio
/
389 apache-site
-c /home
/pumpio
- pump.iankelling.org
<<'EOF'
390 # currently a bug in pump that we cant terminate ssl
393 ProxyPass / https://127.0.0.1:8001/
394 ProxyPassReverse / https://127.0.0.1:8001/
395 # i have sockjs disabled per people suggesting that
396 # it won\'t work with apache right now.
397 # not sure if it would work with this,
398 # but afaik, this is pointless atm.
399 <Location /main/realtime/sockjs/>
400 ProxyPass wss://127.0.0.1:8001/main/realtime/sockjs/
401 ProxyPassReverse wss://127.0.0.1:8001/main/realtime/sockjs/
405 s
dd of
=/etc
/systemd
/system
/pump.service
<<'EOF'
408 After=syslog.target network.target
414 ExecStart=/home/ian/pump.io/bin/pump
415 Environment=NODE_ENV=production
416 # failed to find databank-mongodb without this.
417 # I just looked at my environment variables took a guess.
418 Environment=NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
421 WantedBy=multi-user.target
425 ########## end pump.io setup ############
428 ############# begin setup mastodon ##############
430 # https://store.docker.com/editions/community/docker-ce-server-debian?tab=description
431 pi software-properties-common
432 curl
-fsSL https
://download.docker.com
/linux
/debian
/gpg | sudo apt-key add
-
433 sudo add-apt-repository \
434 "deb [arch=amd64] https://download.docker.com/linux/debian \
440 # this may not be needed
443 curl
-L https
://github.com
/docker
/compose
/releases
/download
/1.12.0/docker-compose-
`uname -s`-`uname -m` | s
dd of
=/usr
/local
/bin
/docker-compose
444 s
chmod +x
/usr
/local
/bin
/docker-compose
446 # i subscrubed to https://github.com/docker/compose/releases.atom
447 # to deal with updates manually.
450 i clone https
://github.com
/tootsuite
/mastodon
452 # https://github.com/tootsuite/mastodon/tree/v1.1.2
453 # subbed to atom feed to deal with updates
456 # per instructions, uncomment redis/postgres persistence in docker-compose.yml
457 sed -i 's/^#//' docker-compose.yml
459 cat >.env.production
<<'EOF'
468 LOCAL_DOMAIN=mast.iankelling.org
471 SINGLE_USER_MODE=true
476 SMTP_FROM_ADDRESS=notifications@mast.iankelling.org
477 SMTP_DOMAIN=mast.iankelling.org
478 SMTP_DELIVERY_METHOD=smtp
481 for key
in PAPERCLIP_SECRET SECRET_KEY_BASE OTP_SECRET
; do
482 printf "%s=%s" $key "$(docker-compose run --rm web rake secret)" >>.env.production
484 s
cat /etc
/mailpass|
while read -r domain port pass
; do
485 if [[ $domain == mail.iankelling.org
]]; then
486 printf "SMTP_PASSWORD=%s" "$pass" >>.env.production
493 docker-compose run
--rm web rails assets
:precompile
495 # docker daemon takes care of starting on boot.
498 acme-tiny-wrapper mast.iankelling.org
499 s a2enmod proxy_wstunnel headers
500 apache-site
-f 3000 - mast.iankelling.org
<<'EOF'
502 RequestHeader set X-Forwarded-Proto "https"
503 ProxyPass /500.html !
504 ProxyPass /oops.png !
505 ProxyPass /api/v1/streaming/ ws://localhost:4000/
506 ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
507 ErrorDocument 500 /500.html
508 ErrorDocument 501 /500.html
509 ErrorDocument 502 /500.html
510 ErrorDocument 503 /500.html
511 ErrorDocument 504 /500.html
515 ############### !!!!!!!!!!!!!!!!!
516 ############### manual steps:
518 # only following 2 people atm, so not bothering to figure out backups
519 # when mastodon has not documented it at all.
524 # johns@status.fsf.org
526 # sign in page is at https://mast.iankelling.org/auth/sign_in
527 # register as iank, then
528 # https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Administration-guide.md
529 # docker-compose run --rm web bundle exec rails mastodon:make_admin USERNAME=iank
531 ############# end setup mastodon ##############
535 echo "$0: $(date): ending now)"
541 ########### end section including li/lj ###############
543 if [[ $HOSTNAME == treetowl
]]; then
544 # note, see bashrc for more documentation.
546 s
dd of
=/etc
/systemd
/system
/rss2email.service
<<'EOF'
548 Description=rss2email
549 After=multi-user.target
554 # about 24 hours of failures
555 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e run
557 s
dd of
=/etc
/systemd
/system
/rss2email.timer
<<'EOF'
559 Description=rss2email
562 # for initial run. required.
564 # for subsequent runs.
565 OnUnitInactiveSec=300
568 WantedBy=timers.target
570 s systemctl daemon-reload
574 ######### begin pump.io periodic backup #############
575 if [[ $HOSTNAME == treetowl
]]; then
576 s
dd of
=/etc
/systemd
/system
/pumpbackup.service
<<'EOF'
578 Description=pump li backup
579 After=multi-user.target
584 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
586 s
dd of
=/etc
/systemd
/system
/pumpbackup.timer
<<'EOF'
588 Description=pump li backup hourly
594 WantedBy=timers.target
596 s systemctl daemon-reload
599 ######### end pump.io periodic backup #############
603 # suggests because we want the resolvconf package.
604 # todo: check other distros to make sure it\'s installed
605 pi-nostart
--install-suggests openvpn
606 # pi-nostart does not disable
612 if private-host
; then
613 vpn-mk-client-cert
-n mail li
614 cn
=$
(s openssl x509
-noout -nameopt multiline
-subject \
615 -in /etc
/openvpn
/client
/mail.crt | \
616 sed -rn 's/^\s*commonName\s*=\s*(.*)/\1/p')
617 echo "ifconfig-push 10.8.0.4 255.255.255.0" | \
618 ssh root@li
dd of
=/etc
/openvpn
/client-config
/"$cn"
621 if [[ $HOSTNAME == treetowl
]]; then
622 # note, this will need to be changed when the mail/contacts host changes
623 sgo openvpn-client@
mail
624 /a
/bin
/distro-setup
/radicale-setup
627 ## android studio setup
628 # this contains the setting for android sdk to point to
629 # /a/opt/androidsdk, which is asked upon first run
630 lnf
/a
/opt
/.AndroidStudio2.2 ~
631 # android site says it needs a bunch of packages for ubuntu,
632 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
634 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
635 # see w.org for more android studio details
636 spa lib32stdc
++6 default-jdk
639 if [[ $HOSTNAME == treetowl
]]; then
640 ############# begin syncthing setup ###########
642 # It\'s simpler to just worry about running it in one place for now.
643 # I assume it would work to clone it\'s config to another non-phone
644 # and just run it in one place instead of the normal having a
645 # separate config. I lean toward using the same config, since btrfs
646 # syncs between comps.
648 arch
) pi syncthing
;;
650 # testing has relatively up to date packages
651 if ! isdebian-testing
; then
652 # based on error when doing apt-get update:
653 # E: The method driver /usr/lib/apt/methods/https could not be found.
654 pi apt-transport-https
655 # google led me here:
656 # https://apt.syncthing.net/
657 curl
-s https
://syncthing.net
/release-key.txt | sudo apt-key add
-
658 s
="deb http://apt.syncthing.net/ syncthing release"
659 if [[ $
(cat /etc
/apt
/sources.list.d
/syncthing.list
) != $s ]]; then
660 echo "$s" | s
dd of
=/etc
/apt
/sources.list.d
/syncthing.list
667 lnf
-T /w
/syncthing
/home
/ian
/.config
/syncthing
668 sgo syncthing@ian
# runs as ian
670 # these things persist in ~/.config/syncthing, which I save in
671 # /w/syncthing (not in /p, because syncthing should continue to
672 # run on home server even when using laptop as primary device)
673 # open http://localhost:8384/
674 # change listen address from default to tcp://:22001,
675 # this is because we do port forward so it doesn\'t have to use
676 # some external server, but the syncthing is broken for port forward,
677 # you get a message, something "like connected to myself, this should not happen"
678 # when connecting to other local devices, so I bump the port up by 1,
680 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
681 # Without this, it was being stuck syncing at 0%.
682 # Set gui username and password.
684 # install syncthing via f-droid,
685 # folder setting, turn off master folder (makes it read only).
686 # on phone, add device, click bar code icon
687 # on dekstop, top right, actions, device id
688 # after adding, notification will appear on desktop to confirm
690 # syncing folder. from phone to desktop: select desktop in the
691 # folder on phone\'s sync options, notification will appear in
692 # desktop\'s web ui within a minute. For the reverse, the
693 # notification will appear in android\'s notifications, you have to
694 # swipe down and tap it to add the folder. It won\'t appear in the
695 # syncthing ui, which would be intuitive, but don\'t wait for it
698 # On phone, set settings to run syncthing all the time, and
699 # show no notification.
701 # Folder versioning would make sense if I didn\'t already use btrfs
702 # for backups. I would choose staggered, or trash can for more space.
704 # if needed to install on a remote comp:
705 # ssh -L 8384:localhost:8384 -N frodo
706 # open http://localhost:8384/
708 # Note, the other thing i did was port forward port 22000,
709 # per https://docs.syncthing.net/users/firewall.html
711 ############# end syncthing setup ###########
716 # no equivalent in other distros:
719 # for gui bug reporting
725 ####### misc packages ###########
727 if [[ $HOSTNAME == treetowl
]]; then
730 # note i had to do this, which is persistent:
732 # s chgrp debian-transmission torrents partial-torrents
734 # syslog says things like
735 # 'Failed to set receive buffer: requested 4194304, got 425984'
736 # google suggets giving it even more than that
737 tu
/etc
/sysctl.conf
<<'EOF'
738 net.core.rmem_max = 67108864
739 net.core.wmem_max = 16777216
743 # some reason it doesn\'t seem to start automatically anyways
744 pi-nostart transmission-daemon
746 # the folder was moved here after an install around 02/2017.
747 # it contains runtime data,
748 # plus a simple symlink to the config file which it\'s
749 # not worth separating out.
750 s lnf
-T /i
/transmission-daemon
/var
/lib
/transmission-daemon
/.config
/transmission-daemon
752 # config file documented here, and it\'s the same config
753 # for daemon vs client, so it\'s documented in the gui.
754 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
756 # I originaly setup rpc-whitelist, but after using
757 # routing to a network namespace, it doesn\'t see the
758 # real source address, so it\'s disabled.
760 # Changed the cache-size to 256 mb, reduces disk use.
761 # It is a read & write cache.
765 p = '/etc/transmission-daemon/settings.json'
766 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
767 'rpc-whitelist-enabled' => false,
768 'rpc-authentication-required' => false,
769 'incomplete-dir' => '/i/k/partial-torrents',
770 'incomplete-dir-enabled' => true,
771 'download-dir' => '/i/k/torrents',
772 "speed-limit-up" => 800,
773 "speed-limit-up-enabled" => true,
774 "peer-port" => 61486,
775 "cache-size-mb" => 256,
776 "ratio-limit" => 5.0,
777 "ratio-limit-enabled" => true,
781 # make sure its not enabled, not sure if this is needed
782 ser disable transmission-daemon
783 sgo transmission-daemon-nn
785 # todo: others unknown
789 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
790 if ! getent passwd debian-transmission
> /dev
/null
; then
796 --home-dir /var
/lib
/transmission-daemon \
805 --disabled-password \
806 --home /var
/lib
/transmission-daemon \
812 # dunno why it\'s there, but get rid of it
814 li|lj
) s
rm -rf /home
/linode
;;
817 # arch had a default config,
818 # debian had nothing until you start it.
819 # With a little trial an error, here is a minimal config
820 # taken from the generated one, plus changes that the
821 # settings ui does, without a bunch of ui crap settings.
823 # only settings I set were
829 # the password is randomly generated on first run
830 rpc_pass
=$
(s ruby
<<'EOF'
832 p = '/etc/transmission-daemon/settings.json'
833 puts JSON.parse(File.read(p))["rpc-password"]
838 d
=$f/.config
/transmission-remote-gtk
841 s
-u $u dd of
=$d/config.json
<<EOF
845 "profile-name" : "Default",
846 "hostname" : "transmission",
847 "rpc-url-path" : "/transmission/rpc",
849 "password" : "$rpc_pass",
850 "auto-connect" : true,
854 "update-active-only" : false,
855 "activeonly-fullsync-enabled" : false,
856 "activeonly-fullsync-every" : 2,
857 "update-interval" : 3,
858 "min-update-interval" : 3,
859 "session-update-interval" : 60,
867 "add-options-dialog" : false
879 wget
-nv -N https
://dl.google.com
/linux
/direct
/google-chrome-stable_current_amd64.deb
882 s dpkg
-i google-chrome-stable_current_amd64.deb |
& tee $log
888 # previously I had a more specific search, but dpkg
889 # changed it\'s output as of 7/2016
890 if grep 'dependency problems' \
891 $log &>/dev
/null
; then
892 s apt-get
-fy install
909 pi cups ghostscript gsfonts
# from arch wiki cups page
910 pi hplip
# from google
911 s gpasswd
-a $USER sys
# from arch wiki
912 sgo org.cups.cupsd.service
913 # goto http://127.0.0.1:631
914 # administration tab, add new printer button.
915 # In debian, I could use hte recommended driver,
916 # in arch, I had to pick out the 6L driver.
921 # other distros unknown
926 ubuntu|debian
) pi
--no-install-recommends mairix notmuch
;;
927 fedora|arch
) spa mairix notmuch
;;
930 arch
) spa nfs-utils
;;
931 ubuntu|debian
) spa nfs-client
;;
934 ubuntu|debian
) spa par2
;;
935 arch|fedora
) spa par2cmdline
;;
938 # needed for my tex resume
940 ubuntu|debian
) spa texlive-full
;;
941 arch
) spa texlive-most
;;
947 # flash, unrar, codecs, ms fonts.
948 # This has a manual prompt.
949 spa ubuntu-restricted-extras
953 # rpm fusion recommended codecs
954 s su
-c "yum localinstall -y --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm"
955 pi gstreamer-plugins-ugly gstreamer-plugins-bad gstreamer-ffmpeg\
956 xine-lib-extras-freeworld
961 # optional dep for firefox for h.264 video
962 arch
) spa gst-libav
;;
963 # other distros, probably come by default
967 fedora|ubuntu|debian
) spa gnupg-agent
;;
973 fedora
) spa pinentry-gtk
;;
974 *) : ;; # comes default or with other packages
978 arch
) spa firefox pulseaudio
;;
979 *) : ;; # comes default or with other packages
984 arch
) spa ttf-dejavu
;;
985 debian|ubuntu
) spa fonts-dejavu
;;
992 debian|ubuntu
) spa x11-utils
;;
997 arch
) pi virt-install
;;&
998 debian|ubuntu
) pi virtinst
;;&
999 *) pi virt-manager
;; # creates the libvirt group in debian at least
1002 # allow user to run vms, from debian handbook
1003 for x
in ian traci
; do s usermod
-a -G libvirt
,kvm
$x; done
1004 # bridge networking as user fails. google lead here, but it doesn\'t work:
1005 # oh well, I give up.
1006 # http://wiki.qemu.org/Features-Done/HelperNetworking
1008 # f=/etc/qemu/bridge.conf
1009 # s dd of=$f <<'EOF'
1012 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1018 debian|ubuntu
) spa genisoimage
;;
1023 arch
) spa spice-gtk3
;;
1024 debian|ubuntu
) spa spice-client-gtk
;;
1028 # general known for debian/ubuntu, not for fedora
1033 # a bit of googling, and added settings to bashrc
1034 go get
-u github.com
/mvdan
/fdroidcl
/cmd
/fdroidcl
1042 # cdrkit for cloud-init isos
1043 # dnsmasq & ebtables for nat networking in libvirt
1044 # qemu for qemu-img, bind-tools for dig
1045 # dmidecode just because syslog complains
1046 pi
unzip xorg-xmodmap dmidecode ebtables\
1047 bridge-utils dnsmasq qemu bind-tools
1048 # otherwise we get error about accessing kvm module.
1049 # seems like there might be a better way, but google was a bit vague.
1050 s
$sed -ri '/^ *user *=/d' /etc
/libvirt
/qemu.conf
1051 echo 'user = "root"' | s
tee -a /etc
/libvirt
/qemu.conf
1052 # https://bbs.archlinux.org/viewtopic.php?id=206206
1053 # # this should prolly go in the wiki
1055 # guessing this is not needed
1056 #sgo virtlogd.service
1063 arch
) pi virtviewer
;;
1064 *) : ;; # other distros have it as a dependency afaik.
1070 fedora
) cabal
install shellcheck
;;
1071 *) spa shellcheck
;;
1072 # unknown for older ubuntu
1077 arch|debian|ubuntu
) spa pumpa
;;
1078 # others unknown. do have a buildscript:
1079 # /a/bin/buildscripts/pumpa ;;
1084 debian|ubuntu
) spa android-tools-adbd
/unstable
;;
1085 arch
) spa android-tools
;;
1086 # other distros unknown
1089 if [[ $HOSTNAME == treetowl
]]; then
1092 if [[ `debian-archive` == testing
]]; then
1093 # has no unstable dependencies
1094 pi bitcoind
/unstable
1095 src
=/a
/opt
/bitcoin
/contrib
/init
/bitcoind.service
1096 s
cp $src /etc
/systemd
/system
1097 p
=/etc
/bitcoin
/bitcoin
1098 dst
=/etc
/systemd
/system
/bitcoinjm.service
1100 $sed -r "/^\s*ExecStart/s,${p}.conf,${p}jm.conf," $src \
1101 >/etc
/systemd
/system
/bitcoinjm.service
1103 d
=jm
; jm
=d
# being clever for succinctness
1105 s
$sed -ri "/^\s*\[Unit\]/a Conflicts=bitcoin${!s}.service" \
1106 /etc
/systemd
/system
/bitcoin
${s}.service
1113 s chown
-R bitcoin
:bitcoin
$dir
1116 s chown
-R root
:bitcoin
$dir
1119 # pruning decreases the bitcoin dir to 2 gb, keeps
1120 # just the recent blocks. can\'t do a few things like
1121 # import a wallet dump.
1122 # pruning works, but people had to do
1123 # some manual stuff in joinmarket. I dun need the
1124 # disk space, so not bothering yet, maybe in a year or so.
1125 # https://github.com/JoinMarket-Org/joinmarket/issues/431
1126 #https://bitcoin.org/en/release/v0.12.0#wallet-pruning
1132 rpcpassword=$(openssl rand -base64 32)
1133 rpcuser=$(openssl rand -base64 32)
1137 f2
=$dir/bitcoinjm.conf
1139 s
tee -a $f2 >/dev
/null
<<EOF
1141 walletnotify=curl -sI --connect-timeout 1 http://localhost:62602/walletnotify?%s
1142 alertnotify=curl -sI --connect-timeout 1 http://localhost:62602/alertnotify?%s
1143 wallet=joinmarket.dat
1145 # dunno about sharing a wallet between multiple instances
1146 # manually did, wallet.dat symlinked in /nocow/.bitcoin
1150 # other distros unknown
1152 pi libsodium-dev python-pip
1153 cd /a
/opt
/joinmarket
1154 # using develop branch, as it seems to be mostly bug fixes,
1155 # and this is quite new software.
1156 # note: python3 does not work.
1157 # has seg fault error due to some bug, but it still works
1158 pip
install -r requirements.txt ||
[[ $?
== 139 ]]
1159 # note, the target must exist ahead of time, or bitcoin
1160 # just overwrites the link, and it\'s not happy with an empty file,
1161 # so we have to create the wallet, then move and link it.
1162 s lnf
-T /q
/bitcoin
/wallet.dat
/nocow
/.bitcoin
/wallet.dat
1163 s lnf
-T /q
/bitcoin
/joinmarket.dat
/nocow
/.bitcoin
/joinmarket.dat
1164 # not technically needed, but seems cleaner not to have
1165 # symlinks be root owned unlike everything else
1166 s chown
-h bitcoin
:bitcoin
/nocow
/.bitcoin
/*
1168 for var
in rpcuser rpcpassword
; do
1169 u
="$(s sed -rn "s
/^
$var=(.
*)/\
1/p
" /etc/bitcoin/bitcoin.conf)"
1170 # escape backslashes
1171 u
="${u//\\/\\\\\\\\}"
1174 sed -ri "s,^(rpc_${var#rpc}\s*=).*,\1 $u," joinmarket.cfg
1176 sed -ri "s/^\s*(blockchain_source\s*=).*/\1 bitcoin-rpc/" joinmarket.cfg
1185 wget http
://tamacom.com
/global
/global-6.3
.2.
tar.gz
1188 # based on https://github.com/leoliu/ggtags
1189 .
/configure
--with-exuberant-ctags=/usr
/bin
/ctags
1192 s pip
install pygments
1208 pi task-cinnamon-desktop
1209 # in settings, change scrolling to two-finger,
1210 # because the default edge scroll doesn\'t work.
1219 # already in debian jessie
1225 # note this failed running at the beginning of this file,
1226 # because no systemd user instance was running.
1227 # Doing systemd --user resulted in
1228 # Trying to run as user instance, but $XDG_RUNTIME_DIR is not set
1230 if isdebian-testing
; then
1231 # as of 7/2016, has no unstable deps, and is not in testing anymore.
1238 # # ubuntu unknown. probably the same as debian, just check if the
1239 # # init scripts come with the package.
1241 # # copied from arch, but moved to etc
1242 # s dd of=/etc/systemd/user/synergys.service <<'EOF'
1244 # Description=Synergy Server Daemon
1245 # After=network.target
1249 # ExecStart=/usr/bin/synergys --no-daemon --config /etc/synergy.conf
1250 # Restart=on-failure
1253 # WantedBy=multi-user.target
1255 # s dd of=/etc/systemd/user/synergys.socket <<'EOF'
1257 # Conflicts=synergys@.service
1260 # ListenStream=24800
1264 # WantedBy=sockets.target
1266 # # had this fail with 'Failed to connect to bus: No such file or directory'
1267 # # then when I tried it manually, it worked fine...
1268 # if ! systemctl --user daemon-reload; then
1270 # echo retrying systemd user daemon reload
1271 # systemctl --user daemon-reload
1275 # # taken from arch wiki.
1276 # s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
1278 # Description=Synergy Client
1279 # After=network.target
1283 # ExecStart=/usr/bin/synergyc --no-daemon frodo
1284 # Restart=on-failure
1285 # # per man systemd.unit, StartLimitInterval, by default we
1286 # # restart more than 5 times in 10 seconds.
1287 # # And this param defaults too 200 miliseconds.
1291 # WantedBy=multi-user.target
1293 # s systemctl daemon-reload
1296 # ser enable synergyc@ian
1297 # ser start synergyc@ian ||: # X might not be running yet
1300 # systemctl --user start synergys ||:
1301 # systemctl --user enable synergys
1308 ######### end misc packages #########
1311 # packages I once used before and liked, but don\'t want installed now for
1313 # python-sqlite is used for offlineimap
1314 # lxappearance python-sqlite dolphin paman dconf-editor
1320 # todo, finish configuring smart.
1323 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1324 # turn on smart. background on options:
1325 # first line, -a = test everyting on all devices.
1326 # -S on, turn on disk internal saving of vendor specific info,
1327 # from google, seems like this is usually already on and fairly standard.
1328 # -o on, turn on 4 hour period non-performance degrading testing.
1329 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1330 sched
="-s (S/../.././02|L/../../6/03)"
1331 s
sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1332 DEVICESCAN -a -o on -S on -n standby,q $sched \
1333 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc
/smartd.conf
1335 # in the default configuration of at least ubuntu 14.04, resolvconf is
1336 # configured to order any nameservers associated with tun* or tap*
1337 # before the normal internet interfaces, which means they are always
1338 # consulted first. This is often slower and undesirable, ie. local dns
1339 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1341 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1342 # however, this breaks dns lookup for hosts on the openvpn lan.
1343 # I can\'t figure out why hosts on the normal lan would not be
1344 # broken under the default ordering, except the host I was
1345 # testing with previously had an entry in /etc/hosts.
1347 ############# end unfinished
1349 ########### misc stuff
1352 for dev
in $
(s btrfs
fi show
/boot |
sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1353 devs
+=($
(devbyid
$dev),)
1355 devs
[-1]=${devs[-1]%,} # jonied by commas
1357 # on grub upgrade, we get prompts unless we do this
1358 s debconf-set-selections
<<EOF
1359 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1363 # the wiki backup script from ofswiki.org uses generic paths
1364 s lnf
/p
/c
/machine_specific
/li
/mw_vars
/root
1365 s lnf
/k
/backup
/wiki_backup
/root
1367 s cedit
/etc
/goaccess.conf
<<'EOF' || [[ $? == 1 ]]
1368 # all things found from looking around the default config
1369 # copied existing NCSA Combined Log Format with Virtual Host, plus %L
1370 log-format %^:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %D
1371 time-format %H:%M:%S
1372 date-format %d/%b/%Y
1373 log-file /var/log/apache2/access.log
1376 # tip: copy access.log files to a stretch host directory, then run
1377 # jessie's goaccess is too old for some options, and it\'s
1378 # not easily installed from a testing.
1379 # goaccess --ignore-crawlers -f <(cat *) -a -o html > x.html
1385 case `debian-archive` in
1387 s
dd of
=/etc
/apt
/preferences.d
/unison-gtk
<<'EOF'
1388 Explanation: Allow unison-gtk to be upgraded
1390 Pin: release a=testing
1393 # dont think using testing is needed since I figured out how to
1394 # deal with mismatching unison compilers, but I dont
1395 # see any reason to revert it, since it only installs
1396 # a single package which is primarily a single binary
1400 pi unison-gtk
/testing
# after to make it the default unison
1409 # default is alsa, doesn\'t work with with pianobar
1410 s
dd of
=/etc
/libao.conf
<<'EOF'
1411 default_driver=pulse
1416 # note, for jessie, it depends on a higher version of btrfs-tools.
1418 # # disabled due to my patch being in btrbk
1420 # arch|debian|ubuntu) pi btrbk ;;
1425 spa pv
# for progress bar when running interactively.
1426 if [[ $HOSTNAME == treetowl
]]; then
1427 # backup/sync manually on others hosts for now.
1429 # note: to see when it was last run,
1433 if [[ $HOSTNAME == treetowl
]] && [[ `debian-archive` != testing
]]; then
1434 # fail2 ban is broken, with a workaround, per
1435 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770171
1436 # ill wait a while to see if it gets fixed
1446 debian|ubuntu
) s gpasswd
-a ian adm
;; #needed for reading logs
1452 # https://www.torproject.org/docs/rpms.html.en
1453 # https://www.torproject.org/docs/debian.html.en
1454 # todo: figure out if the running service needs to be restarted upon updates
1457 # todo on fedora: setup non-dev packages
1459 s
dd of
=/etc
/yum.repos.d
/torproject.repo
<<'EOF'
1461 name=Tor experimental repo
1463 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1465 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1468 name=Tor experimental source repo
1471 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1473 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1476 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1477 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1479 /a
/bin
/buildscripts
/tor-browser
1482 tu
/etc
/apt
/sources.list
"deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1483 gpg
--keyserver keys.gnupg.net
--recv 886DDD89
1484 gpg
--export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add
-
1486 pi deb.torproject.org-keyring
1488 /a
/bin
/buildscripts
/tor-browser
1492 /a
/bin
/buildscripts
/tor-browser
1495 pi tor tor-browser-en
1505 fedora todo: disable the firewall or find a way to automate it.
1506 there's an unused section in t.org for tramikssion firewall setup
1508 fedora manual config for nfs:
1510 change to permanent configuration
1511 check the box for nfs
1512 was hard to figure this out, not sure if this is all needed, but
1514 mountd: udp/tcp 20048
1515 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1516 troubleshooting, unblock things in rpcinfo -p
1517 make sure to reload the firewall to load the persistent configuration
1528 pi nfs-utils || pending_reboot
=true
1530 # this failed until I rebooted
1535 if [[ $HOSTNAME == treetowl
]]; then
1536 # nohide = export filesystems mounted deeper than the export point
1537 # fsid=0 makes this export the "root" export
1538 # not documented in the man page, but this means
1539 # 1. it can be mounted with a shorthand of server:/
1540 # 2. exports that are subdirectories of this one will automatically be mounted
1541 tu
/etc
/exports
<<'EOF'
1542 /k 192.168.1.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1551 # persistent virtual machines
1559 # distro may not know about win 10 yet.
1561 if ! virt-install
--os-variant list
&>/dev
/null
; then # we are using a newer virt-install
1562 for v
in 10 8.1 8; do
1563 if osinfo-query os | gr
"^\s*win${v/./\\.}\s" &>/dev
/null
; then
1570 if ! s virsh list
--all --name |
grep -xF win10
&>/dev
/null
; then
1572 # created account with
1573 # win10vmian@outlook.com, and easy to remember password
1574 # win 10 virtio, makes disk way way way faster
1575 # wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso
1576 # https://wiki.archlinux.org/index.php/QEMU#Change_Existing_Windows_VM_to_use_virtio
1577 # for installing virtio after initial install instead of with initial iso:
1578 # qemu-img create -f qcow2 fake.qcow2 1G
1579 # --disk=/a/images/virtio-win.iso,device=cdrom \
1580 # --disk=/a/images/fake.qcow2,bus=virtio
1582 # went to device manager, saw 2 pci devices with yellow !,
1583 # did search for drivers, pick cdrom location, done.
1585 # from http://www.tenforums.com/tutorials/4189-fast-startup-turn-off-windows-10-a.html.
1586 # google said there was a control panel option for it, but
1587 # that turned out to be a lie.
1588 # Put this in a .bat file and run as administrator to turn off
1589 # hyberboot which fucks things up.
1590 # REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /V HiberbootEnabled /T REG_dWORD /D 0 /F
1591 # power settings, turn off display: never
1592 # run "control userpasswords2", turn on automatic login.
1593 # note: when changing devices, I just undefine, the create the vm again.
1595 if [[ -e /nocow
/user
/vms
/win10.qcow2
]]; then
1596 s virt-install
--noautoconsole --graphics spice
,listen
=0.0.0.0 \
1597 --disk=/a
/images
/win10.qcow2
,bus
=virtio
--vcpus 2 -r 4096 -w bridge
=br0 \
1598 -n win10
--import --os-variant $variant --cpu host-model-only
1600 s virsh destroy win10
1603 if [[ -e /nocow
/user
/vms
/win7.qcow2
]]; then
1604 # this one hasn\'t had the virtio fix done yet.
1605 s virt-install
--noautoconsole --graphics spice
,listen
=0.0.0.0 \
1606 --disk=/a
/images
/win7.qcow2
--vcpus 2 -r 4096 -w bridge
=br0 \
1607 -n win7
--import --os-variant win7
--cpu host-model-only
1608 s virsh destroy win7
1609 # had a problem with --cpu host, so trying out
1610 # --cpu host-model-only
1615 if [[ $HOSTNAME == treetowl
]]; then
1617 # note samba re-reads it\'s config every 1 minute
1619 arch
) s
cp /etc
/samba
/smb.conf.default
/etc
/samba
/smb.conf
;;
1622 # add 2 lines after workgroup option
1623 s
sed -ri --follow-symlinks '/^\s*encrypt passwords\s*=/d' /etc
/samba
/smb.conf
1624 s
sed -ri --follow-symlinks '/^\s*map to guest\s*=/d' /etc
/samba
/smb.conf
1625 s
sed -i --follow-symlinks 's/\(\s*workgroup\s*=\).*/\1 WORKGROUP\n\tencrypt passwords = yes\n\tmap to guest = bad password/' /etc
/samba
/smb.conf
1626 # remove default homes section. not sharing that.
1627 s
sed -ri --follow-symlinks '/^\s*\[homes\]/,/\s*\[/d' /etc
/samba
/smb.conf
1629 if ! grep -xF '[public]' /etc
/samba
/smb.conf
&>/dev
/null
; then
1630 s
tee -a /etc
/samba
/smb.conf
<<'EOF'
1640 # systemd claims it generates units from /etc/init.d, but it
1641 # clearly doesn\'t in debian. I have no idea how they are
1642 # related. fuck debian right now. It\'s not documented. samba
1643 # has a systemd init file linked to /dev/null. There\'s this
1644 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769714 which
1645 # claims samba\'s sub-services will be started automatically by
1646 # systemd... it didn\'t on install, wonder if it will on
1647 # boot. It clued me in how to start it manually though. Nothing
1648 # in /usr/share/doc/samba, debian admin guide says nothing about
1649 # any of this. (this is in debian testing as of 4/2016).
1651 s
/etc
/init.d
/samba start
1659 tu
/etc
/hosts
<<< "127.0.1.1 $(hostname).lan $(hostname)"
1662 ######### begin stuff belonging at the end ##########
1665 # Apps we want to override others for default file handler:
1666 # simplest way in debian is to just install them last.
1679 pi
"${simple_packages[@]}"
1682 if $pending_reboot; then
1683 echo "$0: pending reboot and then finished. doing it now."
1686 echo "$0: $(date): ending now)"