summaryrefslogtreecommitdiffstats
path: root/setup-arch-vm
diff options
context:
space:
mode:
Diffstat (limited to 'setup-arch-vm')
-rw-r--r--setup-arch-vm66
1 files changed, 66 insertions, 0 deletions
diff --git a/setup-arch-vm b/setup-arch-vm
new file mode 100644
index 0000000..eb8d949
--- /dev/null
+++ b/setup-arch-vm
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+set -e
+
+newuser="flo"
+
+mkfs.ext4 /dev/vda
+mount /dev/vda /mnt
+cat <<EOF >/etc/pacman.d/mirrorlist
+Server = http://mirror.server-speed.net/\$repo/os/\$arch
+EOF
+
+pacstrap /mnt base syslinux sudo openssh haveged htop git
+genfstab -p /mnt >> /mnt/etc/fstab
+echo "archvm" > /mnt/etc/hostname
+ln -s /usr/share/zoneinfo/Europe/Athens /mnt/etc/localtime
+echo "en_US.UTF-8 UTF-8" > /mnt/etc/locale.gen
+arch-chroot /mnt locale-gen
+
+echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf
+cat <<EOF > /mnt/etc/vconsole.conf
+KEYMAP=de
+FONT=
+EOF
+
+cat <<EOF >/mnt/boot/syslinux/syslinux.cfg
+serial 0 115200
+DEFAULT arch
+PROMPT 0
+TIMEOUT 50
+
+LABEL arch
+ MENU LABEL Arch Linux
+ LINUX ../vmlinuz-linux
+ APPEND root=/dev/vda ro logo.nologo elevator=deadline console=tty0 console=ttyS0
+ INITRD ../initramfs-linux.img
+EOF
+
+cat <<EOF > /mnt/etc/modprobe.d/modprobe.conf
+blacklist cirrus
+EOF
+
+arch-chroot /mnt mkinitcpio -p linux
+# expected error: /dev/vda - is a block device. Aborting set_active!
+# TODO: create partitions and remove the || true
+arch-chroot /mnt syslinux-install_update -aim || true
+arch-chroot /mnt useradd -m -g users -G wheel $newuser
+mkdir /mnt/root/.ssh
+touch /mnt/root/.ssh/authorized_keys
+chmod 700 /mnt/root/.ssh
+chmod 600 /mnt/root/.ssh/authorized_keys
+cat <<EOF > /mnt/root/.ssh/authorized_keys
+ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAte43fgKVPKvmwhMQcQRYNm27i2cadOIJvpOFA3jPWHFN2YeqxHvgVbAESLOAO/sJ0MqXlQnBc9rr8PbQd67YP7teOBnXLOfX2mofxGEDtP2mtwneAxkMNJcYtxWjPeKL7LF5tknqPb6dXavm4+gJt27CQFFY6DJ+cD0tUUgh17HG6VGiTXF6AgB9aho/ToaMQZ4vCzztvf94kQK2uBYUXsvx4L62ZrEJbIzfB7fynBbl9+deBqsYmWRCbzaYV77YjwLhk9hI/GsUjLkTAB77WbeWJdk7fgJ/PgI69FRMhRlYASRVBqeek6NLcyQ9x54CrUkOFBC5Q+j4yjsDQN7NBw== flo@Marin
+EOF
+
+mkdir /mnt/home/$newuser/.ssh
+chmod 700 /mnt/home/$newuser/.ssh
+cp /mnt/root/.ssh/authorized_keys /mnt/home/$newuser/.ssh/authorized_keys
+chmod 600 /mnt/home/$newuser/.ssh/authorized_keys
+arch-chroot /mnt chown -R $newuser:users /home/$newuser/.ssh
+arch-chroot /mnt passwd -d $newuser
+
+arch-chroot /mnt systemctl enable sshd multi-user.target haveged dhcpcd.service
+
+sync
+systemctl poweroff