2 # Copyright (C) 2016 Ian Kelling
3 # This program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>
5 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
11 IFS
= read -r -d '' y ||
:
53 spa
() { # simple package add
68 # https://apt.syncthing.net/
69 curl
-s https
://syncthing.net
/release-key.txt | sudo apt-key add
-
70 s
="deb http://apt.syncthing.net/ syncthing release"
71 if [[ $
(cat /etc
/apt
/sources.list.d
/syncthing.list
) != $s ]]; then
72 echo "$s" | s
dd of
=/etc
/apt
/sources.list.d
/syncthing.list
78 # installed via f-droid
79 # top right, actions, device id
81 # for installing on a remote comp:
82 # ssh -L 8384:localhost:8384 -N frodo
83 # went to http://localhost:8384/
85 # add folder to sync phone,
86 # staggered file versioning would be my normal choice, but choose
87 # trash can versioning for sake of space on phone, with
88 # clean out after 7 days.
90 # did ser syncthing@ian start
91 # then on phone, add device, hit bar code icon,
92 # install bar code scanner.
95 # things with no equivalent in other distros:
98 # for gui bug reporting
102 # for debconf-get-selections
108 ####### misc packages ###########
119 if [[ $HOSTNAME == frodo
]]; then
122 # note i had to do this, which is persistent:
124 # s chgrp debian-transmission torrents partial-torrents
126 # syslog says things like
127 # 'Failed to set receive buffer: requested 4194304, got 425984'
128 # google suggets giving it even more than that
129 tu
/etc
/sysctl.conf
<<'EOF'
130 net.core.rmem_max = 67108864
131 net.core.wmem_max = 16777216
135 # some reason it doesn't seem to start automatically anyways
136 pi-nostart tranmission-daemon
137 # config file documented here, and it's the same config
138 # for daemon vs client, so it's documented in the gui.
139 # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
142 p = '/etc/transmission-daemon/settings.json'
143 File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
144 'rpc-whitelist': '127.0.0.1,192.168.1.*',
145 'rpc-authentication-required': false,
146 'incomplete-dir': '/i/k/partial-torrents',
147 'download-dir': '/i/k/torrents',
148 "speed-limit-up": 700,
149 "speed-limit-up-enabled": true,
150 "ratio-limit": 1.4000,
151 "ratio-limit-enabled": true,
154 sgo transmission-daemon
157 # todo, setup it's config file & daemon
163 # from /var/lib/dpkg/info/transmission-daemon.postinst
164 if ! getent passwd debian-transmission
> /dev
/null
; then
169 --disabled-password \
170 --home /var
/lib
/transmission-daemon \
175 debian|ubuntu
) pi transmission-remote-gtk
;;
176 arch
) pi transmission-remote-gtk2
;;
178 # arch had a default config,
179 # debian had nothing until you start it.
180 # With a little trial an error, here is a minimal config
181 # taken from the generated one, plus changes that the
182 # settings ui does, without a bunch of ui crap settings.
184 # only settings I set were
189 d
=$f/.config
/transmission-remote-gtk
192 s
-u $u dd of
=$d/config.json
<<'EOF'
196 "profile-name" : "Default",
197 "hostname" : "frodo",
198 "rpc-url-path" : "/transmission/rpc",
201 "auto-connect" : true,
205 "update-active-only" : false,
206 "activeonly-fullsync-enabled" : false,
207 "activeonly-fullsync-every" : 2,
208 "update-interval" : 3,
209 "min-update-interval" : 3,
210 "session-update-interval" : 60,
218 "add-options-dialog" : false
226 # pi-nostart this doesn't seem to be good enough?
227 ser disable openvpn@client
239 wget
-N https
://dl.google.com
/linux
/direct
/google-chrome-stable_current_amd64.deb
241 s dpkg
-i google-chrome-stable_current_amd64.deb
&> $log
246 if grep '^dpkg: dependency problems prevent configuration of' \
247 $log &>/dev
/null
; then
248 s apt-get
-fy install
265 # ubuntu unknown. probably the same as debian, just check if the
266 # init scripts come with the package.
269 s
dd of
=/etc
/systemd
/system
/synergys@.service
<<'EOF'
271 Description=Synergy Server Daemon
276 ExecStart=/usr/bin/synergys --no-daemon --config /etc/synergy.conf
280 WantedBy=multi-user.target
282 s
dd of
=/etc
/systemd
/system
/synergys@.socket
<<'EOF'
284 Conflicts=synergys@.service
291 WantedBy=sockets.target
296 s
dd of
=/etc
/systemd
/system
/synergyc@.service
<<'EOF'
298 Description=Synergy Client
303 ExecStart=/usr/bin/synergyc --no-daemon treetowl
305 # per man systemd.unit, StartLimitInterval, by default we
306 # restart more than 5 times in 10 seconds.
307 # And this param defaults too 200 miliseconds.
311 WantedBy=multi-user.target
316 sgo synergys@ian.socket
318 treetowl
) sgo synergys@ian.socket
;;
330 arch
) spa the_silver_searcher
;;
331 debian|ubuntu
) spa silversearcher-ag
;;
338 pi cups ghostscript gsfonts
# from arch wiki cups page
339 pi hplip
# from google
340 s gpasswd
-a $USER sys
# from arch wiki
341 sgo org.cups.cupsd.service
342 # goto http://127.0.0.1:631
343 # administration tab, add new printer button.
344 # In debian, I could use hte recommended driver,
345 # in arch, I had to pick out the 6L driver.
350 # other distros unknown
355 ubuntu|debian
) spa ack-grep
;;
356 arch|fedora
) spa ack
;;
360 ubuntu|debian
) pi
--no-install-recommends mairix notmuch
;;
361 fedora|arch
) spa mairix notmuch
;;
364 arch
) spa nfs-utils
;;
365 ubuntu|debian
) spa nfs-client
;;
368 ubuntu|debian
) spa par2
;;
369 arch|fedora
) spa par2cmdline
;;
372 # needed for my tex resume
374 ubuntu|debian
) spa texlive-full
;;
375 arch
) spa texlive-most
;;
381 # flash, unrar, codecs, ms fonts.
382 # This has a manual prompt.
383 spa ubuntu-restricted-extras
387 # rpm fusion recommended codecs
388 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"
389 pi gstreamer-plugins-ugly gstreamer-plugins-bad gstreamer-ffmpeg\
390 xine-lib-extras-freeworld
395 # optional dep for firefox for h.264 video
396 arch
) spa gst-libav
;;
397 # other distros, probably come by default
401 fedora|ubuntu|debian
) spa gnupg-agent
;;
407 fedora
) spa pinentry-gtk
;;
408 *) : ;; # comes default or with other packages
412 arch
) spa firefox pulseaudio
;;
413 *) : ;; # comes default or with other packages
425 arch
) spa ttf-dejavu
;;
426 debian|ubuntu
) spa fonts-dejavu
;;
431 debian|ubuntu
) spa ntp
;;
441 debian|ubuntu
) spa x11-utils
;;
446 arch
) pi virt-install
;;&
447 debian|ubuntu
) pi virtinst
;;&
448 *) pi virt-manager
;; # creates the libvirt group in debian at least
451 # allow user to run vms, from debian handbook
452 for x
in ian traci
; do s usermod
-a -G libvirt
$x; done
453 # bridge networking as user fails. google lead here, but it doesn't work:
454 # oh well, I give up.
455 # http://wiki.qemu.org/Features-Done/HelperNetworking
457 # f=/etc/qemu/bridge.conf
461 # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
467 debian|ubuntu
) spa genisoimage
;;
472 arch
) spa spice-gtk3
;;
473 debian|ubuntu
) spa spice-client-gtk
;;
477 # general known for debian/ubuntu, not for fedora
480 # cdrkit for cloud-init isos
481 # dnsmasq for nat networking in libvirt
482 # qemu for qemu-img, bind-tools for dig
483 pi
unzip wget xorg-xmodmap \
484 bridge-utils dnsmasq qemu bind-tools
485 # otherwise we get error about accessing kvm module.
486 # seems like there might be a better way, but google was a bit vague.
487 s
sed -ri '/^ *user *=/d' /etc
/libvirt
/qemu.conf
488 echo 'user = "root"' | s
tee -a /etc
/libvirt
/qemu.conf
489 # https://bbs.archlinux.org/viewtopic.php?id=206206
490 # # this should prolly go in the wiki
502 arch
) pi virtviewer
;;
503 *) : ;; # other distros have it as a dependency afaik.
510 # ubuntu 14.04 uses b-cron,
511 # but it's not maintained in arch.
512 # of the ones in the main repos, cronie is only one maintained.
513 # fcron appears abandoned software.
517 *) : ;; # other distros come with cron.
522 fedora
) cabal
install shellcheck
;;
524 # unknown for older ubuntu
529 arch|debian|ubuntu
) spa pumpa
;;
530 # others unknown. do have a buildscript:
531 # /a/bin/buildscripts/pumpa ;;
536 debian|ubuntu
) spa android-tools-adb
;;
537 arch
) spa android-tools
;;
538 # other distros unknown
548 # proprietary flash. going without for now
551 # pi flashplugin-nonfree
559 wget http
://tamacom.com
/global
/global-6.3
.2.
tar.gz
562 # based on https://github.com/leoliu/ggtags
563 .
/configure
--with-exuberant-ctags=/usr
/bin
/ctags
566 s pip
install pygments
580 # leave this for last so it doesn't do a bunch of other apps
581 # which I want explicitly installed in case I switch DE's
584 pi task-cinnamon-desktop
585 # in settings, change scrolling to two-finger,
586 # because the default edge scroll doesn\'t work.
594 # already in debian jessie
597 pi
"${simple_packages[@]}"
599 ######### end misc packages #########
602 # packages I once used before and liked, but don't want installed now for
604 # python-sqlite is used for offlineimap
605 # lxappearance python-sqlite dolphin paman dconf-editor
611 # todo, finish configuring smart.
612 # mostly from https://wiki.archlinux.org/index.php/S.M.A.R.T.
613 # turn on smart. background on options:
614 # first line, -a = test everyting on all devices.
615 # -S on, turn on disk internal saving of vendor specific info,
616 # from google, seems like this is usually already on and fairly standard.
617 # -o on, turn on 4 hour period non-performance degrading testing.
618 # short test daily 2-3am, extended tests Saturdays between 3-4am:
619 sched
="-s (S/../.././02|L/../../6/03)"
620 s
sed -i "s#^[[:space:]]*DEVICESCAN.*#\
621 DEVICESCAN -a -o on -S on -n standby,q $sched\
622 -m ian@iankelling.org -M exec /usr/local/bin/smart-notify#" /etc
/smartd.conf
624 # in the default configuration of at least ubuntu 14.04, resolvconf is
625 # configured to order any nameservers associated with tun* or tap*
626 # before the normal internet interfaces, which means they are always
627 # consulted first. This is often slower and undesirable, ie. local dns
628 # queries go from 0ms to 10+ or 100+ ms. To reverse the ordering, you
630 #sudo sed -i '/tun\*\|tap\*/d' /etc/resolvconf/interface-order
631 # however, this breaks dns lookup for hosts on the openvpn lan.
632 # I can\'t figure out why hosts on the normal lan would not be
633 # broken under the default ordering, except the host I was
634 # testing with previously had an entry in /etc/hosts.
636 ############# end unfinished
638 ########### misc stuff
640 if [[ $HOSTNAME == frodo
]]; then
641 tu
/etc
/exports
<<'EOF'
642 /k 192.168.1.0/24(rw,nohide,no_subtree_check,insecure)
647 if [[ `debian-archive` == stable
]]; then
648 s
dd of
=/etc
/apt
/preferences.d
/unison-gtk
<<'EOF'
649 Explanation: Allow unison-gtk to be upgraded
651 Pin: release a=unstable
658 # default is alsa, doesn\'t work with with pianobar
659 s
dd of
=/etc
/libao.conf
<<'EOF'
667 arch|debian|ubuntu
) pi btrbk
;;
671 if [[ $HOSTNAME == treetowl
]] && [[ `debian-archive` != testing
]]; then
672 # fail2 ban is broken, with a workaround, per
673 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770171
674 # ill wait a while to see if it gets fixed
682 case $
(distro-name
) in
684 # allows me to pipe with ssh -t, and gets rid of spam
685 # http://forums.debian.net/viewtopic.php?f=5&t=85822
686 # i'd rather disable the service than comment the init file
687 # this says disabling the service, it will still get restarted
688 # but this script doesn't do anything on restart, so it should be fine
689 s
dd of
=/var
/run
/motd.dynamic
if=/dev
/null
690 s update-rc.d motd disable
693 # this isn't a complete solution. It still shows me when updates are available,
694 # but it's no big deal.
695 s t
/etc
/update-motd.d
/10-help-text /etc
/update-motd.d
/00-header
701 # https://debian-handbook.info/browse/stable/sect.regular-upgrades.html
702 # /etc/cron.daily/apt calls unattended-upgrades
703 # /usr/share/doc/unattended-upgrades# cat README.md
704 # /etc/apt/apt.conf.d/50unattended-upgrades
706 pi unattended-upgrades
707 s
dd of
=/etc
/apt
/apt.conf.d
/10periodic
<<'EOF'
708 # this file was mostly just comments.
709 APT::Periodic::Update-Package-Lists "1";
710 APT::Periodic::Download-Upgradeable-Packages "1";
711 APT::Periodic::AutocleanInterval "7";
712 APT::Periodic::Unattended-Upgrade "1";
715 Unattended-Upgrade::Mail "root";
716 Unattended-Upgrade::MailOnlyOnError "true";
717 Unattended-Upgrade::Remove-Unused-Dependencies "true";
718 Unattended-Upgrade::Origins-Pattern {
719 # default is just upgrade main and security, not updates.
721 if isdebian-testing
; then
723 # for testing, only do security updates.
724 "origin=Debian,codename=${distro_codename},label=Debian-Security";
728 # These are stable packages only getting bugfixes anyways.
735 } | s
dd of
=/etc
/apt
/apt.conf.d
/50unattended
-upgrades
741 ######### begin postfix ########
742 # based on,http://www.postfix.org/qmgr.8.html and my notes in gnus
743 # originally tried moving specific directories under /var/spool/postfix,
744 # but postfix didn't like that
745 if [[ ! -L /var
/spool
/postfix
]]; then
747 n
=/q
/postfix-
`distro-name``debian-archive`
749 echo "$0: error: /q/postfix exists but not the link to it"
752 s
mv /var
/spool
/postfix
$n
753 s lnf
-T $n /var
/spool
/postfix
755 journalctl
-n 20 |
cat
759 # This also works instead of ~/.forward
760 # s sed -i '/^root/d' /etc/aliases ||:
761 #echo "root: $HOSTNAME@bog.mm.st" | s tee -a /etc/aliases
762 # this can't be a symlink and has permission restrictions
763 # it might work in /etc/aliases, but this seems more proper.
765 if s
grep amazonaws
/etc
/postfix
/sasl_passwd
&>/dev
/null
; then
766 forward
=$HOSTNAME@sallymae.club
768 forward
=$HOSTNAME@bog.mm.st
770 e
$forward > ~
/.forward
771 e
$forward | s
tee /root
/.forward
774 # if I wanted the from address to be renamed and sent to a different address,
775 # echo "sdx@localhost development@localhost" | sudo dd of=/etc/postfix/recipient_canonical
776 # sudo postmap hash:/etc/postfix/recipient_canonical
777 # sudo service postfix reload
780 # i'm assuming mail just won't work on systems without the sasl_passwd.
782 smtp_sasl_auth_enable = yes
783 smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
784 smtp_sasl_security_options = noanonymous
785 smtp_tls_security_level = secure
786 message_size_limit = 20480000
787 smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
789 # ^ I ran into a log file not sending cuz of size. double from 10 to 20 meg limit
791 s postmap
hash:/etc
/postfix
/sasl_passwd
792 # offlineimap uses this too, it is much easier to use one location than to
793 # condition it's config and postfix's config
795 fedora
) s lnf
-T ca-certificates.crt
/etc
/ssl
/ca-bundle.trust.crt
;;
799 s service postfix reload
802 ############ end postfix #######
806 debian|ubuntu
) s gpasswd
-a ian adm
;; #needed for reading logs
812 # https://www.torproject.org/docs/rpms.html.en
813 # https://www.torproject.org/docs/debian.html.en
814 # todo: figure out if the running service needs to be restarted upon updates
817 # todo on fedora: setup non-dev packages
819 s
dd of
=/etc
/yum.repos.d
/torproject.repo
<<'EOF'
821 name=Tor experimental repo
823 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/$basearch/
825 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
828 name=Tor experimental source repo
831 baseurl=http://deb.torproject.org/torproject.org/rpm/tor-testing/fc/20/SRPMS
833 gpgkey=http://deb.torproject.org/torproject.org/rpm/RPM-GPG-KEY-torproject.org.asc
836 # to be secure, take a look at the fingerprint reported from the following install, and see if it matches from the link above:
837 # 3B9E EEB9 7B1E 827B CF0A 0D96 8AF5 653C 5AC0 01F1
839 /a
/bin
/buildscripts
/tor-browser
842 tu
/etc
/apt
/sources.list
"deb http://deb.torproject.org/torproject.org $(debian-codename) main"
843 gpg
--keyserver keys.gnupg.net
--recv 886DDD89
844 gpg
--export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add
-
846 pi deb.torproject.org-keyring
848 /a
/bin
/buildscripts
/tor-browser
852 /a
/bin
/buildscripts
/tor-browser
855 pi tor tor-browser-en
865 fedora todo: disable the firewall or find a way to automate it.
866 there's an unused section in t.org for tramikssion firewall setup
868 fedora manual config for nfs:
870 change to permanent configuration
871 check the box for nfs
872 was hard to figure this out, not sure if this is all needed, but
874 mountd: udp/tcp 20048
875 portmapper, in firewall-config its called rpc-bind: udp/tcp 111
876 troubleshooting, unblock things in rpcinfo -p
877 make sure to reload the firewall to load the persistent configuration
894 if [[ -e /i
/video
]]; then
895 # nohide = export filesystems mounted deeper than the export point
896 # fsid=0 makes this export the "root" export
897 # not documented in the man page, but this means
898 # 1. it can be mounted with a shorthand of server:/
899 # 2. exports that are subdirectories of this one will automatically be mounted
900 tu
/etc
/exports
'/i/video 192.168.1.0/24(rw,fsid=0,nohide,no_root_squash,async,no_subtree_check,insecure)'
902 showmount
-e localhost
907 f
=/a
/bin
/$HOSTNAME-crontab
915 # persistent virtual machines
923 # distro may not know about win 10 yet.
925 if ! virt-install
--os-variant list
&>/dev
/null
; then # we are using a newer virt-install
926 for v
in 10 8.1 8; do
927 if osinfo-query os | gr
"^\s*win${v/./\\.}\s" &>/dev
/null
; then
934 if ! s virsh list
--all --name |
grep -xF win10
&>/dev
/null
; then
936 # created account with
937 # win10vmian@outlook.com, and easy to remember password
938 # win 10 virtio, makes disk way way way faster
939 # wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso
940 # https://wiki.archlinux.org/index.php/QEMU#Change_Existing_Windows_VM_to_use_virtio
941 # for installing virtio after initial install instead of with initial iso:
942 # qemu-img create -f qcow2 fake.qcow2 1G
943 # --disk=/a/images/virtio-win.iso,device=cdrom \
944 # --disk=/a/images/fake.qcow2,bus=virtio
946 # went to device manager, saw 2 pci devices with yellow !,
947 # did search for drivers, pick cdrom location, done.
949 # from http://www.tenforums.com/tutorials/4189-fast-startup-turn-off-windows-10-a.html.
950 # google said there was a control panel option for it, but
951 # that turned out to be a lie.
952 # Put this in a .bat file and run as administrator to turn off
953 # hyberboot which fucks things up.
954 # REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /V HiberbootEnabled /T REG_dWORD /D 0 /F
955 # power settings, turn off display: never
956 # run "control userpasswords2", turn on automatic login.
957 # note: when changing devices, I just undefine, the create the vm again.
959 s virt-install
--noautoconsole --graphics spice
,listen
=0.0.0.0 \
960 --disk=/a
/images
/win10.qcow2
,bus
=virtio
--vcpus 2 -r 4096 -w bridge
=br0 \
961 -n win10
--import --os-variant $variant --cpu host-model-only
963 s virsh destroy win10
965 # this one hasn\'t had the virtio fix done yet.
966 s virt-install
--noautoconsole --graphics spice
,listen
=0.0.0.0 \
967 --disk=/a
/images
/win7.qcow2
--vcpus 2 -r 4096 -w bridge
=br0 \
968 -n win7
--import --os-variant win7
--cpu host-model-only
970 # had a problem with --cpu host, so trying out
971 # --cpu host-model-only
977 # note samba re-reads it's config every 1 minute
980 # add 2 lines after workgroup option
981 s
sed -ri '/^\s*encrypt passwords\s*=/d' /etc
/samba
/smb.conf
982 s
sed -ri '/^\s*map to guest\s*=/d' /etc
/samba
/smb.conf
983 s
sed -i 's/\(\s*workgroup\s*=\).*/\1 WORKGROUP\n\tencrypt passwords = yes\n\tmap to guest = bad password/' /etc
/samba
/smb.conf
984 # remove default homes section. not sharing that.
985 s
sed -ri '/^\s*\[homes\]/,/\s*\[/d' /etc
/samba
/smb.conf
987 if ! grep -xF '[public]' /etc
/samba
/smb.conf
&>/dev
/null
; then
988 s
tee -a /etc
/samba
/smb.conf
<<'EOF'
998 # systemd claims it generates units from /etc/init.d, but it clearly doesn't
999 # in debian. I have no idea how they are related. fuck debian right now. It's
1000 # not documented. samba has a systemd init file linked to /dev/null.
1001 # There's this https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769714 which
1002 # claims samba's sub-services will be started automatically by systemd... it
1003 # didn't on install, wonder if it will on boot. It clued me in how to start
1004 # it manually though. Nothing in /usr/share/doc/samba, debian admin guide
1005 # says nothing about any of this. (this is in debian testing as of 4/2016).
1007 s
/etc
/init.d
/samba start
1014 tu
/etc
/hosts
<<< "127.0.1.1 $(hostname).lan $(hostname)"
1018 rootdev
=$
(mount |
sed -rn 's#^(\S+) on / .*#\1#p')
1020 tu
/etc
/fstab
<<< "$rootdev /mnt/root btrfs noatime,subvolid=0 0 0"
1021 s mount
/mnt
/root ||
[[ $?
== 32 ]]
1022 idev
=$
(mount |
sed -rn 's#^(\S+) on /i .*#\1#p')
1023 if [[ $idev != $rootdev ]]; then
1025 tu
/etc
/fstab
<<< "$idev /mnt/iroot btrfs noatime,subvolid=0 0 0"
1026 s mount
/mnt
/iroot ||
[[ $?
== 32 ]]
1029 # Do this again because it occasionally has changes and
1030 # it can be run outside initial isntall.
1031 s
/a
/bin
/fai
/fai
/config
/distro-install-common
/end