diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-08-20 11:40:01 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-08-20 11:40:01 +0200 |
commit | 02c8077e4bbf473eb1dfca55afd2eba4def5c003 (patch) | |
tree | eb4e482933c32e8bffa205a6ca46cca631101ecd /archauto.sh | |
download | archauto32-02c8077e4bbf473eb1dfca55afd2eba4def5c003.tar.gz archauto32-02c8077e4bbf473eb1dfca55afd2eba4def5c003.tar.bz2 |
initial version for ArchLinux32 (forked from archauto)
Diffstat (limited to 'archauto.sh')
-rwxr-xr-x | archauto.sh | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/archauto.sh b/archauto.sh new file mode 100755 index 0000000..20ec948 --- /dev/null +++ b/archauto.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +# configuration + +INSTALL_DRIVE=/dev/vda +PARTITION_BOOT=1 +PARTITION_ROOT=2 +LABEL_ROOT=ROOT +MOUNT_PATH=/mnt +HOST=192.168.130.1 +HTTP_SERVER=http://${HOST}:8080 +IP=192.168.130.2 +NETMASK=255.255.255.0 +PREFIX=24 +HOSTNAME=arch32 + +# create early SSH access + +echo 'root:xx' | chpasswd +echo "PermitRootLogin yes" >> /etc/ssh/sshd_config +systemctl start sshd + +echo "Partitioning and creating filesystem.." + +mknod /dev/vda b 254 0 +mknod /dev/vda1 b 254 1 +mknod /dev/vda2 b 254 2 + +wipefs -a ${INSTALL_DRIVE} + +printf ",128M,L,*\n" | /sbin/sfdisk -f ${INSTALL_DRIVE} +printf ",,L,*\n" | /sbin/sfdisk -a -f ${INSTALL_DRIVE} + +mkfs.ext2 ${INSTALL_DRIVE}${PARTITION_BOOT} +mkfs.ext4 ${INSTALL_DRIVE}${PARTITION_ROOT} + +mount ${INSTALL_DRIVE}${PARTITION_ROOT} ${MOUNT_PATH} +mkdir ${MOUNT_PATH}/boot +mount ${INSTALL_DRIVE}${PARTITION_BOOT} ${MOUNT_PATH}/boot + +echo "Patching pacman to play locally.." + +cat >/etc/pacman.d/mirrorlist <<EOF +Server = ${HTTP_SERVER}/mirror/\$arch/\$repo +EOF + +echo "Installing keyring for ArchLinux32." + +sed -i 's/^SigLevel.*/SigLevel = Never/g' /etc/pacman.conf +pacman --noconfirm -Syyw archlinux32-keyring +sed -i 's/^SigLevel.*/SigLevel = Required DatabaseOptional/g' /etc/pacman.conf +pacman --noconfirm -U /var/cache/pacman/pkg/archlinux32-keyring-*.pkg.tar.xz + +echo "Installing minimalistic base system.." + +pacstrap ${MOUNT_PATH} filesystem grep findutils coreutils glibc bash pacman \ + mkinitcpio linux dhcpcd systemd sed systemd-sysvcompat + +echo "Patching pacman in chroot to play locally.." + +cat >${MOUNT_PATH}/etc/pacman.d/mirrorlist <<EOF +Server = ${HTTP_SERVER}/mirror/\$arch/\$repo +EOF + +echo "Test if we can update the system inside chroot." + +arch-chroot ${MOUNT_PATH} pacman -Syyu + +echo "Install /etc/fstab" +genfstab -L -p ${MOUNT_PATH} > ${MOUNT_PATH}/etc/fstab + +echo "Installing boot loader.." + +arch-chroot ${MOUNT_PATH} pacman --noconfirm -S grub +arch-chroot ${MOUNT_PATH} grub-mkconfig -o /boot/grub/grub.cfg +arch-chroot ${MOUNT_PATH} grub-install --force /dev/vda + +echo "Configuring base system.." + +sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' ${MOUNT_PATH}/etc/locale.gen +arch-chroot ${MOUNT_PATH} locale-gen +echo LANG=en_US.UTF-8 > ${MOUNT_PATH}/etc/locale.conf + +ln -fs /usr/share/zoneinfo/Europe/Zurich ${MOUNT_PATH}/etc/localtime +arch-chroot ${MOUNT_PATH} hwclock --systohc --utc + +echo ${HOSTNAME} > ${MOUNT_PATH}/etc/hostname + +cat > ${MOUNT_PATH}/etc/systemd/network/25-wired.network <<EOF +[Match] +Name=ens3 + +[Network] +Address=${IP}/${PREFIX} +Gateway=${HOST} +EOF + +arch-chroot ${MOUNT_PATH} systemctl enable systemd-networkd +arch-chroot ${MOUNT_PATH} systemctl enable systemd-resolved + +arch-chroot ${MOUNT_PATH} sh -c "echo 'root:xx' | chpasswd" + +arch-chroot ${MOUNT_PATH} pacman --noconfirm -S openssh +echo "PermitRootLogin yes" >>${MOUNT_PATH}/etc/ssh/sshd_config +arch-chroot ${MOUNT_PATH} systemctl enable sshd + +echo "Unmounting.." + +umount ${MOUNT_PATH}/boot +umount ${MOUNT_PATH} + +echo "Powering off.." + +sleep 10 + +systemctl poweroff |