# Copyright (C) 2016 Ian Kelling
# This program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>
+# todo. dunno why, but original bootstrap of timezone is not sticking.
+# fixed manually with:
+# s dpkg-reconfigure tzdata
+
# for bootstrapping a new machine
####### end command line parsing
-
if encrypted; then
# I tried making a service which was dependent on reboot.target,
# but it happened too late in the shutdown process.
sudo dd of=/etc/systemd/system/keyscripton.service <<'EOF'
[Unit]
Description=Turn on automatic decryption of drives on boot
-After=multi-user.target
+# tried using graphical.target, but it made my display manager restart before rebooting.
+# generally, I don't think targets order shutdown like they do startup.
+# So, I did systemd-analyze plot > something.svg, and picked a reliably started
+# service that happens late in the game.
+After=postfix.service
+DefaultDependencies=no
+Conflicts=reboot.target
[Service]
Type=oneshot
ExecStop=/a/bin/keyscript-on
[Install]
-WantedBy=multi-user.target
+WantedBy=keyscriptoff.service
EOF
- sudo systemctl start keyscripton.service
+ sudo systemctl daemon-reload # needed if the file was already there
+ sudo systemctl stop keyscripton.service
+ # sudo systemctl start keyscripton.service
sudo systemctl enable keyscripton.service
sudo dd of=/etc/systemd/system/keyscriptoff.service <<'EOF'
[Install]
WantedBy=multi-user.target
EOF
+ sudo systemctl daemon-reload # needed if the file was already there
sudo systemctl enable keyscriptoff.service
sudo systemctl start keyscriptoff.service
fi
# link files
-lnf /a/c/* /a/bin ~
-
for x in /a/c/repos/bash/!(.git); do
- lnf "$x" ~
+ for homedir in /home/*; do
+ sudo chown -R ian:ian $homedir
+ lnf "$x" $homedir
+ done
sudo -i <<EOF
source /a/bin/bash-programs-by-ian/repos/lnf/lnf-function
lnf $x /root
p update
# take care of mozilla signing errors in previous command
pi pkg-mozilla-archive-keyring
+ p update
else
:
# this would change stable to testing, but I set that up already.
# for aur, automatically dl & add gpg keys.
# Just the keyserver-options line goes in dirmngr.conf once
# this bug is fixed: https://bugs.gnupg.org/gnupg/issue2147
- teeu ~/.gnupg/gpg.conf <<EOF
-$(grep -o '^ *keyserver .*' ~/.gnupg/dirmngr.conf)
+ for homedir in /home/*; do
+ teeu $homedir/.gnupg/gpg.conf <<EOF
+$(grep -o '^ *keyserver .*' $homedir/.gnupg/dirmngr.conf)
keyserver-options auto-key-retrieve
EOF
+ done
pi pacserve
x=$(mktemp); pacman.conf-insert_pacserve >$x
sudo dd of=/etc/pacman.conf if=$x; rm $x
###### link files ###########
# convenient to just do all file linking in one place
-lnf /a/* ~
s lnf /a/sdx{,d} /
# if it wasn't set already, we could set hostname here
s lnf /a/c/.inputrc /a/c/.vim /a/c/.vimrc /a/c/.gvimrc /root
-if [[ $HOSTNAME == htpc ]]; then
- lnf -T /i/Videos ~/Downloads
-fi
+# machine is going away
+# if [[ $HOSTNAME == htpc ]]; then
+# lnf -T /i/Videos ~/Downloads
+# fi
if has_p; then
# for dovecot
- lnf -T /i/mboxes ~/mail
+ lnf -T /i/k/mboxes ~/mail
fi
sudo systemctl enable fstrim.timer
fi
-if has_p; then
- # relatime is default, but it still significantly increases writes
- # in comparison because it writes on the first read after each
- # write.
- #
- dirs=(/i /mnt/{1,2,3,4,5,6,7,8,9})
- if ! frodo; then
- dirs+=(/q)
- fi
- s mkdir -p "${dirs[@]}"
- s chown ian:ian "${dirs[@]}"
- # ssh and probably some other things care about parent directory
- # ownership, and ssh doesn\'t allow any group writable parent
- # directories, so we are forced to use a directory structure similar
- # to home directories
- s chown root:ian /q
- s chmod 755 /q
+dirs=(/mnt/{1,2,3,4,5,6,7,8,9})
+s mkdir -p "${dirs[@]}"
+s chown ian:ian "${dirs[@]}"
+if [[ $HOSTNAME == treetowl ]]; then
+ tu /etc/fstab <<'EOF'
+UUID=3f7b31cd-f299-40b4-a86b-7604282e2715 /i btrfs noatime 0 2
+EOF
+else
+ tu /etc/fstab <<'EOF'
+/q/i /i none bind 0 0
+EOF
+fi
+
+tu /etc/fstab <<'EOF'
+/i/w /w none bind 0 0
+/i/k /k none bind 0 0
+EOF
+if ! mountpoint /kfrodo; then
+ s mkdir -p /kfrodo
+ s chown ian:traci /kfrodo
fi
+if [[ $HOSTNAME == frodo ]]; then
+ tu /etc/fstab <<'EOF'
+/k /kfrodo none bind 0 0
+EOF
+else
+ tu /etc/fstab <<'EOF'
+frodo:/k /kfrodo nfs defaults 0 0
+EOF
+fi
+
+for x in i w k; do
+ s mount /$i || [[ $? == 32 ]] # 32 = already mounted
+done
+
+
+# ssh and probably some other things care about parent directory
+# ownership, and ssh doesn\'t allow any group writable parent
+# directories, so we are forced to use a directory structure similar
+# to home directories
+s chown root:ian /q
+s chmod 755 /q
/a/bin/conflink
+# propogate /etc/udev/hwdb.d
+s systemd-hwdb update
+ser restart systemd-udev-trigger
# work desktop doesnt need gpg stuff, but it doesnt hurt
s dd of=/etc/profile.d/environment.sh <<'EOF'
# see /a/bin/old-unused/xmonad-cabal.sh
# trying out the distro's versions newer distros
- pi xmonad
- if isarch; then
- # for displaying error messages.
- # optional dependency in arch, standard elsewhere.
- pi xorg-xmessage xmonad-contrib xorg-xsetroot xorg-xinit
-
- # https://wiki.archlinux.org/index.php/Xinitrc
- cp /etc/X11/xinit/xinitrc ~/.xinitrc
- sed -ri '/^ *twm\b/,$d' ~/.xinitrc
- echo "source /a/bin/xinitrc" >> ~/.xinitrc
- else
- pi suckless-tools
- fi
+pi xmonad
+if isarch; then
+ # for displaying error messages.
+ # optional dependency in arch, standard elsewhere.
+ pi xorg-xmessage xmonad-contrib xorg-xsetroot xorg-xinit
+
+ # https://wiki.archlinux.org/index.php/Xinitrc
+ for homedir in /homme/*; do
+ cp /etc/X11/xinit/xinitrc $homedir/.xinitrc
+ sed -ri '/^ *twm\b/,$d' $homedir/.xinitrc
+ echo "source /a/bin/xinitrc" | tee -a $homedir/.xinitrc
+ done
+else
+ pi suckless-tools
+fi
pi dmenu
if isdeb && (tp || x2); then
pi task-laptop
fi
+
+sudo chown -R traci:traci /home/traci
set -x
end_msg() {
- local y
+ = local y
IFS= read -r -d '' y ||:
end_msg_var+="$y"
}
pup
# universal packages
-x=(
+simple_packages=(
bwm-ng
chromium
duplicity
+ evince
fdupes
filelight
gdb
mailutils
meld
mpv
+ nmon
offlineimap
- openvpn
p7zip
paprefs
pavucontrol
slock
smartmontools
squashfs-tools
+ tcpdump
tree
- virt-manager
+ vim
)
-pi "${x[@]}"
+spa() { # simple package add
+ simple_packages+=($@)
+}
+
+
+case $distro in
+ debian) pi curl ;;
+ arch) : ;;
+ # fedora: unknown
+esac
+
+case $distro in
+ arch) pi syncthing ;;
+ ubuntu|debian)
+ # google led me here:
+ # https://apt.syncthing.net/
+ curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
+ s="deb http://apt.syncthing.net/ syncthing release"
+ if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != $s ]]; then
+ echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list
+ p update
+ fi
+ pi syncthing
+ ;;
+esac
+# installed via f-droid
+# top right, actions, device id
+#
+# for installing on a remote comp:
+# ssh -L 8384:localhost:8384 -N frodo
+# went to http://localhost:8384/
+#
+# add folder to sync phone,
+# staggered file versioning would be my normal choice, but choose
+# trash can versioning for sake of space on phone, with
+# clean out after 7 days.
+#
+# did ser syncthing@ian start
+# then on phone, add device, hit bar code icon,
+# install bar code scanner.
+
# things with no equivalent in other distros:
case $distro in
debian|ubuntu)
# for gui bug reporting
- pi python-vte
+ spa python-vte
pi apt-file aptitude
s apt-file update
# for debconf-get-selections
- pi debconf-utils
+ spa debconf-utils
;;
esac
####### misc packages ###########
+case $distro in
+ ubuntu|debian)
+ spa spacefm-gtk3 ;;
+ arch)
+ spa spacefm ;;
+esac
+
+
+
+if [[ $HOSTNAME == frodo ]]; then
+ case $distro in
+ debian|ubuntu)
+ # note i had to do this, which is persistent:
+ # cd /i/k
+ # s chgrp debian-transmission torrents partial-torrents
+
+ # syslog says things like
+ # 'Failed to set receive buffer: requested 4194304, got 425984'
+ # google suggets giving it even more than that
+ tu /etc/sysctl.conf<<'EOF'
+net.core.rmem_max = 67108864
+net.core.wmem_max = 16777216
+EOF
+ s sysctl -p
+
+ # some reason it doesn't seem to start automatically anyways
+ pi-nostart tranmission-daemon
+ # config file documented here, and it's the same config
+ # for daemon vs client, so it's documented in the gui.
+ # https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
+ s ruby <<'EOF'
+require 'json'
+p = '/etc/transmission-daemon/settings.json'
+File.write(p, JSON.pretty_generate(JSON.parse(File.read(p)).merge({
+'rpc-whitelist': '127.0.0.1,192.168.1.*',
+'rpc-authentication-required': false,
+'incomplete-dir': '/i/k/partial-torrents',
+'download-dir': '/i/k/torrents',
+"speed-limit-up": 700,
+"speed-limit-up-enabled": true,
+"ratio-limit": 1.4000,
+"ratio-limit-enabled": true,
+})) + "\n")
+EOF
+ sgo transmission-daemon
+ ;;
+ arch)
+ # todo, setup it's config file & daemon
+ pi transmission-cli
+ ;;
+ esac
+fi
+
+# from /var/lib/dpkg/info/transmission-daemon.postinst
+if ! getent passwd debian-transmission > /dev/null; then
+ s adduser --quiet \
+ --system \
+ --group \
+ --no-create-home \
+ --disabled-password \
+ --home /var/lib/transmission-daemon \
+ debian-transmission
+fi
+
+case $distro in
+ debian|ubuntu) pi transmission-remote-gtk ;;
+ arch) pi transmission-remote-gtk2 ;;
+esac
+# arch had a default config,
+# debian had nothing until you start it.
+# With a little trial an error, here is a minimal config
+# taken from the generated one, plus changes that the
+# settings ui does, without a bunch of ui crap settings.
+#
+# only settings I set were
+# hostname
+# auto-connect
+#
+for f in /home/*; do
+ d=$f/.config/transmission-remote-gtk
+ u=${f##*/}
+ s -u $u mkdir -p $d
+ s -u $u dd of=$d/config.json <<'EOF'
+{
+ "profiles" : [
+ {
+ "profile-name" : "Default",
+ "hostname" : "frodo",
+ "rpc-url-path" : "/transmission/rpc",
+ "username" : "",
+ "password" : "",
+ "auto-connect" : true,
+ "ssl" : false,
+ "timeout" : 40,
+ "retries" : 3,
+ "update-active-only" : false,
+ "activeonly-fullsync-enabled" : false,
+ "activeonly-fullsync-every" : 2,
+ "update-interval" : 3,
+ "min-update-interval" : 3,
+ "session-update-interval" : 60,
+ "exec-commands" : [
+ ],
+ "destinations" : [
+ ]
+ }
+ ],
+ "profile-id" : 0,
+ "add-options-dialog" : false
+}
+EOF
+done
+
+case $distro in
+ debian|ubuntu)
+ pi-nostart openvpn
+ # pi-nostart this doesn't seem to be good enough?
+ ser disable openvpn@client
+ ser disable openvpn
+ ;;
+ *) pi openvpn ;;
+esac
+
+case $HOSTNAME in
+ tp|frodo)
+ case $distro in
+ debian|ubuntu)
+ log=$(mktemp)
+ cd /a/opt
+ wget -N https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
+ set +e
+ s dpkg -i google-chrome-stable_current_amd64.deb &> $log
+ code=$?
+ set -e
+ case $code in
+ 1)
+ if grep '^dpkg: dependency problems prevent configuration of' \
+ $log &>/dev/null; then
+ s apt-get -fy install
+ else
+ exit 1
+ fi
+ ;;
+ 0) : ;;
+ *) exit $code
+ esac
+ ;;
+ arch)
+ pi google-chrome
+ ;;
+ esac
+ ;;
+esac
+
+case $distro in
+ # ubuntu unknown. probably the same as debian, just check if the
+ # init scripts come with the package.
+ debian)
+ # copied from arch
+ s dd of=/etc/systemd/system/synergys@.service <<'EOF'
+[Unit]
+Description=Synergy Server Daemon
+After=network.target
+
+[Service]
+User=%i
+ExecStart=/usr/bin/synergys --no-daemon --config /etc/synergy.conf
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
+EOF
+ s dd of=/etc/systemd/system/synergys@.socket <<'EOF'
+[Unit]
+Conflicts=synergys@.service
+
+[Socket]
+ListenStream=24800
+Accept=false
+
+[Install]
+WantedBy=sockets.target
+EOF
+ ;;&
+ *)
+ pi synergy
+ s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
+[Unit]
+Description=Synergy Client
+After=network.target
+
+[Service]
+User=%i
+ExecStart=/usr/bin/synergyc --no-daemon treetowl
+Restart=on-failure
+# per man systemd.unit, StartLimitInterval, by default we
+# restart more than 5 times in 10 seconds.
+# And this param defaults too 200 miliseconds.
+RestartSec=3s
+
+[Install]
+WantedBy=multi-user.target
+EOF
+ case $HOSTNAME in
+ frodo)
+ sgo synergyc@ian
+ sgo synergys@ian.socket
+ ;;
+ treetowl) sgo synergys@ian.socket ;;
+ esac
+ ;;
+esac
+
case $distro in
# tk for gitk
- arch) pi git tk ;;
- *) pi git ;;
+ arch) spa git tk ;;
+ *) spa git ;;
esac
case $distro in
- arch) pi the_silver_searcher ;;
- debian|ubuntu) pi silversearcher-ag ;;
+ arch) spa the_silver_searcher ;;
+ debian|ubuntu) spa silversearcher-ag ;;
# fedora unknown
esac
# in arch, I had to pick out the 6L driver.
;;
debian|ubuntu)
- pi hplip
+ spa hplip
;;
# other distros unknown
esac
case $distro in
- ubuntu|debian) pi ack-grep ;;
- arch|fedora) pi ack ;;
+ ubuntu|debian) spa ack-grep ;;
+ arch|fedora) spa ack ;;
# fedora unknown
esac
case $distro in
ubuntu|debian) pi --no-install-recommends mairix notmuch ;;
- fedora|arch) pi mairix notmuch ;;
+ fedora|arch) spa mairix notmuch ;;
esac
case $distro in
- arch) pi nfs-utils ;;
- ubuntu|debian) pi nfs-client ;;
+ arch) spa nfs-utils ;;
+ ubuntu|debian) spa nfs-client ;;
esac
case $distro in
- ubuntu|debian) pi par2 ;;
- arch|fedora) pi par2cmdline ;;
+ ubuntu|debian) spa par2 ;;
+ arch|fedora) spa par2cmdline ;;
esac
# needed for my tex resume
case $distro in
- ubuntu|debian) pi texlive-full ;;
- arch) pi texlive-most ;;
+ ubuntu|debian) spa texlive-full ;;
+ arch) spa texlive-most ;;
# fedora unknown
esac
ubuntu)
# flash, unrar, codecs, ms fonts.
# This has a manual prompt.
- pi ubuntu-restricted-extras
+ spa ubuntu-restricted-extras
;;
fedora)
pi yum-utils
case $distro in
# optional dep for firefox for h.264 video
- arch) pi gst-libav ;;
+ arch) spa gst-libav ;;
# other distros, probably come by default
esac
case $distro in
- fedora|ubuntu|debian) pi gnupg-agent ;;
+ fedora|ubuntu|debian) spa gnupg-agent ;;
arch) : ;;
esac
case $distro in
- fedora|ubuntu|debian) pi transmission ;;
- arch) pi transmission-gtk ;;
-esac
-
-
-case $distro in
- fedora) pi pinentry-gtk ;;
+ fedora) spa pinentry-gtk ;;
*) : ;; # comes default or with other packages
esac
case $distro in
- arch) pi firefox pulseaudio;;
+ arch) spa firefox pulseaudio;;
*) : ;; # comes default or with other packages
esac
case $distro in
arch|debian|ubuntu)
- pi bash-completion
+ spa bash-completion
;;
# others unknown
esac
case $distro in
- arch) pi ttf-dejavu;;
- debian|ubuntu) pi fonts-dejavu ;;
+ arch) spa ttf-dejavu;;
+ debian|ubuntu) spa fonts-dejavu ;;
# others unknown
esac
case $distro in
- arch|debian|ubuntu) pi ntp;;
+ debian|ubuntu) spa ntp;;
+ arch)
+ pi ntp
+ sgo ntpd
+ ;;
# others unknown
esac
case $distro in
- arch) pi xorg-xev;;
- debian|ubuntu) pi x11-utils ;;
+ arch) spa xorg-xev;;
+ debian|ubuntu) spa x11-utils ;;
# others unknown
esac
case $distro in
- arch) pi virt-install;;
- debian|ubuntu) pi virtinst ;;
+ arch) pi virt-install;;&
+ debian|ubuntu) pi virtinst ;;&
+ *) pi virt-manager ;; # creates the libvirt group in debian at least
# others unknown
esac
+# allow user to run vms, from debian handbook
+for x in ian traci; do s usermod -a -G libvirt $x; done
+# bridge networking as user fails. google lead here, but it doesn't work:
+# oh well, I give up.
+# http://wiki.qemu.org/Features-Done/HelperNetworking
+# s mkdir /etc/qemu
+# f=/etc/qemu/bridge.conf
+# s dd of=$f <<'EOF'
+# allow br0
+# EOF
+# #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent?
+# s chmod 640 $f
+
case $distro in
- arch) pi cdrkit;;
- debian|ubuntu) pi genisoimage;;
+ arch) spa cdrkit;;
+ debian|ubuntu) spa genisoimage;;
# others unknown
esac
case $distro in
- arch) pi spice-gtk3 ;;
- debian|ubuntu) pi spice-client-gtk;;
+ arch) spa spice-gtk3 ;;
+ debian|ubuntu) spa spice-client-gtk;;
# others unknown
esac
# qemu for qemu-img, bind-tools for dig
pi unzip wget xorg-xmodmap \
bridge-utils dnsmasq qemu bind-tools
- sgo ntpd
# otherwise we get error about accessing kvm module.
# seems like there might be a better way, but google was a bit vague.
s sed -ri '/^ *user *=/d' /etc/libvirt/qemu.conf
pi cronie
sgo cronie
;;
- *) : ;; # other distros come with cron.
+ *) : ;; # other distros come with cron.
esac
case $distro in
fedora) cabal install shellcheck ;;
- *) pi shellcheck ;;
+ *) spa shellcheck ;;
# unknown for older ubuntu
esac
case $distro in
- arch|debian|ubuntu) pi pumpa ;;
+ arch|debian|ubuntu) spa pumpa ;;
# others unknown. do have a buildscript:
# /a/bin/buildscripts/pumpa ;;
esac
case $distro in
- debian|ubuntu) pi android-tools-adb ;;
- arch) pi android-tools ;;
+ debian|ubuntu) spa android-tools-adb ;;
+ arch) spa android-tools ;;
# other distros unknown
esac
case $distro in
- fedora) pi unrar ;;
- *) pi unrar-free ;;
+ fedora) spa unrar ;;
+ *) spa unrar-free ;;
esac
# pi flashplugin-nonfree
# esac
-case $distro in
- debian) pi curl ;;
- arch) : ;;
- # fedora: unknown
-esac
case $distro in
esac
case $distro in
- arch) pi apg ;;
+ arch) spa apg ;;
+
# already in debian jessie
esac
+pi "${simple_packages[@]}"
+
######### end misc packages #########
########### misc stuff
+if [[ $HOSTNAME == frodo ]]; then
+ tu /etc/exports <<'EOF'
+/k 192.168.1.0/24(rw,nohide,no_subtree_check,insecure)
+EOF
+ s exportfs -ra
+fi
+
if [[ `debian-archive` == stable ]]; then
s dd of=/etc/apt/preferences.d/unison-gtk <<'EOF'
Explanation: Allow unison-gtk to be upgraded
esac
if [[ $HOSTNAME == treetowl ]] && [[ `debian-archive` != testing ]]; then
- # fail2 ban is broken, with a workaround, per
+ # fail2 ban is broken, with a workaround, per
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770171
# ill wait a while to see if it gets fixed
pi fail2ban
# it might work in /etc/aliases, but this seems more proper.
if s grep amazonaws /etc/postfix/sasl_passwd &>/dev/null; then
- forward=x@sallymae.club
+ forward=$HOSTNAME@sallymae.club
else
forward=$HOSTNAME@bog.mm.st
fi
fi
e "$end_msg_var"
+
+
+# persistent virtual machines
+
+case $distro in
+ debian|ubuntu)
+ pi libosinfo-bin;
+ ;;
+esac
+
+# distro may not know about win 10 yet.
+variant=win7
+if ! virt-install --os-variant list &>/dev/null; then # we are using a newer virt-install
+ for v in 10 8.1 8; do
+ if osinfo-query os | gr "^\s*win${v/./\\.}\s" &>/dev/null; then
+ variant=win$v
+ break
+ fi
+ done
+fi
+
+if ! s virsh list --all --name | grep -xF win10 &>/dev/null; then
+
+ # created account with
+ # win10vmian@outlook.com, and easy to remember password
+ # win 10 virtio, makes disk way way way faster
+ # wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso
+ # https://wiki.archlinux.org/index.php/QEMU#Change_Existing_Windows_VM_to_use_virtio
+ # for installing virtio after initial install instead of with initial iso:
+ # qemu-img create -f qcow2 fake.qcow2 1G
+ # --disk=/a/images/virtio-win.iso,device=cdrom \
+ # --disk=/a/images/fake.qcow2,bus=virtio
+ # Also,
+ # went to device manager, saw 2 pci devices with yellow !,
+ # did search for drivers, pick cdrom location, done.
+ #
+ # from http://www.tenforums.com/tutorials/4189-fast-startup-turn-off-windows-10-a.html.
+ # google said there was a control panel option for it, but
+ # that turned out to be a lie.
+ # Put this in a .bat file and run as administrator to turn off
+ # hyberboot which fucks things up.
+ # REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /V HiberbootEnabled /T REG_dWORD /D 0 /F
+ # power settings, turn off display: never
+ # run "control userpasswords2", turn on automatic login.
+ # note: when changing devices, I just undefine, the create the vm again.
+
+ s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
+ --disk=/a/images/win10.qcow2,bus=virtio --vcpus 2 -r 4096 -w bridge=br0 \
+ -n win10 --import --os-variant $variant --cpu host-model-only
+
+ s virsh destroy win10
+
+ # this one hasn\'t had the virtio fix done yet.
+ s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \
+ --disk=/a/images/win7.qcow2 --vcpus 2 -r 4096 -w bridge=br0 \
+ -n win7 --import --os-variant win7 --cpu host-model-only
+ s virsh destroy win7
+ # had a problem with --cpu host, so trying out
+ # --cpu host-model-only
+
+fi
+
+
+pi samba
+# note samba re-reads it's config every 1 minute
+
+
+# add 2 lines after workgroup option
+s sed -ri '/^\s*encrypt passwords\s*=/d' /etc/samba/smb.conf
+s sed -ri '/^\s*map to guest\s*=/d' /etc/samba/smb.conf
+s sed -i 's/\(\s*workgroup\s*=\).*/\1 WORKGROUP\n\tencrypt passwords = yes\n\tmap to guest = bad password/' /etc/samba/smb.conf
+# remove default homes section. not sharing that.
+s sed -ri '/^\s*\[homes\]/,/\s*\[/d' /etc/samba/smb.conf
+
+if ! grep -xF '[public]' /etc/samba/smb.conf &>/dev/null; then
+ s tee -a /etc/samba/smb.conf <<'EOF'
+[public]
+ guest ok = yes
+ read only = no
+ path = /kfrodo
+EOF
+fi
+
+case $distro in
+ debian|ubuntu)
+# systemd claims it generates units from /etc/init.d, but it clearly doesn't
+# in debian. I have no idea how they are related. fuck debian right now. It's
+# not documented. samba has a systemd init file linked to /dev/null.
+# There's this https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769714 which
+# claims samba's sub-services will be started automatically by systemd... it
+# didn't on install, wonder if it will on boot. It clued me in how to start
+# it manually though. Nothing in /usr/share/doc/samba, debian admin guide
+# says nothing about any of this. (this is in debian testing as of 4/2016).
+
+s /etc/init.d/samba start
+;;
+ arch)
+ sgo samba
+ ;;
+esac
+
+tu /etc/hosts <<< "127.0.1.1 $(hostname).lan $(hostname)"
+
+
+
+rootdev=$(mount | sed -rn 's#^(\S+) on / .*#\1#p')
+s mkdir /mnt/root
+tu /etc/fstab <<< "$rootdev /mnt/root btrfs noatime,subvolid=0 0 0"
+s mount /mnt/root || [[ $? == 32 ]]
+idev=$(mount | sed -rn 's#^(\S+) on /i .*#\1#p')
+if [[ $idev != $rootdev ]]; then
+ s mkdir /mnt/iroot
+ tu /etc/fstab <<< "$idev /mnt/iroot btrfs noatime,subvolid=0 0 0"
+ s mount /mnt/iroot || [[ $? == 32 ]]
+fi
+
+# Do this again because it occasionally has changes and
+# it can be run outside initial isntall.
+s /a/bin/fai/fai/config/distro-install-common/end