various fixes
[distro-setup] / distro-begin
index a53cbb4f23ffac9a2d0c583f81b0df620dfe22a7..bf298d58e1fa741762ed8584c65aa782d4dd5a97 100755 (executable)
@@ -68,9 +68,11 @@ fi
 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_p() { treetowl || x2 || frodo || tp || demohost; }
+has_x() { ! linode; }
 linode() { lj || li; }
+has_btrfs() { ! linode; }
+home_network() { ! linode; }
 encrypted() { has_p; }
 
 shopt -s extglob
@@ -217,7 +219,6 @@ EOF
 isfedora && tu /etc/sysctl.conf 'kernel.sysrq = 1'
 
 
-s lnf -T /q/p /p
 # this needs to be before installing pacserve so we have gpg conf.
 conflink
 
@@ -319,12 +320,13 @@ 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. In this case,
+                # I switch to using firefox-esr. 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
@@ -541,33 +543,6 @@ dirs=(/mnt/{1,2,3,4,5,6,7,8,9})
 s mkdir -p "${dirs[@]}"
 s chown ian:ian  "${dirs[@]}"
 
-if [[ $HOSTNAME == treetowl ]]; then
-    # 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
-else
-    tu /etc/fstab <<'EOF'
-/q/i  /i  none  bind  0 0
-EOF
-
-    tu /etc/crypttab <<EOF
-crypt_dev_$dev  /dev/disk/by-id/$dev  /q/root/luks/host-treetowl  discard,luks
-EOF
-fi
 
 tu /etc/fstab <<'EOF'
 /i/w  /w  none  bind  0 0
@@ -580,24 +555,45 @@ 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
+if ! mountpoint $dir; then
+    subvol=/mnt/root/nocow
+    if [[ ! -e nocow ]]; then
+        btrfs subvolume create $subvol
+        chown root:1000 $subvol
+        chattr +C $subvol
+    fi
+
+    first_root_crypt=$(awk '$2 == "/" {print $1}' /etc/mtab)
+    tu /etc/fstab <<EOF
+$first_root_crypt  /nocow  btrfs  noatime,subvol=nocow  0 0
+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
@@ -680,14 +676,24 @@ umask 002
 EOF
 
 
-
-postfix-setup
-
-if isubuntu; then
-    # disable crash report annoying crap
-    s dd of=/etc/default/apport <<<'enabled=0'
+if isdeb; then
+    # I've had problems with postfix on debian:
+    # on stretch, a startup ordering issue caused all mail to fail.
+    # postfix changed defaults to only use ipv6 dns, causing all my mail to fail.
+    # exim4 is default on debian, so I assume it would
+    # be packaged better to avoid these types of things.
+    # I haven't gotten around to getting a non-debian exim
+    # setup.
+    mail-setup exim4
+   else
+       mail-setup postfix
 fi
 
+   if isubuntu; then
+       # disable crash report annoying crap
+       s dd of=/etc/default/apport <<<'enabled=0'
+   fi
+
 # fai sets this an old way that doesn't work for stretch.
 # no harm in setting it universally here.
 # using debconf-set-selection, the area gets reset to ETC