X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=distro-begin;h=a7622848af7171f3437c9f02dcba2c3eb2ef2f1a;hb=c2bf18a9e27233fc9b57450455969fc9e53508b8;hp=a53cbb4f23ffac9a2d0c583f81b0df620dfe22a7;hpb=0dec66207e287c8d5d1d5a5319a7795a3bdec637;p=distro-setup diff --git a/distro-begin b/distro-begin index a53cbb4..a762284 100755 --- a/distro-begin +++ b/distro-begin @@ -1,12 +1,12 @@ #!/bin/bash -l # Copyright (C) 2016 Ian Kelling - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - +# # http://www.apache.org/licenses/LICENSE-2.0 - +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -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 @@ -94,7 +96,7 @@ Description=Turn on automatic decryption of drives on boot # 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 +After=ntp.service DefaultDependencies=no # not sure if needed, makes sure we shut down before reboot.target Conflicts=reboot.target @@ -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 @@ -512,14 +514,14 @@ EOF pi xkbset else # xkbset was in testing for quite a while, dunno - # why it's not anymore. Sometime I should check and - # see if it's back in testing, but the unstable package - # doesn't upgrade anything form testing, and it's tiny - # so I'm not bothering to automate it. + # why it\'s not anymore. Sometime I should check and + # see if it\'s back in testing, but the unstable package + # doesn\'t upgrade anything form testing, and it\'s tiny + # so I\'m not bothering to automate it. pi xkbset/unstable -fi -fi -;;& + fi + fi + ;;& esac if has_x; then @@ -541,63 +543,107 @@ 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 <&2' ERR +for dir in /i /mnt/iroot /k /kr /w; do + if ! mountpoint $dir &>/dev/null && \ + awk '{print $2}' /etc/fstab | grep -xF $dir &>/dev/null; then + if awk '{print $3}' /etc/fstab | grep -xF nfs &>/dev/null; then + mount $dir || echo "warning: failed to mount nfs on $dir" + else + mount $dir + fi + fi +done +EOF + s chmod +x /root/imount + + s dd of=/etc/systemd/system/imount.service <<'EOF' +[Unit] +Description=Mount /i and related mountpoints + +[Service] +Type=oneshot +ExecStart=/root/imount + +[Install] +# note /kr needs networking, this target is the simplest way to +# time it when the network should be up, but not do something +# dumb like delay startup until the network is up. It happens +# at some time after network.target +WantedBy=multi-user.target +EOF + sudo systemctl daemon-reload # needed if the file was already there + sudo systemctl enable imount.service + sudo systemctl start imount.service +fi + +dir=/nocow +if has_btrfs; then + if ! mountpoint $dir; then + subvol=/mnt/root/nocow + if [[ ! -e $subvol ]]; then + s btrfs subvolume create $subvol + s chown root:1000 $subvol + s chattr +C $subvol + fi + + first_root_crypt=$(awk '$2 == "/" {print $1}' /etc/mtab) + tu /etc/fstab <