]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blob - scripts/ovh_cloud_instance/arch_host_script.sh
c188514035d6ab8402981eaa16ef56d48d880f8d
[perso/Immae/Projets/Puppet.git] / scripts / ovh_cloud_instance / arch_host_script.sh
1 #!/bin/bash
2
3 set -e
4
5 git_branch="$1"
6 environment="$2"
7
8 # Randomizer
9 sudo haveged &
10 # /Randomizer
11
12 # Prepare an arch chroot
13 sudo pacman -Sy --noconfirm arch-install-scripts
14 # /Prepare an arch chroot
15
16 # Prepare device information
17 DEVICE=/dev/vdb1
18 MOUNTPOINT=/mnt
19
20 UUID=$(lsblk -rno UUID "$DEVICE")
21 PART="/dev/disk/by-uuid/$UUID"
22 # /Prepare device information
23
24 # Install very basic system (base git puppet)
25 # mkfs.ext4 -F -U "$UUID" "$DEVICE"
26 sudo mount "$DEVICE" /mnt
27
28 ##### FIXME: mkfs.ext4 would be better ####
29 for i in /mnt/*; do
30 if [ "$i" = "/mnt/boot" ]; then
31 # keep /boot/grub
32 sudo rm -f $i/*
33 else
34 sudo rm -rf $i
35 fi
36 done
37 ##### /FIXME ####
38
39 sudo pacstrap /mnt base git puppet
40
41 echo "$PART / auto defaults 0 1" | sudo tee /mnt/etc/fstab
42 # /Install very basic system
43
44 # Install rest of system (via puppet)
45 sudo cp /tmp/arch_install_script.sh "$MOUNTPOINT/root/"
46 sudo cp /tmp/puppet_variables.json "$MOUNTPOINT/root/"
47
48 sudo arch-chroot "$MOUNTPOINT" /root/arch_install_script.sh "$git_branch" "$environment"
49 # /Install rest of system
50