X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=arch-init;h=37fa90b092111e7e829a891fadb6c7e3cef6dfcc;hb=2f13039525488532756a089b8329ab6ee64a6c17;hp=0ce3bf01d1bfc3d6f981d4fa9148840f4bd196d9;hpb=affd7d3cdd0671dcca07f29de9c86b5e3b57ea1f;p=automated-distro-installer diff --git a/arch-init b/arch-init index 0ce3bf0..37fa90b 100755 --- a/arch-init +++ b/arch-init @@ -1,6 +1,19 @@ #!/bin/bash -x +# Copyright (C) 2016 Ian Kelling -# see t.org for how to call +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR @@ -26,7 +39,6 @@ curl -s 'https://www.archlinux.org/mirrorlist/?country=US&protocol=https&ip_vers . /a/bin/fai/fai-wrapper export LUKS_DIR=/root/luks -export HOSTNAME=$hostname export DISTRO=arch partition_script=/a/bin/fai/fai/config/hooks/partition.DEFAULT chmod +x $partition_script @@ -36,7 +48,7 @@ export PARTITION_PROMPT=true # to be idempotent if we fail after partitioning already_partitioned=true mount_out=$(mount) -for dir in /mnt{,/home,/boot,/q}; do +for dir in /mnt{,/home,/boot,/a}; do regex=" on $dir " if [[ ! $mount_out =~ $regex ]]; then already_partitioned=false @@ -61,13 +73,13 @@ sed -ri --follow-symlinks "/^crypt_dev_\S+$rootn /d" /tmp/fai/crypttab if ! $already_partitioned; then mount -o subvol=root_$DISTRO $ROOT_PARTITION /mnt - mkdir -p /mnt/{q,home,boot} - mount -o subvol=q $ROOT_PARTITION /mnt/q + mkdir -p /mnt/{a,home,boot} + mount -o subvol=a $ROOT_PARTITION /mnt/a mount -o subvol=boot_$DISTRO $BOOT_PARTITION /mnt/boot fi # https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption#Keyfiles -cp /root/luks/host-$hostname /mnt/crypto_keyfile.bin +cp /root/luks/host-$HOSTNAME /mnt/crypto_keyfile.bin chmod 600 /mnt/crypto_keyfile.bin @@ -89,7 +101,6 @@ bindmount() { mkdir -p $mountpoint mount -o bind $source $mountpoint } -bindmount /a /mnt/a bindmount /root/shadow /mnt/q/root/shadow mkdir -p /mnt/etc/ssh @@ -104,7 +115,7 @@ rm -f /mnt/etc/resolv.conf ln -s /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf # not necsesary, but makes reboot go fast. -#umount -R /mnt; sleep 1 +umount -R /mnt; sleep 1 # causes 255 exit code, so doing this from the caller script. # reboot now