lots of updates
[distro-setup] / distro-begin
index 833ab0b0c829605aa06bb4b4be07464701146866..fee2249fcbf3146d824bcfc8db489a7e8683adba 100755 (executable)
@@ -2,6 +2,10 @@
 # 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
 
@@ -65,14 +69,19 @@ umask 0002
 
 ####### 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
@@ -81,9 +90,11 @@ ExecStart=/bin/true
 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'
@@ -97,6 +108,7 @@ ExecStart=/a/bin/keyscript-off
 [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
@@ -156,10 +168,11 @@ 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
@@ -209,6 +222,7 @@ EOF
         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.
@@ -241,10 +255,12 @@ if isarch; then
     # 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
@@ -265,7 +281,6 @@ pi trash-cli
 ###### 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
@@ -291,13 +306,14 @@ fi
 
 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
 
 
@@ -357,30 +373,57 @@ if encrypted; then
     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'
@@ -538,21 +581,25 @@ PATH="$PATH:$HOME/.cabal/bin"
 # 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