]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blobdiff - scripts/ovh_cloud_instance/arch_host_script.sh
Move scripts to separate chunks
[perso/Immae/Projets/Puppet.git] / scripts / ovh_cloud_instance / arch_host_script.sh
diff --git a/scripts/ovh_cloud_instance/arch_host_script.sh b/scripts/ovh_cloud_instance/arch_host_script.sh
new file mode 100755 (executable)
index 0000000..c188514
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+set -e
+
+git_branch="$1"
+environment="$2"
+
+# Randomizer
+sudo haveged &
+# /Randomizer
+
+# Prepare an arch chroot
+sudo pacman -Sy --noconfirm arch-install-scripts
+# /Prepare an arch chroot
+
+# Prepare device information
+DEVICE=/dev/vdb1
+MOUNTPOINT=/mnt
+
+UUID=$(lsblk -rno UUID "$DEVICE")
+PART="/dev/disk/by-uuid/$UUID"
+# /Prepare device information
+
+# Install very basic system (base git puppet)
+# mkfs.ext4 -F -U "$UUID" "$DEVICE"
+sudo mount "$DEVICE" /mnt
+
+##### FIXME: mkfs.ext4 would be better ####
+for i in /mnt/*; do
+  if [ "$i" = "/mnt/boot" ]; then
+    # keep /boot/grub
+    sudo rm -f $i/*
+  else
+    sudo rm -rf $i
+  fi
+done
+##### /FIXME ####
+
+sudo pacstrap /mnt base git puppet
+
+echo "$PART / auto defaults 0 1" | sudo tee /mnt/etc/fstab
+# /Install very basic system
+
+# Install rest of system (via puppet)
+sudo cp /tmp/arch_install_script.sh "$MOUNTPOINT/root/"
+sudo cp /tmp/puppet_variables.json "$MOUNTPOINT/root/"
+
+sudo arch-chroot "$MOUNTPOINT" /root/arch_install_script.sh "$git_branch" "$environment"
+# /Install rest of system
+