+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
+