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.
120 transmission-remote-gtk
124 spa $
(apt-cache search ruby
[.0-9]+-doc|
awk '{print $1}')
129 ########### begin section including li ################
134 if [[ `debian-archive` == testing
]]; then
147 # ubuntu 14.04 uses b-cron,
148 # but its not maintained in arch.
149 # of the ones in the main repos, cronie is only one maintained.
150 # fcron appears abandoned software.
154 *) : ;; # other distros come with cron.
184 arch
) spa the_silver_searcher
;;
185 debian|ubuntu
) spa silversearcher-ag
;;
190 debian|ubuntu
) spa ntp
;;
199 # no equivalent in other distros:
203 if ! dpkg
-s apt-file
&>/dev
/null
; then
204 # this condition is just a speed optimization
208 # for debconf-get-selections
214 ubuntu|debian
) spa ack-grep
;;
215 arch|fedora
) spa ack
;;
231 case $
(distro-name
) in
233 # allows me to pipe with ssh -t, and gets rid of spam
234 # http://forums.debian.net/viewtopic.php?f=5&t=85822
235 # i'd rather disable the service than comment the init file
236 # this says disabling the service, it will still get restarted
237 # but this script doesn't do anything on restart, so it should be fine
238 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
239 # stretch doesn't have initscripts pkg installed by default
240 if [[ $
(debian-codename
) == jessie
]]; then
241 s update-rc.d motd disable
245 # this isn't a complete solution. It still shows me when updates are available,
246 # but it's no big deal.
247 s t
/etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
253 # https://debian-handbook.info/browse/stable/sect.regular-upgrades.html
254 # /etc/cron.daily/apt calls unattended-upgrades
255 # /usr/share/doc/unattended-upgrades# cat README.md
256 # /etc/apt/apt.conf.d/50unattended-upgrades
258 setup-debian-auto-update
261 # we've got a few dependencies later on, so install them now.
262 pi
"${simple_packages[@]}"
270 lj
) domain
=iank.bid
; exit 0 ;;
271 li
) domain
=iankelling.org
;;
273 /a
/h
/setup.sh
$domain
276 sudo
-E /a
/bin
/mediawiki-setup
/mw-setup-script
279 pi-nostart mumble-server
280 s
$sed -ri "s/^ *(serverpassword=).*/\1$(< /a/bin/bash_unpublished/mumble_pass)/" /etc
/mumble-server.ini
285 sudo
dd of
=/etc
/systemd
/system
/vpnmail.service
<<EOF
287 Description=Turns on iptables mail nat
292 ExecStart=/a/bin/distro-setup/vpn-mail-forward start
293 ExecStop=/a/bin/distro-setup/vpn-mail-forward stop
296 WantedBy=openvpn.service
299 ser
enable vpnmail.service
300 acme-tiny-wrapper
mail.iankelling.org
301 # needed for li's local mail delivery. there might
302 # be a better way to do it that doesn't require disabling
303 # it during le verification, but whatever for now.
304 f
=/etc
/cron.daily
/lets-encrypt-mail_iankelling_org
305 l
="10.8.0.4 mail.iankelling.org"
306 tu
/etc
/hosts
<<<"$l"
307 s
sed -i '/^\s*sysv acme-tiny-wrapper/i sed -i /^10\.8\.0\.4/d /etc/hosts' $f
308 echo "echo $l >>/etc/hosts" | s
tee -a $f
310 domain
=cal.iankelling.org
311 acme-tiny-wrapper
$domain
312 apache-site
-f 10.8.0.4:5232 - $domain <<'EOF'
313 #https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
314 <Directory "/var/www/cal.iankelling.org/html">
315 Options +FollowSymLinks +Multiviews +Indexes
318 AuthName "Authentication Required"
319 # setup one time, with root:www-data, 640
320 AuthUserFile "/etc/caldav-htpasswd"
324 # nginx version of above would be:
325 # auth_basic "Not currently available";
326 # auth_basic_user_file /etc/nginx/caldav/htpasswd;
329 ########## begin pump.io setup ##########
331 # once pump adds a logrotation script, turn off nologger,
333 # "logfile": "/var/log/pumpio/pumpio.log",
335 s
dd of
=/etc
/pump.io.json
<<'EOF'
337 "secret": "SECRET_REPLACE_ME",
339 "params": { "dbname": "pumpio" },
341 "site": "pump.iankelling.org",
342 "owner": "Ian Kelling",
343 "ownerURL": "https://iankelling.org/",
346 "hostname": "pump.iankelling.org",
348 "datadir": "/home/pumpio/pumpdata",
349 "enableUploads": true,
350 "debugClient": false,
351 "disableRegistration": true,
353 "key": "/home/pumpio/pump.iankelling.org-domain.key",
354 "cert": "/home/pumpio/pump.iankelling.org-chained.pem",
355 "address": "localhost",
359 s
sed -i "s#SECRET_REPLACE_ME#$(cat /p/c/machine_specific/li/pump-secret)#" /etc
/pump.io.json
361 # jessie\'s node is too old
362 # https://nodejs.org/en/download/package-manager/
363 curl
-sL https
://deb.nodesource.com
/setup_6.x | sudo
-E bash
-
367 git clone https
://github.com
/pump-io
/pump.io.git
369 # note: doing this or the npm install pump.io as root had problems.
372 # normally, next command would be
373 # s npm install -g databank-mongodb
374 # but it\'s this until a bug in pump gets fixed
375 s npm
install -g databank-mongodb@
0.19.2
376 s useradd
-m -s /bin
/false pumpio
377 sudo
-u pumpio mkdir
-p /home
/pumpio
/pumpdata
378 # for testing browser when only listening to localhost,
379 # in the pump.io.json, set hostname localhost, urlPort 5233
380 #ssh -L 5233:localhost:5233 li
381 acme-tiny-wrapper
-c /home
/pumpio pump.iankelling.org
383 s mkdir
-p /var
/log
/pumpio
/
384 s chown pumpio
:pumpio
/var
/log
/pumpio
/
386 apache-site
-c /home
/pumpio
- pump.iankelling.org
<<'EOF'
387 # currently a bug in pump that we cant terminate ssl
390 ProxyPass / https://127.0.0.1:8001/
391 ProxyPassReverse / https://127.0.0.1:8001/
392 # i have sockjs disabled per people suggesting that
393 # it won\'t work with apache right now.
394 # not sure if it would work with this,
395 # but afaik, this is pointless atm.
396 <Location /main/realtime/sockjs/>
397 ProxyPass wss://127.0.0.1:8001/main/realtime/sockjs/
398 ProxyPassReverse wss://127.0.0.1:8001/main/realtime/sockjs/
402 s
dd of
=/etc
/systemd
/system
/pump.service
<<'EOF'
405 After=syslog.target network.target
411 ExecStart=/home/ian/pump.io/bin/pump
412 Environment=NODE_ENV=production
413 # failed to find databank-mongodb without this.
414 # I just looked at my environment variables took a guess.
415 Environment=NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
418 WantedBy=multi-user.target
422 ########## end pump.io setup ############
425 ############# begin setup mastodon ##############
427 # https://store.docker.com/editions/community/docker-ce-server-debian?tab=description
428 pi software-properties-common
429 curl
-fsSL https
://download.docker.com
/linux
/debian
/gpg | sudo apt-key add
-
430 sudo add-apt-repository \
431 "deb [arch=amd64] https://download.docker.com/linux/debian \
437 # this may not be needed
440 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
441 s
chmod +x
/usr
/local
/bin
/docker-compose
443 # i subscrubed to https://github.com/docker/compose/releases.atom
444 # to deal with updates manually.
447 i clone https
://github.com
/tootsuite
/mastodon
449 # https://github.com/tootsuite/mastodon/tree/v1.1.2
450 # subbed to atom feed to deal with updates
453 # per instructions, uncomment redis/postgres persistence in docker-compose.yml
454 sed -i 's/^#//' docker-compose.yml
456 cat >.env.production
<<'EOF'
465 LOCAL_DOMAIN=mast.iankelling.org
468 SINGLE_USER_MODE=true
473 SMTP_FROM_ADDRESS=notifications@mast.iankelling.org
474 SMTP_DOMAIN=mast.iankelling.org
475 SMTP_DELIVERY_METHOD=smtp
478 for key
in PAPERCLIP_SECRET SECRET_KEY_BASE OTP_SECRET
; do
479 printf "%s=%s" $key "$(docker-compose run --rm web rake secret)" >>.env.production
481 s
cat /etc
/mailpass|
while read -r domain port pass
; do
482 if [[ $domain == mail.iankelling.org
]]; then
483 printf "SMTP_PASSWORD=%s" "$pass" >>.env.production
490 docker-compose run
--rm web rails assets
:precompile
492 # docker daemon takes care of starting on boot.
495 acme-tiny-wrapper mast.iankelling.org
496 s a2enmod proxy_wstunnel headers
497 apache-site
-f 3000 - mast.iankelling.org
<<'EOF'
499 RequestHeader set X-Forwarded-Proto "https"
500 ProxyPass /500.html !
501 ProxyPass /oops.png !
502 ProxyPass /api/v1/streaming/ ws://localhost:4000/
503 ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
504 ErrorDocument 500 /500.html
505 ErrorDocument 501 /500.html
506 ErrorDocument 502 /500.html
507 ErrorDocument 503 /500.html
508 ErrorDocument 504 /500.html
512 ############### !!!!!!!!!!!!!!!!!
513 ############### manual steps:
515 # only following 2 people atm, so not bothering to figure out backups
516 # when mastodon has not documented it at all.
521 # johns@status.fsf.org
523 # sign in page is at https://mast.iankelling.org/auth/sign_in
524 # register as iank, then
525 # https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Administration-guide.md
526 # docker-compose run --rm web bundle exec rails mastodon:make_admin USERNAME=iank
528 ############# end setup mastodon ##############
530 echo "$0: $(date): ending now)"
536 ########### end section including li/lj ###############
538 if [[ $HOSTNAME == treetowl
]]; then
539 # note, see bashrc for more documentation.
541 s
dd of
=/etc
/systemd
/system
/rss2email.service
<<'EOF'
543 Description=rss2email
544 After=multi-user.target
549 # about 24 hours of failures
550 ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e run
552 s
dd of
=/etc
/systemd
/system
/rss2email.timer
<<'EOF'
554 Description=rss2email
557 OnUnitInactiveSec=300
560 WantedBy=timers.target
562 s systemctl daemon-reload
566 ######### begin pump.io periodic backup #############
567 if [[ $HOSTNAME == treetowl
]]; then
568 s
dd of
=/etc
/systemd
/system
/pumpbackup.service
<<'EOF'
570 Description=pump li backup
571 After=multi-user.target
576 ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup
578 s
dd of
=/etc
/systemd
/system
/pumpbackup.timer
<<'EOF'
580 Description=pump li backup hourly
586 WantedBy=timers.target
588 s systemctl daemon-reload
591 ######### end pump.io periodic backup #############
595 # suggests because we want the resolvconf package.
596 # todo: check other distros to make sure it\'s installed
597 pi-nostart
--install-suggests openvpn
598 # pi-nostart does not disable
604 if private-host
; then
605 vpn-mk-client-cert
-n mail li
606 cn
=$
(s openssl x509
-noout -nameopt multiline
-subject \
607 -in /etc
/openvpn
/client
/mail.crt | \
608 sed -rn 's/^\s*commonName\s*=\s*(.*)/\1/p')
609 echo "ifconfig-push 10.8.0.4 255.255.255.0" | \
610 ssh root@li
dd of
=/etc
/openvpn
/client-config
/"$cn"
613 if [[ $HOSTNAME == treetowl
]]; then
614 # note, this will need to be changed when the mail/contacts host changes
615 sgo openvpn-client@
mail
616 /a
/bin
/distro-setup
/radicale-setup
619 ## android studio setup
620 # this contains the setting for android sdk to point to
621 # /a/opt/androidsdk, which is asked upon first run
622 lnf
/a
/opt
/.AndroidStudio2.2 ~
623 # android site says it needs a bunch of packages for ubuntu,
624 # but I googled for debian, and someone says you just need lib32stdc++6 plus the
626 # https://pid7007blog.blogspot.com/2015/07/installing-android-studio-in-debian-8.html
627 # see w.org for more android studio details
628 spa lib32stdc
++6 default-jdk
631 if [[ $HOSTNAME == treetowl
]]; then
632 ############# begin syncthing setup ###########
634 # It\'s simpler to just worry about running it in one place for now.
635 # I assume it would work to clone it\'s config to another non-phone
636 # and just run it in one place instead of the normal having a
637 # separate config. I lean toward using the same config, since btrfs
638 # syncs between comps.
640 arch
) pi syncthing
;;
642 # testing has relatively up to date packages
643 if ! isdebian-testing
; then
644 # based on error when doing apt-get update:
645 # E: The method driver /usr/lib/apt/methods/https could not be found.
646 pi apt-transport-https
647 # google led me here:
648 # https://apt.syncthing.net/
649 curl
-s https
://syncthing.net
/release-key.txt | sudo apt-key add
-
650 s
="deb http://apt.syncthing.net/ syncthing release"
651 if [[ $
(cat /etc
/apt
/sources.list.d
/syncthing.list
) != $s ]]; then
652 echo "$s" | s
dd of
=/etc
/apt
/sources.list.d
/syncthing.list
659 lnf
-T /w
/syncthing
/home
/ian
/.config
/syncthing
660 sgo syncthing@ian
# runs as ian
662 # these things persist in ~/.config/syncthing, which I save in
663 # /w/syncthing (not in /p, because syncthing should continue to
664 # run on home server even when using laptop as primary device)
665 # open http://localhost:8384/
666 # change listen address from default to tcp://:22001,
667 # this is because we do port forward so it doesn\'t have to use
668 # some external server, but the syncthing is broken for port forward,
669 # you get a message, something "like connected to myself, this should not happen"
670 # when connecting to other local devices, so I bump the port up by 1,
672 # https://forum.syncthing.net/t/connected-to-myself-should-not-happen/1763/19.
673 # Without this, it was being stuck syncing at 0%.
674 # Set gui username and password.
676 # install syncthing via f-droid,
677 # folder setting, turn off master folder (makes it read only).
678 # on phone, add device, click bar code icon
679 # on dekstop, top right, actions, device id
680 # after adding, notification will appear on desktop to confirm
682 # syncing folder. from phone to desktop: select desktop in the
683 # folder on phone\'s sync options, notification will appear in
684 # desktop\'s web ui within a minute. For the reverse, the
685 # notification will appear in android\'s notifications, you have to
686 # swipe down and tap it to add the folder. It won\'t appear in the
687 # syncthing ui, which would be intuitive, but don\'t wait for it
690 # On phone, set settings to run syncthing all the time, and
691 # show no notification.
693 # Folder versioning would make sense if I didn\'t already use btrfs
694 # for backups. I would choose staggered, or trash can for more space.
696 # if needed to install on a remote comp:
697 # ssh -L 8384:localhost:8384 -N frodo
698 # open http://localhost:8384/
700 # Note, the other thing i did was port forward port 22000,
701 # per https://docs.syncthing.net/users/firewall.html
703 ############# end syncthing setup ###########
708 # no equivalent in other distros:
711 # for gui bug reporting
717 ####### misc packages ###########
719 if [[ $HOSTNAME == treetowl
]]; then
722 # note i had to do this, which is persistent:
724 # s chgrp debian-transmission torrents partial-torrents
726 # syslog says things like
727 # 'Failed to set receive buffer: requested 4194304, got 425984'
728 # google suggets giving it even more than that
729 tu
/etc
/sysctl.conf
<<'EOF'
730 net.core.rmem_max = 67108864
731 net.core.wmem_max = 16777216
735 # some reason it doesn\'t seem to start automatically anyways
736 pi-nostart transmission-daemon
738 # the folder was moved here after an install around 02/2017.
739 # it contains runtime data,
740 # plus a simple symlink to the config file which it\'s
741 # not worth separating out.
742 s lnf
-T /i
/transmission-daemon
/var
/lib
/transmission-daemon
/.config
/transmission-daemon
744 # config file documented here, and it\'s the same config
745 # for daemon vs client, so it\'s documented in the gui.
746 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
748 # I originaly setup rpc-whitelist, but after using
749 # routing to a network namespace, it doesn\'t see the
750 # real source address, so it\'s disabled.
752 # Changed the cache-size to 256 mb, reduces disk use.
753 # It is a read & write cache.
757 p = '/etc/transmission-daemon/settings.json'
758 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
759 'rpc-whitelist-enabled' => false,
760 'rpc-authentication-required' => false,
761 'incomplete-dir' => '/i/k/partial-torrents',
762 'incomplete-dir-enabled' => true,
763 'download-dir' => '/i/k/torrents',
764 "speed-limit-up" => 800,
765 "speed-limit-up-enabled" => true,
766 "peer-port" => 61486,
767 "cache-size-mb" => 256,
768 "ratio-limit" => 5.0,
769 "ratio-limit-enabled" => true,
773 # make sure its not enabled, not sure if this is needed
774 ser disable transmission-daemon
775 sgo transmission-daemon-nn
777 # todo: others unknown
781 # adapted from /var/lib/dpkg/info/transmission-daemon.postinst
782 if ! getent passwd debian-transmission
> /dev
/null
; then
788 --home-dir /var
/lib
/transmission-daemon \
797 --disabled-password \
798 --home /var
/lib
/transmission-daemon \
804 # dunno why it\'s there, but get rid of it
806 li|lj
) s
rm -rf /home
/linode
;;
809 # arch had a default config,
810 # debian had nothing until you start it.
811 # With a little trial an error, here is a minimal config
812 # taken from the generated one, plus changes that the
813 # settings ui does, without a bunch of ui crap settings.
815 # only settings I set were
821 # the password is randomly generated on first run
822 rpc_pass
=$
(s ruby
<<'EOF'
824 p = '/etc/transmission-daemon/settings.json'
825 puts JSON.parse(File.read(p))["rpc-password"]
830 d
=$f/.config
/transmission-remote-gtk
833 s
-u $u dd of
=$d/config.json
<<EOF
837 "profile-name" : "Default",
838 "hostname" : "transmission",
839 "rpc-url-path" : "/transmission/rpc",
841 "password" : "$rpc_pass",
842 "auto-connect" : true,
846 "update-active-only" : false,
847 "activeonly-fullsync-enabled" : false,
848 "activeonly-fullsync-every" : 2,
849 "update-interval" : 3,
850 "min-update-interval" : 3,
851 "session-update-interval" : 60,
859 "add-options-dialog" : false
871 wget
-nv -N https
://dl.google.com
/linux
/direct
/google-chrome-stable_current_amd64.deb
874 s dpkg
-i google-chrome-stable_current_amd64.deb |
& tee $log
880 # previously I had a more specific search, but dpkg
881 # changed it\'s output as of 7/2016
882 if grep 'dependency problems' \
883 $log &>/dev
/null
; then
884 s apt-get
-fy install
901 pi cups ghostscript gsfonts
# from arch wiki cups page
902 pi hplip
# from google
903 s gpasswd
-a $USER sys
# from arch wiki
904 sgo org.cups.cupsd.service
905 # goto http://127.0.0.1:631
906 # administration tab, add new printer button.
907 # In debian, I could use hte recommended driver,
908 # in arch, I had to pick out the 6L driver.
913 # other distros unknown
918 ubuntu|debian
) pi
--no-install-recommends mairix notmuch
;;
919 fedora|arch
) spa mairix notmuch
;;
922 arch
) spa nfs-utils
;;
923 ubuntu|debian
) spa nfs-client
;;
926 ubuntu|debian
) spa par2
;;
927 arch|fedora
) spa par2cmdline
;;
930 # needed for my tex resume
932 ubuntu|debian
) spa texlive-full
;;
933 arch
) spa texlive-most
;;
939 # flash, unrar, codecs, ms fonts.
940 # This has a manual prompt.
941 spa ubuntu-restricted-extras
945 # rpm fusion recommended codecs
946 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"
947 pi gstreamer-plugins-ugly gstreamer-plugins-bad gstreamer-ffmpeg\
948 xine-lib-extras-freeworld
953 # optional dep for firefox for h.264 video
954 arch
) spa gst-libav
;;
955 # other distros, probably come by default
959 fedora|ubuntu|debian
) spa gnupg-agent
;;
965 fedora
) spa pinentry-gtk
;;
966 *) : ;; # comes default or with other packages
970 arch
) spa firefox pulseaudio
;;
971 *) : ;; # comes default or with other packages
976 arch
) spa ttf-dejavu
;;
977 debian|ubuntu
) spa fonts-dejavu
;;
984 debian|ubuntu
) spa x11-utils
;;
989 arch
) pi virt-install
;;&
990 debian|ubuntu
) pi virtinst
;;&
991 *) pi virt-manager
;; # creates the libvirt group in debian at least
994 # allow user to run vms, from debian handbook
995 for x
in ian traci
; do s usermod
-a -G libvirt
,kvm
$x; done
996 # bridge networking as user fails. google lead here, but it doesn\'t work:
997 # oh well, I give up.
998 # http://wiki.qemu.org/Features-Done/HelperNetworking
1000 # f=/etc/qemu/bridge.conf
1001 # s dd of=$f <<'EOF'
1004 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
1010 debian|ubuntu
) spa genisoimage
;;
1015 arch
) spa spice-gtk3
;;
1016 debian|ubuntu
) spa spice-client-gtk
;;
1020 # general known for debian/ubuntu, not for fedora
1025 # a bit of googling, and added settings to bashrc
1026 go get
-u github.com
/mvdan
/fdroidcl
/cmd
/fdroidcl
1034 # cdrkit for cloud-init isos
1035 # dnsmasq & ebtables for nat networking in libvirt
1036 # qemu for qemu-img, bind-tools for dig
1037 # dmidecode just because syslog complains
1038 pi
unzip xorg-xmodmap dmidecode ebtables\
1039 bridge-utils dnsmasq qemu bind-tools
1040 # otherwise we get error about accessing kvm module.
1041 # seems like there might be a better way, but google was a bit vague.
1042 s
$sed -ri '/^ *user *=/d' /etc
/libvirt
/qemu.conf
1043 echo 'user = "root"' | s
tee -a /etc
/libvirt
/qemu.conf
1044 # https://bbs.archlinux.org/viewtopic.php?id=206206
1045 # # this should prolly go in the wiki
1047 # guessing this is not needed
1048 #sgo virtlogd.service
1055 arch
) pi virtviewer
;;
1056 *) : ;; # other distros have it as a dependency afaik.
1062 fedora
) cabal
install shellcheck
;;
1063 *) spa shellcheck
;;
1064 # unknown for older ubuntu
1069 arch|debian|ubuntu
) spa pumpa
;;
1070 # others unknown. do have a buildscript:
1071 # /a/bin/buildscripts/pumpa ;;
1076 debian|ubuntu
) spa android-tools-adbd
/unstable
;;
1077 arch
) spa android-tools
;;
1078 # other distros unknown
1081 if [[ $HOSTNAME == treetowl
]]; then
1084 if [[ `debian-archive` == testing
]]; then
1085 # has no unstable dependencies
1086 pi bitcoind
/unstable
1087 src
=/a
/opt
/bitcoin
/contrib
/init
/bitcoind.service
1088 s
cp $src /etc
/systemd
/system
1089 p
=/etc
/bitcoin
/bitcoin
1090 dst
=/etc
/systemd
/system
/bitcoinjm.service
1092 $sed -r "/^\s*ExecStart/s,${p}.conf,${p}jm.conf," $src \
1093 >/etc
/systemd
/system
/bitcoinjm.service
1095 d
=jm
; jm
=d
# being clever for succinctness
1097 s
$sed -ri "/^\s*\[Unit\]/a Conflicts=bitcoin${!s}.service" \
1098 /etc
/systemd
/system
/bitcoin
${s}.service
1105 s chown
-R bitcoin
:bitcoin
$dir
1108 s chown
-R root
:bitcoin
$dir
1111 # pruning decreases the bitcoin dir to 2 gb, keeps
1112 # just the recent blocks. can\'t do a few things like
1113 # import a wallet dump.
1114 # pruning works, but people had to do
1115 # some manual stuff in joinmarket. I dun need the
1116 # disk space, so not bothering yet, maybe in a year or so.
1117 # https://github.com/JoinMarket-Org/joinmarket/issues/431
1118 #https://bitcoin.org/en/release/v0.12.0#wallet-pruning
1124 rpcpassword=$(openssl rand -base64 32)
1125 rpcuser=$(openssl rand -base64 32)
1129 f2
=$dir/bitcoinjm.conf
1131 s
tee -a $f2 >/dev
/null
<<EOF
1133 walletnotify=curl -sI --connect-timeout 1 http://localhost:62602/walletnotify?%s
1134 alertnotify=curl -sI --connect-timeout 1 http://localhost:62602/alertnotify?%s
1135 wallet=joinmarket.dat
1137 # dunno about sharing a wallet between multiple instances
1138 # manually did, wallet.dat symlinked in /nocow/.bitcoin
1142 # other distros unknown
1144 pi libsodium-dev python-pip
1145 cd /a
/opt
/joinmarket
1146 # using develop branch, as it seems to be mostly bug fixes,
1147 # and this is quite new software.
1148 # note: python3 does not work.
1149 # has seg fault error due to some bug, but it still works
1150 pip
install -r requirements.txt ||
[[ $?
== 139 ]]
1151 # note, the target must exist ahead of time, or bitcoin
1152 # just overwrites the link, and it\'s not happy with an empty file,
1153 # so we have to create the wallet, then move and link it.
1154 s lnf
-T /q
/bitcoin
/wallet.dat
/nocow
/.bitcoin
/wallet.dat
1155 s lnf
-T /q
/bitcoin
/joinmarket.dat
/nocow
/.bitcoin
/joinmarket.dat
1156 # not technically needed, but seems cleaner not to have
1157 # symlinks be root owned unlike everything else
1158 s chown
-h bitcoin
:bitcoin
/nocow
/.bitcoin
/*
1160 for var
in rpcuser rpcpassword
; do
1161 u
="$(s sed -rn "s
/^
$var=(.
*)/\
1/p
" /etc/bitcoin/bitcoin.conf)"
1162 # escape backslashes
1163 u
="${u//\\/\\\\\\\\}"
1166 sed -ri "s,^(rpc_${var#rpc}\s*=).*,\1 $u," joinmarket.cfg
1168 sed -ri "s/^\s*(blockchain_source\s*=).*/\1 bitcoin-rpc/" joinmarket.cfg
1177 wget http
://tamacom.com
/global
/global-6.3
.2.
tar.gz
1180 # based on https://github.com/leoliu/ggtags
1181 .
/configure
--with-exuberant-ctags=/usr
/bin
/ctags
1184 s pip
install pygments
1200 pi task-cinnamon-desktop
1201 # in settings, change scrolling to two-finger,
1202 # because the default edge scroll doesn\'t work.
1211 # already in debian jessie
1217 # note this failed running at the beginning of this file,
1218 # because no systemd user instance was running.
1219 # Doing systemd --user resulted in
1220 # Trying to run as user instance, but $XDG_RUNTIME_DIR is not set
1222 if isdebian-testing
; then
1223 # as of 7/2016, has no unstable deps, and is not in testing anymore.
1230 # # ubuntu unknown. probably the same as debian, just check if the
1231 # # init scripts come with the package.
1233 # # copied from arch, but moved to etc
1234 # s dd of=/etc/systemd/user/synergys.service <<'EOF'
1236 # Description=Synergy Server Daemon
1237 # After=network.target
1241 # ExecStart=/usr/bin/synergys --no-daemon --config /etc/synergy.conf
1242 # Restart=on-failure
1245 # WantedBy=multi-user.target
1247 # s dd of=/etc/systemd/user/synergys.socket <<'EOF'
1249 # Conflicts=synergys@.service
1252 # ListenStream=24800
1256 # WantedBy=sockets.target
1258 # # had this fail with 'Failed to connect to bus: No such file or directory'
1259 # # then when I tried it manually, it worked fine...
1260 # if ! systemctl --user daemon-reload; then
1262 # echo retrying systemd user daemon reload
1263 # systemctl --user daemon-reload
1267 # # taken from arch wiki.
1268 # s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
1270 # Description=Synergy Client
1271 # After=network.target
1275 # ExecStart=/usr/bin/synergyc --no-daemon frodo
1276 # Restart=on-failure
1277 # # per man systemd.unit, StartLimitInterval, by default we
1278 # # restart more than 5 times in 10 seconds.
1279 # # And this param defaults too 200 miliseconds.
1283 # WantedBy=multi-user.target
1285 # s systemctl daemon-reload
1288 # ser enable synergyc@ian
1289 # ser start synergyc@ian ||: # X might not be running yet
1292 # systemctl --user start synergys ||:
1293 # systemctl --user enable synergys
1300 ######### end misc packages #########
1303 # packages I once used before and liked, but don\'t want installed now for
1305 # python-sqlite is used for offlineimap
1306 # lxappearance python-sqlite dolphin paman dconf-editor
1312 # todo, finish configuring smart.
1315 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
1316 # turn on smart. background on options:
1317 # first line, -a = test everyting on all devices.
1318 # -S on, turn on disk internal saving of vendor specific info,
1319 # from google, seems like this is usually already on and fairly standard.
1320 # -o on, turn on 4 hour period non-performance degrading testing.
1321 # short test daily 2-3am, extended tests Saturdays between 3-4am:
1322 sched
="-s (S/../.././02|L/../../6/03)"
1323 s
sed -i --follow-symlinks "s#^[[:space:]]*DEVICESCAN.*#\
1324 DEVICESCAN -a -o on -S on -n standby,q $sched \
1325 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc
/smartd.conf
1327 # in the default configuration of at least ubuntu 14.04, resolvconf is
1328 # configured to order any nameservers associated with tun* or tap*
1329 # before the normal internet interfaces, which means they are always
1330 # consulted first. This is often slower and undesirable, ie. local dns
1331 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
1333 #sudo sed -i --follow-symlinks '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
1334 # however, this breaks dns lookup for hosts on the openvpn lan.
1335 # I can\'t figure out why hosts on the normal lan would not be
1336 # broken under the default ordering, except the host I was
1337 # testing with previously had an entry in /etc/hosts.
1339 ############# end unfinished
1341 ########### misc stuff
1344 for dev
in $
(s btrfs
fi show
/boot |
sed -nr 's#.*path\s+(\S+)$#\1#p'); do
1345 devs
+=($
(devbyid
$dev),)
1347 devs
[-1]=${devs[-1]%,} # jonied by commas
1349 # on grub upgrade, we get prompts unless we do this
1350 s debconf-set-selections
<<EOF
1351 grub-pc grub-pc/install_devices multiselect ${devs[*]}
1355 # the wiki backup script from ofswiki.org uses generic paths
1356 s lnf
/p
/c
/machine_specific
/li
/mw_vars
/root
1357 s lnf
/k
/backup
/wiki_backup
/root
1359 s cedit
/etc
/goaccess.conf
<<'EOF' || [[ $? == 1 ]]
1360 # all things found from looking around the default config
1361 # copied existing NCSA Combined Log Format with Virtual Host, plus %L
1362 log-format %^:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %D
1363 time-format %H:%M:%S
1364 date-format %d/%b/%Y
1365 log-file /var/log/apache2/access.log
1368 # tip: copy access.log files to a stretch host directory, then run
1369 # jessie's goaccess is too old for some options, and it\'s
1370 # not easily installed from a testing.
1371 # goaccess --ignore-crawlers -f <(cat *) -a -o html > x.html
1377 case `debian-archive` in
1379 s
dd of
=/etc
/apt
/preferences.d
/unison-gtk
<<'EOF'
1380 Explanation: Allow unison-gtk to be upgraded
1382 Pin: release a=testing
1385 # dont think using testing is needed since I figured out how to
1386 # deal with mismatching unison compilers, but I dont
1387 # see any reason to revert it, since it only installs
1388 # a single package which is primarily a single binary
1392 pi unison-gtk
/testing
# after to make it the default unison
1401 # default is alsa, doesn\'t work with with pianobar
1402 s
dd of
=/etc
/libao.conf
<<'EOF'
1403 default_driver=pulse
1408 # note, for jessie, it depends on a higher version of btrfs-tools.
1410 # # disabled due to my patch being in btrbk
1412 # arch|debian|ubuntu) pi btrbk ;;
1417 spa pv
# for progress bar when running interactively.
1418 if [[ $HOSTNAME == treetowl
]]; then
1419 # backup/sync manually on others hosts for now.
1421 # note: to see when it was last run,
1425 if [[ $HOSTNAME == treetowl
]] && [[ `debian-archive` != testing
]]; then
1426 # fail2 ban is broken, with a workaround, per
1427 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770171
1428 # ill wait a while to see if it gets fixed
1438 debian|ubuntu
) s gpasswd
-a ian adm
;; #needed for reading logs
1444 # https://www.torproject.org/docs/rpms.html.en
1445 # https://www.torproject.org/docs/debian.html.en
1446 # todo: figure out if the running service needs to be restarted upon updates
1449 # todo on fedora: setup non-dev packages
1451 s
dd of
=/etc
/yum.repos.d
/torproject.repo
<<'EOF'
1453 name=Tor experimental repo
1455 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
1457 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1460 name=Tor experimental source repo
1463 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
1465 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
1468 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
1469 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
1471 /a
/bin
/buildscripts
/tor-browser
1474 tu
/etc
/apt
/sources.list
"deb http://deb.torproject.org/torproject.org $(debian-codename) main"
1475 gpg
--keyserver keys.gnupg.net
--recv 886DDD89
1476 gpg
--export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add
-
1478 pi deb.torproject.org-keyring
1480 /a
/bin
/buildscripts
/tor-browser
1484 /a
/bin
/buildscripts
/tor-browser
1487 pi tor tor-browser-en
1497 fedora todo: disable the firewall or find a way to automate it.
1498 there's an unused section in t.org for tramikssion firewall setup
1500 fedora manual config for nfs:
1502 change to permanent configuration
1503 check the box for nfs
1504 was hard to figure this out, not sure if this is all needed, but
1506 mountd: udp/tcp 20048
1507 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
1508 troubleshooting, unblock things in rpcinfo -p
1509 make sure to reload the firewall to load the persistent configuration
1520 pi nfs-utils || pending_reboot
=true
1522 # this failed until I rebooted
1527 if [[ $HOSTNAME == treetowl
]]; then
1528 # nohide = export filesystems mounted deeper than the export point
1529 # fsid=0 makes this export the "root" export
1530 # not documented in the man page, but this means
1531 # 1. it can be mounted with a shorthand of server:/
1532 # 2. exports that are subdirectories of this one will automatically be mounted
1533 tu
/etc
/exports
<<'EOF'
1534 /k 192.168.1.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)
1543 # persistent virtual machines
1551 # distro may not know about win 10 yet.
1553 if ! virt-install
--os-variant list
&>/dev
/null
; then # we are using a newer virt-install
1554 for v
in 10 8.1 8; do
1555 if osinfo-query os | gr
"^\s*win${v/./\\.}\s" &>/dev
/null
; then
1562 if ! s virsh list
--all --name |
grep -xF win10
&>/dev
/null
; then
1564 # created account with
1565 # win10vmian@outlook.com, and easy to remember password
1566 # win 10 virtio, makes disk way way way faster
1567 # wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso
1568 # https://wiki.archlinux.org/index.php/QEMU#Change_Existing_Windows_VM_to_use_virtio
1569 # for installing virtio after initial install instead of with initial iso:
1570 # qemu-img create -f qcow2 fake.qcow2 1G
1571 # --disk=/a/images/virtio-win.iso,device=cdrom \
1572 # --disk=/a/images/fake.qcow2,bus=virtio
1574 # went to device manager, saw 2 pci devices with yellow !,
1575 # did search for drivers, pick cdrom location, done.
1577 # from http://www.tenforums.com/tutorials/4189-fast-startup-turn-off-windows-10-a.html.
1578 # google said there was a control panel option for it, but
1579 # that turned out to be a lie.
1580 # Put this in a .bat file and run as administrator to turn off
1581 # hyberboot which fucks things up.
1582 # REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /V HiberbootEnabled /T REG_dWORD /D 0 /F
1583 # power settings, turn off display: never
1584 # run "control userpasswords2", turn on automatic login.
1585 # note: when changing devices, I just undefine, the create the vm again.
1587 if [[ -e /nocow
/user
/vms
/win10.qcow2
]]; then
1588 s virt-install
--noautoconsole --graphics spice
,listen
=0.0.0.0 \
1589 --disk=/a
/images
/win10.qcow2
,bus
=virtio
--vcpus 2 -r 4096 -w bridge
=br0 \
1590 -n win10
--import --os-variant $variant --cpu host-model-only
1592 s virsh destroy win10
1595 if [[ -e /nocow
/user
/vms
/win7.qcow2
]]; then
1596 # this one hasn\'t had the virtio fix done yet.
1597 s virt-install
--noautoconsole --graphics spice
,listen
=0.0.0.0 \
1598 --disk=/a
/images
/win7.qcow2
--vcpus 2 -r 4096 -w bridge
=br0 \
1599 -n win7
--import --os-variant win7
--cpu host-model-only
1600 s virsh destroy win7
1601 # had a problem with --cpu host, so trying out
1602 # --cpu host-model-only
1607 if [[ $HOSTNAME == treetowl
]]; then
1609 # note samba re-reads it\'s config every 1 minute
1611 arch
) s
cp /etc
/samba
/smb.conf.default
/etc
/samba
/smb.conf
;;
1614 # add 2 lines after workgroup option
1615 s
sed -ri --follow-symlinks '/^\s*encrypt passwords\s*=/d' /etc
/samba
/smb.conf
1616 s
sed -ri --follow-symlinks '/^\s*map to guest\s*=/d' /etc
/samba
/smb.conf
1617 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
1618 # remove default homes section. not sharing that.
1619 s
sed -ri --follow-symlinks '/^\s*\[homes\]/,/\s*\[/d' /etc
/samba
/smb.conf
1621 if ! grep -xF '[public]' /etc
/samba
/smb.conf
&>/dev
/null
; then
1622 s
tee -a /etc
/samba
/smb.conf
<<'EOF'
1632 # systemd claims it generates units from /etc/init.d, but it
1633 # clearly doesn\'t in debian. I have no idea how they are
1634 # related. fuck debian right now. It\'s not documented. samba
1635 # has a systemd init file linked to /dev/null. There\'s this
1636 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769714 which
1637 # claims samba\'s sub-services will be started automatically by
1638 # systemd... it didn\'t on install, wonder if it will on
1639 # boot. It clued me in how to start it manually though. Nothing
1640 # in /usr/share/doc/samba, debian admin guide says nothing about
1641 # any of this. (this is in debian testing as of 4/2016).
1643 s
/etc
/init.d
/samba start
1651 tu
/etc
/hosts
<<< "127.0.1.1 $(hostname).lan $(hostname)"
1654 ######### begin stuff belonging at the end ##########
1657 # Apps we want to override others for default file handler:
1658 # simplest way in debian is to just install them last.
1671 pi
"${simple_packages[@]}"
1674 if $pending_reboot; then
1675 echo "$0: pending reboot and then finished. doing it now."
1678 echo "$0: $(date): ending now)"