wip using btrfs send for sync
[distro-setup] / distro-begin
index b03134890ea3e4e67de6ade28ac275bbbd2771a4..eda0b4d2f3df013810c86cef0b1145f9314d4f58 100755 (executable)
@@ -69,8 +69,10 @@ for f in iank-dev htpc treetowl x2 frodo tp li lj demohost; do
     eval "$f() { [[ $HOSTNAME == $f ]]; }"
 done
 has_p() { treetowl || iank-dev || x2 || frodo || tp || demohost; }
-has_x() { ! { lj || li; }; }
+has_x() { ! linode; }
 linode() { lj || li; }
+has_btrfs() { ! linode; }
+home_network() { ! linode; }
 encrypted() { has_p; }
 
 shopt -s extglob
@@ -319,12 +321,12 @@ case $(distro-name) in
             if isdebian-stable; then
                 pi firefox/$codename-backports
             else
-                # for a while, firefox/unstable had all it\'s deps satisfied
-                # by testing packages, but now i hit a conflict,
-                # it wanted a newer libfontconfig1, but emacs build-deps
-                # wanted an older one. Oh well, they seem to release
-                # a new esr version every 9 months or so.
-                pi firefox-esr
+                # for a while, firefox/unstable did not have
+                # dependencies satisfied by testing packages, and i hit
+                # a conflict, it wanted a newer libfontconfig1, but
+                # emacs build-deps wanted an older one. note: They seem
+                # to release a new esr version every 9 months or so.
+                pi firefox/unstable
             fi
         fi
         # for hosts which require nonfree drivers
@@ -542,13 +544,33 @@ s mkdir -p "${dirs[@]}"
 s chown ian:ian  "${dirs[@]}"
 
 if [[ $HOSTNAME == treetowl ]]; then
-    tu /etc/fstab <<'EOF'
-/dev/disk/by-id/ata-TOSHIBA_MD04ACA500_84REK6NTFS9A-part1 /i btrfs  noatime,subvol=i  0 0
+    # partitioned it with fai partitioner outside of fai,
+    # because it\'s worth it to have 1% space reserved for boot and
+    # swap partitions in case I ever want to boot off those drives.
+    # as root:
+    # . /a/bin/fai/fai-wrapper
+    # eval-fai-classfile /a/bin/fai/fai/config/class/51-multi-boot
+    # fai-setclass ROTATIONAL
+    # export LUKS_DIR=/q/root/luks/
+    # # because the partition nums existed already
+    # fai-setclass REPARTITION
+    # /a/bin/fai/fai/config/hooks/partition.DEFAULT
+
+    # just the first in the btrfs raid
+    dev=ata-TOSHIBA_MD04ACA500_84REK6NTFS9A-part1
+    tu /etc/fstab <<EOF
+/dev/mapper/crypt_dev_$dev /i btrfs  noatime,subvol=i  0 0
+EOF
+
+    tu /etc/crypttab <<EOF
+crypt_dev_$dev  /dev/disk/by-id/$dev  /q/root/luks/host-treetowl  discard,luks
 EOF
+
 else
     tu /etc/fstab <<'EOF'
 /q/i  /i  none  bind  0 0
 EOF
+
 fi
 
 tu /etc/fstab <<'EOF'
@@ -556,28 +578,44 @@ tu /etc/fstab <<'EOF'
 /i/k  /k  none  bind  0 0
 EOF
 
+
+
 if ! mountpoint /kr; then
     s mkdir -p /kr
     s chown ian:traci /kr
 fi
-if [[ $HOSTNAME == treetowl ]]; then
-    tu /etc/fstab <<'EOF'
+
+if home_network; then
+    if [[ $HOSTNAME == treetowl ]]; then
+        tu /etc/fstab <<'EOF'
 /k  /kr  none  bind  0 0
 EOF
-else
-    tu /etc/fstab <<'EOF'
+    else
+        tu /etc/fstab <<'EOF'
 treetowl:/k  /kr  nfs  defaults  0 0
 EOF
+    fi
 fi
 
 s mkdir -p /q/i/{w,k}
 for dir in /{i,w,k}; do
-    if mountpoint $dir; then continue; fi
+    if mountpoint $dir; then continue; fi # already mounted
     s mkdir -p $dir
     s chown ian:ian $dir
     s mount $dir
 done
 
+dir=/nocow
+l=$(sed -rn "s#^(\s*\S+\s+)/q(\s.*)(subvol=q)#\1$dir\2subvol=nocow#p" /etc/fstab)
+if [[ $l ]] && ! mountpoint $dir; then
+    tu /etc/fstab <<EOF
+$l
+EOF
+    s mkdir -p $dir
+    s chown ian:ian $dir
+    s mount $dir
+fi
+
 
 # ssh and probably some other things care about parent directory
 # ownership, and ssh doesn\'t allow any group writable parent