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 ################
143 # ubuntu 14.04 uses b-cron,
144 # but its not maintained in arch.
145 # of the ones in the main repos, cronie is only one maintained.
146 # fcron appears abandoned software.
150 *) : ;; # other distros come with cron.
180 arch
) spa the_silver_searcher
;;
181 debian|ubuntu
) spa silversearcher-ag
;;
186 debian|ubuntu
) spa ntp
;;
195 # no equivalent in other distros:
199 if ! dpkg
-s apt-file
&>/dev
/null
; then
200 # this condition is just a speed optimization
204 # for debconf-get-selections
210 ubuntu|debian
) spa ack-grep
;;
211 arch|fedora
) spa ack
;;
229 # allows me to pipe with ssh -t, and gets rid of spam
230 # http://forums.debian.net/viewtopic.php?f=5&t=85822
231 # i'd rather disable the service than comment the init file
232 # this says disabling the service, it will still get restarted
233 # but this script doesn't do anything on restart, so it should be fine
234 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
235 # stretch doesn't have initscripts pkg installed by default
236 if [[ $
(debian-codename
) == jessie
]]; then
237 s update-rc.d motd disable
241 # this isn't a complete solution. It still shows me when updates are available,
242 # but it's no big deal.
243 s t
/etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
249 # https://debian-handbook.info/browse/stable/sect.regular-upgrades.html
250 # /etc/cron.daily/apt calls unattended-upgrades
251 # /usr/share/doc/unattended-upgrades# cat README.md
252 # /etc/apt/apt.conf.d/50unattended-upgrades
254 setup-debian-auto-update
257 # we've got a few dependencies later on, so install them now.
258 pi
"${simple_packages[@]}"
264 if isdebian-testing
; then
265 p
install --install-suggests jessie-backports certbot python-certbot-nginx
267 p
install --install-suggests -t jessie-backports certbot python-certbot-nginx
269 # make a version of the certbot timer that emails me.
270 x
=/systemd
/system
/certbot
271 $sed -r -f - /lib
$x.timer
<<'EOF' |s dd of=/etc${x}mail.timer
272 s,^Description.*,\0 mail version,
274 $sed -r -f - /lib
$x.service
<<'EOF' |s dd of=/etc${x}mail.service
275 s,(ExecStart=)(/usr/bin/certbot),\1/a/bin/log-quiet/sysd-mail-once certbotmail \2,
278 sgo certbotmail.timer
281 # todo: other distros unknown
289 lj
) domain
=iank.bid
; exit 0 ;;
290 li
) domain
=iankelling.org
;;
292 /a
/h
/setup.sh
$domain
295 sudo
-E /a
/bin
/mediawiki-setup
/mw-setup-script
298 pi-nostart mumble-server
299 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
304 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
306 Description=Turns on iptables mail nat
311 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
312 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
315 WantedBy=openvpn.service
318 ser
enable vpnmail.service
319 # needed for li's local mail delivery.
320 l
="10.8.0.4 mail.iankelling.org"
321 tu
/etc
/hosts
<<<"$l"
323 domain
=cal.iankelling.org
324 web-conf
-f 10.8.0.4:5232 - apache2
$domain <<'EOF'
325 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
326 <Directory "/var/www/cal.iankelling.org/html">
327 Options +FollowSymLinks +Multiviews +Indexes
330 AuthName "Authentication Required"
331 # setup one time, with root:www-data, 640
332 AuthUserFile "/etc/caldav-htpasswd"
336 # nginx version of above would be:
337 # auth_basic "Not currently available";
338 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
341 ########## begin pump.io setup ##########
343 # once pump adds a logrotation script, turn off nologger,
345 # "logfile": "/var/log/pumpio/pumpio.log",
347 s
dd of
=/etc
/pump.io.json
<<'EOF'
349 "secret": "SECRET_REPLACE_ME",
351 "params": { "dbname": "pumpio" },
353 "site": "pump.iankelling.org",
354 "owner": "Ian Kelling",
355 "ownerURL": "https://iankelling.org/",
358 "hostname": "pump.iankelling.org",
360 "datadir": "/home/pumpio/pumpdata",
361 "enableUploads": true,
362 "debugClient": false,
363 "disableRegistration": true,
365 "key": "/home/pumpio/pump.iankelling.org-domain.key",
366 "cert": "/home/pumpio/pump.iankelling.org-chained.pem",
367 "address": "localhost",
371 s
sed -i "s#SECRET_REPLACE_ME#$(cat /p/c/machine_specific/li/pump-secret)#" /etc
/pump.io.json
373 # jessie\'s node is too old
374 # https://nodejs.org/en/download/package-manager/
375 curl
-sL https
://deb.nodesource.com
/setup_6.x | sudo
-E bash
-
379 git clone https
://github.com
/pump-io
/pump.io.git
381 # note: doing this or the npm install pump.io as root had problems.
384 # normally, next command would be
385 # s npm install -g databank-mongodb
386 # but it\'s this until a bug in pump gets fixed
387 s npm
install -g databank-mongodb@
0.19.2
388 s useradd
-m -s /bin
/false pumpio
389 sudo
-u pumpio mkdir
-p /home
/pumpio
/pumpdata
390 # for testing browser when only listening to localhost,
391 # in the pump.io.json, set hostname localhost, urlPort 5233
392 #ssh -L 5233:localhost:5233 li
394 s mkdir
-p /var
/log
/pumpio
/
395 s chown pumpio
:pumpio
/var
/log
/pumpio
/
397 web-conf
-c /home
/pumpio
- apache2 pump.iankelling.org
<<'EOF'
398 # currently a bug in pump that we cant terminate ssl
401 ProxyPass / https://127.0.0.1:8001/
402 ProxyPassReverse / https://127.0.0.1:8001/
403 # i have sockjs disabled per people suggesting that
404 # it won\'t work with apache right now.
405 # not sure if it would work with this,
406 # but afaik, this is pointless atm.
407 <Location /main/realtime/sockjs/>
408 ProxyPass wss://127.0.0.1:8001/main/realtime/sockjs/
409 ProxyPassReverse wss://127.0.0.1:8001/main/realtime/sockjs/
413 s
dd of
=/etc
/systemd
/system
/pump.service
<<'EOF'
416 After=syslog.target network.target
422 ExecStart=/home/ian/pump.io/bin/pump
423 Environment=NODE_ENV=production
424 # failed to find databank-mongodb without this.
425 # I just looked at my environment variables took a guess.
426 Environment=NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
429 WantedBy=multi-user.target
433 ########## end pump.io setup ############
436 ############# begin setup mastodon ##############
438 # https://store.docker.com/editions/community/docker-ce-server-debian?tab=description
439 pi software-properties-common
440 curl
-fsSL https
://download.docker.com
/linux
/debian
/gpg | sudo apt-key add
-
441 sudo add-apt-repository \
442 "deb [arch=amd64] https://download.docker.com/linux/debian \
448 # this may not be needed
451 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
452 s
chmod +x
/usr
/local
/bin
/docker-compose
454 # i subscrubed to https://github.com/docker/compose/releases.atom
455 # to deal with updates manually.
458 i clone https
://github.com
/tootsuite
/mastodon
460 # https://github.com/tootsuite/mastodon/tree/v1.1.2
461 # subbed to atom feed to deal with updates
464 # per instructions, uncomment redis/postgres persistence in docker-compose.yml
465 sed -i 's/^#//' docker-compose.yml
467 cat >.env.production
<<'EOF'
476 LOCAL_DOMAIN=mast.iankelling.org
479 SINGLE_USER_MODE=true
484 SMTP_FROM_ADDRESS=notifications@mast.iankelling.org
485 SMTP_DOMAIN=mast.iankelling.org
486 SMTP_DELIVERY_METHOD=smtp
489 for key
in PAPERCLIP_SECRET SECRET_KEY_BASE OTP_SECRET
; do
490 printf "%s=%s" $key "$(docker-compose run --rm web rake secret)" >>.env.production
492 s
cat /etc
/mailpass|
while read -r domain port pass
; do
493 if [[ $domain == mail.iankelling.org
]]; then
494 printf "SMTP_PASSWORD=%s" "$pass" >>.env.production
501 docker-compose run
--rm web rails assets
:precompile
503 # docker daemon takes care of starting on boot.
506 s a2enmod proxy_wstunnel headers
507 web-conf
-f 3000 - apache2 mast.iankelling.org
<<'EOF'
509 RequestHeader set X-Forwarded-Proto "https"
510 ProxyPass /500.html !
511 ProxyPass /oops.png !
512 ProxyPass /api/v1/streaming/ ws://localhost:4000/
513 ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
514 ErrorDocument 500 /500.html
515 ErrorDocument 501 /500.html
516 ErrorDocument 502 /500.html
517 ErrorDocument 503 /500.html
518 ErrorDocument 504 /500.html
522 ############### !!!!!!!!!!!!!!!!!
523 ############### manual steps:
525 # only following 2 people atm, so not bothering to figure out backups
526 # when mastodon has not documented it at all.
531 # johns@status.fsf.org
533 # sign in page is at https://mast.iankelling.org/auth/sign_in
534 # register as iank, then
535 # https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Administration-guide.md
536 # docker-compose run --rm web bundle exec rails mastodon:make_admin USERNAME=iank
538 ############# end setup mastodon ##############
542 echo "$0: $(date): ending now)"
548 ########### end section including li/lj ###############
550 if [[ $HOSTNAME == treetowl
]]; then
551 # note, see bashrc for more documentation.
553 s
dd of
=/etc
/systemd
/system
/rss2email.service
<<'EOF'
555 Description=rss2email
556 After=multi-user.target
561 # about 24 hours of failures
562 # it copies over its files without respecting symlinks, so
563 # we pass options to use different location.
564 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run
566 s
dd of
=/etc
/systemd
/system
/rss2email.timer
<<'EOF'
568 Description=rss2email
571 # for initial run. required.
573 # for subsequent runs.
574 OnUnitInactiveSec=300
577 WantedBy=timers.target
579 s systemctl daemon-reload
583 ######### begin pump.io periodic backup #############
584 if [[ $HOSTNAME == treetowl
]]; then
585 s
dd of
=/etc
/systemd
/system
/pumpbackup.service
<<'EOF'
587 Description=pump li backup
588 After=multi-user.target
593 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
595 s
dd of
=/etc
/systemd
/system
/pumpbackup.timer
<<'EOF'
597 Description=pump li backup hourly
603 WantedBy=timers.target
605 s systemctl daemon-reload
608 ######### end pump.io periodic backup #############
612 # suggests because we want the resolvconf package.
613 # todo: check other distros to make sure it\'s installed
614 pi-nostart
--install-suggests openvpn
615 # pi-nostart does not disable
621 if private-host
; then
622 vpn-mk-client-cert
-n mail li
623 cn
=$
(s openssl x509
-noout -nameopt multiline
-subject \
624 -in /etc
/openvpn
/client
/mail.crt | \
625 sed -rn 's/^\s*commonName\s*=\s*(.*)/\1/p')
626 echo "ifconfig-push 10.8.0.4 255.255.255.0" | \
627 ssh root@li
dd of
=/etc
/openvpn
/client-config
/"$cn"
630 if [[ $HOSTNAME == treetowl
]]; then
631 # note, this will need to be changed when the mail/contacts host changes
632 sgo openvpn-client@
mail
633 /a
/bin
/distro-setup
/radicale-setup
636 ## android studio setup
637 # this contains the setting for android sdk to point to
638 # /a/opt/androidsdk, which is asked upon first run
639 lnf
/a
/opt
/.AndroidStudio2.2 ~
640 # android site says it needs a bunch of packages for ubuntu,
641 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
643 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
644 # see w.org for more android studio details
645 spa lib32stdc
++6 default-jdk
648 if [[ $HOSTNAME == treetowl
]]; then
649 ############# begin syncthing setup ###########
651 # It\'s simpler to just worry about running it in one place for now.
652 # I assume it would work to clone it\'s config to another non-phone
653 # and just run it in one place instead of the normal having a
654 # separate config. I lean toward using the same config, since btrfs
655 # syncs between comps.
657 arch
) pi syncthing
;;
659 # testing has relatively up to date packages
660 if ! isdebian-testing
; then
661 # based on error when doing apt-get update:
662 # E: The method driver /usr/lib/apt/methods/https could not be found.
663 pi apt-transport-https
664 # google led me here:
665 # https://apt.syncthing.net/
666 curl
-s https
://syncthing.net
/release-key.txt | sudo apt-key add
-
667 s
="deb http://apt.syncthing.net/ syncthing release"
668 if [[ $
(cat /etc
/apt
/sources.list.d
/syncthing.list
) != $s ]]; then
669 echo "$s" | s
dd of
=/etc
/apt
/sources.list.d
/syncthing.list
676 lnf
-T /w
/syncthing
/home
/ian
/.config
/syncthing
677 sgo syncthing@ian
# runs as ian
679 # these things persist in ~/.config/syncthing, which I save in
680 # /w/syncthing (not in /p, because syncthing should continue to
681 # run on home server even when using laptop as primary device)
682 # open http://localhost:8384/
683 # change listen address from default to tcp://:22001,
684 # this is because we do port forward so it doesn\'t have to use
685 # some external server, but the syncthing is broken for port forward,
686 # you get a message, something "like connected to myself, this should not happen"
687 # when connecting to other local devices, so I bump the port up by 1,
689 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
690 # Without this, it was being stuck syncing at 0%.
691 # Set gui username and password.
693 # install syncthing via f-droid,
694 # folder setting, turn off master folder (makes it read only).
695 # on phone, add device, click bar code icon
696 # on dekstop, top right, actions, device id
697 # after adding, notification will appear on desktop to confirm
699 # syncing folder. from phone to desktop: select desktop in the
700 # folder on phone\'s sync options, notification will appear in
701 # desktop\'s web ui within a minute. For the reverse, the
702 # notification will appear in android\'s notifications, you have to
703 # swipe down and tap it to add the folder. It won\'t appear in the
704 # syncthing ui, which would be intuitive, but don\'t wait for it
707 # On phone, set settings to run syncthing all the time, and
708 # show no notification.
710 # Folder versioning would make sense if I didn\'t already use btrfs
711 # for backups. I would choose staggered, or trash can for more space.
713 # if needed to install on a remote comp:
714 # ssh -L 8384:localhost:8384 -N frodo
715 # open http://localhost:8384/
717 # Note, the other thing i did was port forward port 22000,
718 # per https://docs.syncthing.net/users/firewall.html
720 ############# end syncthing setup ###########
725 # no equivalent in other distros:
728 # for gui bug reporting
734 ####### misc packages ###########
736 if [[ $HOSTNAME == treetowl
]]; then
739 # note i had to do this, which is persistent:
741 # s chgrp debian-transmission torrents partial-torrents
743 # syslog says things like
744 # 'Failed to set receive buffer: requested 4194304, got 425984'
745 # google suggets giving it even more than that
746 tu
/etc
/sysctl.conf
<<'EOF'
747 net.core.rmem_max = 67108864
748 net.core.wmem_max = 16777216
752 # some reason it doesn\'t seem to start automatically anyways
753 pi-nostart transmission-daemon
755 # the folder was moved here after an install around 02/2017.
756 # it contains runtime data,
757 # plus a simple symlink to the config file which it\'s
758 # not worth separating out.
759 s lnf
-T /i
/transmission-daemon
/var
/lib
/transmission-daemon
/.config
/transmission-daemon
761 # config file documented here, and it\'s the same config
762 # for daemon vs client, so it\'s documented in the gui.
763 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
765 # I originaly setup rpc-whitelist, but after using
766 # routing to a network namespace, it doesn\'t see the
767 # real source address, so it\'s disabled.
769 # Changed the cache-size to 256 mb, reduces disk use.
770 # It is a read & write cache.
774 p = '/etc/transmission-daemon/settings.json'
775 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
776 'rpc-whitelist-enabled' => false,
777 'rpc-authentication-required' => false,
778 'incomplete-dir' => '/i/k/partial-torrents',
779 'incomplete-dir-enabled' => true,
780 'download-dir' => '/i/k/torrents',
781 "speed-limit-up" => 800,
782 "speed-limit-up-enabled" => true,
783 "peer-port" => 61486,
784 "cache-size-mb" => 256,
785 "ratio-limit" => 5.0,
786 "ratio-limit-enabled" => true,
790 # make sure its not enabled, not sure if this is needed
791 ser disable transmission-daemon
792 sgo transmission-daemon-nn
794 # todo: others unknown
798 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
799 if ! getent passwd debian-transmission
> /dev
/null
; then
805 --home-dir /var
/lib
/transmission-daemon \
814 --disabled-password \
815 --home /var
/lib
/transmission-daemon \
821 # dunno why it\'s there, but get rid of it
823 li|lj
) s
rm -rf /home
/linode
;;
826 # arch had a default config,
827 # debian had nothing until you start it.
828 # With a little trial an error, here is a minimal config
829 # taken from the generated one, plus changes that the
830 # settings ui does, without a bunch of ui crap settings.
832 # only settings I set were
838 # the password is randomly generated on first run
839 rpc_pass
=$
(s ruby
<<'EOF'
841 p = '/etc/transmission-daemon/settings.json'
842 puts JSON.parse(File.read(p))["rpc-password"]
847 d
=$f/.config
/transmission-remote-gtk
850 s
-u $u dd of
=$d/config.json
<<EOF
854 "profile-name" : "Default",
855 "hostname" : "transmission",
856 "rpc-url-path" : "/transmission/rpc",
858 "password" : "$rpc_pass",
859 "auto-connect" : true,
863 "update-active-only" : false,
864 "activeonly-fullsync-enabled" : false,
865 "activeonly-fullsync-every" : 2,
866 "update-interval" : 3,
867 "min-update-interval" : 3,
868 "session-update-interval" : 60,
876 "add-options-dialog" : false
888 wget
-nv -N https
://dl.google.com
/linux
/direct
/google-chrome-stable_current_amd64.deb
891 s dpkg
-i google-chrome-stable_current_amd64.deb |
& tee $log
897 # previously I had a more specific search, but dpkg
898 # changed it\'s output as of 7/2016
899 if grep 'dependency problems' \
900 $log &>/dev
/null
; then
901 s apt-get
-fy install
918 pi cups ghostscript gsfonts
# from arch wiki cups page
919 pi hplip
# from google
920 s gpasswd
-a $USER sys
# from arch wiki
921 sgo org.cups.cupsd.service
922 # goto http://127.0.0.1:631
923 # administration tab, add new printer button.
924 # In debian, I could use hte recommended driver,
925 # in arch, I had to pick out the 6L driver.
930 # other distros unknown
935 ubuntu|debian
) pi
--no-install-recommends mairix notmuch
;;
936 fedora|arch
) spa mairix notmuch
;;
939 arch
) spa nfs-utils
;;
940 ubuntu|debian
) spa nfs-client
;;
943 ubuntu|debian
) spa par2
;;
944 arch|fedora
) spa par2cmdline
;;
947 # needed for my tex resume
949 ubuntu|debian
) spa texlive-full
;;
950 arch
) spa texlive-most
;;
956 # flash, unrar, codecs, ms fonts.
957 # This has a manual prompt.
958 spa ubuntu-restricted-extras
962 # rpm fusion recommended codecs
963 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"
964 pi gstreamer-plugins-ugly gstreamer-plugins-bad gstreamer-ffmpeg\
965 xine-lib-extras-freeworld
970 # optional dep for firefox for h.264 video
971 arch
) spa gst-libav
;;
972 # other distros, probably come by default
976 fedora|ubuntu|debian
) spa gnupg-agent
;;
982 fedora
) spa pinentry-gtk
;;
983 *) : ;; # comes default or with other packages
987 arch
) spa firefox pulseaudio
;;
988 *) : ;; # comes default or with other packages
993 arch
) spa ttf-dejavu
;;
994 debian|ubuntu
) spa fonts-dejavu
;;
1000 arch
) spa xorg-xev
;;
1001 debian|ubuntu
) spa x11-utils
;;
1006 arch
) pi virt-install
;;&
1007 debian|ubuntu
) pi virtinst
;;&
1008 *) pi virt-manager
;; # creates the libvirt group in debian at least
1011 # allow user to run vms, from debian handbook
1012 for x
in ian traci
; do s usermod
-a -G libvirt
,kvm
$x; done
1013 # bridge networking as user fails. google lead here, but it doesn\'t work:
1014 # oh well, I give up.
1015 # http://wiki.qemu.org/Features-Done/HelperNetworking
1017 # f=/etc/qemu/bridge.conf
1018 # s dd of=$f <<'EOF'
1021 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1027 debian|ubuntu
) spa genisoimage
;;
1032 arch
) spa spice-gtk3
;;
1033 debian|ubuntu
) spa spice-client-gtk
;;
1037 # general known for debian/ubuntu, not for fedora
1042 # a bit of googling, and added settings to bashrc
1043 go get
-u github.com
/mvdan
/fdroidcl
/cmd
/fdroidcl
1051 # cdrkit for cloud-init isos
1052 # dnsmasq & ebtables for nat networking in libvirt
1053 # qemu for qemu-img, bind-tools for dig
1054 # dmidecode just because syslog complains
1055 pi
unzip xorg-xmodmap dmidecode ebtables\
1056 bridge-utils dnsmasq qemu bind-tools
1057 # otherwise we get error about accessing kvm module.
1058 # seems like there might be a better way, but google was a bit vague.
1059 s
$sed -ri '/^ *user *=/d' /etc
/libvirt
/qemu.conf
1060 echo 'user = "root"' | s
tee -a /etc
/libvirt
/qemu.conf
1061 # https://bbs.archlinux.org/viewtopic.php?id=206206
1062 # # this should prolly go in the wiki
1064 # guessing this is not needed
1065 #sgo virtlogd.service
1072 arch
) pi virtviewer
;;
1073 *) : ;; # other distros have it as a dependency afaik.
1079 fedora
) cabal
install shellcheck
;;
1080 *) spa shellcheck
;;
1081 # unknown for older ubuntu
1086 arch|debian|ubuntu
) spa pumpa
;;
1087 # others unknown. do have a buildscript:
1088 # /a/bin/buildscripts/pumpa ;;
1093 debian|ubuntu
) spa android-tools-adbd
/unstable
;;
1094 arch
) spa android-tools
;;
1095 # other distros unknown
1098 if [[ $HOSTNAME == treetowl
]]; then
1101 if [[ `debian-archive` == testing
]]; then
1102 # has no unstable dependencies
1103 pi bitcoind
/unstable
1104 src
=/a
/opt
/bitcoin
/contrib
/init
/bitcoind.service
1105 s
cp $src /etc
/systemd
/system
1106 p
=/etc
/bitcoin
/bitcoin
1107 dst
=/etc
/systemd
/system
/bitcoinjm.service
1109 $sed -r "/^\s*ExecStart/s,${p}.conf,${p}jm.conf," $src \
1110 >/etc
/systemd
/system
/bitcoinjm.service
1112 d
=jm
; jm
=d
# being clever for succinctness
1114 s
$sed -ri "/^\s*\[Unit\]/a Conflicts=bitcoin${!s}.service" \
1115 /etc
/systemd
/system
/bitcoin
${s}.service
1122 s chown
-R bitcoin
:bitcoin
$dir
1125 s chown
-R root
:bitcoin
$dir
1128 # pruning decreases the bitcoin dir to 2 gb, keeps
1129 # just the recent blocks. can\'t do a few things like
1130 # import a wallet dump.
1131 # pruning works, but people had to do
1132 # some manual stuff in joinmarket. I dun need the
1133 # disk space, so not bothering yet, maybe in a year or so.
1134 # https://github.com/JoinMarket-Org/joinmarket/issues/431
1135 #https://bitcoin.org/en/release/v0.12.0#wallet-pruning
1141 rpcpassword=$(openssl rand -base64 32)
1142 rpcuser=$(openssl rand -base64 32)
1146 f2
=$dir/bitcoinjm.conf
1148 s
tee -a $f2 >/dev
/null
<<EOF
1150 walletnotify=curl -sI --connect-timeout 1 http://localhost:62602/walletnotify?%s
1151 alertnotify=curl -sI --connect-timeout 1 http://localhost:62602/alertnotify?%s
1152 wallet=joinmarket.dat
1154 # dunno about sharing a wallet between multiple instances
1155 # manually did, wallet.dat symlinked in /nocow/.bitcoin
1159 # other distros unknown
1161 pi libsodium-dev python-pip
1162 cd /a
/opt
/joinmarket
1163 # using develop branch, as it seems to be mostly bug fixes,
1164 # and this is quite new software.
1165 # note: python3 does not work.
1166 # has seg fault error due to some bug, but it still works
1167 pip
install -r requirements.txt ||
[[ $?
== 139 ]]
1168 # note, the target must exist ahead of time, or bitcoin
1169 # just overwrites the link, and it\'s not happy with an empty file,
1170 # so we have to create the wallet, then move and link it.
1171 s lnf
-T /q
/bitcoin
/wallet.dat
/nocow
/.bitcoin
/wallet.dat
1172 s lnf
-T /q
/bitcoin
/joinmarket.dat
/nocow
/.bitcoin
/joinmarket.dat
1173 # not technically needed, but seems cleaner not to have
1174 # symlinks be root owned unlike everything else
1175 s chown
-h bitcoin
:bitcoin
/nocow
/.bitcoin
/*
1177 for var
in rpcuser rpcpassword
; do
1178 u
="$(s sed -rn "s
/^
$var=(.
*)/\
1/p
" /etc/bitcoin/bitcoin.conf)"
1179 # escape backslashes
1180 u
="${u//\\/\\\\\\\\}"
1183 sed -ri "s,^(rpc_${var#rpc}\s*=).*,\1 $u," joinmarket.cfg
1185 sed -ri "s/^\s*(blockchain_source\s*=).*/\1 bitcoin-rpc/" joinmarket.cfg
1194 wget http
://tamacom.com
/global
/global-6.3
.2.
tar.gz
1197 # based on https://github.com/leoliu/ggtags
1198 .
/configure
--with-exuberant-ctags=/usr
/bin
/ctags
1201 s pip
install pygments
1217 pi task-cinnamon-desktop
1218 # in settings, change scrolling to two-finger,
1219 # because the default edge scroll doesn\'t work.
1228 # already in debian jessie
1234 # note this failed running at the beginning of this file,
1235 # because no systemd user instance was running.
1236 # Doing systemd --user resulted in
1237 # Trying to run as user instance, but $XDG_RUNTIME_DIR is not set
1239 if isdebian-testing
; then
1240 # as of 7/2016, has no unstable deps, and is not in testing anymore.
1247 # # ubuntu unknown. probably the same as debian, just check if the
1248 # # init scripts come with the package.
1250 # # copied from arch, but moved to etc
1251 # s dd of=/etc/systemd/user/synergys.service <<'EOF'
1253 # Description=Synergy Server Daemon
1254 # After=network.target
1258 # ExecStart=/usr/bin/synergys --no-daemon --config /etc/synergy.conf
1259 # Restart=on-failure
1262 # WantedBy=multi-user.target
1264 # s dd of=/etc/systemd/user/synergys.socket <<'EOF'
1266 # Conflicts=synergys@.service
1269 # ListenStream=24800
1273 # WantedBy=sockets.target
1275 # # had this fail with 'Failed to connect to bus: No such file or directory'
1276 # # then when I tried it manually, it worked fine...
1277 # if ! systemctl --user daemon-reload; then
1279 # echo retrying systemd user daemon reload
1280 # systemctl --user daemon-reload
1284 # # taken from arch wiki.
1285 # s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
1287 # Description=Synergy Client
1288 # After=network.target
1292 # ExecStart=/usr/bin/synergyc --no-daemon frodo
1293 # Restart=on-failure
1294 # # per man systemd.unit, StartLimitInterval, by default we
1295 # # restart more than 5 times in 10 seconds.
1296 # # And this param defaults too 200 miliseconds.
1300 # WantedBy=multi-user.target
1302 # s systemctl daemon-reload
1305 # ser enable synergyc@ian
1306 # ser start synergyc@ian ||: # X might not be running yet
1309 # systemctl --user start synergys ||:
1310 # systemctl --user enable synergys
1317 ######### end misc packages #########
1320 # packages I once used before and liked, but don\'t want installed now for
1322 # python-sqlite is used for offlineimap
1323 # lxappearance python-sqlite dolphin paman dconf-editor
1329 # todo, finish configuring smart.
1332 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1333 # turn on smart. background on options:
1334 # first line, -a = test everyting on all devices.
1335 # -S on, turn on disk internal saving of vendor specific info,
1336 # from google, seems like this is usually already on and fairly standard.
1337 # -o on, turn on 4 hour period non-performance degrading testing.
1338 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1339 sched
="-s (S/../.././02|L/../../6/03)"
1340 s
sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1341 DEVICESCAN -a -o on -S on -n standby,q $sched \
1342 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc
/smartd.conf
1344 # in the default configuration of at least ubuntu 14.04, resolvconf is
1345 # configured to order any nameservers associated with tun* or tap*
1346 # before the normal internet interfaces, which means they are always
1347 # consulted first. This is often slower and undesirable, ie. local dns
1348 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1350 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1351 # however, this breaks dns lookup for hosts on the openvpn lan.
1352 # I can\'t figure out why hosts on the normal lan would not be
1353 # broken under the default ordering, except the host I was
1354 # testing with previously had an entry in /etc/hosts.
1356 ############# end unfinished
1358 ########### misc stuff
1361 for dev
in $
(s btrfs
fi show
/boot |
sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1362 devs
+=($
(devbyid
$dev),)
1364 devs
[-1]=${devs[-1]%,} # jonied by commas
1366 # on grub upgrade, we get prompts unless we do this
1367 s debconf-set-selections
<<EOF
1368 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1372 # the wiki backup script from ofswiki.org uses generic paths
1373 s lnf
/p
/c
/machine_specific
/li
/mw_vars
/root
1374 s lnf
/k
/backup
/wiki_backup
/root
1376 s cedit
/etc
/goaccess.conf
<<'EOF' || [[ $? == 1 ]]
1377 # all things found from looking around the default config
1378 # copied existing NCSA Combined Log Format with Virtual Host, plus %L
1379 log-format %^:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %D
1380 time-format %H:%M:%S
1381 date-format %d/%b/%Y
1382 log-file /var/log/apache2/access.log
1385 # tip: copy access.log files to a stretch host directory, then run
1386 # jessie's goaccess is too old for some options, and it\'s
1387 # not easily installed from a testing.
1388 # goaccess --ignore-crawlers -f <(cat *) -a -o html > x.html
1394 case `debian-archive` in
1396 s
dd of
=/etc
/apt
/preferences.d
/unison-gtk
<<'EOF'
1397 Explanation: Allow unison-gtk to be upgraded
1399 Pin: release a=testing
1402 # dont think using testing is needed since I figured out how to
1403 # deal with mismatching unison compilers, but I dont
1404 # see any reason to revert it, since it only installs
1405 # a single package which is primarily a single binary
1409 pi unison-gtk
/testing
# after to make it the default unison
1418 # default is alsa, doesn\'t work with with pianobar
1419 s
dd of
=/etc
/libao.conf
<<'EOF'
1420 default_driver=pulse
1425 # note, for jessie, it depends on a higher version of btrfs-tools.
1427 # # disabled due to my patch being in btrbk
1429 # arch|debian|ubuntu) pi btrbk ;;
1434 spa pv
# for progress bar when running interactively.
1435 if [[ $HOSTNAME == treetowl
]]; then
1436 # backup/sync manually on others hosts for now.
1438 # note: to see when it was last run,
1442 if [[ $HOSTNAME == treetowl
]] && [[ `debian-archive` != testing
]]; then
1443 # fail2 ban is broken, with a workaround, per
1444 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770171
1445 # ill wait a while to see if it gets fixed
1455 debian|ubuntu
) s gpasswd
-a ian adm
;; #needed for reading logs
1461 # https://www.torproject.org/docs/rpms.html.en
1462 # https://www.torproject.org/docs/debian.html.en
1463 # todo: figure out if the running service needs to be restarted upon updates
1466 # todo on fedora: setup non-dev packages
1468 s
dd of
=/etc
/yum.repos.d
/torproject.repo
<<'EOF'
1470 name=Tor experimental repo
1472 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1474 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1477 name=Tor experimental source repo
1480 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1482 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1485 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1486 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1488 /a
/bin
/buildscripts
/tor-browser
1491 tu
/etc
/apt
/sources.list
"deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1492 gpg
--keyserver keys.gnupg.net
--recv 886DDD89
1493 gpg
--export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add
-
1495 pi deb.torproject.org-keyring
1497 /a
/bin
/buildscripts
/tor-browser
1501 /a
/bin
/buildscripts
/tor-browser
1504 pi tor tor-browser-en
1514 fedora todo: disable the firewall or find a way to automate it.
1515 there's an unused section in t.org for tramikssion firewall setup
1517 fedora manual config for nfs:
1519 change to permanent configuration
1520 check the box for nfs
1521 was hard to figure this out, not sure if this is all needed, but
1523 mountd: udp/tcp 20048
1524 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1525 troubleshooting, unblock things in rpcinfo -p
1526 make sure to reload the firewall to load the persistent configuration
1537 pi nfs-utils || pending_reboot
=true
1539 # this failed until I rebooted
1544 if [[ $HOSTNAME == treetowl
]]; then
1545 # nohide = export filesystems mounted deeper than the export point
1546 # fsid=0 makes this export the "root" export
1547 # not documented in the man page, but this means
1548 # 1. it can be mounted with a shorthand of server:/
1549 # 2. exports that are subdirectories of this one will automatically be mounted
1550 tu
/etc
/exports
<<'EOF'
1551 /k 192.168.1.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1560 # persistent virtual machines
1568 # distro may not know about win 10 yet.
1570 if ! virt-install
--os-variant list
&>/dev
/null
; then # we are using a newer virt-install
1571 for v
in 10 8.1 8; do
1572 if osinfo-query os | gr
"^\s*win${v/./\\.}\s" &>/dev
/null
; then
1579 if ! s virsh list
--all --name |
grep -xF win10
&>/dev
/null
; then
1581 # created account with
1582 # win10vmian@outlook.com, and easy to remember password
1583 # win 10 virtio, makes disk way way way faster
1584 # wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso
1585 # https://wiki.archlinux.org/index.php/QEMU#Change_Existing_Windows_VM_to_use_virtio
1586 # for installing virtio after initial install instead of with initial iso:
1587 # qemu-img create -f qcow2 fake.qcow2 1G
1588 # --disk=/a/images/virtio-win.iso,device=cdrom \
1589 # --disk=/a/images/fake.qcow2,bus=virtio
1591 # went to device manager, saw 2 pci devices with yellow !,
1592 # did search for drivers, pick cdrom location, done.
1594 # from http://www.tenforums.com/tutorials/4189-fast-startup-turn-off-windows-10-a.html.
1595 # google said there was a control panel option for it, but
1596 # that turned out to be a lie.
1597 # Put this in a .bat file and run as administrator to turn off
1598 # hyberboot which fucks things up.
1599 # REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /V HiberbootEnabled /T REG_dWORD /D 0 /F
1600 # power settings, turn off display: never
1601 # run "control userpasswords2", turn on automatic login.
1602 # note: when changing devices, I just undefine, the create the vm again.
1604 if [[ -e /nocow
/user
/vms
/win10.qcow2
]]; then
1605 s virt-install
--noautoconsole --graphics spice
,listen
=0.0.0.0 \
1606 --disk=/a
/images
/win10.qcow2
,bus
=virtio
--vcpus 2 -r 4096 -w bridge
=br0 \
1607 -n win10
--import --os-variant $variant --cpu host-model-only
1609 s virsh destroy win10
1612 if [[ -e /nocow
/user
/vms
/win7.qcow2
]]; then
1613 # this one hasn\'t had the virtio fix done yet.
1614 s virt-install
--noautoconsole --graphics spice
,listen
=0.0.0.0 \
1615 --disk=/a
/images
/win7.qcow2
--vcpus 2 -r 4096 -w bridge
=br0 \
1616 -n win7
--import --os-variant win7
--cpu host-model-only
1617 s virsh destroy win7
1618 # had a problem with --cpu host, so trying out
1619 # --cpu host-model-only
1624 if [[ $HOSTNAME == treetowl
]]; then
1626 # note samba re-reads it\'s config every 1 minute
1628 arch
) s
cp /etc
/samba
/smb.conf.default
/etc
/samba
/smb.conf
;;
1631 # add 2 lines after workgroup option
1632 s
sed -ri --follow-symlinks '/^\s*encrypt passwords\s*=/d' /etc
/samba
/smb.conf
1633 s
sed -ri --follow-symlinks '/^\s*map to guest\s*=/d' /etc
/samba
/smb.conf
1634 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
1635 # remove default homes section. not sharing that.
1636 s
sed -ri --follow-symlinks '/^\s*\[homes\]/,/\s*\[/d' /etc
/samba
/smb.conf
1638 if ! grep -xF '[public]' /etc
/samba
/smb.conf
&>/dev
/null
; then
1639 s
tee -a /etc
/samba
/smb.conf
<<'EOF'
1649 # systemd claims it generates units from /etc/init.d, but it
1650 # clearly doesn\'t in debian. I have no idea how they are
1651 # related. fuck debian right now. It\'s not documented. samba
1652 # has a systemd init file linked to /dev/null. There\'s this
1653 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769714 which
1654 # claims samba\'s sub-services will be started automatically by
1655 # systemd... it didn\'t on install, wonder if it will on
1656 # boot. It clued me in how to start it manually though. Nothing
1657 # in /usr/share/doc/samba, debian admin guide says nothing about
1658 # any of this. (this is in debian testing as of 4/2016).
1660 s
/etc
/init.d
/samba start
1668 tu
/etc
/hosts
<<< "127.0.1.1 $(hostname).lan $(hostname)"
1671 ######### begin stuff belonging at the end ##########
1674 # Apps we want to override others for default file handler:
1675 # simplest way in debian is to just install them last.
1688 pi
"${simple_packages[@]}"
1691 if $pending_reboot; then
1692 echo "$0: pending reboot and then finished. doing it now."
1695 echo "$0: $(date): ending now)"