minor bug fix
[distro-setup] / distro-begin
index b2b21f783f68c67b380e38f17704c2b91e6f2b41..89a09babf4e1f78c6a9af33ed530985da90a0359 100755 (executable)
 # set the scrollback to unlimited in case something goes wrong
 
 
+# send to registrar, glue records:
+# for iankelling.org:
+
+# ns1.iankelling.org 72.14.176.105
+# ns1.iankelling.org 2600:3c00::f03c:91ff:fe6d:baf8
+# ns2.iankelling.org 172.105.84.95
+# ns2.iankelling.org 2a01:7e01::f03c:91ff:feb5:baec
+
+# for zroe.org:
+
+# ns1.zroe.org 72.14.176.105
+# ns1.zroe.org 2600:3c00::f03c:91ff:fe6d:baf8
+# ns2.zroe.org 172.105.84.95
+# ns2.zroe.org 2a01:7e01::f03c:91ff:feb5:baec
+#
+
+
+
 ####### begin setup environment #######
 
 
@@ -36,6 +54,11 @@ if ! $interactive; then
   set -x
 fi
 source /a/bin/errhandle/err
+
+_errcatch_cleanup() {
+  echo 1 >~/.local/distro-begin
+}
+
 source /a/bin/distro-functions/src/package-manager-abstractions
 
 ### setup logging
@@ -75,14 +98,14 @@ source $script_dir/pkgs
 set +x
 source /a/bin/distro-functions/src/identify-distros
 $interactive || set -x
-for f in kd x2 x3 frodo tp li lj demohost kw; do
+for f in kd x2 x3 frodo tp li l2 demohost kw; do
   eval "$f() { [[ $HOSTNAME == $f ]]; }"
 done
 codename=$(debian-codename)
 has_wayland() { has_monitor && [[ $codename == buster ]]; }
 has_x() { has_monitor && [[ $codename != buster ]]; }
 has_monitor() { ! linode ; }
-linode() { lj || li; }
+linode() { l2 || li; }
 # linode actually has btrfs now, but we dont do anything with it.
 has_btrfs() { ! linode; }
 home_network() { ! linode && ! kw; }
@@ -106,6 +129,8 @@ if encrypted; then
   sudo dd of=/etc/systemd/system/keyscripton.service <<'EOF'
 [Unit]
 Description=Turn on automatic decryption of drives on boot
+# This is triggered by reboot and when keyscriptoff stops.
+
 # 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
@@ -125,8 +150,6 @@ ExecStop=/a/exe/keyscript-on
 WantedBy=keyscriptoff.service
 EOF
   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'
@@ -153,7 +176,7 @@ EOF
     | sudo dd of=$tmp
   if ! diff -q /etc/initramfs-tools/modules $tmp &>/dev/null; then
     sudo dd if=$tmp of=/etc/initramfs-tools/modules
-    sudo /usr/sbin update-initramfs -u -k all
+    sudo /usr/sbin/update-initramfs -u -k all
   fi
   # initram auth keys get setup with rootsshsync
   $script_dir/rootsshsync
@@ -190,8 +213,10 @@ if [[ $HOSTNAME != $(cat /etc/hostname) ]]; then
   echo $HOSTNAME > /etc/hostname
   hostname -F /etc/hostname
 fi
-sudo $sed -i '/^127\.0\.1\.1/d' /etc/hosts
-echo "127.0.1.1 $HOSTNAME.b8.nz $HOSTNAME" | sudo tee -a /etc/hosts
+sudo sed -i --follow-symlinks -f - /etc/hosts <<EOF
+\$a 127.0.1.1 $HOSTNAME.b8.nz $HOSTNAME
+/^127\.0\.1\.1/d
+EOF
 
 
 ##### exit first stage if running as root
@@ -202,7 +227,7 @@ fi
 
 
 #### setup bash for root
-for x in /a/c/{.bashrc,brc,.bash_profile,.profile,.inputrc,path_add_function}; do
+for x in /a/c/{.bashrc,brc,brc2,.bash_profile,.profile,.inputrc,path_add_function}; do
   sudo -i <<EOF
 PATH="/a/exe:$PATH"
 lnf $x /root
@@ -210,9 +235,9 @@ EOF
 done
 
 ###### do conflink
-# li needs the bind group before conflink
-if [[ $HOSTNAME == li ]]; then
-  getent group bind &>/dev/null || sudo groupadd -r bind
+# linode needs bind group before conflink
+if $linode; then
+  pi-nostart bind9
 fi
 # this needs to be before installing pacserve so we have gpg conf.
 conflink
@@ -582,5 +607,7 @@ if $emacs; then
   /a/exe/ssh-emacs-setup
 fi
 
+
+echo 0 >~/.local/distro-begin
 echo "$0: $(date): ending now"
 exit 0